-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.bat
More file actions
114 lines (98 loc) · 3.68 KB
/
make.bat
File metadata and controls
114 lines (98 loc) · 3.68 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
@echo off
if "%1"=="" goto help
if "%1"=="help" goto help
if "%1"=="install_base" goto install_base
if "%1"=="install_deps" goto install_deps
if "%1"=="build_docs" goto build_docs
if "%1"=="build" goto build
if "%1"=="test" goto test
if "%1"=="run" goto run
if "%1"=="build_wasm" goto build_wasm
if "%1"=="build_docker" goto build_docker
if "%1"=="run_docker" goto run_docker
if "%1"=="build_with_ts_go" goto build_with_ts_go
if "%1"=="build_with_ts_go_assemblyscript" goto build_with_ts_go_assemblyscript
:help
echo Available commands:
echo make.bat install_base - Install Node.js
echo make.bat install_deps - Install dependencies (npm install)
echo make.bat build_docs - Build API docs
echo make.bat build - Build the CLI binary
echo make.bat test - Run tests locally
echo make.bat run - Run the CLI
echo make.bat build_wasm - Build the WASM output
echo make.bat build_docker - Build Docker images
echo make.bat run_docker - Run Docker images
echo make.bat build_with_ts_go - Build cdd-ts utilizing the local ts-morph wasm fork
echo make.bat build_with_ts_go_assemblyscript - Build cdd-ts utilizing the new AOT Go+AS architecture
goto end
:install_base
echo Please install Node.js ^>= 18.0.0 manually if not installed.
npm --version || echo npm not found. Please install Node.js.
goto end
:install_deps
call npm install
goto end
:build_docs
call npm run docs
goto end
:build
call npm run build
goto end
:test
call npm run test
goto end
:run
call npm run build
node dist\cli.js %2 %3 %4 %5 %6 %7 %8 %9
goto end
:build_wasm
echo Building WASM (browser bundle)...
call npx esbuild dist\index.js --bundle --platform=browser --target=es2020 --external:node:fs --external:node:path --external:node:url --external:node:crypto --external:node:os --outfile=wasm\cdd-ts.js
echo Compiling to WebAssembly...
call npx -y javy-cli compile wasm\cdd-ts.js -o wasm\cdd-ts-javy.wasm
goto end
:build_docker
docker build -f debian.Dockerfile -t cdd-ts:debian .
docker build -f alpine.Dockerfile -t cdd-ts:alpine .
goto end
:run_docker
docker run -d -p 8080:8080 --name cdd-ts-test cdd-ts:alpine
timeout /t 2 /nobreak
curl -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\":\"2.0\",\"method\":\"version\",\"id\":1}" http://localhost:8080
docker stop cdd-ts-test
docker rm cdd-ts-test
goto end
:end
:build_with_ts_go
echo Installing local ts-morph with Wasm backend...
call npm install file:..\ts-morph\packages\ts-morph file:..\ts-morph\packages\common --force
echo Building cdd-ts using local ts-morph fork...
call npm run build
echo Building WASM (browser bundle)...
call npx esbuild dist\index.js --bundle --platform=browser --target=es2020 --external:node:fs --external:node:path --external:node:url --external:node:crypto --external:node:os --outfile=wasm\cdd-ts.js
echo Compiling to WebAssembly via javy...
call npx -y javy-cli compile wasm\cdd-ts.js -o wasm\cdd-ts-go-javy.wasm
echo build_with_ts_go completed successfully!
goto end
:build_with_ts_go_assemblyscript
echo Building Go engine (WASM)...
if not exist wasm mkdir wasm
cd ..\ts-morph\packages\compiler-go-source
set GOOS=wasip1
set GOARCH=wasm
call go build -o ..\..\..\cdd-ts\wasm\typescript-go.wasm .\cmd\wasm-wasi
set GOOS=
set GOARCH=
cd ..\..\..\cdd-ts
echo Building AssemblyScript bridge (WASM)...
cd ..\ts-morph\packages\ts-morph-as
call npm run asbuild:release
copy /Y build\release.wasm ..\..\..\cdd-ts\wasm\cdd-ts.wasm
cd ..\..\..\cdd-ts
echo ================================
echo Success! Compare filesizes:
dir wasm\typescript-go.wasm
dir wasm\cdd-ts.wasm
echo ================================
goto end