Skip to content

Commit d9c29bd

Browse files
author
Paweł Aniszewski
committed
refactor(build): replace eslint/prettier with oxlint/oxfmt, add debug build variant, remove checksum cache
Linting/formatting: - Replace eslint + prettier with oxlint and oxfmt - Add .oxlintrc.json and .oxfmtrc.json config files - Remove eslint.config.mjs, prettier.config.js - Update package.json: lint/format scripts; remove eslint/prettier devDeps; add oxlint Debug/release build variants: - Add PRIVMX_BUILD_TYPE CMake cache variable to all five C++ components (async-engine, webendpoint-cpp, drv-crypto, drv-ecc, drv-net) - Debug: -O0 -g, ASSERTIONS=2, SAFE_HEAP=1, STACK_OVERFLOW_CHECK=2, no LTO - Release: unchanged (-O3, LTO, ASSERTIONS=0, SAFE_HEAP=0) - Add build:debug and build:wasm:debug npm scripts - pipeline.sh reads PRIVMX_BUILD_TYPE from env; passes it to build_api - build_api, build_async_engine, build_webdrivers read build type; reconfigure only when CMakeCache.txt is absent or the build type changed - Add configure_if_needed helper in build_webdrivers to avoid repetition Remove custom checksum cache: - Delete scripts/check_dir_checksum - Remove check_dir_checksum calls, RESULT case/esac blocks, and need_rebuild sentinel logic from build_gmp, build_poco, build_privmx_endpoint, build_pson, build_secp, build_api, build_async_engine, build_webdrivers - Replace with: configure step guarded by CMakeCache.txt / Makefile existence; make always runs (Make's own dependency graph skips unchanged units) Add clean:wasm script: - scripts/clean_wasm removes build-emscripten/ from every first-party C++ component and all dependency_sources/ subdirectories - Add "clean:wasm" npm script README: - Update build scripts table to include build:debug, build:wasm:debug, clean:wasm - Add "Release vs Debug builds" section with flag comparison table
1 parent 599df5e commit d9c29bd

22 files changed

Lines changed: 436 additions & 522 deletions

File tree

.oxfmtrc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"semi": true,
4+
"singleQuote": false,
5+
"printWidth": 100,
6+
"trailingComma": "all",
7+
"bracketSpacing": true,
8+
"arrowParens": "always",
9+
"tabWidth": 4,
10+
"sortPackageJson": false,
11+
"ignorePatterns": []
12+
}

.oxlintrc.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "unicorn", "oxc"],
4+
"categories": {
5+
"correctness": "error",
6+
"suspicious": "warn"
7+
},
8+
"env": {
9+
"builtin": true,
10+
"browser": true
11+
},
12+
"ignorePatterns": [
13+
"dist/**",
14+
"assets/**",
15+
"node_modules/**",
16+
"dependency_sources/**",
17+
"drivers/**",
18+
"async-engine/**",
19+
"webendpoint-cpp/**",
20+
"emsdk/**"
21+
],
22+
"overrides": [
23+
{
24+
"files": ["**/*.test.ts", "**/__tests__/**", "**/__mocks__/**"],
25+
"plugins": ["jest"],
26+
"rules": {
27+
"jest/expect-expect": "off",
28+
"jest/require-to-throw-message": "off"
29+
}
30+
}
31+
],
32+
"rules": {
33+
"no-console": "off",
34+
"no-shadow": "off",
35+
"no-useless-constructor": "off",
36+
"preserve-caught-error": "off",
37+
"typescript/no-extraneous-class": "off",
38+
"unicorn/prefer-query-selector": "off",
39+
"unicorn/no-array-for-each": "off",
40+
"unicorn/no-array-reduce": "off",
41+
"unicorn/prefer-add-event-listener": "off",
42+
"unicorn/require-post-message-target-origin": "off"
43+
}
44+
}

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,41 @@ The project uses a combined pipeline to compile the C++ core to Wasm and bundle
4747

4848
| Command | Description |
4949
| --- | --- |
50-
| `npm run build` | Runs the full pipeline: Clean -> Build Wasm -> Compile TS -> Bundle Webpack. |
51-
| `npm run build:wasm` | Compiles the C++ source code to WebAssembly using `scripts/pipeline.sh`. |
50+
| `npm run build` | Full release build: Clean → Build Wasm → Compile TS → Bundle Webpack. |
51+
| `npm run build:debug` | Full debug build (see below). |
52+
| `npm run build:wasm` | Compiles the C++ source to WebAssembly (release flags). |
53+
| `npm run build:wasm:debug` | Compiles the C++ source to WebAssembly (debug flags). |
5254
| `npm run build:js` | Compiles TypeScript (`tsc`) and bundles assets (`webpack`). |
5355
| `npm run watch:types` | Watches for TypeScript changes. |
5456

