measur-tools-suite 1.0.13-beta.141 → 1.0.13-beta.142

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,443 @@
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
+ > **Tip:** Use dedicated build directories (for example, `build-cpp` and `build-wasm`) instead of reconfiguring the same directory when you switch scenarios. This avoids stale cache entries and conflicting options.
80
+
81
+ ---
82
+
83
+ ## 5. Common Build Scenarios
84
+
85
+ | Scenario | Commands (summary) |
86
+ | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
87
+ | Standard C++ (library + CLI) | `cmake -S . -B build-cpp && cmake --build build-cpp` (Windows: add `--config Release` or desired configuration) |
88
+ | C++ Tests | (after standard build) run `./build-cpp/bin/cpp_tests` (Linux/macOS) or `./build-cpp/Debug/cpp_tests.exe` (Windows; use `Release/` as needed) |
89
+ | WASM Module | `emcmake cmake -S . -B build-wasm -DBUILD_WASM=ON` then `emmake make -C build-wasm` |
90
+ | WASM Tests (browser) | `npm install && npm run test:browser` |
91
+ | Documentation | `doxygen Doxyfile` |
92
+ | Package | `cmake -S . -B build-pkg -DBUILD_PACKAGE=ON -DBUILD_TESTING=OFF && cmake --build build-pkg --target package` |
93
+
94
+ ---
95
+
96
+ ## 6. Native Build Instructions
97
+
98
+ ### 6.1 Standard C++ Build
99
+
100
+ ```bash
101
+ git clone <repo-url> MEASUR-Tools-Suite
102
+ cd MEASUR-Tools-Suite
103
+ cmake -S . -B build-cpp # add -G "Ninja" or other generator if desired
104
+ cmake --build build-cpp # builds library + CLI + tests (if enabled)
105
+ ```
106
+ (On Windows multi-config generators (e.g., Visual Studio), specify a configuration: `cmake --build build-cpp --config Release` (or `Debug`).)
107
+
108
+ Artifacts appear under `build-cpp/bin/` or on Windows `build-cpp/Debug/` or `build-cpp/Release/`.
109
+
110
+ ### 6.2 Running the CLI
111
+
112
+ ```bash
113
+ ./build-cpp/bin/measur_tools_suite --help
114
+ ```
115
+ (Adjust path for Windows: `./build-cpp/Debug/measur_tools_suite.exe` or `./build-cpp/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
+ ./build-cpp/bin/cpp_tests
122
+ ```
123
+ Windows (multi-config):
124
+ ```bash
125
+ ./build-cpp/Debug/cpp_tests.exe
126
+ # or
127
+ ./build-cpp/Release/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
+ emcmake cmake -S . -B build-wasm -DBUILD_WASM=ON
175
+ emmake make -C build-wasm
176
+ ```
177
+ Artifacts appear under `build-wasm/bin/`. Copy them to `bin/` for standard access:
178
+ ```bash
179
+ cp -a build-wasm/bin ./bin
180
+ ```
181
+
182
+ ### 6.5 WebAssembly Usage Example
183
+
184
+ ```js
185
+ // Initialize module
186
+ const moduleFactory = (await import('/path/to/client.js')).default;
187
+ const toolsSuiteModule = await moduleFactory({
188
+ locateFile: (filename) => '/path/to/client.wasm'
189
+ });
190
+
191
+ // Example call
192
+ const totalHeatLoss = toolsSuiteModule.wallTotalHeatLoss(
193
+ 500, 80, 225, 10, 0.9, 1.394, 1
194
+ );
195
+ ```
196
+
197
+ ### 6.6 WebAssembly Tests (Browser)
198
+
199
+ Run from repository root (uses mocha):
200
+ ```bash
201
+ npm install
202
+ npm run test:browser
203
+ ```
204
+ 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. Rerun `npm install` only when dependencies change or the lockfile updates.
205
+
206
+ ### 6.7 Documentation Generation
207
+
208
+ ```bash
209
+ doxygen Doxyfile
210
+ ```
211
+ Output: `docs/html/index.html`.
212
+
213
+ ### 6.8 Packaging
214
+
215
+ Single-config (Linux/macOS):
216
+ ```bash
217
+ cmake -S . -B build-pkg -DBUILD_PACKAGE=ON -DBUILD_TESTING=OFF
218
+ cmake --build build-pkg --target package
219
+ ```
220
+ Windows (multi-config):
221
+ ```bash
222
+ cmake -S . -B build-pkg -DBUILD_PACKAGE=ON -DBUILD_TESTING=OFF
223
+ cmake --build build-pkg --config Release --target package
224
+ ```
225
+ Resulting archives appear in the build directory (`.tar.gz` / `.zip`).
226
+
227
+ ---
228
+
229
+ ## 7. Docker Workflow
230
+
231
+ Docker provides an automated, containerized build environment that handles all dependencies and produces both native (C++) and WebAssembly artifacts without manual setup.
232
+
233
+ ### 7.1 Prerequisites
234
+
235
+ - Docker Engine
236
+ - Docker Compose
237
+
238
+ Installation varies by platform:
239
+ ```bash
240
+ # Ubuntu/Debian
241
+ sudo apt-get update && sudo apt-get install -y docker.io docker-compose-plugin
242
+ sudo systemctl enable --now docker
243
+ sudo usermod -aG docker $USER
244
+ newgrp docker # activate group immediately
245
+
246
+ # macOS / Windows
247
+ # Install Docker Desktop from https://docker.com
248
+ ```
249
+
250
+ ### 7.2 Building with Docker
251
+
252
+ From repository root:
253
+ ```bash
254
+ docker compose up -d
255
+ ```
256
+
257
+ This command:
258
+ - Builds a Docker image with CMake, Emscripten SDK, Node.js, and Chrome
259
+ - Starts a container named `measur-tools-suite-build`
260
+ - Executes a full clean build of both native C++ and WebAssembly targets
261
+ - Keeps the container running for inspection
262
+
263
+ ### 7.3 Monitoring Build Progress
264
+
265
+ View real-time logs:
266
+ ```bash
267
+ docker compose logs -f
268
+ ```
269
+
270
+ View last N lines:
271
+ ```bash
272
+ docker compose logs --tail 20
273
+ ```
274
+
275
+ ### 7.4 Accessing Build Artifacts
276
+
277
+ Build outputs appear in host directories (via volume mounts):
278
+ - `build-cpp/bin/cpp_tests` - Native C++ test executable
279
+ - `build-cpp/bin/measur_tools_suite` - Native CLI executable
280
+ - `build-cpp/lib/libmeasur_tools_suite.a` - Static library
281
+ - `bin/client.js` + `client.wasm` - WebAssembly module
282
+
283
+ Run C++ tests on host:
284
+ ```bash
285
+ ./build-cpp/bin/cpp_tests
286
+ ```
287
+
288
+ Run WASM tests on host:
289
+ ```bash
290
+ npm install
291
+ npm run test:browser
292
+ ```
293
+
294
+ ### 7.5 Working Inside the Container
295
+
296
+ Exec into running container:
297
+ ```bash
298
+ docker exec -it measur-tools-suite-build /bin/bash
299
+ ```
300
+
301
+ Inside container, source tree is at `/home/MEASUR-Tools-Suite/`:
302
+ ```bash
303
+ # Run C++ tests
304
+ ./build-cpp/bin/cpp_tests
305
+ # Windows: ./build-cpp/Debug/cpp_tests.exe (or Release)
306
+
307
+ # Run WASM tests
308
+ npm run tests
309
+
310
+ # Exit container
311
+ exit
312
+ ```
313
+
314
+ ### 7.6 Stopping and Cleaning Up
315
+
316
+ Stop container (preserves build artifacts on host):
317
+ ```bash
318
+ docker compose down
319
+ ```
320
+
321
+ Remove all build artifacts and start fresh:
322
+ ```bash
323
+ rm -rf build-cpp build-wasm bin
324
+ docker compose up -d
325
+ ```
326
+
327
+ Rebuild Docker image (if Dockerfile changed):
328
+ ```bash
329
+ docker compose build --no-cache
330
+ docker compose up -d
331
+ ```
332
+
333
+ ### 7.7 Volume Mount Behavior
334
+
335
+ The `docker-compose.yml` mounts host directories into the container:
336
+ - `../MEASUR-Tools-Suite:/home/MEASUR-Tools-Suite` - Source code (editable from host)
337
+ - `./bin:/home/MEASUR-Tools-Suite/bin` - WASM build outputs
338
+ - `./build-cpp:/home/MEASUR-Tools-Suite/build-cpp` - Native build outputs
339
+ - `./build-wasm:/home/MEASUR-Tools-Suite/build-wasm` - WASM build outputs
340
+
341
+ Changes to source files on the host are immediately visible inside the container, enabling iterative development.
342
+
343
+ ### 7.8 Docker Build Process Details
344
+
345
+ The container executes the following sequence:
346
+ 1. Cleans prior `bin/`, `build-cpp/`, and `build-wasm/` contents
347
+ 2. Configures native build: `cd build-cpp && cmake ..`
348
+ 3. Builds native targets: `cmake --build . -j 8`
349
+ 4. Configures WASM build: `cd build-wasm && emcmake cmake -DBUILD_WASM=ON ..`
350
+ 5. Builds WASM targets: `emmake make -j 8`
351
+ 6. Copies WASM artifacts to mounted `bin/` directory
352
+ 7. Installs Node dependencies: `npm install`
353
+ 8. Runs browser-based WASM tests using headless Chrome: `npm run tests`
354
+ 9. Sleeps indefinitely to keep container accessible
355
+
356
+ ### 7.9 Docker Troubleshooting
357
+
358
+ **Permission denied on `/var/run/docker.sock`:**
359
+ ```bash
360
+ sudo usermod -aG docker $USER
361
+ newgrp docker # or log out/in
362
+ ```
363
+
364
+ **Container exits immediately:**
365
+ ```bash
366
+ docker compose logs # check for build errors
367
+ ```
368
+
369
+ **Stale build artifacts:**
370
+ ```bash
371
+ rm -rf build-cpp build-wasm bin
372
+ docker compose up -d
373
+ ```
374
+
375
+ **Emscripten errors inside container:**
376
+ ```bash
377
+ docker exec -it measur-tools-suite-build /bin/bash
378
+ source /home/emsdk/emsdk_env.sh
379
+ emcc --version # verify Emscripten is active
380
+ ```
381
+
382
+ ---
383
+
384
+ ## 8. Troubleshooting (Native Builds)
385
+
386
+ - Multiple compilers: specify generator `-G "Ninja"` or `-G "Unix Makefiles"`; on MinGW use `-G "MinGW Makefiles"`.
387
+ - Switching between WASM and native builds: create separate build directories (`build-cpp`, `build-wasm`). Re-configuring in-place can leave incompatible flags.
388
+ - WASM link failures for undefined symbols: build excludes tests and packaging; confirm `BUILD_WASM=ON` only.
389
+ - Windows binary paths: look under `Debug/` or `Release/` if using multi-config IDE/toolchain.
390
+ - Emscripten environment not active: rerun `source ./emsdk_env.sh`.
391
+ - Stale cache: remove build directory (`rm -rf build-*`) instead of editing `CMakeCache.txt` manually.
392
+
393
+ ---
394
+
395
+ ## 9. Quick Reference
396
+
397
+ ### Native Builds
398
+
399
+ ```bash
400
+ # Native build (library + CLI + tests)
401
+ cmake -S . -B build-cpp && cmake --build build-cpp
402
+ # Windows multi-config generators: cmake --build build-cpp --config Release
403
+
404
+ # Run C++ tests
405
+ ./build-cpp/bin/cpp_tests
406
+
407
+ # WASM build
408
+ emcmake cmake -S . -B build-wasm -DBUILD_WASM=ON && emmake make -C build-wasm
409
+
410
+ # WASM browser tests
411
+ npm install && npm run test:browser # install needed only on first run
412
+
413
+ # Docs
414
+ doxygen Doxyfile
415
+
416
+ # Package
417
+ cmake -S . -B build-pkg -DBUILD_PACKAGE=ON -DBUILD_TESTING=OFF && cmake --build build-pkg --target package
418
+ # Windows multi-config generators: cmake --build build-pkg --config Release --target package
419
+ ```
420
+
421
+ ### Docker Builds
422
+
423
+ ```bash
424
+ # Start automated build
425
+ docker compose up -d
426
+
427
+ # Monitor progress
428
+ docker compose logs -f
429
+
430
+ # Run tests on host
431
+ ./build-cpp/bin/cpp_tests
432
+ npm run test:browser
433
+
434
+ # Access container
435
+ docker exec -it measur-tools-suite-build /bin/bash
436
+
437
+ # Stop container
438
+ docker compose down
439
+ ```
440
+
441
+ ---
442
+
443
+ If any scenario you need is missing here, open an issue or submit a PR to extend this guide.