Skip to content

Commit 20199c8

Browse files
authored
Merge pull request #191 from bentruyman/build-improvements
Make CI pass, make Node.js 18 the minimum, disables `standard` checking for now
2 parents f1c2f07 + 240aab6 commit 20199c8

File tree

15 files changed

+664
-873
lines changed

15 files changed

+664
-873
lines changed

.github/workflows/release.yml

Lines changed: 217 additions & 181 deletions
Large diffs are not rendered by default.

.github/workflows/test.yml

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,26 @@
11
name: Test
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
6-
style:
7-
runs-on: ubuntu-latest
8-
steps:
9-
- name: checkout
10-
uses: actions/checkout@v2
11-
with:
12-
fetch-depth: 0
13-
- uses: actions/setup-node@v2
14-
- name: Code Style Check
15-
run: npx -y prettier -c .
16-
# run: npx @biomejs/biome format . # do this after we move to biome config
17-
186
build:
197
strategy:
208
fail-fast: false
219
matrix:
22-
node-version: [18.x]
10+
node-version: ['18', '20', '22']
2311
os: [ubuntu, macos, windows]
2412
runs-on: ${{ matrix.os }}-latest
2513
steps:
2614
- name: checkout
27-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
2816
with:
2917
fetch-depth: 0
3018
- name: Use Node.js ${{ matrix.node-version }}
31-
uses: actions/setup-node@v2
19+
uses: actions/setup-node@v4
3220
with:
3321
node-version: ${{ matrix.node-version }}
34-
- name: Cache Node Dependencies
35-
id: cache
36-
uses: actions/cache@v2
37-
with:
38-
path: ./node_modules
39-
key: modules-${{ hashFiles('package-lock.json') }}
22+
cache: 'npm'
4023
- name: Install Node Dependencies
41-
if: steps.cache.outputs.cache-hit != 'true'
4224
run: npm ci --ignore-scripts
4325
- name: Install System Dependencies
4426
if: matrix.os == 'ubuntu'
@@ -47,37 +29,73 @@ jobs:
4729
run: npm run compile
4830
- name: Test
4931
run: npm test
32+
5033
build-linux-arm:
5134
runs-on: ubuntu-latest
5235
steps:
5336
- name: checkout
54-
uses: actions/checkout@v2
37+
uses: actions/checkout@v4
5538
with:
5639
fetch-depth: 0
5740
- name: Set up QEMU
58-
uses: docker/setup-qemu-action@v2
59-
- name: Cache Node Dependencies
60-
id: cache
61-
uses: actions/cache@v2
41+
uses: docker/setup-qemu-action@v3
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v4
6244
with:
63-
path: ./node_modules
64-
key: modules-${{ hashFiles('package-lock.json') }}
45+
node-version: '20'
46+
cache: 'npm'
6547
- name: Build for arm
66-
run: docker run --platform linux/arm --rm -v "${PWD}:/work" -w /work node ./tools/crossbuild.sh
48+
run: docker run --platform linux/arm/v7 --rm -v "${PWD}:/work" -w /work node:20-bullseye ./tools/crossbuild.sh
49+
50+
build-linux-arm64:
51+
runs-on: ubuntu-24.04-arm64
52+
steps:
53+
- name: checkout
54+
uses: actions/checkout@v4
55+
with:
56+
fetch-depth: 0
57+
- name: Setup Node.js
58+
uses: actions/setup-node@v4
59+
with:
60+
node-version: '20'
61+
cache: 'npm'
62+
- name: Install Node Dependencies
63+
run: npm ci --ignore-scripts
64+
- name: Install System Dependencies
65+
run: sudo apt-get update && sudo apt-get install -y xorg-dev libglu1-mesa-dev cmake build-essential
66+
- name: Build Node Addon
67+
run: npm run compile
68+
6769
build-linux-arm-drm:
6870
runs-on: ubuntu-latest
6971
steps:
7072
- name: checkout
71-
uses: actions/checkout@v2
73+
uses: actions/checkout@v4
7274
with:
7375
fetch-depth: 0
7476
- name: Set up QEMU
75-
uses: docker/setup-qemu-action@v2
76-
- name: Cache Node Dependencies
77-
id: cache
78-
uses: actions/cache@v2
77+
uses: docker/setup-qemu-action@v3
78+
- name: Setup Node.js
79+
uses: actions/setup-node@v4
7980
with:
80-
path: ./node_modules
81-
key: modules-${{ hashFiles('package-lock.json') }}
82-
- name: Build for arm
83-
run: docker run --platform linux/arm --rm -v "${PWD}:/work" -w /work node ./tools/crossbuild-drm.sh
81+
node-version: '20'
82+
cache: 'npm'
83+
- name: Build for arm DRM
84+
run: docker run --platform linux/arm/v7 --rm -v "${PWD}:/work" -w /work node:20-bullseye ./tools/crossbuild-drm.sh
85+
86+
build-linux-arm64-drm:
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: checkout
90+
uses: actions/checkout@v4
91+
with:
92+
fetch-depth: 0
93+
- name: Set up QEMU
94+
uses: docker/setup-qemu-action@v3
95+
- name: Setup Node.js
96+
uses: actions/setup-node@v4
97+
with:
98+
node-version: '20'
99+
cache: 'npm'
100+
- name: Build for arm64 DRM
101+
run: docker run --platform linux/arm64 --rm -v "${PWD}:/work" -w /work node:20-bullseye ./tools/crossbuild-drm.sh

