Files
bun.sh/scripts/cross-compile-codegen.sh
dave caruso d712254128 internal: remove secret hidden internals and introduce new way to call native code from js (#8166)
* oooooh magic

* stuff

* run format

* ok

* yippee

* run the formatter back

* finish things up

* fix webkit

* more

* [autofix.ci] apply automated fixes

* fix compile

* fix compilation on windows, it seems to not work though :(

* update

* a

* v

* ok

* [autofix.ci] apply automated fixes

* OOPS

* bump bun to reduce ci bugs

* a

* js2native is done!

* improve array binding

* rebase

* some final stuff

* wasi fixes

* os

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-29 21:47:11 -07:00

74 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
export TARGET_PLATFORM=${1:-win32}
export TARGET_ARCH=${2:-x64}
if ! which bun; then
export PATH="$PATH:$HOME/.bun/bin"
fi
cd "$(dirname "${BASH_SOURCE[0]}")/../"
OUT=build-codegen-${TARGET_PLATFORM}-${TARGET_ARCH}
if [ -n "$3" ]; then
OUT="$3"
fi
rm -rf "$OUT/codegen"
rm -rf "$OUT/js"
mkdir -p "$OUT"
mkdir -p "$OUT/"{codegen,js,tmp_functions,tmp_modules}
OUT=$(realpath "$OUT")
task() {
echo '$ '"$@"
"$@"
if [ "$?" != "0" ]; then
# some scripts are flaky, run them again
echo "!!! retrying"
"$@"
if [ "$?" != "0" ]; then
echo "!!! failed"
exit 1
fi
fi
}
task bun ./src/codegen/bundle-modules.ts --debug=OFF "$OUT"
rm -rf "$OUT/tmp_functions"
rm -rf "$OUT/tmp_modules"
CLASSES=(
./src/bun.js/*.classes.ts
./src/bun.js/api/*.classes.ts
./src/bun.js/test/*.classes.ts
./src/bun.js/webcore/*.classes.ts
./src/bun.js/node/*.classes.ts
)
task bun "./src/codegen/generate-classes.ts" ${CLASSES[@]} "$OUT/codegen"
LUTS=(
./src/bun.js/bindings/BunObject.cpp
./src/bun.js/bindings/ZigGlobalObject.lut.txt
./src/bun.js/bindings/JSBuffer.cpp
./src/bun.js/bindings/BunProcess.cpp
./src/bun.js/bindings/ProcessBindingConstants.cpp
./src/bun.js/bindings/ProcessBindingNatives.cpp
)
for lut in ${LUTS[@]}; do
result=$(basename $lut | sed 's/.lut.txt/.cpp/' | sed 's/.cpp/.lut.h/')
task bun "./src/codegen/create-hash-table.ts" "$lut" "$OUT/codegen/$result"
done
task bun "./src/codegen/generate-jssink.ts" "$OUT/codegen"
wait
rm -rf "$OUT/tmp"*
echo "-> `basename "$OUT"`"