feat(cli): add --compile flag and cmake build system to fmu export · modelscript/modelscript@3858cb7 · GitHub
Skip to content

Commit 3858cb7

Browse files
committed
feat(cli): add --compile flag and cmake build system to fmu export
1 parent 1ec8b6b commit 3858cb7

3 files changed

Lines changed: 184 additions & 10 deletions

File tree

‎packages/cli/src/commands/export-fmu.ts‎

Lines changed: 115 additions & 4 deletions

‎packages/core/src/compiler/modelica/fmu-archive.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ export function buildFmuArchive(
7575
files.set("sources/fmi2Functions.h", encoder.encode(FMI2_FUNCTIONS_H));
7676
files.set("sources/fmi2TypesPlatform.h", encoder.encode(FMI2_TYPES_PLATFORM_H));
7777
files.set("sources/fmi2FunctionTypes.h", encoder.encode(FMI2_FUNCTION_TYPES_H));
78+
79+
// CMake build system
80+
files.set("sources/CMakeLists.txt", encoder.encode(sources.cmakeLists));
7881
}
7982

8083
// ── model.json (serialized DAE for JS runtime) ──
@@ -95,7 +98,7 @@ export function buildFmuArchive(
9598

9699
// ── ZIP file builder (pure TypeScript, no external deps beyond pako) ──
97100

98-
function createZip(files: Map<string, Uint8Array>): Uint8Array {
101+
export function createZip(files: Map<string, Uint8Array>): Uint8Array {
99102
const centralDirectory: Uint8Array[] = [];
100103
const localFiles: Uint8Array[] = [];
101104
let offset = 0;
@@ -201,7 +204,7 @@ function crc32(data: Uint8Array): number {
201204

202205
// ── FMI 2.0 standard header files (minimal, self-contained) ──
203206

204-
const FMI2_TYPES_PLATFORM_H = `/* FMI 2.0 Type Platform — auto-included by ModelScript */
207+
export const FMI2_TYPES_PLATFORM_H = `/* FMI 2.0 Type Platform — auto-included by ModelScript */
205208
#ifndef fmi2TypesPlatform_h
206209
#define fmi2TypesPlatform_h
207210
@@ -253,7 +256,7 @@ typedef struct {
253256
#endif
254257
`;
255258

256-
const FMI2_FUNCTION_TYPES_H = `/* FMI 2.0 Function Types — auto-included by ModelScript */
259+
export const FMI2_FUNCTION_TYPES_H = `/* FMI 2.0 Function Types — auto-included by ModelScript */
257260
#ifndef fmi2FunctionTypes_h
258261
#define fmi2FunctionTypes_h
259262
@@ -276,7 +279,7 @@ typedef struct {
276279
#endif
277280
`;
278281

279-
const FMI2_FUNCTIONS_H = `/* FMI 2.0 Functions — auto-included by ModelScript */
282+
export const FMI2_FUNCTIONS_H = `/* FMI 2.0 Functions — auto-included by ModelScript */
280283
#ifndef fmi2Functions_h
281284
#define fmi2Functions_h
282285

‎packages/core/src/compiler/modelica/fmu-codegen.ts‎

Lines changed: 62 additions & 2 deletions

0 commit comments

Comments
 (0)