Skip to content

Commit d7e538a

Browse files
Update the NUClear codebase to the latest version (#21)
Updates the NUClear codebase to the latest version to help with some compile errors and improve the stability --------- Co-authored-by: Josephus Paye II <j.paye96@gmail.com>
1 parent 8b72040 commit d7e538a

File tree

229 files changed

+11809
-6913
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+11809
-6913
lines changed

.clang-format

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# C++ files
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
AccessModifierOffset: -4
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveMacros: true
7+
AlignConsecutiveAssignments: true
8+
AlignConsecutiveDeclarations: false
9+
AlignEscapedNewlines: Left
10+
AlignOperands: true
11+
AlignTrailingComments: true
12+
AllowAllArgumentsOnNextLine: false
13+
AllowAllConstructorInitializersOnNextLine: true
14+
AllowAllParametersOfDeclarationOnNextLine: false
15+
AllowShortBlocksOnASingleLine: false
16+
AllowShortCaseLabelsOnASingleLine: true
17+
AllowShortFunctionsOnASingleLine: Empty
18+
AllowShortLambdasOnASingleLine: All
19+
AllowShortIfStatementsOnASingleLine: Never
20+
AllowShortLoopsOnASingleLine: false
21+
AlwaysBreakAfterReturnType: None
22+
AlwaysBreakBeforeMultilineStrings: true
23+
AlwaysBreakTemplateDeclarations: Yes
24+
BinPackArguments: false
25+
BinPackParameters: false
26+
BraceWrapping:
27+
AfterCaseLabel: false
28+
AfterClass: false
29+
AfterControlStatement: false
30+
AfterEnum: false
31+
AfterFunction: false
32+
AfterNamespace: false
33+
AfterStruct: false
34+
AfterUnion: false
35+
AfterExternBlock: false
36+
BeforeCatch: true
37+
BeforeElse: true
38+
IndentBraces: false
39+
SplitEmptyFunction: false
40+
SplitEmptyRecord: false
41+
SplitEmptyNamespace: false
42+
BreakBeforeBinaryOperators: NonAssignment
43+
BreakBeforeBraces: Custom
44+
BreakInheritanceList: BeforeComma
45+
BreakBeforeTernaryOperators: true
46+
BreakConstructorInitializers: BeforeComma
47+
BreakStringLiterals: true
48+
ColumnLimit: 120
49+
CompactNamespaces: false
50+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
51+
ConstructorInitializerIndentWidth: 4
52+
ContinuationIndentWidth: 4
53+
Cpp11BracedListStyle: true
54+
DerivePointerAlignment: false
55+
FixNamespaceComments: true
56+
IncludeBlocks: Regroup
57+
IndentCaseLabels: true
58+
IndentPPDirectives: BeforeHash
59+
IndentWrappedFunctionNames: true
60+
IndentWidth: 4
61+
KeepEmptyLinesAtTheStartOfBlocks: true
62+
MaxEmptyLinesToKeep: 2
63+
NamespaceIndentation: Inner
64+
PointerAlignment: Left
65+
ReflowComments: true
66+
SortIncludes: true
67+
SortUsingDeclarations: true
68+
SpaceAfterCStyleCast: true
69+
SpaceAfterLogicalNot: false
70+
SpaceAfterTemplateKeyword: true
71+
SpaceBeforeAssignmentOperators: true
72+
SpaceBeforeCpp11BracedList: false
73+
SpaceBeforeCtorInitializerColon: true
74+
SpaceBeforeInheritanceColon: true
75+
SpaceBeforeParens: ControlStatements
76+
SpaceBeforeRangeBasedForLoopColon: true
77+
SpaceInEmptyParentheses: false
78+
SpacesBeforeTrailingComments: 2
79+
SpacesInAngles: false
80+
SpacesInCStyleCastParentheses: false
81+
SpacesInContainerLiterals: false
82+
SpacesInParentheses: false
83+
SpacesInSquareBrackets: false
84+
Standard: Cpp11
85+
TabWidth: 4
86+
UseTab: Never

.github/workflows/node.js.yml

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@ name: Node.js CI
55

66
on:
77
push:
8-
branches: [ main ]
8+
branches: [main]
99
pull_request:
10-
branches: [ main ]
10+
branches: [main]
11+
12+
# Ensure that only one instance of the workflow is run at a time for each branch/tag.
13+
# Jobs currently running on the branch/tag will be cancelled when new commits are pushed.
14+
# See https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency.
15+
concurrency:
16+
# `github.workflow` is the workflow name, `github.ref` is the current branch/tag identifier
17+
group: ${{ format('{0}:{1}', github.workflow, github.ref) }}
18+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1119

1220
jobs:
1321
build:
14-
1522
runs-on: ${{ matrix.os }}
23+
continue-on-error: true
1624

1725
strategy:
1826
matrix:
@@ -21,19 +29,23 @@ jobs:
2129
node-version: [18.x, 20.x]
2230

2331
steps:
24-
# Install node-gyp
25-
- name: Install node-gyp
26-
run: npm install -g node-gyp
27-
- uses: actions/checkout@v2
28-
- name: Use Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v2
30-
with:
31-
node-version: ${{ matrix.node-version }}
32-
cache: 'npm'
33-
- run: npm ci
34-
- run: npm run build --if-present
35-
# Run the tests up to 5 times if it fails (to avoid the error "Network error when sending
36-
# the announce packet: Bad file descriptor" that occurs sometimes on startup)
37-
# TODO: investigate and fix the actual issue.
38-
- shell: bash
39-
run: ./tests/run-with-retries.sh
32+
- name: Checkout Code
33+
uses: actions/checkout@v3
34+
35+
- name: Use Node.js ${{ matrix.node-version }}
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: ${{ matrix.node-version }}
39+
cache: "npm"
40+
41+
- name: Install node-gyp
42+
run: npm install -g node-gyp
43+
44+
- name: Install dependencies
45+
run: npm ci
46+
47+
- name: Build
48+
run: npm run build --if-present
49+
50+
- name: Run tests
51+
run: npm test

.github/workflows/publish-to-npm.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@ jobs:
88
publish_to_npm:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- name: Checkout Code
12+
uses: actions/checkout@v3
1213
with:
1314
ref: main
15+
1416
# Installs Node and sets up up the .npmrc file to publish to npm
15-
- uses: actions/setup-node@v2
17+
- uses: actions/setup-node@v4
1618
with:
17-
node-version: '16.x'
18-
registry-url: 'https://registry.npmjs.org'
19-
- run: npm ci
20-
# Run the tests up to 5 times if it fails (to avoid the error "Network error when sending
21-
# the announce packet: Bad file descriptor" that occurs sometimes on startup)
22-
# TODO: investigate and fix the actual issue.
23-
- shell: bash
24-
run: ./tests/run-with-retries.sh
25-
- run: node .github/auto-publish-action.js
19+
node-version: "18.x"
20+
registry-url: "https://registry.npmjs.org"
21+
22+
- name: "Install Dependencies"
23+
run: npm ci
24+
25+
- name: "Test Code"
26+
run: npm test
27+
28+
- name: "Publish to npm"
29+
run: node .github/auto-publish-action.js
2630
env:
2731
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ build/Release
2626
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
2727
node_modules
2828
build
29+
30+
# # Mac OS X clutter
31+
.DS_Store

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.tabSize": 4,
4+
"editor.insertSpaces": true,
5+
"files.insertFinalNewline": true,
6+
"files.trimFinalNewlines": true,
7+
"files.eol": "\n",
8+
"editor.rulers": [120],
9+
"files.associations": {
10+
"*.ipp": "cpp"
11+
}
12+
}

