Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build improvements and fixes #616

Merged
merged 5 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,27 @@ SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInAngles: "Never"
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never
---

IncludeBlocks: Regroup
IncludeCategories:
# # Specific external headers in <> to put first
- Regex: "<(catch2|gtest).*>"
Priority: 1
# External headers in <> with extension or /
- Regex: '<[-\w\/-_]+[\.\/][-\w\/-_]+>'
Priority: 2
# Standard headers in <>
- Regex: '<[-\w\/-_]+>'
Priority: 3
# Local headers in ""
- Regex: '"[-\w\/-_]*"'
Priority: 4
SortUsingDeclarations: true
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
CompilationDatabase: build/Debug
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"v5-compat.d.ts",
"draft.d.ts",
"script/*.js",
"script/*.d.ts"
"script/*.d.ts",
"docs/",
"docs-raw/"
]
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/prebuilds
/node_modules
pnpm-lock.yaml
/build
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@types/node": "^18.19.34",
"@types/semver": "^7.5.8",
"@types/shelljs": "^0.8.15",
"@types/weak-napi": "^2.0.3",
"@types/which": "^2.0.2",
"benchmark": "^2.1.4",
"chai": "^4.4.1",
Expand All @@ -54,7 +53,6 @@
"ts-node": "~10.9.2",
"typedoc": "^0.25.13",
"typescript": "~4.9.5",
"weak-napi": "^2.0.2",
"which": "^3.0.1"
},
"pnpm": {
Expand Down Expand Up @@ -91,13 +89,14 @@
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser",
"deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"",
"prebuild": "run-s build.js && node ./script/prebuild.js",
"build.native": "node-gyp configure --release && node-gyp build --release",
"build.native.debug": "cross-env CMAKE_BUILD_TYPE=Debug node-gyp configure --debug && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug",
"build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release",
"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",
"build": "run-s build.js build.native",
"build.debug": "run-s build.js build.native.debug",
"test": "run-s build && mocha --exit",
"test.skip_gc_tests": "run-s build.debug && cross-env SKIP_GC_TESTS=true mocha --exit",
"test.electron.main": "run-s build && electron-mocha",
"test.deps": "cd test && pnpm install && cd ..",
"test": "run-s test.deps build && mocha --exit",
"test.skip_gc_tests": "run-s test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha --exit",
"test.electron.main": "run-s test.deps build && electron-mocha",
"format": "prettier --write .",
"test.electron.renderer": "run-s build && electron-mocha --renderer",
"lint.clang-format": "clang-format -i -style=file ./src/*.cc ./src/*.h ./src/util/*.h",
Expand Down
43 changes: 0 additions & 43 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function main() {
console.log(cmake_configure)
exec(cmake_configure, execOptions)

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

Expand Down
9 changes: 9 additions & 0 deletions src/closable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

/* A thing that can be closed. Simple interface to allow us to correctly clean
up ZMQ resources at agent exit. */
namespace zmq {
struct Closable {
virtual void Close() = 0;
};
}
10 changes: 6 additions & 4 deletions src/context.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#include "context.h"
#include "module.h"
#include "socket.h"
#include "./context.h"

#include "util/uvwork.h"
#include "./module.h"
#include "./socket.h"
#include "util/arguments.h"
#include "util/error.h"
#include "util/object.h"

namespace zmq {
Context::Context(const Napi::CallbackInfo& info)
Expand Down
4 changes: 3 additions & 1 deletion src/context.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"
#include <napi.h>

#include "closable.h"

namespace zmq {
class Module;
Expand Down
4 changes: 3 additions & 1 deletion src/incoming_msg.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#include "incoming_msg.h"
#include "./incoming_msg.h"

#include <cassert>

#include "util/electron_helper.h"
#include "util/error.h"
Expand Down
4 changes: 3 additions & 1 deletion src/incoming_msg.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"
#include <napi.h>

#include "./zmq_inc.h"

namespace zmq {
class IncomingMsg {
Expand Down
7 changes: 7 additions & 0 deletions src/inline.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#ifdef _MSC_VER
#define force_inline inline __forceinline
#else
#define force_inline inline __attribute__((always_inline))
#endif
15 changes: 9 additions & 6 deletions src/module.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#include "module.h"
#include "context.h"
#include "observer.h"
#include "outgoing_msg.h"
#include "proxy.h"
#include "socket.h"
#include "./module.h"

#include "./context.h"
#include "./observer.h"
#include "./outgoing_msg.h"
#include "./proxy.h"
#include "./socket.h"
#include "util/error.h"
#include "util/to_string.h"

namespace zmq {
static inline Napi::String Version(const Napi::Env& env) {
Expand Down
15 changes: 4 additions & 11 deletions src/module.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"

#include "outgoing_msg.h"
#include <cstdio>
#include <future>

#include "util/arguments.h"
#include "util/error.h"
#include "util/object.h"
#include "./closable.h"
#include "./outgoing_msg.h"
#include "util/reaper.h"
#include "util/to_string.h"
#include "util/trash.h"

#include <chrono>
#include <cstdio>
#include <future>

namespace zmq {
class Context;
class Socket;
Expand Down
13 changes: 6 additions & 7 deletions src/observer.cc
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#include "observer.h"
#include "context.h"
#include "module.h"
#include "socket.h"
#include "./observer.h"

#include "incoming_msg.h"
#include "./context.h"
#include "./module.h"
#include "./socket.h"
#include "util/arguments.h"
#include "util/async_scope.h"
#include "util/error.h"
#include "util/take.h"

#include <array>

namespace zmq {
static inline constexpr const char* EventName(uint32_t val) {
switch (val) {
Expand Down
8 changes: 5 additions & 3 deletions src/observer.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"

#include "poller.h"
#include <napi.h>

#include <optional>

#include "./closable.h"
#include "./inline.h"
#include "./poller.h"

namespace zmq {
class Module;

Expand Down
4 changes: 2 additions & 2 deletions src/outgoing_msg.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#include "outgoing_msg.h"
#include "module.h"
#include "./outgoing_msg.h"

#include "./module.h"
#include "util/error.h"

namespace zmq {
Expand Down
4 changes: 3 additions & 1 deletion src/outgoing_msg.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once

#include "prefix.h"
#include <napi.h>

#include <forward_list>

#include "./zmq_inc.h"

namespace zmq {
class Module;

Expand Down
8 changes: 4 additions & 4 deletions src/proxy.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Copyright (c) 2017-2019 Rolf Timmermans */
#include "proxy.h"
#include "context.h"
#include "module.h"
#include "socket.h"
#include "./proxy.h"

#include "./context.h"
#include "./module.h"
#include "./socket.h"
#include "util/arguments.h"
#include "util/async_scope.h"
#include "util/error.h"
Expand Down
Loading
Loading