wyvrnpm 2.10.2 → 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.
Files changed (49) hide show
  1. package/README.md +1914 -1860
  2. package/bin/{wyvrn.js → wyvrnpm.js} +66 -0
  3. package/cmake/cpp.cmake +9 -9
  4. package/cmake/functions.cmake +224 -224
  5. package/cmake/macros.cmake +284 -284
  6. package/package.json +3 -2
  7. package/src/auth.js +66 -66
  8. package/src/binary-dir.js +95 -0
  9. package/src/bootstrap/cookbook.js +196 -196
  10. package/src/bootstrap/detect.js +150 -150
  11. package/src/bootstrap/index.js +220 -220
  12. package/src/bootstrap/version.js +72 -72
  13. package/src/build/cache.js +344 -344
  14. package/src/build/clone.js +170 -170
  15. package/src/build/cmake.js +342 -342
  16. package/src/build/index.js +299 -297
  17. package/src/build/msvc-env.js +260 -260
  18. package/src/build/recipe.js +188 -188
  19. package/src/commands/add.js +141 -141
  20. package/src/commands/bootstrap.js +96 -96
  21. package/src/commands/build.js +482 -452
  22. package/src/commands/cache.js +189 -189
  23. package/src/commands/clean.js +80 -80
  24. package/src/commands/configure.js +92 -92
  25. package/src/commands/init.js +70 -70
  26. package/src/commands/install-skill.js +115 -115
  27. package/src/commands/install.js +730 -674
  28. package/src/commands/link.js +320 -320
  29. package/src/commands/profile.js +237 -237
  30. package/src/commands/publish.js +584 -555
  31. package/src/commands/show.js +252 -252
  32. package/src/commands/version.js +187 -0
  33. package/src/compat.js +273 -273
  34. package/src/conf/index.js +415 -391
  35. package/src/conf/namespaces.js +94 -94
  36. package/src/context.js +230 -230
  37. package/src/http-fetch.js +53 -53
  38. package/src/ignore.js +118 -118
  39. package/src/logger.js +122 -122
  40. package/src/options.js +303 -303
  41. package/src/settings-overrides.js +152 -152
  42. package/src/toolchain/deps.js +164 -164
  43. package/src/toolchain/index.js +212 -212
  44. package/src/toolchain/presets.js +356 -340
  45. package/src/toolchain/template.cmake +77 -77
  46. package/src/upload-built.js +265 -265
  47. package/src/version-range.js +301 -301
  48. package/src/zip-safe.js +52 -52
  49. package/src/zip-stream.js +126 -0
@@ -5,6 +5,7 @@
5
5
  const yargs = require('yargs');
6
6
  const init = require('../src/commands/init');
7
7
  const add = require('../src/commands/add');
8
+ const versionCmd = require('../src/commands/version');
8
9
  const install = require('../src/commands/install');
9
10
  const clean = require('../src/commands/clean');
10
11
  const publish = require('../src/commands/publish');
@@ -143,6 +144,40 @@ yargs
143
144
  (argv) => add(argv),
144
145
  )
145
146
 
147
+ // ── version ───────────────────────────────────────────────────────────────
148
+ .command(
149
+ 'version [newVersion]',
150
+ 'Read, set, or partially update the top-level `version` field in wyvrn.json. ' +
151
+ 'Bare `wyvrnpm version` prints the current value on stdout (for `VER=$(...)` ' +
152
+ 'capture). Pass a full 4-part value (1.2.3.4) or component flags (--major / ' +
153
+ '--minor / --patch / --build) to tweak individual parts. Designed for CI/CD — ' +
154
+ 'pair with --format json to capture { previous, version } on stdout.',
155
+ (y) => {
156
+ y
157
+ .positional('newVersion', {
158
+ type: 'string',
159
+ describe: 'Full 4-part version to write verbatim (e.g. 1.2.3.4). ' +
160
+ 'Mutually exclusive with --major/--minor/--patch/--build.',
161
+ })
162
+ .option('major', { type: 'number', description: 'Replace the 1st component (major).' })
163
+ .option('minor', { type: 'number', description: 'Replace the 2nd component (minor).' })
164
+ .option('patch', { type: 'number', description: 'Replace the 3rd component (patch).' })
165
+ .option('build', { type: 'number', description: 'Replace the 4th component (build) — typical CI use.' })
166
+ .option('dry-run', {
167
+ type: 'boolean',
168
+ default: false,
169
+ description: 'Compute and print the proposed version without writing wyvrn.json.',
170
+ })
171
+ .option('format', {
172
+ type: 'string',
173
+ choices: ['text', 'json'],
174
+ default: 'text',
175
+ description: 'Output format. "json" emits { command, previous, version, ... } on stdout.',
176
+ });
177
+ },
178
+ (argv) => versionCmd({ ...argv, dryRun: argv['dry-run'] }),
179
+ )
180
+
146
181
  // ── install ───────────────────────────────────────────────────────────────
147
182
  .command(
148
183
  'install',
@@ -227,6 +262,15 @@ yargs
227
262
  choices: ['win_x64', 'win_x86', 'linux_x64', 'linux_x86', 'osx_x64', 'osx_arm64'],
228
263
  default: 'win_x64',
229
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
+ })
230
274
  .option('timeout', {
231
275
  type: 'number',
232
276
  description: 'HTTP timeout in seconds',
@@ -246,6 +290,7 @@ yargs
246
290
  awsProfile: argv['aws-profile'],
247
291
  tokenEnv: argv['token-env'],
248
292
  dryRun: argv['dry-run'],
293
+ buildDir: argv['build-dir'],
249
294
  }),
250
295
  )
251
296
 
@@ -346,6 +391,15 @@ yargs
346
391
  '--conf cmake.cache.CHROMA_ENABLE_TEST=ON. CLI --conf does NOT ' +
347
392
  'regenerate CMakePresets.json; edit wyvrn.local.json and re-run ' +
348
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.',
349
403
  });
350
404
  },
351
405
  (argv) => build({
@@ -353,6 +407,7 @@ yargs
353
407
  autoInstall: argv['auto-install'],
354
408
  installPrefix: argv['install-prefix'],
355
409
  allConfigs: argv['all-configs'],
410
+ buildDir: argv['build-dir'],
356
411
  }),
357
412
  )
358
413
 
@@ -557,6 +612,16 @@ yargs
557
612
  'Reads recipe conf + CLI only; wyvrn.local.json is intentionally ' +
558
613
  'ignored for publish.',
559
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
+ })
560
625
  .option('format', {
561
626
  type: 'string',
562
627
  choices: ['text', 'json'],
@@ -570,6 +635,7 @@ yargs
570
635
  awsProfile: argv['aws-profile'],
571
636
  tokenEnv: argv['token-env'],
572
637
  dryRun: argv['dry-run'],
638
+ buildDir: argv['build-dir'],
573
639
  }),
574
640
  )
575
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)
@@ -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()