57+
### Release vs Debug builds
58+
59+
By default all builds are **release** builds: `-O3`, LTO enabled, `ASSERTIONS=0`, `SAFE_HEAP=0`.
60+
61+
A **debug** build swaps in the following flags for the WASM module:
62+
63+
| Flag | Release | Debug |
64+
| --- | --- | --- |
65+
| Optimisation | `-O3` + `-flto` | `-O0 -g` |
66+
| Emscripten assertions | `ASSERTIONS=0` | `ASSERTIONS=2` |
67+
| Heap safety checks | `SAFE_HEAP=0` | `SAFE_HEAP=1` |
68+
| Stack overflow check | off | `STACK_OVERFLOW_CHECK=2` |
69+
| Demangled stack traces | off | `DEMANGLE_SUPPORT=1` |
70+
| C++ `DEBUG` macro | not defined | defined |
71+
72+
```bash
73+
# Full debug build (WASM + JS)
74+
npm run build:debug
75+
76+
# WASM only (faster iteration)
77+
npm run build:wasm:debug
78+
79+
# Or pass the env variable directly to the pipeline script
80+
PRIVMX_BUILD_TYPE=debug npm run build:wasm
81+
```
82+
83+
> **Note:** Debug builds are significantly larger and slower than release builds. Use them only for local development and troubleshooting.
84+
5585
## Testing
5686

5787
The project employs a dual testing strategy: **Jest** for unit logic and **Playwright** for End-to-End (E2E) integration testing.

async-engine/CMakeLists.txt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,27 @@ Threads::Threads
3434
Pson
3535
)
3636

37-
target_compile_options(asyncengine PUBLIC
38-
-O3
39-
-pthread
40-
-fexceptions # Ensure exceptions are enabled for async logic
41-
)
37+
# ---------------------------------------------------------------------------
38+
# Build variant: release (default) or debug
39+
# ---------------------------------------------------------------------------
40+
set(PRIVMX_BUILD_TYPE "release" CACHE STRING "Build variant: release or debug")
41+
42+
if(PRIVMX_BUILD_TYPE STREQUAL "debug")
43+
message(STATUS "Building asyncengine: DEBUG")
44+
target_compile_options(asyncengine PUBLIC
45+
-O0 -g
46+
-pthread
47+
-fexceptions
48+
-DDEBUG
49+
)
50+
else()
51+
message(STATUS "Building asyncengine: RELEASE")
52+
target_compile_options(asyncengine PUBLIC
53+
-O3
54+
-pthread
55+
-fexceptions
56+
)
57+
endif()
4258

