Skip to content

Commit a683f9f

Browse files
committed
cmake: Migrate to proper preset template
1 parent d5d59c9 commit a683f9f

7 files changed

Lines changed: 139 additions & 55 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,8 +1288,8 @@ if(PLAYER_BUILD_EXECUTABLE AND ${PLAYER_TARGET_PLATFORM} MATCHES "^SDL.*$" AND N
12881288

12891289
target_link_libraries(${EXE_NAME} "idbfs.js")
12901290
target_link_libraries(${EXE_NAME} "websocket.js")
1291-
set_property(TARGET ${EXE_NAME} APPEND_STRING PROPERTY LINK_FLAGS " -s EXPORTED_RUNTIME_METHODS='[\"ccall\",\"cwrap\",\"intArrayFromString\",\"ALLOC_NORMAL\",\"allocate\",\"getValue\",\"FS\"]'")
1292-
set_target_properties(${EXE_NAME} PROPERTIES OUTPUT_NAME "${PLAYER_JS_OUTPUT_NAME}")
1291+
player_find_githash(HASH_VAR GIT_HASH)
1292+
set_target_properties(${EXE_NAME} PROPERTIES OUTPUT_NAME "${PLAYER_JS_OUTPUT_NAME}.${GIT_HASH}")
12931293
endif()
12941294

12951295
# installation

CMakePresets.json

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

builds/cmake/CMakePresets.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"PLAYER_FIND_ROOT_PATH_APPEND": "ON",
7979
"PLAYER_JS_BUILD_SHELL": "ON"
8080
},
81-
"easyrpg_platforms": ["sdl3", "sdl2"]
81+
"easyrpg_platforms": ["sdl3", "sdl2", "yno", "yno-simd"]
8282
},
8383
{
8484
"name": "android-armeabi-v7a",

builds/cmake/CMakePresetsBase.json

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
"displayName": "windows base preset",
4141
"hidden": true,
4242
"toolchainFile": "$env{EASYRPG_BUILDSCRIPTS}/windows/vcpkg/scripts/buildsystems/vcpkg.cmake",
43-
"inherits": ["base"],
43+
"inherits": [
44+
"base"
45+
],
4446
"condition": {
4547
"type": "equals",
4648
"lhs": "${hostSystemName}",
@@ -83,6 +85,35 @@
8385
"PLAYER_TARGET_PLATFORM": "SDL2"
8486
}
8587
},
88+
{
89+
"name": "build-yno",
90+
"displayName": "builds for YNO (SDL2)",
91+
"hidden": true,
92+
"cacheVariables": {
93+
"PLAYER_ENABLE_FMMIDI": "OFF",
94+
"PLAYER_WITH_MPG123": "OFF",
95+
"PLAYER_WITH_LIBSNDFILE": "OFF",
96+
"PLAYER_WITH_OGGVORBIS": "OFF",
97+
"PLAYER_WITH_WILDMIDI": "OFF",
98+
"PLAYER_WITH_FLUIDLITE": "OFF",
99+
"PLAYER_WITH_XMP": "OFF",
100+
"PLAYER_ENABLE_DRWAV": "OFF",
101+
"PLAYER_JS_BUILD_SHELL": "ON",
102+
"PLAYER_JS_OUTPUT_NAME": "ynoengine",
103+
"PLAYER_JS_GAME_URL": "/data/",
104+
"PLAYER_TARGET_PLATFORM": "SDL2"
105+
}
106+
},
107+
{
108+
"name": "build-yno-simd",
109+
"displayName": "builds for YNO (SDL2, SIMD)",
110+
"hidden": true,
111+
"inherits": "build-yno",
112+
"cacheVariables": {
113+
"PLAYER_JS_OUTPUT_NAME": "ynoengine-simd",
114+
"CMAKE_CXX_FLAGS": "-msimd128"
115+
}
116+
},
86117
{
87118
"name": "build-sdl3",
88119
"displayName": "builds using SDL3 backend",
@@ -100,4 +131,4 @@
100131
}
101132
}
102133
]
103-
}
134+
}

builds/cmake/Modules/PlayerMisc.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,25 @@ function(player_find_gitversion)
8181
set(${FIND_GITVER_MESSAGE_VAR} ${message} PARENT_SCOPE)
8282
endif()
8383
endfunction()
84+
85+
function(player_find_githash)
86+
cmake_parse_arguments(FIND_GITHASH "" "HASH_VAR" "" ${ARGN})
87+
git_describe(GIT_DESCRIPTION)
88+
if(GIT_DESCRIPTION)
89+
string(REPLACE "-" ";" GIT_DESCRIPTION ${GIT_DESCRIPTION})
90+
list(LENGTH GIT_DESCRIPTION GIT_DESCRIPTION_PARTS)
91+
if(GIT_DESCRIPTION_PARTS EQUAL 3)
92+
list(GET GIT_DESCRIPTION 0 GIT_TAG)
93+
list(GET GIT_DESCRIPTION 1 GIT_COMMITS)
94+
list(GET GIT_DESCRIPTION 2 GIT_HASH)
95+
string(PREPEND GIT_COMMITS "+")
96+
string(SUBSTRING ${GIT_HASH} 1 -1 GIT_HASH) # strip the g prefix
97+
else()
98+
# no tags found, only hash (checkout without history/detached head)
99+
list(GET GIT_DESCRIPTION 0 GIT_HASH)
100+
endif()
101+
if(FIND_GITHASH_HASH_VAR)
102+
set(${FIND_GITHASH_HASH_VAR} ${GIT_HASH} PARENT_SCOPE)
103+
endif()
104+
endif()
105+
endfunction()

builds/cmake/gen-cmake-presets.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ def append_name(name):
2323
item["name"] += "-"
2424
item["name"] += name
2525

26-
platform_display = dict(
27-
sdl1="SDL1",
28-
sdl2="SDL2",
29-
sdl3="SDL3",
30-
libretro="libretro core"
31-
)
26+
platform_display = {
27+
"sdl1": "SDL1",
28+
"sdl2": "SDL2",
29+
"sdl3": "SDL3",
30+
"libretro": "libretro core",
31+
"yno": "YNO",
32+
"yno-simd": "YNO [SIMD]",
33+
}
3234

3335
# This creates the following configurePresets from the one in the template:
3436
# - As specified in the template

justfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build-all: (build "emscripten-yno-release") (build "emscripten-yno-simd-release") zip
2+
3+
build preset:
4+
cmake --preset={{ preset }}
5+
cmake --build --preset={{ preset }}
6+
7+
zip:
8+
zip -j ynoengine.zip build/emscripten-yno-simd-release/*.{js,wasm} build/emscripten-yno-release/*.{js,wasm}

0 commit comments

Comments
 (0)