-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.bat
More file actions
95 lines (82 loc) · 2.54 KB
/
make.bat
File metadata and controls
95 lines (82 loc) · 2.54 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
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
IF "%1"=="" GOTO help
IF "%1"=="help" GOTO help
IF "%1"=="all" 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
ECHO Unknown command: %1
GOTO help
:help
ECHO Available commands:
ECHO install_base - Install Rust and WASM targets
ECHO install_deps - Fetch dependencies
ECHO build_docs - Build API docs (Use DOC_DIR to override path)
ECHO build - Build CLI binary (Use BIN_DIR to override path)
ECHO test - Run tests
ECHO run - Run the CLI tool (e.g., make.bat run --version)
ECHO build_wasm - Build the WASM target
ECHO build_docker - Build Alpine and Debian images
ECHO run_docker - Run built Docker images to test them
GOTO :EOF
:install_base
rustup update
rustup target add wasm32-unknown-unknown
GOTO :EOF
:install_deps
cargo fetch
GOTO :EOF
:build_docs
IF "%DOC_DIR%"=="" SET DOC_DIR=target\doc
cargo doc --no-deps --target-dir %DOC_DIR%
GOTO :EOF
:build
IF "%BIN_DIR%"=="" SET BIN_DIR=target\release
cargo build --release
IF NOT "%BIN_DIR%"=="target\release" (
IF NOT EXIST "%BIN_DIR%" MKDIR "%BIN_DIR%"
COPY target\release\cdd-rust.exe "%BIN_DIR%\"
)
GOTO :EOF
:test
cargo test
GOTO :EOF
:run
CALL :build
SHIFT
SET RUN_ARGS=
:loop
IF "%1"=="" GOTO end_loop
SET RUN_ARGS=%RUN_ARGS% %1
SHIFT
GOTO loop
:end_loop
target\release\cdd-rust.exe %RUN_ARGS%
GOTO :EOF
:build_wasm
ECHO Attempting WASM build. See WASM.md for current limitations.
cargo build -p cdd-cli --target wasm32-unknown-unknown --release || ECHO WASM build is currently unsupported. See WASM.md for details.
GOTO :EOF
:build_docker
docker build -t cdd-rust:alpine -f alpine.Dockerfile .
docker build -t cdd-rust:debian -f debian.Dockerfile .
GOTO :EOF
:run_docker
ECHO Testing Alpine image...
docker run --rm -d --name cdd_alpine -p 8082:8082 cdd-rust:alpine
timeout /T 2
curl -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"version\", \"id\": 1}" http://localhost:8082 || VER>NUL
docker stop cdd_alpine
ECHO Testing Debian image...
docker run --rm -d --name cdd_debian -p 8082:8082 cdd-rust:debian
timeout /T 2
curl -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"version\", \"id\": 1}" http://localhost:8082 || VER>NUL
docker stop cdd_debian
GOTO :EOF