forked from donalffons/opencascade.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-native.sh
More file actions
executable file
·66 lines (54 loc) · 2.01 KB
/
build-native.sh
File metadata and controls
executable file
·66 lines (54 loc) · 2.01 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
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
echo "=== OpenCascade.js Native Build ==="
# Shared emsdk with assimpjs
export EMSDK="${EMSDK:-$(cd ../assimpjs/emsdk && pwd)}"
echo "Using EMSDK: $EMSDK"
source "$EMSDK/emsdk_env.sh"
echo "Emscripten: $(emcc --version | head -1)"
# Dependency roots
export OCJS_ROOT="$(pwd)"
export OCCT_ROOT="${OCCT_ROOT:-$(cd ../OCCT && pwd)}"
export RAPIDJSON_ROOT="${RAPIDJSON_ROOT:-$(cd ../rapidjson && pwd)}"
export FREETYPE_ROOT="${FREETYPE_ROOT:-$(cd ../freetype && pwd)}"
# Dev build flags: -O0 and no LTO for fast iteration
export OCJS_OPT="${OCJS_OPT:--O0}"
export OCJS_LTO="${OCJS_LTO:-0}"
echo "OCJS_ROOT: $OCJS_ROOT"
echo "OCCT_ROOT: $OCCT_ROOT"
echo "RAPIDJSON_ROOT: $RAPIDJSON_ROOT"
echo "FREETYPE_ROOT: $FREETYPE_ROOT"
echo "OCJS_OPT: $OCJS_OPT"
echo "OCJS_LTO: $OCJS_LTO"
echo ""
# Ensure build directories exist
mkdir -p build/{bindings,sources,dist}
# Step 1: Apply OCCT patches
echo "=== Step 1: Applying patches ==="
python3 src/applyPatches.py
# Step 2: Build flat includes + PCH (25x compilation speedup)
echo "=== Step 2: Building flat includes + precompiled header ==="
python3 -c "
import sys; sys.path.insert(0, 'src')
from Common import buildFlatIncludes, buildPch
buildFlatIncludes()
buildPch()
"
# Step 3: Generate bindings
echo "=== Step 3: Generating bindings ==="
python3 src/generateBindings.py
# Step 4: Compile bindings (uses PCH + flat includes)
echo "=== Step 4: Compiling bindings ==="
python3 src/compileBindings.py single-threaded
# Step 5: Compile OCCT sources (uses flat includes)
echo "=== Step 5: Compiling OCCT sources ==="
python3 src/compileSources.py single-threaded
echo ""
echo "=== Build complete ==="
echo "Run 'python3 src/buildFromYaml.py <config.yml>' to link into final WASM."
echo ""
echo "Build optimization summary:"
echo " - Flat includes: 467 -I paths -> 1 (eliminates stat() overhead)"
echo " - PCH: 5,640 headers precompiled once (~92MB binary)"
echo " - Combined: ~25x per-file speedup (52s -> 2s per binding file)"