. "$BST_LIB" # libyaml is the reference YAML 1.1 parser and emitter in C. It is the largest # of the compiled libraries shipped for their own sake here: three layers rather # than one -- a scanner/parser that turns a stream into tokens and events, an # emitter that writes events back out, and a document layer that composes events # into a node graph. The distro is static-only, so the payload is one header plus # a pkg-config file (-dev) and the static archive libyaml.a (-staticdev). There # is no on-target C compiler to link against it, so the on-target assertion is # that the shipped payload is real -- the header carrying its include guard, the # declared API of all three layers and the public types they exchange, the .pc # file describing the library the image actually ships, and the archive carrying # every compiled member plus the exported symbols of each layer in its index. # That symbol index is what distinguishes a wasm32 compile that produced the # parser and emitter from an empty stub. inc=/usr/include/yaml.h pc=/usr/lib/pkgconfig/yaml-0.1.pc lib=/usr/lib/libyaml.a check libyaml/header-present test -f "$inc" check libyaml/header-nonempty test -s "$inc" check_out libyaml/header-guard "define YAML_H" cat "$inc" # Version query. libyaml states its version only at runtime and in the .pc file # -- the header declares the two accessors but defines no YAML_VERSION_* macro, # so the header assertion is the declaration and the number is checked on the .pc. check_out libyaml/api-version-string "yaml_get_version_string(" cat "$inc" check_out libyaml/api-version-nums "yaml_get_version(" cat "$inc" # Layer 1 -- the scanner/parser: lifecycle, the two input sources this port can # use, the encoding selector, and the three escalating consumption calls # (tokens, events, documents). for f in yaml_parser_initialize yaml_parser_delete yaml_parser_set_input_string \ yaml_parser_set_input_file yaml_parser_set_encoding \ yaml_parser_scan yaml_parser_parse yaml_parser_load; do check_out "libyaml/api-${f#yaml_}" "$f(" cat "$inc" done # Layer 2 -- the emitter: lifecycle, both output sinks, the stream framing calls, # and the document dump that pairs with the parser's load. for f in yaml_emitter_initialize yaml_emitter_delete yaml_emitter_set_output_string \ yaml_emitter_set_output_file yaml_emitter_emit yaml_emitter_open \ yaml_emitter_close yaml_emitter_flush yaml_emitter_dump; do check_out "libyaml/api-${f#yaml_}" "$f(" cat "$inc" done # The emitter's presentation tunables: shipped unconfigured, so a caller selects # canonical form, indent, wrap width and line break itself. for f in yaml_emitter_set_canonical yaml_emitter_set_indent \ yaml_emitter_set_width yaml_emitter_set_break; do check_out "libyaml/api-${f#yaml_}" "$f(" cat "$inc" done # Layer 3 -- the document/node graph: lifecycle, node lookup, and the three # constructors plus the two calls that attach a child to a collection. for f in yaml_document_initialize yaml_document_delete yaml_document_get_root_node \ yaml_document_add_scalar yaml_document_add_sequence yaml_document_add_mapping \ yaml_document_append_sequence_item yaml_document_append_mapping_pair; do check_out "libyaml/api-${f#yaml_}" "$f(" cat "$inc" done # Event constructors a caller drives the emitter with, plus the two destructors # that free what the parser hands back. for f in yaml_stream_start_event_initialize yaml_document_start_event_initialize \ yaml_scalar_event_initialize yaml_sequence_start_event_initialize \ yaml_mapping_start_event_initialize yaml_alias_event_initialize \ yaml_event_delete yaml_token_delete; do check_out "libyaml/api-${f#yaml_}" "$f(" cat "$inc" done # The public types the three layers exchange. yaml_node_t is a forward typedef # over an opaque-until-defined struct, so it is asserted in both of its parts # rather than by the closing-brace form the other types use. for t in yaml_encoding_t yaml_error_type_t yaml_scalar_style_t yaml_token_type_t \ yaml_token_t yaml_event_type_t yaml_event_t yaml_node_type_t \ yaml_document_t yaml_parser_t yaml_emitter_t; do check_out "libyaml/type-${t#yaml_}" "} $t;" cat "$inc" done check_out libyaml/type-node-typedef "typedef struct yaml_node_s yaml_node_t;" cat "$inc" check_out libyaml/type-node-struct "struct yaml_node_s {" cat "$inc" # Enum constants: one per enum that a caller has to name to use the API at all. for c in YAML_UTF8_ENCODING YAML_SCANNER_ERROR YAML_EMITTER_ERROR \ YAML_PLAIN_SCALAR_STYLE YAML_MAPPING_NODE YAML_SCALAR_EVENT; do check_out "libyaml/enum-$c" "$c" cat "$inc" done # The failsafe/JSON schema tags libyaml resolves untagged nodes to. for c in YAML_STR_TAG YAML_INT_TAG YAML_SEQ_TAG YAML_MAP_TAG; do check_out "libyaml/tag-$c" "$c" cat "$inc" done # pkg-config metadata: shipped so a future recipe can DEPEND on libyaml, and the # one place the port's version and link line are stated on target. libdir is # asserted substituted rather than left as a literal placeholder. check libyaml/pc-present test -f "$pc" check_out libyaml/pc-name "Name: LibYAML" cat "$pc" check_out libyaml/pc-version "Version: 0.2.5" cat "$pc" check_out libyaml/pc-libs "-lyaml" cat "$pc" check_out libyaml/pc-cflags "-I\${includedir}" cat "$pc" check_out libyaml/pc-libdir "libdir=/usr/lib" cat "$pc" check libyaml/lib-present test -f "$lib" check libyaml/lib-nonempty test -s "$lib" check_out libyaml/lib-archive "!" head -c 8 "$lib" # Flatten the archive to printable text once: GNU grep suppresses matches inside # binary data, and busybox tr does not handle [:print:] under -c, so the octal # range is the formulation both greps and both trs agree on. flat=${TMPDIR:-/tmp}/bst-libyaml.$$ tr -c '\40-\176\n' ' ' < "$lib" > "$flat" 2>/dev/null # All eight upstream translation units, so a partial compile cannot pass: the # scanner/parser chain (reader, scanner, parser, loader), the emitter chain # (writer, emitter, dumper), and the shared allocation/event API in api.o. for m in api.o reader.o scanner.o parser.o loader.o writer.o emitter.o dumper.o; do check "libyaml/member-$m" grep -q "$m" "$flat" done # Exported symbols, sampled across all three layers plus the version accessors, # so the archive's index is evidence the wasm32 compile really produced each one. for s in yaml_get_version_string yaml_parser_initialize yaml_parser_scan \ yaml_parser_parse yaml_parser_load yaml_parser_set_input_string \ yaml_emitter_initialize yaml_emitter_emit yaml_emitter_open \ yaml_emitter_dump yaml_document_initialize yaml_document_add_scalar \ yaml_document_add_mapping yaml_document_get_root_node \ yaml_scalar_event_initialize yaml_event_delete yaml_token_delete; do check "libyaml/sym-$s" grep -q "$s" "$flat" done # No shared object and no libtool archive: static-only is distro policy, and # libyaml's autotools build defaults to a shared library, so a stray libyaml.so # or .la here would mean the distro's --disable-shared override was lost. check libyaml/no-shared sh -c 'set -- /usr/lib/libyaml.so*; [ ! -e "$1" ]' check libyaml/no-libtool sh -c 'set -- /usr/lib/libyaml.la; [ ! -e "$1" ]' rm -f "$flat"