From 6a79c786ab01118f4458763c71cff36eeb145630 Mon Sep 17 00:00:00 2001 From: Gorochu Date: Sat, 30 May 2026 21:40:16 -0700 Subject: [PATCH] Update --- kmake/src/Exporters/MakeExporter.ts | 41 +++++++++++++++++++++----- kmake/src/main.ts | 14 +-------- lib/kmake/Exporters/MakeExporter.js | 45 +++++++++++++++++++++++++++-- 3 files changed, 77 insertions(+), 23 deletions(-) diff --git a/kmake/src/Exporters/MakeExporter.ts b/kmake/src/Exporters/MakeExporter.ts index 1b14d053..72471403 100644 --- a/kmake/src/Exporters/MakeExporter.ts +++ b/kmake/src/Exporters/MakeExporter.ts @@ -33,14 +33,39 @@ export class MakeExporter extends Exporter { } async exportSolution(project: Project, from: string, to: string, platform: string, vrApi: any, options: any) { - let mFiles = [ - path.join(from, 'Kinc/Backends/System/Apple/Sources/kinc/backend/appleunit.m'), - path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/macosunit.m'), - path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/system.m.h'), - path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/BasicOpenGLView.m.h'), - path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/display.m.h'), - path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/mouse.m.h') - ]; + // TODO: Figure out why we cant get the relative path and if we even need to manually include the m files + let koreBasePath = ''; + for (let fileobject of project.getFiles()) { + if (fileobject.file.includes('Kore/Backends')) { + let parts = fileobject.file.split('/'); + let koreIndex = parts.indexOf('Kore'); + if (koreIndex !== -1) { + koreBasePath = parts.slice(0, koreIndex + 1).join('/'); + break; + } + } + } + let mFiles = [ + koreBasePath + '/Backends/System/Apple/Sources/kinc/backend/appleunit.m', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/macosunit.m', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/system.m.h', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/BasicOpenGLView.m.h', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/display.m.h', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/mouse.m.h' + ]; + for (let mFile of mFiles) { + let found = false; + for (let fileobject of project.getFiles()) { + if (fileobject.file === mFile) { + found = true; + break; + } + } + if (!found) { + project.files.push({file: mFile, options: null, projectDir: from, projectName: project.name}); + } + } + for (let mFile of mFiles) { let found = false; for (let fileobject of project.getFiles()) { diff --git a/kmake/src/main.ts b/kmake/src/main.ts index be5223d6..f7df3143 100644 --- a/kmake/src/main.ts +++ b/kmake/src/main.ts @@ -631,19 +631,7 @@ async function exportKoremakeProject(from: string, to: string, platform: string, exporter = new MesonExporter(options); } else if (platform === Platform.OSX) { - // Use MakeExporter directly for macOS to ensure .m files are compiled - let linkerFlags = '-pthread'; - if (options.lib) { - linkerFlags += ' -static'; - } - let outputExtension = ''; - if (options.lib) { - outputExtension = '.a'; - } - else if (options.dynlib) { - outputExtension = '.dylib'; - } - exporter = new MakeExporter(options, 'clang', 'clang++', '', '', linkerFlags, outputExtension); + exporter = new MacOSExporter(options); } else if (platform === Platform.iOS || platform === Platform.tvOS) exporter = new XCodeExporter(options); else if (platform === Platform.Android) exporter = new AndroidExporter(options); diff --git a/lib/kmake/Exporters/MakeExporter.js b/lib/kmake/Exporters/MakeExporter.js index 8b57ff09..d1e171f2 100644 --- a/lib/kmake/Exporters/MakeExporter.js +++ b/lib/kmake/Exporters/MakeExporter.js @@ -25,13 +25,46 @@ class MakeExporter extends Exporter_1.Exporter { return libs; } async exportSolution(project, from, to, platform, vrApi, options) { + // TODO: Figure out why we cant get the relative path and if we even need to manually include the m files + let koreBasePath = ''; + for (let fileobject of project.getFiles()) { + if (fileobject.file.includes('Kore/Backends')) { + let parts = fileobject.file.split('/'); + let koreIndex = parts.indexOf('Kore'); + if (koreIndex !== -1) { + koreBasePath = parts.slice(0, koreIndex + 1).join('/'); + break; + } + } + } + let mFiles = [ + koreBasePath + '/Backends/System/Apple/Sources/kinc/backend/appleunit.m', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/macosunit.m', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/system.m.h', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/BasicOpenGLView.m.h', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/display.m.h', + koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/mouse.m.h' + ]; + for (let mFile of mFiles) { + let found = false; + for (let fileobject of project.getFiles()) { + if (fileobject.file === mFile) { + found = true; + break; + } + } + if (!found) { + project.files.push({file: mFile, options: null, projectDir: from, projectName: project.name}); + } + } + let objects = {}; let ofiles = {}; let outputPath = path.resolve(to, options.buildPath); fs.ensureDirSync(outputPath); for (let fileobject of project.getFiles()) { let file = fileobject.file; - if (file.endsWith('.cpp') || file.endsWith('.c') || file.endsWith('.cc') || file.endsWith('.s') || file.endsWith('.S')) { + if (file.endsWith('.cpp') || file.endsWith('.c') || file.endsWith('.cc') || file.endsWith('.s') || file.endsWith('.S') || file.endsWith('.m') || file.endsWith('.mm')) { if (fileobject.options && fileobject.options.nocompile) { continue; } @@ -166,7 +199,7 @@ class MakeExporter extends Exporter_1.Exporter { } for (let fileobject of project.getFiles()) { let file = fileobject.file; - if (file.endsWith('.c') || file.endsWith('.cpp') || file.endsWith('.cc') || file.endsWith('.s') || file.endsWith('.S')) { + if (file.endsWith('.c') || file.endsWith('.cpp') || file.endsWith('.cc') || file.endsWith('.s') || file.endsWith('.S') || file.endsWith('.m') || file.endsWith('.mm')) { if (fileobject.options && fileobject.options.nocompile) { continue; } @@ -185,6 +218,14 @@ class MakeExporter extends Exporter_1.Exporter { compiler = this.cCompiler; flags = ''; } + else if (file.endsWith('.m')) { + compiler = this.cCompiler; + flags = '$(CPPFLAGS)'; + } + else if (file.endsWith('.mm')) { + compiler = this.cppCompiler; + flags = '$(CPPFLAGS)'; + } this.p('\t' + compiler + ' ' + optimization + ' $(INC) $(DEF) -MD ' + flags + ' -c ' + realfile + ' -o ' + name + '.o'); } }