-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·70 lines (61 loc) · 1.89 KB
/
build.sh
File metadata and controls
executable file
·70 lines (61 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
echo "=== T-Ruby WASM Build ==="
echo "Script directory: $SCRIPT_DIR"
echo "Project root: $PROJECT_ROOT"
# Create dist directory
rm -rf "$SCRIPT_DIR/dist"
mkdir -p "$SCRIPT_DIR/dist/lib/t_ruby"
# Copy only the core compilation files needed for WASM
# Excluded: lsp_server, watcher, cli, cache, package_manager, bundler_integration, benchmark, doc_generator
# These require external gems (listen, etc.) not available in WASM
echo ""
echo "=== Copying T-Ruby core compilation files ==="
CORE_FILES=(
"version.rb"
"config.rb"
"ir.rb"
"parser_combinator.rb"
"smt_solver.rb"
"type_alias_registry.rb"
"parser.rb"
"union_type_parser.rb"
"generic_type_parser.rb"
"intersection_type_parser.rb"
"type_erasure.rb"
"error_handler.rb"
"declaration_generator.rb"
"compiler.rb"
"constraint_checker.rb"
"type_inferencer.rb"
"runtime_validator.rb"
"type_checker.rb"
)
for file in "${CORE_FILES[@]}"; do
echo " Copying: t_ruby/$file"
cp "$PROJECT_ROOT/lib/t_ruby/$file" "$SCRIPT_DIR/dist/lib/t_ruby/"
done
# Process compiler.rb to remove fileutils require (not available in WASM)
echo ""
echo "=== Processing compiler.rb for WASM compatibility ==="
sed -i.bak 's/^require "fileutils"$/# require "fileutils" # Not available in WASM/' "$SCRIPT_DIR/dist/lib/t_ruby/compiler.rb"
rm -f "$SCRIPT_DIR/dist/lib/t_ruby/compiler.rb.bak"
# Generate manifest.json with file list
echo ""
echo "=== Generating manifest.json ==="
VERSION=$(node -p "require('$SCRIPT_DIR/package.json').version")
cat > "$SCRIPT_DIR/dist/manifest.json" << EOF
{
"version": "$VERSION",
"files": [
$(printf ' "%s",\n' "${CORE_FILES[@]}" | sed '$ s/,$//')
]
}
EOF
echo ""
echo "=== Build complete ==="
echo "Output directory: $SCRIPT_DIR/dist/"
ls -la "$SCRIPT_DIR/dist/"
ls -la "$SCRIPT_DIR/dist/lib/t_ruby/"