CMakeLists.txt

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,27 @@ include(FetchContent)
33
# 2025-02-15: based on https://github.com/raysan5/raylib/blob/master/src/external/glfw/CMakeLists.txt, make sure the CMake version are between 3.4 and 3.28 or the whole raylib lib will face fatal errors
44
cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR)
55
project (node-raylib
6-
VERSION 0.10.0
6+
VERSION 0.20.0
77
DESCRIPTION "Node.js bindings for raylib"
88
HOMEPAGE_URL "https://github.com/RobLoach/node-raylib"
99
LANGUAGES C CXX)
1010

11-
if ( CMAKE_COMPILER_IS_GNUCC )
11+
# Compiler-specific flags
12+
if ( CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
1213
set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS} -Wno-unused-result")
13-
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
14+
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
15+
# Enable additional security flags
16+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong")
1417
endif()
15-
# 2025-02-15: based on @link: https://learn.microsoft.com/en-us/cpp/build/reference/o-options-optimize-code?view=msvc-170. MSVC only accept O2 and don't have O3 optimization flag
18+
19+
# MSVC-specific flags
1620
if ( MSVC )
1721
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
18-
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
22+
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
23+
# Enable security features but suppress CRT warnings
24+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS")
25+
# Define _CRT_SECURE_NO_WARNINGS to suppress deprecated function warnings
26+
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
1927
else()
2028
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
2129
endif()
@@ -26,6 +34,13 @@ endif()
2634

2735
set(CMAKE_CXX_FLAGS_DEBUG "-g")
2836

