Skip to content
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
398 changes: 217 additions & 181 deletions .github/workflows/release.yml

Large diffs are not rendered by default.

98 changes: 58 additions & 40 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,26 @@
name: Test

on: [push]
on: [push, pull_request]

jobs:
style:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
- name: Code Style Check
run: npx -y prettier -c .
# run: npx @biomejs/biome format . # do this after we move to biome config

build:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
node-version: ['18', '20', '22']
os: [ubuntu, macos, windows]
runs-on: ${{ matrix.os }}-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node Dependencies
id: cache
uses: actions/cache@v2
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
cache: 'npm'
- name: Install Node Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Install System Dependencies
if: matrix.os == 'ubuntu'
Expand All @@ -47,37 +29,73 @@ jobs:
run: npm run compile
- name: Test
run: npm test

build-linux-arm:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Cache Node Dependencies
id: cache
uses: actions/cache@v2
uses: docker/setup-qemu-action@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
node-version: '20'
cache: 'npm'
- name: Build for arm
run: docker run --platform linux/arm --rm -v "${PWD}:/work" -w /work node ./tools/crossbuild.sh
run: docker run --platform linux/arm/v7 --rm -v "${PWD}:/work" -w /work node:20-bullseye ./tools/crossbuild.sh

build-linux-arm64:
runs-on: ubuntu-24.04-arm64
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install Node Dependencies
run: npm ci --ignore-scripts
- name: Install System Dependencies
run: sudo apt-get update && sudo apt-get install -y xorg-dev libglu1-mesa-dev cmake build-essential
- name: Build Node Addon
run: npm run compile

build-linux-arm-drm:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Cache Node Dependencies
id: cache
uses: actions/cache@v2
uses: docker/setup-qemu-action@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Build for arm
run: docker run --platform linux/arm --rm -v "${PWD}:/work" -w /work node ./tools/crossbuild-drm.sh
node-version: '20'
cache: 'npm'
- name: Build for arm DRM
run: docker run --platform linux/arm/v7 --rm -v "${PWD}:/work" -w /work node:20-bullseye ./tools/crossbuild-drm.sh

build-linux-arm64-drm:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Build for arm64 DRM
run: docker run --platform linux/arm64 --rm -v "${PWD}:/work" -w /work node:20-bullseye ./tools/crossbuild-drm.sh
52 changes: 47 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@ include(FetchContent)
# 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
cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR)
project (node-raylib
VERSION 0.10.0
VERSION 0.20.0
DESCRIPTION "Node.js bindings for raylib"
HOMEPAGE_URL "https://github.com/RobLoach/node-raylib"
LANGUAGES C CXX)

if ( CMAKE_COMPILER_IS_GNUCC )
# Compiler-specific flags
if ( CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS} -Wno-unused-result")
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
# Enable additional security flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong")
endif()
# 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

