wyvrnpm 2.11.0 → 2.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1914 -1905
- package/bin/{wyvrn.js → wyvrnpm.js} +31 -0
- package/cmake/cpp.cmake +9 -9
- package/cmake/functions.cmake +224 -224
- package/cmake/macros.cmake +284 -284
- package/package.json +3 -2
- package/src/auth.js +66 -66
- package/src/binary-dir.js +95 -0
- package/src/bootstrap/cookbook.js +196 -196
- package/src/bootstrap/detect.js +150 -150
- package/src/bootstrap/index.js +220 -220
- package/src/bootstrap/version.js +72 -72
- package/src/build/cache.js +344 -344
- package/src/build/clone.js +170 -170
- package/src/build/cmake.js +342 -342
- package/src/build/index.js +299 -297
- package/src/build/msvc-env.js +260 -260
- package/src/build/recipe.js +188 -188
- package/src/commands/add.js +141 -141
- package/src/commands/bootstrap.js +96 -96
- package/src/commands/build.js +482 -452
- package/src/commands/cache.js +189 -189
- package/src/commands/clean.js +80 -80
- package/src/commands/configure.js +92 -92
- package/src/commands/init.js +70 -70
- package/src/commands/install-skill.js +115 -115
- package/src/commands/install.js +730 -674
- package/src/commands/link.js +320 -320
- package/src/commands/profile.js +237 -237
- package/src/commands/publish.js +584 -555
- package/src/commands/show.js +252 -252
- package/src/commands/version.js +187 -187
- package/src/compat.js +273 -273
- package/src/conf/index.js +415 -391
- package/src/conf/namespaces.js +94 -94
- package/src/context.js +230 -230
- package/src/http-fetch.js +53 -53
- package/src/ignore.js +118 -118
- package/src/logger.js +122 -122
- package/src/options.js +303 -303
- package/src/settings-overrides.js +152 -152
- package/src/toolchain/deps.js +164 -164
- package/src/toolchain/index.js +212 -212
- package/src/toolchain/presets.js +356 -340
- package/src/toolchain/template.cmake +77 -77
- package/src/upload-built.js +265 -265
- package/src/version-range.js +301 -301
- package/src/zip-safe.js +52 -52
- package/src/zip-stream.js +126 -0
|
@@ -262,6 +262,15 @@ yargs
|
|
|
262
262
|
choices: ['win_x64', 'win_x86', 'linux_x64', 'linux_x86', 'osx_x64', 'osx_arm64'],
|
|
263
263
|
default: 'win_x64',
|
|
264
264
|
})
|
|
265
|
+
.option('build-dir', {
|
|
266
|
+
type: 'string',
|
|
267
|
+
description:
|
|
268
|
+
'Project-relative subdir for the generated preset\'s binaryDir ' +
|
|
269
|
+
'(default: "build"). Use this when the repo has a `BUILD` ' +
|
|
270
|
+
'Bazel/Buck file at root that collides with `build/` on ' +
|
|
271
|
+
'case-insensitive filesystems (gRPC, …). For persistent ' +
|
|
272
|
+
'override, set `binaryDirRoot` in wyvrn.local.json.',
|
|
273
|
+
})
|
|
265
274
|
.option('timeout', {
|
|
266
275
|
type: 'number',
|
|
267
276
|
description: 'HTTP timeout in seconds',
|
|
@@ -281,6 +290,7 @@ yargs
|
|
|
281
290
|
awsProfile: argv['aws-profile'],
|
|
282
291
|
tokenEnv: argv['token-env'],
|
|
283
292
|
dryRun: argv['dry-run'],
|
|
293
|
+
buildDir: argv['build-dir'],
|
|
284
294
|
}),
|
|
285
295
|
)
|
|
286
296
|
|
|
@@ -381,6 +391,15 @@ yargs
|
|
|
381
391
|
'--conf cmake.cache.CHROMA_ENABLE_TEST=ON. CLI --conf does NOT ' +
|
|
382
392
|
'regenerate CMakePresets.json; edit wyvrn.local.json and re-run ' +
|
|
383
393
|
'`wyvrnpm install` for persistent overrides. See claude/PLAN-CONF.md.',
|
|
394
|
+
})
|
|
395
|
+
.option('build-dir', {
|
|
396
|
+
type: 'string',
|
|
397
|
+
description:
|
|
398
|
+
'Project-relative subdir for the build tree (default: "build"). ' +
|
|
399
|
+
'Must match the value used at install time — the preset baked ' +
|
|
400
|
+
'in by `wyvrnpm install` is the source of truth for the ' +
|
|
401
|
+
'cmake binaryDir. For persistent override, set `binaryDirRoot` ' +
|
|
402
|
+
'in wyvrn.local.json so install + build agree without a flag.',
|
|
384
403
|
});
|
|
385
404
|
},
|
|
386
405
|
(argv) => build({
|
|
@@ -388,6 +407,7 @@ yargs
|
|
|
388
407
|
autoInstall: argv['auto-install'],
|
|
389
408
|
installPrefix: argv['install-prefix'],
|
|
390
409
|
allConfigs: argv['all-configs'],
|
|
410
|
+
buildDir: argv['build-dir'],
|
|
391
411
|
}),
|
|
392
412
|
)
|
|
393
413
|
|
|
@@ -592,6 +612,16 @@ yargs
|
|
|
592
612
|
'Reads recipe conf + CLI only; wyvrn.local.json is intentionally ' +
|
|
593
613
|
'ignored for publish.',
|
|
594
614
|
})
|
|
615
|
+
.option('build-dir', {
|
|
616
|
+
type: 'string',
|
|
617
|
+
description:
|
|
618
|
+
'Project-relative subdir to look up the install tree under ' +
|
|
619
|
+
'(default: "build"). Must match the value used at install/build ' +
|
|
620
|
+
'time so publish can find `<root>/wyvrn-<profile>/<installDir>/`. ' +
|
|
621
|
+
'For persistent override, set `binaryDirRoot` in wyvrn.local.json. ' +
|
|
622
|
+
'Reading the overlay value here is path-only — no `conf` from the ' +
|
|
623
|
+
'overlay is folded into the published artefact.',
|
|
624
|
+
})
|
|
595
625
|
.option('format', {
|
|
596
626
|
type: 'string',
|
|
597
627
|
choices: ['text', 'json'],
|
|
@@ -605,6 +635,7 @@ yargs
|
|
|
605
635
|
awsProfile: argv['aws-profile'],
|
|
606
636
|
tokenEnv: argv['token-env'],
|
|
607
637
|
dryRun: argv['dry-run'],
|
|
638
|
+
buildDir: argv['build-dir'],
|
|
608
639
|
}),
|
|
609
640
|
)
|
|
610
641
|
|
package/cmake/cpp.cmake
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# Define the cpp information ( version, compilation type, thread type, exception handling )
|
|
2
|
-
# Set a C++20 default only if the consumer (or wyvrnpm's toolchain) has not
|
|
3
|
-
# already chosen a standard — the toolchain sets CMAKE_CXX_STANDARD from the
|
|
4
|
-
# active build profile before project(), and that explicit choice must win.
|
|
5
|
-
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
|
6
|
-
set(CMAKE_CXX_STANDARD 20)
|
|
7
|
-
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
8
|
-
endif()
|
|
9
|
-
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API OFF)
|
|
1
|
+
# Define the cpp information ( version, compilation type, thread type, exception handling )
|
|
2
|
+
# Set a C++20 default only if the consumer (or wyvrnpm's toolchain) has not
|
|
3
|
+
# already chosen a standard — the toolchain sets CMAKE_CXX_STANDARD from the
|
|
4
|
+
# active build profile before project(), and that explicit choice must win.
|
|
5
|
+
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
|
6
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
7
|
+
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
8
|
+
endif()
|
|
9
|
+
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API OFF)
|
package/cmake/functions.cmake
CHANGED
|
@@ -1,224 +1,224 @@
|
|
|
1
|
-
# ── Internal helper ───────────────────────────────────────────────────────────
|
|
2
|
-
# Collects all sources for the calling directory in three layers:
|
|
3
|
-
#
|
|
4
|
-
# 1. General sources — all .cpp/.h/.hpp under CMAKE_CURRENT_SOURCE_DIR,
|
|
5
|
-
# excluding HAL/, Platform/, and include/HAL|Platform/
|
|
6
|
-
# 2. HAL common — files sitting directly (non-recursive) in any HAL/ or
|
|
7
|
-
# Platform/ root; these are platform-neutral shared headers
|
|
8
|
-
# 3. HAL layered — recursive sources from each applicable subdirectory,
|
|
9
|
-
# resolved in order: family → leaf
|
|
10
|
-
#
|
|
11
|
-
# Family tiers (from variables.cmake derived vars):
|
|
12
|
-
# microsoft — Windows + Xbox
|
|
13
|
-
# unix — Linux + SteamOS + Android + Darwin + PlayStation
|
|
14
|
-
# darwin — macOS + iOS
|
|
15
|
-
# playstation— PS4 + PS5
|
|
16
|
-
#
|
|
17
|
-
# Leaf dirs:
|
|
18
|
-
# win xbox linux steamos mac ios
|
|
19
|
-
# android ps4 ps5
|
|
20
|
-
#
|
|
21
|
-
# Search roots for both family and leaf dirs:
|
|
22
|
-
# HAL/ Platform/ src/HAL/ src/Platform/
|
|
23
|
-
# include/HAL/ include/Platform/
|
|
24
|
-
#
|
|
25
|
-
# Result is written to the variable named by <out_var> in the caller's scope.
|
|
26
|
-
# Any additional arguments are treated as regex patterns to exclude from all source lists.
|
|
27
|
-
function(_wyvrn_collect_sources out_var)
|
|
28
|
-
set(_extra_excludes ${ARGN})
|
|
29
|
-
file(GLOB_RECURSE _sources
|
|
30
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
|
31
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
|
|
32
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/*.hpp"
|
|
33
|
-
)
|
|
34
|
-
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]HAL[/\\\\].*")
|
|
35
|
-
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]Platform[/\\\\].*")
|
|
36
|
-
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]tests[/\\\\].*")
|
|
37
|
-
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]vendors[/\\\\].*")
|
|
38
|
-
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]wyvrn_internal[/\\\\].*")
|
|
39
|
-
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]build[/\\\\].*")
|
|
40
|
-
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]output[/\\\\].*")
|
|
41
|
-
|
|
42
|
-
# Shared / platform-neutral files sitting directly in any HAL/ or Platform/ root
|
|
43
|
-
file(GLOB _hal_common
|
|
44
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/HAL/*.*"
|
|
45
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/Platform/*.*"
|
|
46
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/src/HAL/*.*"
|
|
47
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/*.*"
|
|
48
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/include/HAL/*.*"
|
|
49
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/include/Platform/*.*"
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
# Build an ordered list of HAL subdirectory names to search: family first, then leaf.
|
|
53
|
-
# Each entry is searched under every search root listed in _hal_roots below.
|
|
54
|
-
set(_plat_dirs)
|
|
55
|
-
|
|
56
|
-
# ── Family tiers ──────────────────────────────────────────────────────────
|
|
57
|
-
if(WYVRN_PLATFORM_MICROSOFT)
|
|
58
|
-
list(APPEND _plat_dirs microsoft)
|
|
59
|
-
endif()
|
|
60
|
-
if(WYVRN_PLATFORM_UNIX)
|
|
61
|
-
list(APPEND _plat_dirs unix)
|
|
62
|
-
endif()
|
|
63
|
-
if(WYVRN_PLATFORM_DARWIN)
|
|
64
|
-
list(APPEND _plat_dirs darwin)
|
|
65
|
-
endif()
|
|
66
|
-
if(WYVRN_PLATFORM_PLAYSTATION)
|
|
67
|
-
list(APPEND _plat_dirs playstation)
|
|
68
|
-
endif()
|
|
69
|
-
|
|
70
|
-
# ── Leaf tiers ────────────────────────────────────────────────────────────
|
|
71
|
-
# Exactly one leaf is set by variables.cmake; SteamOS also gets a linux pass
|
|
72
|
-
# first (most SteamOS-targeting code lives there) then a steamos overlay pass.
|
|
73
|
-
if(WYVRN_PLATFORM_WINDOWS)
|
|
74
|
-
list(APPEND _plat_dirs win)
|
|
75
|
-
elseif(WYVRN_PLATFORM_XBOX)
|
|
76
|
-
list(APPEND _plat_dirs xbox)
|
|
77
|
-
elseif(WYVRN_PLATFORM_PS5)
|
|
78
|
-
list(APPEND _plat_dirs ps5)
|
|
79
|
-
elseif(WYVRN_PLATFORM_PS4)
|
|
80
|
-
list(APPEND _plat_dirs ps4)
|
|
81
|
-
elseif(WYVRN_PLATFORM_ANDROID)
|
|
82
|
-
list(APPEND _plat_dirs android)
|
|
83
|
-
elseif(WYVRN_PLATFORM_IOS)
|
|
84
|
-
list(APPEND _plat_dirs ios)
|
|
85
|
-
elseif(WYVRN_PLATFORM_MACOS)
|
|
86
|
-
list(APPEND _plat_dirs mac)
|
|
87
|
-
elseif(WYVRN_PLATFORM_STEAMOS)
|
|
88
|
-
list(APPEND _plat_dirs linux steamos)
|
|
89
|
-
elseif(WYVRN_PLATFORM_LINUX)
|
|
90
|
-
list(APPEND _plat_dirs linux)
|
|
91
|
-
endif()
|
|
92
|
-
|
|
93
|
-
# All directory roots that may contain HAL/<subdir>/ trees
|
|
94
|
-
set(_hal_roots
|
|
95
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/HAL"
|
|
96
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/Platform"
|
|
97
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/src/HAL"
|
|
98
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/src/Platform"
|
|
99
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/include/HAL"
|
|
100
|
-
"${CMAKE_CURRENT_SOURCE_DIR}/include/Platform"
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
set(_hal_plat)
|
|
104
|
-
foreach(_dir IN LISTS _plat_dirs)
|
|
105
|
-
foreach(_root IN LISTS _hal_roots)
|
|
106
|
-
file(GLOB_RECURSE _tmp "${_root}/${_dir}/*.*")
|
|
107
|
-
list(APPEND _hal_plat ${_tmp})
|
|
108
|
-
endforeach()
|
|
109
|
-
endforeach()
|
|
110
|
-
|
|
111
|
-
foreach(_pat IN LISTS _extra_excludes)
|
|
112
|
-
list(FILTER _sources EXCLUDE REGEX "${_pat}")
|
|
113
|
-
list(FILTER _hal_common EXCLUDE REGEX "${_pat}")
|
|
114
|
-
list(FILTER _hal_plat EXCLUDE REGEX "${_pat}")
|
|
115
|
-
endforeach()
|
|
116
|
-
|
|
117
|
-
set(${out_var} ${_sources} ${_hal_common} ${_hal_plat} PARENT_SCOPE)
|
|
118
|
-
endfunction()
|
|
119
|
-
|
|
120
|
-
# ── Internal helper ───────────────────────────────────────────────────────────
|
|
121
|
-
# Applies the standard Wyvrn compiler flags to <target>.
|
|
122
|
-
function(_wyvrn_apply_compiler_flags target)
|
|
123
|
-
get_target_property(_wyvrn_target_type ${target} TYPE)
|
|
124
|
-
if(_wyvrn_target_type STREQUAL "INTERFACE_LIBRARY")
|
|
125
|
-
return()
|
|
126
|
-
endif()
|
|
127
|
-
target_compile_options(${target} PRIVATE ${WYVRN_COMPILER_FLAGS})
|
|
128
|
-
target_compile_options(${target} PRIVATE $<$<CONFIG:Debug>:${WYVRN_COMPILER_FLAGS_DEBUG}>)
|
|
129
|
-
target_compile_options(${target} PRIVATE $<$<CONFIG:Release>:${WYVRN_COMPILER_FLAGS_RELEASE}>)
|
|
130
|
-
endfunction()
|
|
131
|
-
|
|
132
|
-
# ── SETUP_LIBRARY(target type [EXCLUDE pat...] [extra_sources...]) ────────────
|
|
133
|
-
# Creates a library target from all sources in CMAKE_CURRENT_SOURCE_DIR,
|
|
134
|
-
# with platform-specific HAL sources included automatically.
|
|
135
|
-
#
|
|
136
|
-
# Arguments:
|
|
137
|
-
# target CMake target name
|
|
138
|
-
# type Library type: STATIC | SHARED | INTERFACE | OBJECT
|
|
139
|
-
# EXCLUDE (optional) One or more regex patterns; matched files are
|
|
140
|
-
# excluded from the auto-collected source list
|
|
141
|
-
# extra_sources (optional) Additional source files to append (positional,
|
|
142
|
-
# or via the SOURCES keyword)
|
|
143
|
-
#
|
|
144
|
-
# Side effects:
|
|
145
|
-
# - Registers aliases chroma::<target> and wyvrn::<target>
|
|
146
|
-
# - Applies standard Wyvrn compiler flags
|
|
147
|
-
# - Configures source_group for IDE folder view
|
|
148
|
-
#
|
|
149
|
-
# Example:
|
|
150
|
-
# SETUP_LIBRARY(WyvrnLog STATIC)
|
|
151
|
-
# SETUP_LIBRARY(WyvrnRenderer SHARED ${PLATFORM_GENERATED_SOURCES})
|
|
152
|
-
# SETUP_LIBRARY(WyvrnCore STATIC EXCLUDE ".*legacy.*" ".*_old\\.cpp")
|
|
153
|
-
function(SETUP_LIBRARY target type)
|
|
154
|
-
cmake_parse_arguments(_SETUP "" "" "EXCLUDE;SOURCES" ${ARGN})
|
|
155
|
-
_wyvrn_collect_sources(_sources ${_SETUP_EXCLUDE})
|
|
156
|
-
list(APPEND _sources ${_SETUP_SOURCES} ${_SETUP_UNPARSED_ARGUMENTS})
|
|
157
|
-
|
|
158
|
-
add_library(${target} ${type} ${_sources})
|
|
159
|
-
_wyvrn_apply_compiler_flags(${target})
|
|
160
|
-
set(_src_sources "")
|
|
161
|
-
set(_gen_sources "")
|
|
162
|
-
foreach(_f IN LISTS _sources)
|
|
163
|
-
cmake_path(IS_PREFIX CMAKE_CURRENT_SOURCE_DIR "${_f}" NORMALIZE _is_under_src)
|
|
164
|
-
if(_is_under_src)
|
|
165
|
-
list(APPEND _src_sources "${_f}")
|
|
166
|
-
else()
|
|
167
|
-
list(APPEND _gen_sources "${_f}")
|
|
168
|
-
endif()
|
|
169
|
-
endforeach()
|
|
170
|
-
if(_src_sources)
|
|
171
|
-
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${_src_sources})
|
|
172
|
-
endif()
|
|
173
|
-
if(_gen_sources)
|
|
174
|
-
source_group("Generated" FILES ${_gen_sources})
|
|
175
|
-
endif()
|
|
176
|
-
|
|
177
|
-
# chroma is a legacy alias namespace; new code should use wyvrn::, but both are provided for compatibility
|
|
178
|
-
add_library(chroma::${target} ALIAS ${target})
|
|
179
|
-
add_library(wyvrn::${target} ALIAS ${target})
|
|
180
|
-
|
|
181
|
-
get_target_property(_wyvrn_target_type ${target} TYPE)
|
|
182
|
-
if(_wyvrn_target_type STREQUAL "INTERFACE_LIBRARY")
|
|
183
|
-
return()
|
|
184
|
-
endif()
|
|
185
|
-
|
|
186
|
-
target_include_directories(${target}
|
|
187
|
-
PUBLIC
|
|
188
|
-
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/${target}>
|
|
189
|
-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
190
|
-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
191
|
-
)
|
|
192
|
-
|
|
193
|
-
endfunction()
|
|
194
|
-
|
|
195
|
-
# ── SETUP_EXE(target [EXCLUDE pat...] [extra_sources...]) ─────────────────────
|
|
196
|
-
# Creates an executable target from all sources in CMAKE_CURRENT_SOURCE_DIR,
|
|
197
|
-
# with platform-specific HAL sources included automatically.
|
|
198
|
-
# On Windows and Xbox the WIN32 subsystem flag is set automatically.
|
|
199
|
-
#
|
|
200
|
-
# Arguments:
|
|
201
|
-
# target CMake target name
|
|
202
|
-
# EXCLUDE (optional) One or more regex patterns; matched files are
|
|
203
|
-
# excluded from the auto-collected source list
|
|
204
|
-
# extra_sources (optional) Additional source files to append (positional,
|
|
205
|
-
# or via the SOURCES keyword)
|
|
206
|
-
#
|
|
207
|
-
# Example:
|
|
208
|
-
# SETUP_EXE(ChromaApp)
|
|
209
|
-
# SETUP_EXE(ChromaTool ${TOOL_GENERATED_SOURCES})
|
|
210
|
-
# SETUP_EXE(ChromaTool EXCLUDE ".*test_stub.*" SOURCES ${EXTRA})
|
|
211
|
-
function(SETUP_EXE target)
|
|
212
|
-
cmake_parse_arguments(_SETUP "" "" "EXCLUDE;SOURCES" ${ARGN})
|
|
213
|
-
_wyvrn_collect_sources(_sources ${_SETUP_EXCLUDE})
|
|
214
|
-
list(APPEND _sources ${_SETUP_SOURCES} ${_SETUP_UNPARSED_ARGUMENTS})
|
|
215
|
-
|
|
216
|
-
if(WYVRN_PLATFORM_WINDOWS OR WYVRN_PLATFORM_XBOX)
|
|
217
|
-
add_executable(${target} WIN32 ${_sources})
|
|
218
|
-
else()
|
|
219
|
-
add_executable(${target} ${_sources})
|
|
220
|
-
endif()
|
|
221
|
-
|
|
222
|
-
_wyvrn_apply_compiler_flags(${target})
|
|
223
|
-
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${_sources})
|
|
224
|
-
endfunction()
|
|
1
|
+
# ── Internal helper ───────────────────────────────────────────────────────────
|
|
2
|
+
# Collects all sources for the calling directory in three layers:
|
|
3
|
+
#
|
|
4
|
+
# 1. General sources — all .cpp/.h/.hpp under CMAKE_CURRENT_SOURCE_DIR,
|
|
5
|
+
# excluding HAL/, Platform/, and include/HAL|Platform/
|
|
6
|
+
# 2. HAL common — files sitting directly (non-recursive) in any HAL/ or
|
|
7
|
+
# Platform/ root; these are platform-neutral shared headers
|
|
8
|
+
# 3. HAL layered — recursive sources from each applicable subdirectory,
|
|
9
|
+
# resolved in order: family → leaf
|
|
10
|
+
#
|
|
11
|
+
# Family tiers (from variables.cmake derived vars):
|
|
12
|
+
# microsoft — Windows + Xbox
|
|
13
|
+
# unix — Linux + SteamOS + Android + Darwin + PlayStation
|
|
14
|
+
# darwin — macOS + iOS
|
|
15
|
+
# playstation— PS4 + PS5
|
|
16
|
+
#
|
|
17
|
+
# Leaf dirs:
|
|
18
|
+
# win xbox linux steamos mac ios
|
|
19
|
+
# android ps4 ps5
|
|
20
|
+
#
|
|
21
|
+
# Search roots for both family and leaf dirs:
|
|
22
|
+
# HAL/ Platform/ src/HAL/ src/Platform/
|
|
23
|
+
# include/HAL/ include/Platform/
|
|
24
|
+
#
|
|
25
|
+
# Result is written to the variable named by <out_var> in the caller's scope.
|
|
26
|
+
# Any additional arguments are treated as regex patterns to exclude from all source lists.
|
|
27
|
+
function(_wyvrn_collect_sources out_var)
|
|
28
|
+
set(_extra_excludes ${ARGN})
|
|
29
|
+
file(GLOB_RECURSE _sources
|
|
30
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
|
31
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
|
|
32
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/*.hpp"
|
|
33
|
+
)
|
|
34
|
+
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]HAL[/\\\\].*")
|
|
35
|
+
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]Platform[/\\\\].*")
|
|
36
|
+
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]tests[/\\\\].*")
|
|
37
|
+
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]vendors[/\\\\].*")
|
|
38
|
+
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]wyvrn_internal[/\\\\].*")
|
|
39
|
+
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]build[/\\\\].*")
|
|
40
|
+
list(FILTER _sources EXCLUDE REGEX ".*[/\\\\]output[/\\\\].*")
|
|
41
|
+
|
|
42
|
+
# Shared / platform-neutral files sitting directly in any HAL/ or Platform/ root
|
|
43
|
+
file(GLOB _hal_common
|
|
44
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/HAL/*.*"
|
|
45
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/Platform/*.*"
|
|
46
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src/HAL/*.*"
|
|
47
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/*.*"
|
|
48
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/include/HAL/*.*"
|
|
49
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/include/Platform/*.*"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# Build an ordered list of HAL subdirectory names to search: family first, then leaf.
|
|
53
|
+
# Each entry is searched under every search root listed in _hal_roots below.
|
|
54
|
+
set(_plat_dirs)
|
|
55
|
+
|
|
56
|
+
# ── Family tiers ──────────────────────────────────────────────────────────
|
|
57
|
+
if(WYVRN_PLATFORM_MICROSOFT)
|
|
58
|
+
list(APPEND _plat_dirs microsoft)
|
|
59
|
+
endif()
|
|
60
|
+
if(WYVRN_PLATFORM_UNIX)
|
|
61
|
+
list(APPEND _plat_dirs unix)
|
|
62
|
+
endif()
|
|
63
|
+
if(WYVRN_PLATFORM_DARWIN)
|
|
64
|
+
list(APPEND _plat_dirs darwin)
|
|
65
|
+
endif()
|
|
66
|
+
if(WYVRN_PLATFORM_PLAYSTATION)
|
|
67
|
+
list(APPEND _plat_dirs playstation)
|
|
68
|
+
endif()
|
|
69
|
+
|
|
70
|
+
# ── Leaf tiers ────────────────────────────────────────────────────────────
|
|
71
|
+
# Exactly one leaf is set by variables.cmake; SteamOS also gets a linux pass
|
|
72
|
+
# first (most SteamOS-targeting code lives there) then a steamos overlay pass.
|
|
73
|
+
if(WYVRN_PLATFORM_WINDOWS)
|
|
74
|
+
list(APPEND _plat_dirs win)
|
|
75
|
+
elseif(WYVRN_PLATFORM_XBOX)
|
|
76
|
+
list(APPEND _plat_dirs xbox)
|
|
77
|
+
elseif(WYVRN_PLATFORM_PS5)
|
|
78
|
+
list(APPEND _plat_dirs ps5)
|
|
79
|
+
elseif(WYVRN_PLATFORM_PS4)
|
|
80
|
+
list(APPEND _plat_dirs ps4)
|
|
81
|
+
elseif(WYVRN_PLATFORM_ANDROID)
|
|
82
|
+
list(APPEND _plat_dirs android)
|
|
83
|
+
elseif(WYVRN_PLATFORM_IOS)
|
|
84
|
+
list(APPEND _plat_dirs ios)
|
|
85
|
+
elseif(WYVRN_PLATFORM_MACOS)
|
|
86
|
+
list(APPEND _plat_dirs mac)
|
|
87
|
+
elseif(WYVRN_PLATFORM_STEAMOS)
|
|
88
|
+
list(APPEND _plat_dirs linux steamos)
|
|
89
|
+
elseif(WYVRN_PLATFORM_LINUX)
|
|
90
|
+
list(APPEND _plat_dirs linux)
|
|
91
|
+
endif()
|
|
92
|
+
|
|
93
|
+
# All directory roots that may contain HAL/<subdir>/ trees
|
|
94
|
+
set(_hal_roots
|
|
95
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/HAL"
|
|
96
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/Platform"
|
|
97
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src/HAL"
|
|
98
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src/Platform"
|
|
99
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/include/HAL"
|
|
100
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/include/Platform"
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
set(_hal_plat)
|
|
104
|
+
foreach(_dir IN LISTS _plat_dirs)
|
|
105
|
+
foreach(_root IN LISTS _hal_roots)
|
|
106
|
+
file(GLOB_RECURSE _tmp "${_root}/${_dir}/*.*")
|
|
107
|
+
list(APPEND _hal_plat ${_tmp})
|
|
108
|
+
endforeach()
|
|
109
|
+
endforeach()
|
|
110
|
+
|
|
111
|
+
foreach(_pat IN LISTS _extra_excludes)
|
|
112
|
+
list(FILTER _sources EXCLUDE REGEX "${_pat}")
|
|
113
|
+
list(FILTER _hal_common EXCLUDE REGEX "${_pat}")
|
|
114
|
+
list(FILTER _hal_plat EXCLUDE REGEX "${_pat}")
|
|
115
|
+
endforeach()
|
|
116
|
+
|
|
117
|
+
set(${out_var} ${_sources} ${_hal_common} ${_hal_plat} PARENT_SCOPE)
|
|
118
|
+
endfunction()
|
|
119
|
+
|
|
120
|
+
# ── Internal helper ───────────────────────────────────────────────────────────
|
|
121
|
+
# Applies the standard Wyvrn compiler flags to <target>.
|
|
122
|
+
function(_wyvrn_apply_compiler_flags target)
|
|
123
|
+
get_target_property(_wyvrn_target_type ${target} TYPE)
|
|
124
|
+
if(_wyvrn_target_type STREQUAL "INTERFACE_LIBRARY")
|
|
125
|
+
return()
|
|
126
|
+
endif()
|
|
127
|
+
target_compile_options(${target} PRIVATE ${WYVRN_COMPILER_FLAGS})
|
|
128
|
+
target_compile_options(${target} PRIVATE $<$<CONFIG:Debug>:${WYVRN_COMPILER_FLAGS_DEBUG}>)
|
|
129
|
+
target_compile_options(${target} PRIVATE $<$<CONFIG:Release>:${WYVRN_COMPILER_FLAGS_RELEASE}>)
|
|
130
|
+
endfunction()
|
|
131
|
+
|
|
132
|
+
# ── SETUP_LIBRARY(target type [EXCLUDE pat...] [extra_sources...]) ────────────
|
|
133
|
+
# Creates a library target from all sources in CMAKE_CURRENT_SOURCE_DIR,
|
|
134
|
+
# with platform-specific HAL sources included automatically.
|
|
135
|
+
#
|
|
136
|
+
# Arguments:
|
|
137
|
+
# target CMake target name
|
|
138
|
+
# type Library type: STATIC | SHARED | INTERFACE | OBJECT
|
|
139
|
+
# EXCLUDE (optional) One or more regex patterns; matched files are
|
|
140
|
+
# excluded from the auto-collected source list
|
|
141
|
+
# extra_sources (optional) Additional source files to append (positional,
|
|
142
|
+
# or via the SOURCES keyword)
|
|
143
|
+
#
|
|
144
|
+
# Side effects:
|
|
145
|
+
# - Registers aliases chroma::<target> and wyvrn::<target>
|
|
146
|
+
# - Applies standard Wyvrn compiler flags
|
|
147
|
+
# - Configures source_group for IDE folder view
|
|
148
|
+
#
|
|
149
|
+
# Example:
|
|
150
|
+
# SETUP_LIBRARY(WyvrnLog STATIC)
|
|
151
|
+
# SETUP_LIBRARY(WyvrnRenderer SHARED ${PLATFORM_GENERATED_SOURCES})
|
|
152
|
+
# SETUP_LIBRARY(WyvrnCore STATIC EXCLUDE ".*legacy.*" ".*_old\\.cpp")
|
|
153
|
+
function(SETUP_LIBRARY target type)
|
|
154
|
+
cmake_parse_arguments(_SETUP "" "" "EXCLUDE;SOURCES" ${ARGN})
|
|
155
|
+
_wyvrn_collect_sources(_sources ${_SETUP_EXCLUDE})
|
|
156
|
+
list(APPEND _sources ${_SETUP_SOURCES} ${_SETUP_UNPARSED_ARGUMENTS})
|
|
157
|
+
|
|
158
|
+
add_library(${target} ${type} ${_sources})
|
|
159
|
+
_wyvrn_apply_compiler_flags(${target})
|
|
160
|
+
set(_src_sources "")
|
|
161
|
+
set(_gen_sources "")
|
|
162
|
+
foreach(_f IN LISTS _sources)
|
|
163
|
+
cmake_path(IS_PREFIX CMAKE_CURRENT_SOURCE_DIR "${_f}" NORMALIZE _is_under_src)
|
|
164
|
+
if(_is_under_src)
|
|
165
|
+
list(APPEND _src_sources "${_f}")
|
|
166
|
+
else()
|
|
167
|
+
list(APPEND _gen_sources "${_f}")
|
|
168
|
+
endif()
|
|
169
|
+
endforeach()
|
|
170
|
+
if(_src_sources)
|
|
171
|
+
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${_src_sources})
|
|
172
|
+
endif()
|
|
173
|
+
if(_gen_sources)
|
|
174
|
+
source_group("Generated" FILES ${_gen_sources})
|
|
175
|
+
endif()
|
|
176
|
+
|
|
177
|
+
# chroma is a legacy alias namespace; new code should use wyvrn::, but both are provided for compatibility
|
|
178
|
+
add_library(chroma::${target} ALIAS ${target})
|
|
179
|
+
add_library(wyvrn::${target} ALIAS ${target})
|
|
180
|
+
|
|
181
|
+
get_target_property(_wyvrn_target_type ${target} TYPE)
|
|
182
|
+
if(_wyvrn_target_type STREQUAL "INTERFACE_LIBRARY")
|
|
183
|
+
return()
|
|
184
|
+
endif()
|
|
185
|
+
|
|
186
|
+
target_include_directories(${target}
|
|
187
|
+
PUBLIC
|
|
188
|
+
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/${target}>
|
|
189
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
190
|
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
endfunction()
|
|
194
|
+
|
|
195
|
+
# ── SETUP_EXE(target [EXCLUDE pat...] [extra_sources...]) ─────────────────────
|
|
196
|
+
# Creates an executable target from all sources in CMAKE_CURRENT_SOURCE_DIR,
|
|
197
|
+
# with platform-specific HAL sources included automatically.
|
|
198
|
+
# On Windows and Xbox the WIN32 subsystem flag is set automatically.
|
|
199
|
+
#
|
|
200
|
+
# Arguments:
|
|
201
|
+
# target CMake target name
|
|
202
|
+
# EXCLUDE (optional) One or more regex patterns; matched files are
|
|
203
|
+
# excluded from the auto-collected source list
|
|
204
|
+
# extra_sources (optional) Additional source files to append (positional,
|
|
205
|
+
# or via the SOURCES keyword)
|
|
206
|
+
#
|
|
207
|
+
# Example:
|
|
208
|
+
# SETUP_EXE(ChromaApp)
|
|
209
|
+
# SETUP_EXE(ChromaTool ${TOOL_GENERATED_SOURCES})
|
|
210
|
+
# SETUP_EXE(ChromaTool EXCLUDE ".*test_stub.*" SOURCES ${EXTRA})
|
|
211
|
+
function(SETUP_EXE target)
|
|
212
|
+
cmake_parse_arguments(_SETUP "" "" "EXCLUDE;SOURCES" ${ARGN})
|
|
213
|
+
_wyvrn_collect_sources(_sources ${_SETUP_EXCLUDE})
|
|
214
|
+
list(APPEND _sources ${_SETUP_SOURCES} ${_SETUP_UNPARSED_ARGUMENTS})
|
|
215
|
+
|
|
216
|
+
if(WYVRN_PLATFORM_WINDOWS OR WYVRN_PLATFORM_XBOX)
|
|
217
|
+
add_executable(${target} WIN32 ${_sources})
|
|
218
|
+
else()
|
|
219
|
+
add_executable(${target} ${_sources})
|
|
220
|
+
endif()
|
|
221
|
+
|
|
222
|
+
_wyvrn_apply_compiler_flags(${target})
|
|
223
|
+
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${_sources})
|
|
224
|
+
endfunction()
|