Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
30 changes: 29 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release
on:
push:
tags:
- 'v*'
- "v*"
jobs:
create_release:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -215,3 +215,31 @@ jobs:
asset_path: ./build/Release/node-raylib.node
asset_name: node-raylib-darwin-x64.node
asset_content_type: application/octet-stream
macos-apple-silicon:
runs-on: macos-14
needs: create_release
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache Node Dependencies
id: cache
uses: actions/cache@v2
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Install Node Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Build Node Addon
run: npm run compile
- name: upload macos artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./build/Release/node-raylib.node
asset_name: node-raylib-darwin-arm64.node
asset_content_type: application/octet-stream
17 changes: 10 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include(FetchContent)

cmake_minimum_required(VERSION 3.11)
# 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
DESCRIPTION "Node.js bindings for raylib"
Expand All @@ -11,33 +12,35 @@ if ( CMAKE_COMPILER_IS_GNUCC )
set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS} -Wno-unused-result")
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
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
if ( MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
else()
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

# version doesn't seem to pick correct version
#find_package(raylib 4.5 QUIET EXACT)
#find_package(raylib 5.5 QUIET EXACT)
if (NOT raylib_FOUND)
include(FetchContent)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 4.5.0
GIT_TAG 5.5
GIT_SHALLOW TRUE
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED)
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(raylib)
FetchContent_MakeAvailable(raylib)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
endif()
endif()

Expand Down Expand Up @@ -75,7 +78,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
SUFFIX ".node"
)

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)

target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_JS_INC}"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Tested only on ARM MacOS.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked on Ubuntu over here.

Suggested change
Tested only on ARM MacOS.

Copy link
Copy Markdown
Collaborator

@konsumer konsumer Feb 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested on these and it built/ran:

  • x86_64 fedora
  • x86_64 mac
  • ARM (M1) mac

I still think we need to double-check CI (since there were changes to mac build) to make sure it's building the pre-builds correct on Github, but it looks good to me, otherwise. Not sure about windows, and it's a bit harder for me to test there, maybe @twuky can take a look.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@konsumer my local machine is running on window so I can confirm the build is working on my end

![node-raylib Logo](logo/raylib-node_256x256.png)

# node-raylib [![npm version](http://img.shields.io/npm/v/raylib.svg)](https://npmjs.org/package/raylib "View this project on npm") [![Tests](https://github.com/RobLoach/node-raylib/workflows/Tests/badge.svg)](https://github.com/RobLoach/node-raylib/actions?query=workflow%3ATests+branch%3Amaster "See automated test status on GitHub Actions")
Expand Down
Loading