Skip to content

Commit 2f13ee2

Browse files
authored
Merge pull request #616 from zeromq/build-improve
Build improvements and fixes
2 parents 261a226 + 7c74763 commit 2f13ee2

37 files changed

+228
-139
lines changed

.clang-format

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,27 @@ SpaceBeforeAssignmentOperators: true
5656
SpaceBeforeParens: ControlStatements
5757
SpaceInEmptyParentheses: false
5858
SpacesBeforeTrailingComments: 2
59-
SpacesInAngles: false
59+
SpacesInAngles: "Never"
6060
SpacesInContainerLiterals: true
6161
SpacesInCStyleCastParentheses: false
6262
SpacesInParentheses: false
6363
SpacesInSquareBrackets: false
6464
Standard: Auto
6565
TabWidth: 4
6666
UseTab: Never
67-
---
6867

68+
IncludeBlocks: Regroup
69+
IncludeCategories:
70+
# # Specific external headers in <> to put first
71+
- Regex: "<(catch2|gtest).*>"
72+
Priority: 1
73+
# External headers in <> with extension or /
74+
- Regex: '<[-\w\/-_]+[\.\/][-\w\/-_]+>'
75+
Priority: 2
76+
# Standard headers in <>
77+
- Regex: '<[-\w\/-_]+>'
78+
Priority: 3
79+
# Local headers in ""
80+
- Regex: '"[-\w\/-_]*"'
81+
Priority: 4
82+
SortUsingDeclarations: true

