measur-tools-suite 1.0.13-beta.132 → 1.0.13-beta.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ # Architecture Overview
2
+
3
+ TODO: Add architecture overview content here.
package/BUILD.md ADDED
@@ -0,0 +1,447 @@
1
+ # Build Guide
2
+
3
+ This document centralizes all build, test, packaging, WebAssembly, and Docker workflows for the MEASUR Tools Suite.
4
+
5
+ ---
6
+
7
+ ## 1. Overview
8
+
9
+ The project provides:
10
+ - A C++ static library: `measur_tools_suite`
11
+ - A C++ CLI executable: `measur_tools_suite` (target `TOOLS_SUITE_main`)
12
+ - Optional C++ unit tests (Catch2 based)
13
+ - Optional WebAssembly build producing `client.js` + `client.wasm`
14
+ - Optional binary/package artifacts (via CPack)
15
+
16
+ All builds are driven by CMake (minimum 3.5). WebAssembly builds use Emscripten toolchain integration via `emcmake` / `emmake`.
17
+
18
+ ---
19
+
20
+ ## 2. Supported Platforms
21
+
22
+ | Platform | Status | Notes |
23
+ | -------- | --------------- | -------------------------------------------------------- |
24
+ | Linux | Fully supported | Primary development environment |
25
+ | macOS | Supported | Uses same CMake flow |
26
+ | Windows | Supported | MinGW, MSYS2, or Visual Studio toolchain; WASM via emsdk |
27
+
28
+ ---
29
+
30
+ ## 3. Prerequisites
31
+
32
+ Install only what you need for the scenario you plan to use.
33
+
34
+ ### Core (C++ build)
35
+
36
+ - GCC/Clang/MSVC with C++20 support
37
+ - CMake >= 3.5
38
+ - make or ninja (optional alternative generator)
39
+
40
+ ### WebAssembly
41
+
42
+ - Emscripten SDK (emsdk) latest
43
+ ```bash
44
+ ./emsdk install latest
45
+ ./emsdk activate latest
46
+ source ./emsdk_env.sh # (emsdk_env.bat on Windows)
47
+ ```
48
+ Repeat `source ./emsdk_env.sh` for every new shell or add it to your profile.
49
+
50
+ ### Tests (WASM & JS harness)
51
+
52
+ - Node.js (LTS) + npm
53
+
54
+ ### Documentation (optional)
55
+
56
+ - Doxygen >= 1.14.0
57
+
58
+ ### Packaging (optional)
59
+
60
+ - CPack (bundled with CMake)
61
+
62
+ ### Docker (optional convenience)
63
+
64
+ - Docker & Docker Compose
65
+
66
+ ---
67
+
68
+ ## 4. CMake Options
69
+
70
+ | Option | Default | Purpose |
71
+ | --------------- | ------- | ----------------------------------- |
72
+ | `BUILD_TESTING` | ON | Build C++ unit tests (`cpp_tests`) |
73
+ | `BUILD_WASM` | OFF | Build WebAssembly module (`client`) |
74
+ | `BUILD_PACKAGE` | OFF | Enable install + packaging targets |
75
+
76
+ Mutually influential behavior:
77
+ - When `BUILD_WASM=ON` the build disables `BUILD_TESTING` & `BUILD_PACKAGE` internally (see `CMakeLists.txt`). Toggle intentionally—do not expect tests with WASM in a single configure.
78
+
79
+ ---
80
+
81
+ ## 5. Common Build Scenarios
82
+
83
+ | Scenario | Commands (summary) |
84
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------- |
85
+ | Standard C++ (library + CLI) | `mkdir build-cpp && cd build-cpp && cmake .. && cmake --build .` |
86
+ | C++ Tests | (after standard build) run `./bin/cpp_tests` (Linux/macOS) or `./cpp_tests` inside `Debug/` or `Release/` (Windows) |
87
+ | WASM Module | `emcmake cmake -DBUILD_WASM=ON ..` then `emmake make` |
88
+ | WASM Tests (browser) | `npm install && npm run test:browser` |
89
+ | Documentation | `doxygen Doxyfile` |
90
+ | Package | `cmake -DBUILD_PACKAGE=ON -DBUILD_TESTING=OFF .. && cmake --build . --target package` |
91
+
92
+ ---
93
+
94
+ ## 6. Native Build Instructions
95
+
96
+ ### 6.1 Standard C++ Build
97
+
98
+ ```bash
99
+ git clone <repo-url> MEASUR-Tools-Suite
100
+ cd MEASUR-Tools-Suite
101
+ mkdir build-cpp
102
+ cd build-cpp
103
+ cmake .. # add -G "Ninja" or other generator if desired
104
+ cmake --build . # builds library + CLI + tests (if enabled)
105
+ ```
106
+ Artifacts:
107
+ - Library: `build-cpp/lib/libmeasur_tools_suite.a` (Linux/macOS) or `.lib` (Windows)
108
+ - CLI executable: `build-cpp/bin/measur_tools_suite` (Linux/macOS) or `measur_tools_suite.exe` (Windows under `Debug/` or `Release/` if multi-config)
109
+
110
+ ### 6.2 Running the CLI
111
+
112
+ ```bash
113
+ ./bin/measur_tools_suite --help
114
+ ```
115
+ (Adjust path for Windows: `./Debug/measur_tools_suite.exe` or `./Release/measur_tools_suite.exe`.)
116
+
117
+ ### 6.3 C++ Unit Tests
118
+
119
+ If `BUILD_TESTING=ON` (default in non-WASM builds):
120
+ ```bash
121
+ cd build-cpp/bin
122
+ ./cpp_tests
123
+ ```
124
+ Windows (multi-config):
125
+ ```bash
126
+ cd build-cpp/Debug
127
+ ./cpp_tests.exe
128
+ ```
129
+
130
+ ### 6.4 WebAssembly Build
131
+
132
+ #### Prerequisites: Emscripten SDK Setup
133
+
134
+ If you haven't installed Emscripten SDK yet:
135
+ ```bash
136
+ # Clone emsdk repository
137
+ git clone https://github.com/emscripten-core/emsdk.git
138
+ cd emsdk
139
+
140
+ # Install and activate latest version
141
+ ./emsdk install latest
142
+ ./emsdk activate latest
143
+ ```
144
+
145
+ #### Activate Emscripten Environment
146
+
147
+ Before building, activate emsdk in your current shell:
148
+ ```bash
149
+ # Linux/macOS
150
+ source /path/to/emsdk/emsdk_env.sh
151
+
152
+ # Windows
153
+ emsdk_env.bat
154
+ ```
155
+
156
+ To avoid running this every time, add it to your shell profile:
157
+ ```bash
158
+ # Linux/macOS (add to ~/.bashrc or ~/.zshrc)
159
+ echo 'source /path/to/emsdk/emsdk_env.sh' >> ~/.bashrc
160
+
161
+ # Then reload
162
+ source ~/.bashrc
163
+ ```
164
+
165
+ Verify activation:
166
+ ```bash
167
+ emcc --version # should show Emscripten version
168
+ ```
169
+
170
+ #### Build WebAssembly Module
171
+
172
+ With emsdk activated, configure and build:
173
+ ```bash
174
+ mkdir build-wasm
175
+ cd build-wasm
176
+ emcmake cmake -DBUILD_WASM=ON ..
177
+ emmake make
178
+ ```
179
+
180
+ Artifacts appear under `build-wasm/bin/`:
181
+ - `client.js` (glue / loader)
182
+ - `client.wasm` (compiled module)
183
+
184
+ ### 6.5 WebAssembly Usage Example
185
+
186
+ ```js
187
+ // Initialize module
188
+ const moduleFactory = (await import('/path/to/client.js')).default;
189
+ const toolsSuiteModule = await moduleFactory({
190
+ locateFile: (filename) => '/path/to/client.wasm'
191
+ });
192
+
193
+ // Example call
194
+ const totalHeatLoss = toolsSuiteModule.wallTotalHeatLoss(
195
+ 500, 80, 225, 10, 0.9, 1.394, 1
196
+ );
197
+ ```
198
+
199
+ ### 6.6 WebAssembly Tests (Browser)
200
+
201
+ Run from repository root (uses mocha):
202
+ ```bash
203
+ npm install
204
+ npm run test:browser
205
+ ```
206
+ Mocha tests reside in `tests/wasm-mocha/`. Re-running tests after editing JS/WASM test files does not require a rebuild unless C++ sources changed.
207
+
208
+ ### 6.7 Documentation Generation
209
+
210
+ ```bash
211
+ doxygen Doxyfile
212
+ ```
213
+ Output: `docs/html/index.html`.
214
+
215
+ ### 6.8 Packaging
216
+
217
+ Single-config (Linux/macOS):
218
+ ```bash
219
+ mkdir build-pkg && cd build-pkg
220
+ cmake -DBUILD_PACKAGE=ON -DBUILD_TESTING=OFF ..
221
+ cmake --build . --target package
222
+ ```
223
+ Windows (multi-config):
224
+ ```bash
225
+ cmake -B build-pkg -DBUILD_PACKAGE=ON -DBUILD_TESTING=OFF .
226
+ cmake --build build-pkg --config Release --target package
227
+ ```
228
+ Resulting archives appear in the build directory (`.tar.gz` / `.zip`).
229
+
230
+ ---
231
+
232
+ ## 7. Docker Workflow
233
+
234
+ Docker provides an automated, containerized build environment that handles all dependencies and produces both native (C++) and WebAssembly artifacts without manual setup.
235
+
236
+ ### 7.1 Prerequisites
237
+
238
+ - Docker Engine
239
+ - Docker Compose
240
+
241
+ Installation varies by platform:
242
+ ```bash
243
+ # Ubuntu/Debian
244
+ sudo apt-get update && sudo apt-get install -y docker.io docker-compose-plugin
245
+ sudo systemctl enable --now docker
246
+ sudo usermod -aG docker $USER
247
+ newgrp docker # activate group immediately
248
+
249
+ # macOS / Windows
250
+ # Install Docker Desktop from https://docker.com
251
+ ```
252
+
253
+ ### 7.2 Building with Docker
254
+
255
+ From repository root:
256
+ ```bash
257
+ docker compose up -d
258
+ ```
259
+
260
+ This command:
261
+ - Builds a Docker image with CMake, Emscripten SDK, Node.js, and Chrome
262
+ - Starts a container named `measur-tools-suite-build`
263
+ - Executes a full clean build of both native C++ and WebAssembly targets
264
+ - Keeps the container running for inspection
265
+
266
+ ### 7.3 Monitoring Build Progress
267
+
268
+ View real-time logs:
269
+ ```bash
270
+ docker compose logs -f
271
+ ```
272
+
273
+ View last N lines:
274
+ ```bash
275
+ docker compose logs --tail 20
276
+ ```
277
+
278
+ ### 7.4 Accessing Build Artifacts
279
+
280
+ Build outputs appear in host directories (via volume mounts):
281
+ - `build-cpp/bin/cpp_tests` - Native C++ test executable
282
+ - `build-cpp/bin/measur_tools_suite` - Native CLI executable
283
+ - `build-cpp/lib/libmeasur_tools_suite.a` - Static library
284
+ - `build-wasm/bin/client.js` + `client.wasm` - WebAssembly module
285
+
286
+ Run C++ tests on host:
287
+ ```bash
288
+ ./build-cpp/bin/cpp_tests
289
+ ```
290
+
291
+ Run WASM tests on host:
292
+ ```bash
293
+ npm install
294
+ npm run test:browser
295
+ ```
296
+
297
+ ### 7.5 Working Inside the Container
298
+
299
+ Exec into running container:
300
+ ```bash
301
+ docker exec -it measur-tools-suite-build /bin/bash
302
+ ```
303
+
304
+ Inside container, source tree is at `/home/MEASUR-Tools-Suite/`:
305
+ ```bash
306
+ # Run C++ tests
307
+ ./build-cpp/bin/cpp_tests
308
+
309
+ # Run WASM tests
310
+ npm run tests
311
+
312
+ # Incremental rebuild (native)
313
+ cmake --build build-cpp -j 8
314
+
315
+ # Incremental rebuild (WASM)
316
+ source /home/emsdk/emsdk_env.sh
317
+ emmake make -C build-wasm -j 8
318
+
319
+ # Exit container
320
+ exit
321
+ ```
322
+
323
+ ### 7.6 Stopping and Cleaning Up
324
+
325
+ Stop container (preserves build artifacts on host):
326
+ ```bash
327
+ docker compose down
328
+ ```
329
+
330
+ Remove all build artifacts and start fresh:
331
+ ```bash
332
+ rm -rf build-cpp build-wasm bin
333
+ docker compose up -d
334
+ ```
335
+
336
+ Rebuild Docker image (if Dockerfile changed):
337
+ ```bash
338
+ docker compose build --no-cache
339
+ docker compose up -d
340
+ ```
341
+
342
+ ### 7.7 Volume Mount Behavior
343
+
344
+ The `docker-compose.yml` mounts host directories into the container:
345
+ - `../MEASUR-Tools-Suite:/home/MEASUR-Tools-Suite` - Source code (editable from host)
346
+ - `./build-cpp:/home/MEASUR-Tools-Suite/build-cpp` - Native build outputs
347
+ - `./build-wasm:/home/MEASUR-Tools-Suite/build-wasm` - WASM build outputs
348
+
349
+ Changes to source files on the host are immediately visible inside the container, enabling iterative development.
350
+
351
+ ### 7.8 Docker Build Process Details
352
+
353
+ The container executes the following sequence:
354
+ 1. Cleans prior `bin/`, `build-cpp/`, and `build-wasm/` contents
355
+ 2. Configures native build: `cd build-cpp && cmake ..`
356
+ 3. Builds native targets: `cmake --build . -j 8`
357
+ 4. Configures WASM build: `cd build-wasm && emcmake cmake -DBUILD_WASM=ON ..`
358
+ 5. Builds WASM targets: `emmake make -j 8`
359
+ 6. Installs Node dependencies: `npm install`
360
+ 7. Sleeps indefinitely to keep container accessible
361
+
362
+ ### 7.9 Docker Troubleshooting
363
+
364
+ **Permission denied on `/var/run/docker.sock`:**
365
+ ```bash
366
+ sudo usermod -aG docker $USER
367
+ newgrp docker # or log out/in
368
+ ```
369
+
370
+ **Container exits immediately:**
371
+ ```bash
372
+ docker compose logs # check for build errors
373
+ ```
374
+
375
+ **Stale build artifacts:**
376
+ ```bash
377
+ rm -rf build-cpp build-wasm bin
378
+ docker compose up -d
379
+ ```
380
+
381
+ **Emscripten errors inside container:**
382
+ ```bash
383
+ docker exec -it measur-tools-suite-build /bin/bash
384
+ source /home/emsdk/emsdk_env.sh
385
+ emcc --version # verify Emscripten is active
386
+ ```
387
+
388
+ ---
389
+
390
+ ## 8. Troubleshooting (Native Builds)
391
+
392
+ - Multiple compilers: specify generator `-G "Ninja"` or `-G "Unix Makefiles"`; on MinGW use `-G "MinGW Makefiles"`.
393
+ - Switching between WASM and native builds: create separate build directories (`build-cpp`, `build-wasm`). Re-configuring in-place can leave incompatible flags.
394
+ - WASM link failures for undefined symbols: build excludes tests and packaging; confirm `BUILD_WASM=ON` only.
395
+ - Windows binary paths: look under `Debug/` or `Release/` if using multi-config IDE/toolchain.
396
+ - Emscripten environment not active: rerun `source ./emsdk_env.sh`.
397
+ - Stale cache: remove build directory (`rm -rf build-*`) instead of editing `CMakeCache.txt` manually.
398
+
399
+ ---
400
+
401
+ ## 9. Quick Reference
402
+
403
+ ### Native Builds
404
+
405
+ ```bash
406
+ # Native build (library + CLI + tests)
407
+ mkdir build-cpp && cd build-cpp && cmake .. && cmake --build .
408
+
409
+ # Run C++ tests
410
+ ./bin/cpp_tests
411
+
412
+ # WASM build
413
+ mkdir build-wasm && cd build-wasm && emcmake cmake -DBUILD_WASM=ON .. && emmake make
414
+
415
+ # WASM browser tests
416
+ npm install && npm run test:browser
417
+
418
+ # Docs
419
+ doxygen Doxyfile
420
+
421
+ # Package
422
+ cmake -DBUILD_PACKAGE=ON -DBUILD_TESTING=OFF .. && cmake --build . --target package
423
+ ```
424
+
425
+ ### Docker Builds
426
+
427
+ ```bash
428
+ # Start automated build
429
+ docker compose up -d
430
+
431
+ # Monitor progress
432
+ docker compose logs -f
433
+
434
+ # Run tests on host
435
+ ./build-cpp/bin/cpp_tests
436
+ npm run test:browser
437
+
438
+ # Access container
439
+ docker exec -it measur-tools-suite-build /bin/bash
440
+
441
+ # Stop container
442
+ docker compose down
443
+ ```
444
+
445
+ ---
446
+
447
+ If any scenario you need is missing here, open an issue or submit a PR to extend this guide.