···11+#!/bin/bash
22+set -e
33+44+. "$(dirname "$0")/common.sh"
55+66+CONFIG_H="$1"
77+OUTPUT="$2"
88+INCLUDE_DIR="$ROOT_DIR/include"
99+1010+if [ -z "$CONFIG_H" ] || [ -z "$OUTPUT" ]; then
1111+ echo "Usage: $0 <config.h> <output.h>"
1212+ exit 1
1313+fi
1414+1515+VENDOR_DIR="$SCRIPT_DIR/vendor"
1616+1717+HEADERS=(
1818+ "config.h:$CONFIG_H"
1919+ "compat.h:$INCLUDE_DIR/compat.h"
2020+ "ant.h:$INCLUDE_DIR/ant.h"
2121+ "utils.h:$INCLUDE_DIR/utils.h"
2222+ "gc_version.h:$VENDOR_DIR/gc-8.2.10/include/gc_version.h"
2323+ "gc_config_macros.h:$VENDOR_DIR/gc-8.2.10/include/gc_config_macros.h"
2424+ "gc.h:$VENDOR_DIR/gc-8.2.10/include/gc.h"
2525+ "minicoro.h:$VENDOR_DIR/minicoro/minicoro.h"
2626+ "arena.h:$INCLUDE_DIR/arena.h"
2727+ "runtime.h:$INCLUDE_DIR/runtime.h"
2828+ "esm/remote.h:$INCLUDE_DIR/esm/remote.h"
2929+)
3030+3131+for f in "$INCLUDE_DIR"/modules/*.h; do
3232+ name="modules/$(basename "$f")"
3333+ HEADERS+=("$name:$f")
3434+done
3535+3636+cat > "$OUTPUT" << 'EOF'
3737+/*
3838+ * Ant JavaScript Engine
3939+ * https://github.com/themackabu/ant
4040+ *
4141+ * The MIT License (MIT)
4242+ *
4343+ * Copyright (c) 2026 theMackabu (me@themackabu.dev)
4444+ *
4545+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4646+ * of this software and associated documentation files (the "Software"), to deal
4747+ * in the Software without restriction, including without limitation the rights
4848+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4949+ * copies of the Software, and to permit persons to whom the Software is
5050+ * furnished to do so, subject to the following conditions:
5151+ *
5252+ * The above copyright notice and this permission notice shall be included in all
5353+ * copies or substantial portions of the Software.
5454+ *
5555+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5656+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5757+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5858+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5959+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6060+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6161+ * SOFTWARE.
6262+ *
6363+ * ---
6464+ *
6565+ * This is an auto-generated amalgamated header containing all public APIs.
6666+ * Link with libant.a and required system libraries:
6767+ * macOS: -framework Security -framework CoreFoundation -lpthread
6868+ * Linux: -lpthread -ldl -lm
6969+ * Windows: -lws2_32 -lrpcrt4 -lsecur32 -lntdll -lcrypt32 -luserenv
7070+ */
7171+#ifndef LIBANT_H
7272+#define LIBANT_H
7373+7474+EOF
7575+7676+for entry in "${HEADERS[@]}"; do
7777+ name="${entry%%:*}"
7878+ path="${entry##*:}"
7979+8080+ if [ ! -f "$path" ]; then
8181+ echo "Warning: $path not found, skipping" >&2
8282+ continue
8383+ fi
8484+8585+ echo "/* === $name === */" >> "$OUTPUT"
8686+8787+ while IFS= read -r line || [ -n "$line" ]; do
8888+ if [[ "$line" =~ ^[[:space:]]*#[[:space:]]*pragma[[:space:]]+once ]]; then
8989+ continue
9090+ fi
9191+9292+ if [[ "$line" =~ ^[[:space:]]*#[[:space:]]*include[[:space:]]+\"(config\.h|compat\.h|ant\.h|utils\.h|arena\.h|runtime\.h|internal\.h)\" ]]; then
9393+ continue
9494+ fi
9595+ if [[ "$line" =~ ^[[:space:]]*#[[:space:]]*include[[:space:]]+\"esm/ ]]; then
9696+ continue
9797+ fi
9898+ if [[ "$line" =~ ^[[:space:]]*#[[:space:]]*include[[:space:]]+\"modules/ ]]; then
9999+ continue
100100+ fi
101101+102102+ if [[ "$line" =~ ^[[:space:]]*#[[:space:]]*include[[:space:]]+\<config\.h\> ]]; then
103103+ continue
104104+ fi
105105+106106+ echo "$line" >> "$OUTPUT"
107107+ done < "$path"
108108+109109+ echo "" >> "$OUTPUT"
110110+done
111111+112112+echo "#endif /* LIBANT_H */" >> "$OUTPUT"
113113+114114+echo "Generated $OUTPUT"