Skip to content

Commit 4a01412

Browse files
0.20.0
- Fix window build - Change all import to node builtin prefix to prevent future conflict - Add some comment on CMakeLists
1 parent 35039d0 commit 4a01412

21 files changed

Lines changed: 42 additions & 4682 deletions

CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include(FetchContent)
22

3-
cmake_minimum_required(VERSION 3.11)
3+
# 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
4+
cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR)
45
project (node-raylib
56
VERSION 0.10.0
67
DESCRIPTION "Node.js bindings for raylib"
@@ -11,16 +12,19 @@ if ( CMAKE_COMPILER_IS_GNUCC )
1112
set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS} -Wno-unused-result")
1213
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
1314
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
1416
if ( MSVC )
1517
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
18+
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
19+
else()
20+
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
1621
endif()
1722

1823
if(NOT CMAKE_BUILD_TYPE)
1924
set(CMAKE_BUILD_TYPE Release)
2025
endif()
2126

2227
set(CMAKE_CXX_FLAGS_DEBUG "-g")
23-
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
2428

2529
# version doesn't seem to pick correct version
2630
#find_package(raylib 5.5 QUIET EXACT)
@@ -35,9 +39,8 @@ if (NOT raylib_FOUND)
3539
FetchContent_GetProperties(raylib)
3640
if (NOT raylib_POPULATED)
3741
set(FETCHCONTENT_QUIET NO)
38-
FetchContent_Populate(raylib)
42+
FetchContent_MakeAvailable(raylib)
3943
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
40-
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
4144
endif()
4245
endif()
4346

@@ -75,7 +78,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
7578
SUFFIX ".node"
7679
)
7780

78-
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
81+
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
7982

8083
target_include_directories(${PROJECT_NAME} PUBLIC
8184
"${CMAKE_JS_INC}"

drm/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
const raylib = require('../src/generated/node-raylib-drm')
8-
const { format } = require('util')
8+
const { format } = require('node:util')
99

1010
// Constants
1111
raylib.MAX_GAMEPADS = 4

examples/audio/audio_multichannel_sound.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
********************************************************************************************/
1313

1414
const r = require('raylib')
15-
const { join } = require('path')
15+
const { join } = require('node:path')
1616

1717
// Initialization
1818
// --------------------------------------------------------------------------------------

examples/audio/audio_music_stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
********************************************************************************************/
1111

1212
const r = require('raylib')
13-
const { join } = require('path')
13+
const { join } = require('node:path')
1414

1515
// Initialization
1616
// --------------------------------------------------------------------------------------

examples/audio/audio_sound_loading.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
********************************************************************************************/
1111

1212
const r = require('raylib')
13-
const { join } = require('path')
13+
const { join } = require('node:path')
1414

1515
// Initialization
1616
// --------------------------------------------------------------------------------------

examples/core/core_vr_simulator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
********************************************************************************************/
1111

1212
const r = require('raylib')
13-
const { join } = require('path')
13+
const { join } = require('node:path')
1414

1515
// #if defined(PLATFORM_DESKTOP)
1616
const GLSL_VERSION = 330

examples/raw/bunnymark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// performance test of drawing a bunch of bunnies with current code
22

33
const r = require('../../index.js')
4-
const { join } = require('path')
4+
const { join } = require('node:path')
55

66
const MAX_BUNNIES = 1000000
77

examples/shaders/shaders_and_uniforms.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* raylib [shaders] example - Drawing textures with an effective shader
44
*
55
********************************************************************************************/
6-
const { readFileSync } = require('fs')
7-
const { resolve, join } = require('path')
6+
const { readFileSync } = require('node:fs')
7+
const { resolve, join } = require('node:path')
88
const r = require('raylib')
99

1010
// Initialization

examples/text/text_font_loading.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
********************************************************************************************/
2020

2121
const r = require('raylib')
22-
const { join } = require('path')
22+
const { join } = require('node:path')
2323

2424
// Initialization
2525
// --------------------------------------------------------------------------------------

examples/textures/textures_bunnymark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// performance test of drawing a bunch of bunnies with current code
22

33
const r = require('raylib')
4-
const { join } = require('path')
4+
const { join } = require('node:path')
55

66
const MAX_BUNNIES = 1000000
77

0 commit comments

Comments
 (0)