# MSVC-specific flags
if ( MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
# Enable security features but suppress CRT warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS")
# Define _CRT_SECURE_NO_WARNINGS to suppress deprecated function warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
else()
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif()
Expand All @@ -26,6 +34,13 @@ endif()

set(CMAKE_CXX_FLAGS_DEBUG "-g")

# Configure raylib platform settings
if(DEFINED PLATFORM AND PLATFORM STREQUAL "DRM")
set(PLATFORM_DRM ON CACHE BOOL "" FORCE)
set(GRAPHICS_API_OPENGL_ES2 ON CACHE BOOL "" FORCE)
message(STATUS "Building for DRM platform with OpenGL ES 2.0")
endif()

# version doesn't seem to pick correct version
#find_package(raylib 5.5 QUIET EXACT)
if (NOT raylib_FOUND)
Expand Down Expand Up @@ -95,3 +110,30 @@ target_link_libraries(${PROJECT_NAME}
${CMAKE_JS_LIB}
raylib
)

# Add DRM-specific libraries if building for DRM platform
if(DEFINED PLATFORM AND PLATFORM STREQUAL "DRM")
# Find required DRM libraries using pkg-config
find_package(PkgConfig REQUIRED)
pkg_check_modules(DRM REQUIRED libdrm)
pkg_check_modules(GBM REQUIRED gbm)
pkg_check_modules(EGL REQUIRED egl)
pkg_check_modules(GLESV2 REQUIRED glesv2)

# Debug: Print all available variables
message(STATUS "DRM_LIBRARIES: ${DRM_LIBRARIES}")
message(STATUS "DRM_LINK_LIBRARIES: ${DRM_LINK_LIBRARIES}")
message(STATUS "DRM_LDFLAGS: ${DRM_LDFLAGS}")
message(STATUS "DRM_LDFLAGS_OTHER: ${DRM_LDFLAGS_OTHER}")
message(STATUS "GBM_LIBRARIES: ${GBM_LIBRARIES}")
message(STATUS "GBM_LINK_LIBRARIES: ${GBM_LINK_LIBRARIES}")
message(STATUS "EGL_LIBRARIES: ${EGL_LIBRARIES}")
message(STATUS "EGL_LINK_LIBRARIES: ${EGL_LINK_LIBRARIES}")
message(STATUS "GLESV2_LIBRARIES: ${GLESV2_LIBRARIES}")
message(STATUS "GLESV2_LINK_LIBRARIES: ${GLESV2_LINK_LIBRARIES}")

# Try using LDFLAGS instead of LINK_LIBRARIES
target_link_libraries(${PROJECT_NAME} ${DRM_LDFLAGS} ${GBM_LDFLAGS} ${EGL_LDFLAGS} ${GLESV2_LDFLAGS})

message(STATUS "Added DRM libraries: ${DRM_LIBRARIES} ${GBM_LIBRARIES} ${EGL_LIBRARIES} ${GLESV2_LIBRARIES}")
endif()
2 changes: 1 addition & 1 deletion bin/node-raylib
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const raylib = require('..')
const pkg = require('../package.json')

const usage = `
Node.js bindings for raylib.
${pkg.description}
Usage
$ node-raylib [file]

Expand Down
19 changes: 15 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,33 @@
"benchmark": "bin/node-raylib examples/textures/textures_bunnymark.js",
"test": "vitest run --globals --reporter verbose",
"test:watch": "vitest --globals --ui",
"posttest": "standard tools test examples index.js",
"test:coverage": "vitest run --globals --coverage",
"test:fix": "standard --fix",
"lint": "standard tools test examples index.js",
"lint:fix": "standard --fix tools test examples index.js",
"postinstall": "node tools/postinstall.js || npm run compile",
"clean": "rm -rf build",
"precompile": "npm i --no-save node-addon-api cmake-js",
"compile": "cmake-js compile",
"compile:debug": "cmake-js compile --debug",
"precompile-drm": "npm i --no-save node-addon-api cmake-js",
"compile-drm": "cmake-js compile --CDPLATFORM=DRM",
"prepkg": "npm run build",
"build": "npm run gen:code && npm run compile",
"build:all": "npm run clean && npm run build",
"prepkg": "npm run build:all",
"pkg": "node tools/pkg.js",
"gen:code": "node tools/generate.js",
"gen:docs": "jsdoc2md > docs/API.md"
"gen:docs": "jsdoc2md > docs/API.md",

"crossbuild:arm64": "docker run --platform linux/arm64 --rm -v \"${PWD}:/work\" -w /work node:20-bullseye ./tools/crossbuild.sh",
"crossbuild:arm": "docker run --platform linux/arm/v7 --rm -v \"${PWD}:/work\" -w /work node:20-bullseye ./tools/crossbuild.sh",
"preversion": "npm run test && npm run lint",
"version": "npm run gen:docs && git add docs/API.md",
"postversion": "git push && git push --tags"
},
"repository": "RobLoach/node-raylib",
"engines": {
"node": ">=10"
"node": ">=18.0.0"
},
"bin": "./bin/node-raylib",
"man": "./man/node-raylib.1",
Expand Down
Loading
Loading