26 lines
849 B
Bash
Executable file
26 lines
849 B
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Build a native (AOT) pipe binary.
|
|
#
|
|
# Why bother: `dart run` pays Dart JIT startup on every invocation, measured at
|
|
# ~6.4s even for a two-file project, which makes pipe unpleasant in a loop and
|
|
# expensive in CI. The AOT binary starts in ~0.2s and is also faster per file.
|
|
#
|
|
# Prefers `dart build cli` (the endorsed path, Dart 3.9+) and falls back to
|
|
# `dart compile exe`.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
if dart build cli --target bin/pipe.dart >/dev/null 2>&1; then
|
|
binary=$(find build/cli -type f -name 'pipe' -perm -u+x 2>/dev/null | head -1 || true)
|
|
if [ -n "$binary" ]; then
|
|
echo "built with 'dart build cli': $binary"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
output="${1:-build/pipe}"
|
|
mkdir -p "$(dirname "$output")"
|
|
dart compile exe bin/pipe.dart -o "$output" >/dev/null
|
|
echo "built with 'dart compile exe': $output"
|