binding.gyp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
'src/NetworkListener.cpp',
99
'src/nuclear/src/extension/network/NUClearNetwork.cpp',
1010
'src/nuclear/src/util/platform.cpp',
11-
'src/nuclear/src/util/serialise/xxhash.c',
12-
'src/nuclear/src/util/network/get_interfaces.cpp'
11+
'src/nuclear/src/util/network/get_interfaces.cpp',
12+
'src/nuclear/src/util/network/if_number_from_address.cpp',
13+
'src/nuclear/src/util/network/resolve.cpp',
14+
'src/nuclear/src/util/serialise/xxhash.cpp'
1315
],
1416
'cflags': [],
1517
'include_dirs': [
1618
'<!@(node -p "require(\'node-addon-api\').include")',
17-
"<!@(node -p \"require('napi-thread-safe-callback').include\")",
1819
'src/nuclear/src/include'
1920
],
2021
"defines": [

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ class NUClearNet extends EventEmitter {
6868
}
6969
});
7070

71-
// Bind our callback functions
72-
this._net.on('packet', this._onPacket.bind(this));
73-
this._net.on('join', this._onJoin.bind(this));
74-
this._net.on('leave', this._onLeave.bind(this));
75-
this._net.on('wait', this._onWait.bind(this));
71+
// Pass our javascript callbacks to the C++ side
72+
this._net.onPacket(this._onPacket.bind(this));
73+
this._net.onJoin(this._onJoin.bind(this));
74+
this._net.onLeave(this._onLeave.bind(this));
75+
this._net.onWait(this._onWait.bind(this));
7676
}
7777

7878
_onPacket(name, address, port, reliable, hash, payload) {

package-lock.json

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

0 commit comments

Comments
 (0)