This commit is contained in:
Gorochu
2026-05-30 21:40:16 -07:00
parent b7808b2b6e
commit 6a79c786ab
3 changed files with 77 additions and 23 deletions

View File

@ -33,13 +33,25 @@ export class MakeExporter extends Exporter {
} }
async exportSolution(project: Project, from: string, to: string, platform: string, vrApi: any, options: any) { async exportSolution(project: Project, from: string, to: string, platform: string, vrApi: any, options: any) {
// 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 = [ let mFiles = [
path.join(from, 'Kinc/Backends/System/Apple/Sources/kinc/backend/appleunit.m'), koreBasePath + '/Backends/System/Apple/Sources/kinc/backend/appleunit.m',
path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/macosunit.m'), koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/macosunit.m',
path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/system.m.h'), koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/system.m.h',
path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/BasicOpenGLView.m.h'), koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/BasicOpenGLView.m.h',
path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/display.m.h'), koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/display.m.h',
path.join(from, 'Kinc/Backends/System/macOS/Sources/kinc/backend/mouse.m.h') koreBasePath + '/Backends/System/macOS/Sources/kinc/backend/mouse.m.h'
]; ];
for (let mFile of mFiles) { for (let mFile of mFiles) {
let found = false; let found = false;
@ -54,6 +66,19 @@ export class MakeExporter extends Exporter {
} }
} }
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: any = {}; let objects: any = {};
let ofiles: any = {}; let ofiles: any = {};
let outputPath = path.resolve(to, options.buildPath); let outputPath = path.resolve(to, options.buildPath);

View File

@ -631,19 +631,7 @@ async function exportKoremakeProject(from: string, to: string, platform: string,
exporter = new MesonExporter(options); exporter = new MesonExporter(options);
} }
else if (platform === Platform.OSX) { else if (platform === Platform.OSX) {
// Use MakeExporter directly for macOS to ensure .m files are compiled exporter = new MacOSExporter(options);
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);
} }
else if (platform === Platform.iOS || platform === Platform.tvOS) exporter = new XCodeExporter(options); else if (platform === Platform.iOS || platform === Platform.tvOS) exporter = new XCodeExporter(options);
else if (platform === Platform.Android) exporter = new AndroidExporter(options); else if (platform === Platform.Android) exporter = new AndroidExporter(options);

View File

@ -25,13 +25,46 @@ class MakeExporter extends Exporter_1.Exporter {
return libs; return libs;
} }
async exportSolution(project, from, to, platform, vrApi, options) { 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 objects = {};
let ofiles = {}; let ofiles = {};
let outputPath = path.resolve(to, options.buildPath); let outputPath = path.resolve(to, options.buildPath);
fs.ensureDirSync(outputPath); fs.ensureDirSync(outputPath);
for (let fileobject of project.getFiles()) { for (let fileobject of project.getFiles()) {
let file = fileobject.file; 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) { if (fileobject.options && fileobject.options.nocompile) {
continue; continue;
} }
@ -166,7 +199,7 @@ class MakeExporter extends Exporter_1.Exporter {
} }
for (let fileobject of project.getFiles()) { for (let fileobject of project.getFiles()) {
let file = fileobject.file; 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) { if (fileobject.options && fileobject.options.nocompile) {
continue; continue;
} }
@ -185,6 +218,14 @@ class MakeExporter extends Exporter_1.Exporter {
compiler = this.cCompiler; compiler = this.cCompiler;
flags = ''; 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'); this.p('\t' + compiler + ' ' + optimization + ' $(INC) $(DEF) -MD ' + flags + ' -c ' + realfile + ' -o ' + name + '.o');
} }
} }