"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;