imxc 0.3.0 → 0.3.1
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/dist/index.js +9 -1
- package/dist/init.d.ts +1 -0
- package/dist/init.js +58 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from 'node:util';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
-
import { initProject } from './init.js';
|
|
4
|
+
import { initProject, addToProject } from './init.js';
|
|
5
5
|
import { compile } from './compile.js';
|
|
6
6
|
import { startWatch } from './watch.js';
|
|
7
7
|
// Handle `imxc init [dir]` subcommand
|
|
@@ -11,6 +11,13 @@ if (process.argv[2] === 'init') {
|
|
|
11
11
|
initProject(absDir, path.basename(absDir));
|
|
12
12
|
process.exit(0);
|
|
13
13
|
}
|
|
14
|
+
// Handle `imxc add [dir]` subcommand
|
|
15
|
+
if (process.argv[2] === 'add') {
|
|
16
|
+
const dir = process.argv[3] ?? '.';
|
|
17
|
+
const absDir = path.resolve(dir);
|
|
18
|
+
addToProject(absDir);
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
14
21
|
// Handle `imxc watch <dir> -o <output-dir>` subcommand
|
|
15
22
|
if (process.argv[2] === 'watch') {
|
|
16
23
|
const watchDir = process.argv[3];
|
|
@@ -35,6 +42,7 @@ else {
|
|
|
35
42
|
if (positionals.length === 0) {
|
|
36
43
|
console.error('Usage: imxc <input.tsx ...> -o <output-dir>');
|
|
37
44
|
console.error(' imxc init [project-dir]');
|
|
45
|
+
console.error(' imxc add [project-dir]');
|
|
38
46
|
console.error(' imxc watch <dir> -o <output-dir>');
|
|
39
47
|
process.exit(1);
|
|
40
48
|
}
|
package/dist/init.d.ts
CHANGED
package/dist/init.js
CHANGED
|
@@ -354,12 +354,15 @@ set(CMAKE_CXX_STANDARD 20)
|
|
|
354
354
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
355
355
|
|
|
356
356
|
include(FetchContent)
|
|
357
|
+
set(FETCHCONTENT_QUIET OFF)
|
|
357
358
|
|
|
358
359
|
FetchContent_Declare(
|
|
359
360
|
imx
|
|
360
361
|
GIT_REPOSITORY ${repoUrl}
|
|
361
362
|
GIT_TAG main
|
|
363
|
+
GIT_PROGRESS TRUE
|
|
362
364
|
)
|
|
365
|
+
message(STATUS "Fetching IMX (includes ImGui + GLFW)...")
|
|
363
366
|
FetchContent_MakeAvailable(imx)
|
|
364
367
|
|
|
365
368
|
include(ImxCompile)
|
|
@@ -385,6 +388,61 @@ add_custom_command(TARGET ${projectName} POST_BUILD
|
|
|
385
388
|
)
|
|
386
389
|
`;
|
|
387
390
|
}
|
|
391
|
+
export function addToProject(projectDir) {
|
|
392
|
+
const srcDir = path.join(projectDir, 'src');
|
|
393
|
+
if (fs.existsSync(path.join(srcDir, 'App.tsx'))) {
|
|
394
|
+
console.error(`Error: ${srcDir}/App.tsx already exists. Aborting.`);
|
|
395
|
+
process.exit(1);
|
|
396
|
+
}
|
|
397
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
398
|
+
const publicDir = path.join(projectDir, 'public');
|
|
399
|
+
fs.mkdirSync(publicDir, { recursive: true });
|
|
400
|
+
// Write TSX source files only — no CMakeLists.txt or main.cpp
|
|
401
|
+
fs.writeFileSync(path.join(srcDir, 'App.tsx'), APP_TSX);
|
|
402
|
+
fs.writeFileSync(path.join(srcDir, 'imx.d.ts'), IMX_DTS);
|
|
403
|
+
fs.writeFileSync(path.join(projectDir, 'tsconfig.json'), TSCONFIG);
|
|
404
|
+
console.log(`imxc: added IMX sources to project`);
|
|
405
|
+
console.log('');
|
|
406
|
+
console.log(' Created:');
|
|
407
|
+
console.log(` src/App.tsx — your root component`);
|
|
408
|
+
console.log(` src/imx.d.ts — type definitions for IDE support`);
|
|
409
|
+
console.log(` tsconfig.json — TypeScript config`);
|
|
410
|
+
console.log(` public/ — static assets (copied to exe directory)`);
|
|
411
|
+
console.log('');
|
|
412
|
+
console.log(' Add to your CMakeLists.txt:');
|
|
413
|
+
console.log('');
|
|
414
|
+
console.log(' # --- IMX integration ---');
|
|
415
|
+
console.log(' include(FetchContent)');
|
|
416
|
+
console.log(' FetchContent_Declare(imx');
|
|
417
|
+
console.log(' GIT_REPOSITORY https://github.com/bgocumlu/imx.git');
|
|
418
|
+
console.log(' GIT_TAG main');
|
|
419
|
+
console.log(' )');
|
|
420
|
+
console.log(' FetchContent_MakeAvailable(imx)');
|
|
421
|
+
console.log(' include(ImxCompile)');
|
|
422
|
+
console.log('');
|
|
423
|
+
console.log(' imx_compile_tsx(GENERATED');
|
|
424
|
+
console.log(' SOURCES src/App.tsx');
|
|
425
|
+
console.log(' OUTPUT_DIR ${CMAKE_BINARY_DIR}/generated');
|
|
426
|
+
console.log(' )');
|
|
427
|
+
console.log('');
|
|
428
|
+
console.log(' # Add ${GENERATED} to your target sources:');
|
|
429
|
+
console.log(' target_sources(your_app PRIVATE ${GENERATED})');
|
|
430
|
+
console.log(' target_link_libraries(your_app PRIVATE imx::renderer)');
|
|
431
|
+
console.log(' target_include_directories(your_app PRIVATE ${CMAKE_BINARY_DIR}/generated)');
|
|
432
|
+
console.log('');
|
|
433
|
+
console.log(' # Copy assets to exe directory:');
|
|
434
|
+
console.log(' add_custom_command(TARGET your_app POST_BUILD');
|
|
435
|
+
console.log(' COMMAND ${CMAKE_COMMAND} -E copy_directory');
|
|
436
|
+
console.log(' ${CMAKE_CURRENT_SOURCE_DIR}/public $<TARGET_FILE_DIR:your_app>');
|
|
437
|
+
console.log(' )');
|
|
438
|
+
console.log('');
|
|
439
|
+
console.log(' Then add the IMX render call to your main loop:');
|
|
440
|
+
console.log('');
|
|
441
|
+
console.log(' #include <imx/runtime.h>');
|
|
442
|
+
console.log(' imx::Runtime runtime;');
|
|
443
|
+
console.log(' // In your frame loop, between NewFrame() and Render():');
|
|
444
|
+
console.log(' imx::render_root(runtime);');
|
|
445
|
+
}
|
|
388
446
|
export function initProject(projectDir, projectName) {
|
|
389
447
|
const name = projectName ?? path.basename(projectDir);
|
|
390
448
|
const srcDir = path.join(projectDir, 'src');
|