From b7808b2b6eaec60b0e81909d49717c35621c62d6 Mon Sep 17 00:00:00 2001 From: Gorochu Date: Sat, 30 May 2026 19:09:17 +0000 Subject: [PATCH] Add lib/kmake/Exporters/MacOSExporter.js --- lib/kmake/Exporters/MacOSExporter.js | 75 ++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 lib/kmake/Exporters/MacOSExporter.js diff --git a/lib/kmake/Exporters/MacOSExporter.js b/lib/kmake/Exporters/MacOSExporter.js new file mode 100644 index 00000000..a99a083a --- /dev/null +++ b/lib/kmake/Exporters/MacOSExporter.js @@ -0,0 +1,75 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MacOSExporter = void 0; +const Exporter_1 = require("kmake/Exporters/Exporter"); +const Options_1 = require("kmake/Options"); +const Compiler_1 = require("kmake/Compiler"); +const NinjaExporter_1 = require("kmake/Exporters/NinjaExporter"); +const MakeExporter_1 = require("kmake/Exporters/MakeExporter"); +const CLionExporter_1 = require("kmake/Exporters/CLionExporter"); +const CompileCommandsExporter_1 = require("kmake/Exporters/CompileCommandsExporter"); +class MacOSExporter extends Exporter_1.Exporter { + constructor(options) { + super(options); + let linkerFlags = '-pthread -framework Security'; + if (options.lib) { + linkerFlags += ' -static'; + } + let outputExtension = ''; + if (options.lib) { + outputExtension = '.a'; + } + else if (options.dynlib) { + outputExtension = '.dylib'; + } + const macLibsLine = (project) => { + let libs = ''; + for (let lib of project.getLibs()) { + if (['OpenGL', 'Cocoa', 'IOKit', 'AppKit', 'CoreAudio', 'CoreData', 'CoreMedia', 'CoreVideo', 'AVFoundation', 'Foundation', 'Metal', 'MetalKit'].includes(lib)) { + libs += ' -framework ' + lib; + } + else { + libs += ' -l' + lib; + } + } + return libs; + }; + this.ninja = new NinjaExporter_1.NinjaExporter(options, this.getCCompiler(), this.getCPPCompiler(), '', '', linkerFlags, outputExtension); + this.make = new MakeExporter_1.MakeExporter(options, this.getCCompiler(), this.getCPPCompiler(), '', '', linkerFlags, outputExtension, macLibsLine); + this.clion = new CLionExporter_1.CLionExporter(options); + this.compileCommands = new CompileCommandsExporter_1.CompilerCommandsExporter(options); + } + async exportSolution(project, from, to, platform, vrApi, options) { + this.ninja.exportSolution(project, from, to, platform, vrApi, options); + this.make.exportSolution(project, from, to, platform, vrApi, options); + this.clion.exportSolution(project, from, to, platform, vrApi, options); + this.compileCommands.exportSolution(project, from, to, platform, vrApi, options); + } + getCCompiler() { + switch (Options_1.Options.compiler) { + case Compiler_1.Compiler.Default: + case Compiler_1.Compiler.Clang: + return 'clang'; + case Compiler_1.Compiler.GCC: + return 'gcc'; + case Compiler_1.Compiler.Custom: + return Options_1.Options.ccPath; + default: + throw 'Unsupported compiler ' + Options_1.Options.compiler; + } + } + getCPPCompiler() { + switch (Options_1.Options.compiler) { + case Compiler_1.Compiler.Default: + case Compiler_1.Compiler.Clang: + return 'clang++'; + case Compiler_1.Compiler.GCC: + return 'g++'; + case Compiler_1.Compiler.Custom: + return Options_1.Options.cxxPath; + default: + throw 'Unsupported compiler ' + Options_1.Options.compiler; + } + } +} +exports.MacOSExporter = MacOSExporter;