4359
target_link_options(asyncengine PUBLIC
4460
-L $ENV{SDK_DIR}/upstream/emscripten/cache/sysroot/lib

drivers/privmx-webendpoint-drv-crypto/CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@ add_library(privmxdrvcrypto ${SOURCES})
1111
target_include_directories(privmxdrvcrypto PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
1212
set_target_properties(privmxdrvcrypto PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/privmx/drv/crypto.h)
1313
target_link_libraries(privmxdrvcrypto embind)
14-
target_compile_options(privmxdrvcrypto PUBLIC
15-
-O3
16-
-pthread
17-
)
18-
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
14+
# ---------------------------------------------------------------------------
15+
# Build variant: release (default) or debug
16+
# ---------------------------------------------------------------------------
17+
set(PRIVMX_BUILD_TYPE "release" CACHE STRING "Build variant: release or debug")
18+
19+
if(PRIVMX_BUILD_TYPE STREQUAL "debug")
20+
message(STATUS "Building privmxdrvcrypto: DEBUG")
21+
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
22+
target_compile_options(privmxdrvcrypto PUBLIC -O0 -g -pthread -DDEBUG)
23+
else()
24+
message(STATUS "Building privmxdrvcrypto: RELEASE")
25+
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
26+
target_compile_options(privmxdrvcrypto PUBLIC -O3 -pthread)
27+
endif()
1928
target_link_options(privmxdrvcrypto PUBLIC
2029
-sUSE_PTHREADS
2130
-sEXPORTED_RUNTIME_METHODS=['HEAPU8','ccall']

drivers/privmx-webendpoint-drv-ecc/CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@ target_include_directories(privmxdrvecc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/incl
1212
set_target_properties(privmxdrvecc PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/privmx/drv/ecc.h)
1313
target_link_libraries(privmxdrvecc)
1414
target_link_libraries(privmxdrvecc embind)
15-
target_compile_options(privmxdrvecc PUBLIC
16-
-O3
17-
-pthread
18-
)
19-
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
15+
# ---------------------------------------------------------------------------
16+
# Build variant: release (default) or debug
17+
# ---------------------------------------------------------------------------
18+
set(PRIVMX_BUILD_TYPE "release" CACHE STRING "Build variant: release or debug")
19+
20+
if(PRIVMX_BUILD_TYPE STREQUAL "debug")
21+
message(STATUS "Building privmxdrvecc: DEBUG")
22+
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
23+
target_compile_options(privmxdrvecc PUBLIC -O0 -g -pthread -DDEBUG)
24+
else()
25+
message(STATUS "Building privmxdrvecc: RELEASE")
26+
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
27+
target_compile_options(privmxdrvecc PUBLIC -O3 -pthread)
28+
endif()
2029
target_link_options(privmxdrvecc PUBLIC
2130
-L $ENV{SDK_DIR}/upstream/emscripten/cache/sysroot/lib
2231
-sUSE_PTHREADS

drivers/privmx-webendpoint-drv-net/CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@ add_library(privmxdrvnet ${SOURCES})
1010
target_include_directories(privmxdrvnet PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
1111
set_target_properties(privmxdrvnet PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/privmx/drv/net.h)
1212
target_link_libraries(privmxdrvnet PRIVATE embind)
13-
target_compile_options(privmxdrvnet PUBLIC
14-
-O3
15-
-pthread
16-
)
17-
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
13+
# ---------------------------------------------------------------------------
14+
# Build variant: release (default) or debug
15+
# ---------------------------------------------------------------------------
16+
set(PRIVMX_BUILD_TYPE "release" CACHE STRING "Build variant: release or debug")
17+
18+
if(PRIVMX_BUILD_TYPE STREQUAL "debug")
19+
message(STATUS "Building privmxdrvnet: DEBUG")
20+
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
21+
target_compile_options(privmxdrvnet PUBLIC -O0 -g -pthread -DDEBUG)
22+
else()
23+
message(STATUS "Building privmxdrvnet: RELEASE")
24+
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
25+
target_compile_options(privmxdrvnet PUBLIC -O3 -pthread)
26+
endif()
1827
target_link_options(privmxdrvnet PUBLIC
1928
-L $ENV{SDK_DIR}/upstream/emscripten/cache/sysroot/lib
2029
-sUSE_PTHREADS

eslint.config.mjs

Lines changed: 0 additions & 95 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,20 @@
4040
"clean": "rm -rf ./dist",
4141
"test": "jest src",
4242
"build": "npm run clean && npm run build:wasm && npm run build:js && scripts/move_wasm_assets",
43+
"build:debug": "npm run clean && npm run build:wasm:debug && npm run build:js && scripts/move_wasm_assets",
4344
"build:wasm": "scripts/pipeline.sh",
45+
"build:wasm:debug": "PRIVMX_BUILD_TYPE=debug scripts/pipeline.sh",
4446
"build:js": "npm run compile && npm run bundle && npm run build:worker && cp ./dist/assets/* ./assets/ && cp ./dist/bundle/rms-processor.js ./assets/",
4547
"build:worker": "webpack --config ./webpack.worker.config.js",
48+
"clean:wasm": "scripts/clean_wasm",
4649
"compile": "tsc",
4750
"bundle": "webpack",
4851
"watch:types": "tsc -w",
4952
"test:e2e": "playwright test --project=chromium",
5053
"test:e2e:manybrowsers": "playwright test",
51-
"lint": "eslint -c eslint.config.mjs .",
52-
"format": "prettier --write '{src,tests}/**/*.{ts,tsx,css,md}'",
54+
"lint": "oxlint src/",
55+
"format": "oxfmt src/",
56+
"format:check": "oxfmt --check src/",
5357
"format:clang": "find webendpoint-cpp drivers async-engine -type f \\( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \\) -print0 | xargs -0 clang-format -i",
5458
"lint:clang-format": "find webendpoint-cpp drivers async-engine -type f \\( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \\) -print0 | xargs -0 clang-format --dry-run --Werror",
5559
"prepack": "mkdir -p ./builds",
@@ -68,23 +72,15 @@
6872
"node": ">=4"
6973
},
7074
"devDependencies": {
71-
"@eslint/js": "^9.39.2",
7275
"@playwright/test": "^1.57.0",
73-
"@stylistic/eslint-plugin": "^5.6.1",
7476
"@types/aes-js": "^3.1.4",
7577
"@types/jest": "^29.5.14",
7678
"@types/node": "^20.9.0",
7779
"@types/webpack": "^5.28.5",
78-
"@typescript-eslint/eslint-plugin": "^8.51.0",
79-
"@typescript-eslint/parser": "^8.51.0",
8080
"copy-webpack-plugin": "^14.0.0",
81-
"eslint": "^9.39.2",
82-
"eslint-config-prettier": "^10.1.8",
83-
"eslint-plugin-indent-empty-lines": "^1.0.2",
84-
"eslint-plugin-prettier": "^5.5.4",
8581
"jest": "^29.7.0",
8682
"mongodb": "^7.0.0",
87-
"prettier": "^3.7.4",
83+
"oxlint": "^1.60.0",
8884
"ts-jest": "^29.2.5",
8985
"ts-loader": "^9.5.1",
9086
"ts-node": "^10.9.1",

prettier.config.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)