.clangd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CompileFlags:
2+
CompilationDatabase: build/Debug

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"v5-compat.d.ts",
1414
"draft.d.ts",
1515
"script/*.js",
16-
"script/*.d.ts"
16+
"script/*.d.ts",
17+
"docs/",
18+
"docs-raw/"
1719
]
1820
}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/prebuilds
55
/node_modules
66
pnpm-lock.yaml
7+
/build

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"@types/node": "^18.19.34",
3232
"@types/semver": "^7.5.8",
3333
"@types/shelljs": "^0.8.15",
34-
"@types/weak-napi": "^2.0.3",
3534
"@types/which": "^2.0.2",
3635
"benchmark": "^2.1.4",
3736
"chai": "^4.4.1",
@@ -54,7 +53,6 @@
5453
"ts-node": "~10.9.2",
5554
"typedoc": "^0.25.13",
5655
"typescript": "~4.9.5",
57-
"weak-napi": "^2.0.2",
5856
"which": "^3.0.1"
5957
},
6058
"pnpm": {
@@ -91,13 +89,14 @@
9189
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser",
9290
"deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"",
9391
"prebuild": "run-s build.js && node ./script/prebuild.js",
94-
"build.native": "node-gyp configure --release && node-gyp build --release",
95-
"build.native.debug": "cross-env CMAKE_BUILD_TYPE=Debug node-gyp configure --debug && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug",
92+
"build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release",
93+
"build.native.debug": "node-gyp configure --debug && node-gyp configure --debug -- -f compile_commands_json && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug",
9694
"build": "run-s build.js build.native",
9795
"build.debug": "run-s build.js build.native.debug",
98-
"test": "run-s build && mocha --exit",
99-
"test.skip_gc_tests": "run-s build.debug && cross-env SKIP_GC_TESTS=true mocha --exit",
100-
"test.electron.main": "run-s build && electron-mocha",
96+
"test.deps": "cd test && pnpm install && cd ..",
97+
"test": "run-s test.deps build && mocha --exit",
98+
"test.skip_gc_tests": "run-s test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha --exit",
99+
"test.electron.main": "run-s test.deps build && electron-mocha",
101100
"format": "prettier --write .",
102101
"test.electron.renderer": "run-s build && electron-mocha --renderer",
103102
"lint.clang-format": "clang-format -i -style=file ./src/*.cc ./src/*.h ./src/util/*.h",

pnpm-lock.yaml

Lines changed: 0 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

script/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function main() {
8282
console.log(cmake_configure)
8383
exec(cmake_configure, execOptions)
8484

85-
const cmake_build = `cmake --build ./build --config ${CMAKE_BUILD_TYPE} --target install`
85+
const cmake_build = `cmake --build ./build --config ${CMAKE_BUILD_TYPE} --target install --parallel`
8686
console.log(cmake_build)
8787
exec(cmake_build, execOptions)
8888

src/closable.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
/* A thing that can be closed. Simple interface to allow us to correctly clean
4+
up ZMQ resources at agent exit. */
5+
namespace zmq {
6+
struct Closable {
7+
virtual void Close() = 0;
8+
};
9+
}

src/context.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
2-
#include "context.h"
3-
#include "module.h"
4-
#include "socket.h"
2+
#include "./context.h"
53

6-
#include "util/uvwork.h"
4+
#include "./module.h"
5+
#include "./socket.h"
6+
#include "util/arguments.h"
7+
#include "util/error.h"
8+
#include "util/object.h"
79

810
namespace zmq {
911
Context::Context(const Napi::CallbackInfo& info)

src/context.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
22
#pragma once
33

4-
#include "prefix.h"
4+
#include <napi.h>
5+
6+
#include "closable.h"
57

68
namespace zmq {
79
class Module;

src/incoming_msg.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
2-
#include "incoming_msg.h"
2+
#include "./incoming_msg.h"
3+
4+
#include <cassert>
35

46
#include "util/electron_helper.h"
57
#include "util/error.h"

src/incoming_msg.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
22
#pragma once
33

4-
#include "prefix.h"
4+
#include <napi.h>
5+
6+
#include "./zmq_inc.h"
57

68
namespace zmq {
79
class IncomingMsg {

src/inline.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#ifdef _MSC_VER
4+
#define force_inline inline __forceinline
5+
#else
6+
#define force_inline inline __attribute__((always_inline))
7+
#endif

src/module.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
2-
#include "module.h"
3-
#include "context.h"
4-
#include "observer.h"
5-
#include "outgoing_msg.h"
6-
#include "proxy.h"
7-
#include "socket.h"
2+
#include "./module.h"
3+
4+
#include "./context.h"
5+
#include "./observer.h"
6+
#include "./outgoing_msg.h"
7+
#include "./proxy.h"
8+
#include "./socket.h"
9+
#include "util/error.h"
10+
#include "util/to_string.h"
811

912
namespace zmq {
1013
static inline Napi::String Version(const Napi::Env& env) {

src/module.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
22
#pragma once
33

4-
#include "prefix.h"
5-
6-
#include "outgoing_msg.h"
4+
#include <cstdio>
5+
#include <future>
76

8-
#include "util/arguments.h"
9-
#include "util/error.h"
10-
#include "util/object.h"
7+
#include "./closable.h"
8+
#include "./outgoing_msg.h"
119
#include "util/reaper.h"
12-
#include "util/to_string.h"
1310
#include "util/trash.h"
1411

15-
#include <chrono>
16-
#include <cstdio>
17-
#include <future>
18-
1912
namespace zmq {
2013
class Context;
2114
class Socket;

src/observer.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
2-
#include "observer.h"
3-
#include "context.h"
4-
#include "module.h"
5-
#include "socket.h"
2+
#include "./observer.h"
63

7-
#include "incoming_msg.h"
4+
#include "./context.h"
5+
#include "./module.h"
6+
#include "./socket.h"
7+
#include "util/arguments.h"
88
#include "util/async_scope.h"
9+
#include "util/error.h"
910
#include "util/take.h"
1011

11-
#include <array>
12-
1312
namespace zmq {
1413
static inline constexpr const char* EventName(uint32_t val) {
1514
switch (val) {

src/observer.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
22
#pragma once
33

4-
#include "prefix.h"
5-
6-
#include "poller.h"
4+
#include <napi.h>
75

86
#include <optional>
97

8+
#include "./closable.h"
9+
#include "./inline.h"
10+
#include "./poller.h"
11+
1012
namespace zmq {
1113
class Module;
1214

src/outgoing_msg.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
2-
#include "outgoing_msg.h"
3-
#include "module.h"
2+
#include "./outgoing_msg.h"
43

4+
#include "./module.h"
55
#include "util/error.h"
66

77
namespace zmq {

src/outgoing_msg.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
22
#pragma once
33

4-
#include "prefix.h"
4+
#include <napi.h>
55

66
#include <forward_list>
77

8+
#include "./zmq_inc.h"
9+
810
namespace zmq {
911
class Module;
1012

src/proxy.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* Copyright (c) 2017-2019 Rolf Timmermans */
2-
#include "proxy.h"
3-
#include "context.h"
4-
#include "module.h"
5-
#include "socket.h"
2+
#include "./proxy.h"
63

4+
#include "./context.h"
5+
#include "./module.h"
6+
#include "./socket.h"
77
#include "util/arguments.h"
88
#include "util/async_scope.h"
99
#include "util/error.h"

0 commit comments

Comments
 (0)