37+
# Configure raylib platform settings
38+
if(DEFINED PLATFORM AND PLATFORM STREQUAL "DRM")
39+
set(PLATFORM_DRM ON CACHE BOOL "" FORCE)
40+
set(GRAPHICS_API_OPENGL_ES2 ON CACHE BOOL "" FORCE)
41+
message(STATUS "Building for DRM platform with OpenGL ES 2.0")
42+
endif()
43+
2944
# version doesn't seem to pick correct version
3045
#find_package(raylib 5.5 QUIET EXACT)
3146
if (NOT raylib_FOUND)
@@ -95,3 +110,30 @@ target_link_libraries(${PROJECT_NAME}
95110
${CMAKE_JS_LIB}
96111
raylib
97112
)
113+
114+
# Add DRM-specific libraries if building for DRM platform
115+
if(DEFINED PLATFORM AND PLATFORM STREQUAL "DRM")
116+
# Find required DRM libraries using pkg-config
117+
find_package(PkgConfig REQUIRED)
118+
pkg_check_modules(DRM REQUIRED libdrm)
119+
pkg_check_modules(GBM REQUIRED gbm)
120+
pkg_check_modules(EGL REQUIRED egl)
121+
pkg_check_modules(GLESV2 REQUIRED glesv2)
122+
123+
# Debug: Print all available variables
124+
message(STATUS "DRM_LIBRARIES: ${DRM_LIBRARIES}")
125+
message(STATUS "DRM_LINK_LIBRARIES: ${DRM_LINK_LIBRARIES}")
126+
message(STATUS "DRM_LDFLAGS: ${DRM_LDFLAGS}")
127+
message(STATUS "DRM_LDFLAGS_OTHER: ${DRM_LDFLAGS_OTHER}")
128+
message(STATUS "GBM_LIBRARIES: ${GBM_LIBRARIES}")
129+
message(STATUS "GBM_LINK_LIBRARIES: ${GBM_LINK_LIBRARIES}")
130+
message(STATUS "EGL_LIBRARIES: ${EGL_LIBRARIES}")
131+
message(STATUS "EGL_LINK_LIBRARIES: ${EGL_LINK_LIBRARIES}")
132+
message(STATUS "GLESV2_LIBRARIES: ${GLESV2_LIBRARIES}")
133+
message(STATUS "GLESV2_LINK_LIBRARIES: ${GLESV2_LINK_LIBRARIES}")
134+
135+
# Try using LDFLAGS instead of LINK_LIBRARIES
136+
target_link_libraries(${PROJECT_NAME} ${DRM_LDFLAGS} ${GBM_LDFLAGS} ${EGL_LDFLAGS} ${GLESV2_LDFLAGS})
137+
138+
message(STATUS "Added DRM libraries: ${DRM_LIBRARIES} ${GBM_LIBRARIES} ${EGL_LIBRARIES} ${GLESV2_LIBRARIES}")
139+
endif()

bin/node-raylib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const raylib = require('..')
99
const pkg = require('../package.json')
1010

1111
const usage = `
12-
Node.js bindings for raylib.
12+
${pkg.description}
1313
Usage
1414
$ node-raylib [file]
1515

package.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,33 @@
99
"benchmark": "bin/node-raylib examples/textures/textures_bunnymark.js",
1010
"test": "vitest run --globals --reporter verbose",
1111
"test:watch": "vitest --globals --ui",
12-
"posttest": "standard tools test examples index.js",
12+
"test:coverage": "vitest run --globals --coverage",
1313
"test:fix": "standard --fix",
14+
"lint": "standard tools test examples index.js",
15+
"lint:fix": "standard --fix tools test examples index.js",
1416
"postinstall": "node tools/postinstall.js || npm run compile",
1517
"clean": "rm -rf build",
1618
"precompile": "npm i --no-save node-addon-api cmake-js",
1719
"compile": "cmake-js compile",
20+
"compile:debug": "cmake-js compile --debug",
1821
"precompile-drm": "npm i --no-save node-addon-api cmake-js",
1922
"compile-drm": "cmake-js compile --CDPLATFORM=DRM",
20-
"prepkg": "npm run build",
23+
"build": "npm run gen:code && npm run compile",
24+
"build:all": "npm run clean && npm run build",
25+
"prepkg": "npm run build:all",
2126
"pkg": "node tools/pkg.js",
2227
"gen:code": "node tools/generate.js",
23-
"gen:docs": "jsdoc2md > docs/API.md"
28+
"gen:docs": "jsdoc2md > docs/API.md",
29+
30+
"crossbuild:arm64": "docker run --platform linux/arm64 --rm -v \"${PWD}:/work\" -w /work node:20-bullseye ./tools/crossbuild.sh",
31+
"crossbuild:arm": "docker run --platform linux/arm/v7 --rm -v \"${PWD}:/work\" -w /work node:20-bullseye ./tools/crossbuild.sh",
32+
"preversion": "npm run test && npm run lint",
33+
"version": "npm run gen:docs && git add docs/API.md",
34+
"postversion": "git push && git push --tags"
2435
},
2536
"repository": "RobLoach/node-raylib",
2637
"engines": {
27-
"node": ">=10"
38+
"node": ">=18.0.0"
2839
},
2940
"bin": "./bin/node-raylib",
3041
"man": "./man/node-raylib.1",

0 commit comments

Comments
 (0)