Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,279 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AndroidExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const GraphicsApi_1 = require("kmake/GraphicsApi");
const Project_1 = require("kmake/Project");
const Architecture_1 = require("kmake/Architecture");
const Options_1 = require("kmake/Options");
const Icon = require("kmake/Icon");
const fs = require("kmake/fsextra");
const os = require("os");
const path = require("path");
const CompileCommandsExporter_1 = require("kmake/Exporters/CompileCommandsExporter");
class AndroidExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
this.compileCommands = new CompileCommandsExporter_1.CompilerCommandsExporter(options);
}
async exportSolution(project, from, to, platform, vrApi, options) {
this.safeName = project.getSafeName();
const indir = path.join(__dirname, '..', '..', 'Data', 'android');
const outdir = path.join(to.toString(), this.safeName);
fs.ensureDirSync(outdir);
const targetOptions = {
package: 'tech.kore',
installLocation: 'internalOnly',
versionCode: 1,
versionName: '1.0',
compileSdkVersion: 33,
minSdkVersion: (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Vulkan || Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Default) ? 24 : 21,
targetSdkVersion: 33,
screenOrientation: 'sensor',
permissions: ['android.permission.VIBRATE'],
disableStickyImmersiveMode: false,
metadata: new Array(),
customFilesPath: null,
buildGradlePath: null,
globalBuildGradlePath: null,
proguardRulesPath: null,
abiFilters: new Array()
};
if (project.targetOptions != null && project.targetOptions.android != null) {
const userOptions = project.targetOptions.android;
for (let key in userOptions) {
if (userOptions[key] == null)
continue;
switch (key) {
case 'customFilesPath':
case 'buildGradlePath':
case 'globalBuildGradlePath':
case 'proguardRulesPath':
// fix path slashes and normalize
const p = userOptions[key].split('/').join(path.sep);
targetOptions[key] = path.join(from, p);
break;
default:
targetOptions[key] = userOptions[key];
}
}
}
const binaryData = require('fs').getEmbeddedBinaryData();
const textData = require('fs').getEmbeddedData();
fs.writeFileSync(path.join(outdir, '.gitignore'), textData['android_gitignore']);
if (targetOptions.globalBuildGradlePath) {
fs.copyFileSync(targetOptions.globalBuildGradlePath, path.join(outdir, 'build.gradle.kts'));
}
else {
fs.writeFileSync(path.join(outdir, 'build.gradle.kts'), textData['android_build_gradle']);
}
fs.writeFileSync(path.join(outdir, 'gradle.properties'), textData['android_gradle_properties']);
fs.writeFileSync(path.join(outdir, 'gradlew'), textData['android_gradlew']);
if (os.platform() !== 'win32') {
fs.chmodSync(path.join(outdir, 'gradlew'), 0o755);
}
fs.writeFileSync(path.join(outdir, 'gradlew.bat'), textData['android_gradlew_bat']);
let settings = textData['android_settings_gradle'];
settings = settings.replace(/{name}/g, project.getName());
fs.writeFileSync(path.join(outdir, 'settings.gradle.kts'), settings);
fs.ensureDirSync(path.join(outdir, 'app'));
fs.writeFileSync(path.join(outdir, 'app', '.gitignore'), textData['android_app_gitignore']);
if (targetOptions.proguardRulesPath) {
fs.copyFileSync(targetOptions.proguardRulesPath, path.join(outdir, 'app', 'proguard-rules.pro'));
}
else {
fs.writeFileSync(path.join(outdir, 'app', 'proguard-rules.pro'), textData['android_app_proguard_rules_pro']);
}
this.writeAppGradle(project, outdir, from, targetOptions, textData);
this.writeCMakeLists(project, outdir, from, targetOptions, textData);
fs.ensureDirSync(path.join(outdir, 'app', 'src'));
// fs.emptyDirSync(path.join(outdir, 'app', 'src'));
fs.ensureDirSync(path.join(outdir, 'app', 'src', 'main'));
this.writeManifest(outdir, targetOptions, textData);
let strings = textData['android_main_res_values_strings_xml'];
strings = strings.replace(/{name}/g, project.getName());
fs.ensureDirSync(path.join(outdir, 'app', 'src', 'main', 'res', 'values'));
fs.writeFileSync(path.join(outdir, 'app', 'src', 'main', 'res', 'values', 'strings.xml'), strings);
await this.exportIcons(project.icon, outdir, from, to);
fs.ensureDirSync(path.join(outdir, 'gradle', 'wrapper'));
fs.writeFileSync(path.join(outdir, 'gradle', 'wrapper', 'gradle-wrapper.jar'), binaryData['android_gradle_wrapper_gradle_wrapper_jar']);
fs.writeFileSync(path.join(outdir, 'gradle', 'wrapper', 'gradle-wrapper.properties'), textData['android_gradle_wrapper_gradle_wrapper_properties']);
/*fs.ensureDirSync(path.join(outdir, '.idea'));
fs.writeFileSync(path.join(outdir, '.idea', '.gitignore'), textData['android_idea_gitignore']);
fs.writeFileSync(path.join(outdir, '.idea', 'gradle.xml'), textData['android_idea_gradle_xml']);
fs.writeFileSync(path.join(outdir, '.idea', 'misc.xml'), textData['android_idea_misc_xml']);
let modules = textData['android_idea_modules_xml'];
modules = modules.replace(/{name}/g, project.getName());
fs.writeFileSync(path.join(outdir, '.idea', 'modules.xml'), modules);
fs.writeFileSync(path.join(outdir, '.idea', 'compiler.xml'), textData['android_idea_compiler_xml']);
fs.writeFileSync(path.join(outdir, '.idea', 'kotlinc.xml'), textData['android_idea_kotlinc_xml']);
fs.ensureDirSync(path.join(outdir, '.idea', 'modules'));
fs.ensureDirSync(path.join(outdir, '.idea', 'modules', 'app'));
fs.writeFileSync(path.join(outdir, '.idea', 'modules', 'app', project.getName() + '.app.main.iml'), textData['android_idea_modules_my_application_iml']);*/
if (targetOptions.customFilesPath != null) {
const dir = targetOptions.customFilesPath;
if (!fs.existsSync(dir))
throw dir + ' folder does not exist';
fs.copyDirSync(dir, outdir);
}
if (project.getDebugDir().length > 0)
fs.copyDirSync(path.resolve(from, project.getDebugDir()), path.resolve(to, this.safeName, 'app', 'src', 'main', 'assets'));
this.compileCommands.exportSolution(project, from, to, platform, vrApi, options);
}
writeAppGradle(project, outdir, from, targetOptions, textData) {
let cflags = '';
for (let flag of project.cFlags)
cflags += flag + ' ';
let cppflags = '';
for (let flag of project.cppFlags)
cppflags += flag + ' ';
let gradle = null;
if (targetOptions.buildGradlePath) {
gradle = fs.readFileSync(targetOptions.buildGradlePath, 'utf8');
}
else {
gradle = textData['android_app_build_gradle'];
}
gradle = gradle.replace(/{package}/g, targetOptions.package);
gradle = gradle.replace(/{versionCode}/g, targetOptions.versionCode.toString());
gradle = gradle.replace(/{versionName}/g, targetOptions.versionName);
gradle = gradle.replace(/{compileSdkVersion}/g, targetOptions.compileSdkVersion.toString());
gradle = gradle.replace(/{minSdkVersion}/g, targetOptions.minSdkVersion.toString());
gradle = gradle.replace(/{targetSdkVersion}/g, targetOptions.targetSdkVersion.toString());
let arch = '';
if (targetOptions.abiFilters.length > 0) {
for (let item of targetOptions.abiFilters) {
if (arch.length === 0) {
arch = '"' + item + '"';
}
else {
arch = arch + ', "' + item + '"';
}
}
arch = `ndk { abiFilters += listOf(${arch}) }`;
}
else {
switch (Options_1.Options.architecture) {
case Architecture_1.Architecture.Default:
arch = '';
break;
case Architecture_1.Architecture.arm:
arch = 'armeabi-v7a';
break;
case Architecture_1.Architecture.arm64:
arch = 'arm64-v8a';
break;
case Architecture_1.Architecture.x64:
arch = 'x86';
break;
case Architecture_1.Architecture.x64:
arch = 'x86_64';
break;
default: throw 'Unknown architecture ' + Options_1.Options.architecture;
}
if (Options_1.Options.architecture !== Architecture_1.Architecture.Default) {
arch = `ndk {abiFilters += listOf("${arch}")}`;
}
}
gradle = gradle.replace(/{architecture}/g, arch);
gradle = gradle.replace(/{cflags}/g, cflags);
cppflags = '-frtti -fexceptions ' + cppflags;
if (project.cppStd !== '') {
cppflags = '-std=' + project.cppStd + ' ' + cppflags;
}
gradle = gradle.replace(/{cppflags}/g, cppflags);
let javasources = '';
for (let dir of project.getJavaDirs()) {
javasources += '"' + path.relative(path.join(outdir, 'app'), path.resolve(from, dir)).replace(/\\/g, '/') + '", ';
}
javasources += '"' + path.relative(path.join(outdir, 'app'), path.join(Project_1.Project.koreDir.toString(), 'Backends', 'System', 'Android', 'Java-Sources')).replace(/\\/g, '/') + '"';
gradle = gradle.replace(/{javasources}/g, javasources);
fs.writeFileSync(path.join(outdir, 'app', 'build.gradle.kts'), gradle);
}
writeCMakeLists(project, outdir, from, targetOptions, textData) {
let cmake = textData['android_app_cmakelists_txt'];
let debugDefines = '';
for (const def of project.getDefines()) {
if (!def.config || def.config.toLowerCase() === 'debug') {
debugDefines += ' -D' + def.value.replace(/\"/g, '\\\\\\\"');
}
}
cmake = cmake.replace(/{debug_defines}/g, debugDefines);
let releaseDefines = '';
for (const def of project.getDefines()) {
if (!def.config || def.config.toLowerCase() === 'release') {
releaseDefines += ' -D' + def.value.replace(/\"/g, '\\\\\\\"');
}
}
cmake = cmake.replace(/{release_defines}/g, releaseDefines);
let includes = '';
for (let inc of project.getIncludeDirs()) {
includes += ' "' + path.resolve(inc).replace(/\\/g, '/') + '"\n';
}
cmake = cmake.replace(/{includes}/g, includes);
let files = '';
for (let file of project.getFiles()) {
if (file.file.endsWith('.c') || file.file.endsWith('.cc')
|| file.file.endsWith('.cpp') || file.file.endsWith('.h')) {
if (file.options && file.options.nocompile) {
continue;
}
if (path.isAbsolute(file.file)) {
files += ' "' + path.resolve(file.file).replace(/\\/g, '/') + '"\n';
}
else {
files += ' "' + path.resolve(path.join(from, file.file)).replace(/\\/g, '/') + '"\n';
}
}
}
cmake = cmake.replace(/{files}/g, files);
let libraries1 = '';
let libraries2 = '';
for (let lib of project.getLibs()) {
libraries1 += 'find_library(' + lib + '-lib ' + lib + ')\n';
libraries2 += ' ${' + lib + '-lib}\n';
}
cmake = cmake.replace(/{libraries1}/g, libraries1)
.replace(/{libraries2}/g, libraries2);
const cmakePath = path.join(outdir, 'app', 'CMakeLists.txt');
if (this.isCmakeSame(cmakePath, cmake))
return;
fs.writeFileSync(cmakePath, cmake);
}
isCmakeSame(cmakePath, cmake) {
// prevent overwriting CMakeLists.txt if it has not changed
if (!fs.existsSync(cmakePath))
return false;
return fs.readFileSync(cmakePath, 'utf8') === cmake;
}
writeManifest(outdir, targetOptions, textData) {
let manifest = textData['android_main_androidmanifest_xml'];
manifest = manifest.replace(/{package}/g, targetOptions.package);
manifest = manifest.replace(/{installLocation}/g, targetOptions.installLocation);
manifest = manifest.replace(/{versionCode}/g, targetOptions.versionCode.toString());
manifest = manifest.replace(/{versionName}/g, targetOptions.versionName);
manifest = manifest.replace(/{screenOrientation}/g, targetOptions.screenOrientation);
manifest = manifest.replace(/{targetSdkVersion}/g, targetOptions.targetSdkVersion);
manifest = manifest.replace(/{permissions}/g, targetOptions.permissions.map((p) => { return '\n\t<uses-permission android:name="' + p + '"/>'; }).join(''));
let metadata = targetOptions.disableStickyImmersiveMode ? '\n\t\t<meta-data android:name="disableStickyImmersiveMode" android:value="true"/>' : '';
for (const meta of targetOptions.metadata) {
metadata += '\n\t\t' + meta;
}
manifest = manifest.replace(/{metadata}/g, metadata);
fs.ensureDirSync(path.join(outdir, 'app', 'src', 'main'));
fs.writeFileSync(path.join(outdir, 'app', 'src', 'main', 'AndroidManifest.xml'), manifest);
}
async exportIcons(icon, outdir, from, to) {
const folders = ['mipmap-mdpi', 'mipmap-hdpi', 'mipmap-xhdpi', 'mipmap-xxhdpi', 'mipmap-xxxhdpi'];
const dpis = [48, 72, 96, 144, 192];
for (let i = 0; i < dpis.length; ++i) {
const folder = folders[i];
const dpi = dpis[i];
fs.ensureDirSync(path.join(outdir, 'app', 'src', 'main', 'res', folder));
await Icon.exportPng(icon, path.resolve(to, this.safeName, 'app', 'src', 'main', 'res', folder, 'ic_launcher.png'), dpi, dpi, undefined, from);
await Icon.exportPng(icon, path.resolve(to, this.safeName, 'app', 'src', 'main', 'res', folder, 'ic_launcher_round.png'), dpi, dpi, undefined, from);
}
}
}
exports.AndroidExporter = AndroidExporter;
//# sourceMappingURL=AndroidExporter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLionExporter = void 0;
const fs = require("kmake/fsextra");
const path = require("path");
const Exporter_1 = require("kmake/Exporters/Exporter");
const CMakeExporter_1 = require("kmake/Exporters/CMakeExporter");
class CLionExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
this.cmake = new CMakeExporter_1.CMakeExporter(options);
}
async exportSolution(project, from, to, platform, vrApi, options) {
let name = project.getSafeName();
fs.ensureDirSync(path.resolve(to, name, '.idea'));
let misc = require('fs').getEmbeddedData()['linux_idea_misc_xml'];
misc = misc.replace(/{root}/g, path.resolve(from));
fs.writeFileSync(path.join(to, name, '.idea', 'misc.xml'), misc, 'utf8');
let workspace = require('fs').getEmbeddedData()['linux_idea_workspace_xml'];
workspace = workspace.replace(/{workingdir}/g, path.resolve(project.getDebugDir()));
workspace = workspace.replace(/{project}/g, name);
workspace = workspace.replace(/{target}/g, name);
fs.writeFileSync(path.join(to, name, '.idea', 'workspace.xml'), workspace, 'utf8');
this.cmake.exportSolution(project, from, to, platform, vrApi, options);
}
}
exports.CLionExporter = CLionExporter;
//# sourceMappingURL=CLionExporter.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"CLionExporter.js","sourceRoot":"","sources":["../../../kmake/src/Exporters/CLionExporter.ts"],"names":[],"mappings":";;;AACA,oCAAoC;AACpC,6BAA6B;AAC7B,uDAAoD;AACpD,iEAA8D;AAE9D,MAAa,aAAc,SAAQ,mBAAQ;IAG1C,YAAY,OAAY;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,IAAI,6BAAa,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAgB,EAAE,IAAY,EAAE,EAAU,EAAE,QAAgB,EAAE,KAAU,EAAE,OAAY;QAC1G,IAAI,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QAEjC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QAElD,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC,qBAAqB,CAAC,CAAC;QAClE,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAEzE,IAAI,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC,0BAA0B,CAAC,CAAC;QAC5E,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QACpF,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAClD,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACjD,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAEnF,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;CACD;AAzBD,sCAyBC"}

View File

@ -0,0 +1,165 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CMakeExporter = void 0;
const path = require("path");
const Exporter_1 = require("kmake/Exporters/Exporter");
class CMakeExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
}
async exportSolution(project, from, to, platform, vrApi, options) {
let name = project.getSafeName();
this.writeFile(path.resolve(to, name, 'CMakeLists.txt'));
let cmakeVersion = '3.10';
switch (project.cppStd) {
case 'gnu++03':
case 'c++03':
case 'gnu++11':
case 'c++11':
case 'gnu++14':
case 'c++14':
case 'gnu++17':
case 'c++17':
break;
case 'gnu++2a':
case 'c++2a':
case 'gnu++20':
case 'c++20':
cmakeVersion = '3.12';
break;
case 'gnu++2b':
case 'c++2b':
case 'gnu++23':
case 'c++23':
cmakeVersion = '3.20';
break;
default:
break;
}
switch (project.cStd) {
case 'gnu9x':
case 'gnu99':
case 'c9x':
case 'c99':
case 'gnu1x':
case 'gnu11':
case 'c1x':
case 'c11':
break;
case 'gnu18':
case 'gnu17':
case 'c18':
case 'c17':
case 'gnu2x':
case 'c2x':
cmakeVersion = '3.21';
break;
default:
break;
}
this.p('cmake_minimum_required(VERSION ' + cmakeVersion + ')');
this.p('project(' + name + ')');
switch (project.cppStd) {
case 'gnu++03':
case 'c++03':
this.p('set(CMAKE_CXX_STANDARD 03)');
break;
case 'gnu++11':
case 'c++11':
this.p('set(CMAKE_CXX_STANDARD 11)');
break;
case 'gnu++14':
case 'c++14':
this.p('set(CMAKE_CXX_STANDARD 14)');
break;
case 'gnu++17':
case 'c++17':
this.p('set(CMAKE_CXX_STANDARD 17)');
break;
case 'gnu++2a':
case 'c++2a':
case 'gnu++20':
case 'c++20':
this.p('set(CMAKE_CXX_STANDARD 20)');
break;
case 'gnu++2b':
case 'c++2b':
case 'gnu++23':
case 'c++23':
this.p('set(CMAKE_CXX_STANDARD 23)');
break;
default:
this.p('set(CMAKE_CXX_STANDARD 98)');
break;
}
switch (project.cStd) {
case 'gnu9x':
case 'gnu99':
case 'c9x':
case 'c99':
this.p('set(CMAKE_C_STANDARD 99)');
break;
case 'gnu1x':
case 'gnu11':
case 'c1x':
case 'c11':
this.p('set(CMAKE_C_STANDARD 11)');
break;
case 'gnu18':
case 'gnu17':
case 'c18':
case 'c17':
this.p('set(CMAKE_C_STANDARD 17)');
break;
case 'gnu2x':
case 'c2x':
this.p('set(CMAKE_C_STANDARD 23)');
break;
default:
this.p('set(CMAKE_C_STANDARD 99)');
break;
}
this.p('set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -static-libgcc -static-libstdc++")');
let debugDefines = '';
for (const def of project.getDefines()) {
if (!def.config || def.config.toLowerCase() === 'debug') {
debugDefines += ' -D' + def.value;
}
}
this.p('set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}' + debugDefines + '")');
this.p('set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}' + debugDefines + '")');
let releaseDefines = '';
for (const def of project.getDefines()) {
if (!def.config || def.config.toLowerCase() === 'release') {
releaseDefines += ' -D' + def.value;
}
}
releaseDefines += ' -DNDEBUG';
this.p('set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}' + releaseDefines + '")');
this.p('set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}' + releaseDefines + '")');
let includes = '';
for (let inc of project.getIncludeDirs()) {
includes += ' "' + path.resolve(inc).replace(/\\/g, '/') + '"\n';
}
this.p('include_directories(\n' + includes + ')');
let files = '';
for (let file of project.getFiles()) {
if (file.file.endsWith('.c') || file.file.endsWith('.cc') || file.file.endsWith('.cpp') || file.file.endsWith('.h')) {
if (file.options && file.options.nocompile) {
continue;
}
files += ' "' + path.resolve(file.file).replace(/\\/g, '/') + '"\n';
}
}
this.p('set(SOURCE_FILES\n' + files + ')');
this.p('add_executable(' + name + ' ${SOURCE_FILES})');
let libraries = '';
for (let lib of project.getLibs()) {
libraries += ' ' + lib + '\n';
}
this.p('target_link_libraries(' + name + '\n' + libraries + ')');
this.closeFile();
}
}
exports.CMakeExporter = CMakeExporter;
//# sourceMappingURL=CMakeExporter.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"CMakeExporter.js","sourceRoot":"","sources":["../../../kmake/src/Exporters/CMakeExporter.ts"],"names":[],"mappings":";;;AACA,6BAA6B;AAC7B,uDAAoD;AAEpD,MAAa,aAAc,SAAQ,mBAAQ;IAC1C,YAAY,OAAY;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAgB,EAAE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,CAAC,wBAAwB,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,GAAG,CAAC,CAAC;QAEjE,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;CACD;AA/KD,sCA+KC"}

View File

@ -0,0 +1,152 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompilerCommandsExporter = void 0;
const fs = require("kmake/fsextra");
const path = require("path");
const Platform_1 = require("kmake/Platform");
const log = require("kmake/log");
const os = require("os");
const child_process = require("child_process");
const Exporter_1 = require("kmake/Exporters/Exporter");
class CompilerCommandsExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
}
async exportSolution(project, _from, to, platform, vrApi, options) {
var _a;
let from = path.resolve(process.cwd(), _from);
this.writeFile(path.resolve(to, 'compile_commands.json'));
let includes = [];
for (let inc of project.getIncludeDirs()) {
includes.push('-I');
includes.push(path.resolve(from, inc));
}
let defines = [];
for (let def of project.getDefines()) {
defines.push('-D');
defines.push(def.value.replace(/\"/g, '\\"'));
}
let objects = {};
let ofiles = {};
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 (fileobject.options && fileobject.options.nocompile) {
continue;
}
let name = file.toLowerCase();
if (name.indexOf('/') >= 0)
name = name.substr(name.lastIndexOf('/') + 1);
name = name.substr(0, name.lastIndexOf('.'));
if (!objects[name]) {
objects[name] = true;
ofiles[file] = name;
}
else {
while (objects[name]) {
name = name + '_';
}
objects[name] = true;
ofiles[file] = name;
}
}
}
let defaultArgs = [];
// TODO: same for MacOS, Windows, etc...
if (platform === Platform_1.Platform.Android) {
defaultArgs.push('--target=aarch64-none-linux-android21');
defaultArgs.push('-DANDROID');
// take a guess at where the ndk could be
function ndkFromSdkRoot() {
var _a;
let sdkEnv = (_a = process.env['ANDROID_HOME']) !== null && _a !== void 0 ? _a : process.env['ANDROID_SDK_ROOT'];
if (!sdkEnv)
return null;
let ndk_dir = path.join(sdkEnv, 'ndk');
if (!fs.existsSync(ndk_dir)) {
return null;
}
let ndks = fs.readdirSync(ndk_dir);
ndks = ndks.filter(item => !item.startsWith("."));
if (ndks.length < 1) {
return null;
}
return path.join(ndk_dir, ndks[0]);
}
let android_ndk = (_a = process.env['ANDROID_NDK']) !== null && _a !== void 0 ? _a : ndkFromSdkRoot();
if (android_ndk) {
let host_tag = '';
switch (os.platform()) {
// known host tags
// TODO: figure out the host tag for aarch64 darwin/linux/windows
case 'linux':
host_tag = 'linux-x86_64';
break;
case 'darwin':
host_tag = 'darwin-x86_64';
break;
case 'win32':
host_tag = 'windows-x86_64';
break;
}
let ndk_toolchain = path.join(android_ndk, `toolchains/llvm/prebuilt/${host_tag}`);
if (host_tag !== '' && fs.existsSync(ndk_toolchain)) {
defaultArgs.push(`--gcc-toolchain=${ndk_toolchain}`);
defaultArgs.push(`--sysroot=${ndk_toolchain}/sysroot`);
}
else {
// fallback to the first found toolchain
let toolchains = fs.readdirSync(path.join(android_ndk, `toolchains/llvm/prebuilt/`));
if (toolchains.length > 0) {
let host_tag = toolchains[0];
let ndk_toolchain = path.join(android_ndk, `toolchains/llvm/prebuilt/${host_tag}`);
defaultArgs.push(`--gcc-toolchain=${ndk_toolchain}`);
defaultArgs.push(`--sysroot=${ndk_toolchain}/sysroot`);
log.info(`Found android ndk toolchain in ${ndk_toolchain}.`);
}
else {
log.error('Platform is set to Android, but android toolchain not found.');
}
}
}
else {
log.error('Platform is set to Android, but android toolchain not found.\nPlease set the ANDROID_NDK environment variable if you need a compile_commands.json for your IDE.');
}
}
else if (platform === Platform_1.Platform.Emscripten) {
const emcc_bin = (process.platform === 'win32') ? 'emcc.bat' : 'emcc';
let emcc = child_process.spawnSync(emcc_bin, ['--cflags']);
// log.info(emcc.status);
if (emcc.status === 0) {
let flags = emcc.output.toString().split(' ');
defaultArgs.push(...flags);
}
else {
log.error('Platform is set to Emscripten, but emcc could not be found. Please add it to your PATH environment variable if you need a compile_commands.json for your IDE.');
}
}
let commands = [];
for (let fileobject of project.getFiles()) {
let file = fileobject.file;
if (file.endsWith('.c') || file.endsWith('.cpp') || file.endsWith('.cc')) {
let args = ['/usr/bin/clang', '-c', '-o', (options.debug ? 'debug' : 'release') + ofiles[file] + '.o'];
if (file.endsWith('.c')) {
args.push('-std=c99');
}
args.push(...defaultArgs);
args.push(path.resolve(from, file));
let command = {
directory: from,
file: path.resolve(from, file),
output: path.resolve(to, ofiles[file] + '.o'),
arguments: args.concat(includes).concat(defines)
};
commands.push(command);
}
}
this.p(JSON.stringify(commands));
this.closeFile();
}
}
exports.CompilerCommandsExporter = CompilerCommandsExporter;
//# sourceMappingURL=CompileCommandsExporter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmscriptenExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const fs = require("kmake/fsextra");
const path = require("path");
const CompileCommandsExporter_1 = require("kmake/Exporters/CompileCommandsExporter");
const MakeExporter_1 = require("kmake/Exporters/MakeExporter");
const NinjaExporter_1 = require("kmake/Exporters/NinjaExporter");
const Icon = require("kmake/Icon");
class EmscriptenExporter extends Exporter_1.Exporter {
constructor(project, options) {
super(options);
this.compileCommands = new CompileCommandsExporter_1.CompilerCommandsExporter(options);
let linkerFlags = '-static-libgcc -static-libstdc++';
if (project.targetOptions.emscripten.threads) {
linkerFlags += ' -pthread';
}
linkerFlags += ' -sTOTAL_MEMORY=134217728 ';
linkerFlags += ' --preload-file ' + this.debugDirName(project);
const emcc = (process.platform === 'win32') ? 'emcc.bat' : 'emcc';
this.make = new MakeExporter_1.MakeExporter(options, emcc, emcc, '', '', linkerFlags, '.html');
this.ninja = new NinjaExporter_1.NinjaExporter(options, emcc, emcc, '', '', linkerFlags, '.html');
}
debugDirName(project) {
let name = project.getDebugDir();
name = name.replace(/\\/g, '/');
if (name.endsWith('/')) {
name = name.substr(0, name.length - 1);
}
if (name.lastIndexOf('/') >= 0) {
name = name.substr(name.lastIndexOf('/') + 1);
}
return name;
}
async exportSolution(project, from, to, platform, vrApi, options) {
let outputPath = path.resolve(to, options.buildPath);
fs.ensureDirSync(outputPath);
fs.copyDirSync(path.resolve(from, this.debugDirName(project)), path.resolve(outputPath, this.debugDirName(project)));
this.make.exportSolution(project, from, to, platform, vrApi, options);
this.ninja.exportSolution(project, from, to, platform, vrApi, options);
this.compileCommands.exportSolution(project, from, to, platform, vrApi, options);
await Icon.exportIco(project.icon, path.resolve(outputPath, 'favicon.ico'), from, true);
}
}
exports.EmscriptenExporter = EmscriptenExporter;
//# sourceMappingURL=EmscriptenExporter.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"EmscriptenExporter.js","sourceRoot":"","sources":["../../../kmake/src/Exporters/EmscriptenExporter.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAIpD,oCAAoC;AACpC,6BAA6B;AAC7B,qFAAmF;AACnF,+DAA4D;AAC5D,iEAA8D;AAC9D,mCAAmC;AAEnC,MAAa,kBAAmB,SAAQ,mBAAQ;IAK/C,YAAY,OAAgB,EAAE,OAAY;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,eAAe,GAAG,IAAI,kDAAwB,CAAC,OAAO,CAAC,CAAC;QAE7D,IAAI,WAAW,GAAG,kCAAkC,CAAC;QACrD,IAAI,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,EAAE;YAC7C,WAAW,IAAI,WAAW,CAAC;SAC3B;QAED,WAAW,IAAI,4BAA4B,CAAC;QAC5C,WAAW,IAAI,kBAAkB,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAE/D,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;QAElE,IAAI,CAAC,IAAI,GAAG,IAAI,2BAAY,CAAC,OAAO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c,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACtE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACvE,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAEjF,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACzF,CAAC;CACD;AA/CD,gDA+CC"}

View File

@ -0,0 +1,71 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Exporter = void 0;
const fs = require("kmake/fsextra");
const path = require("path");
const log = require("kmake/log");
var WriteMode;
(function (WriteMode) {
WriteMode[WriteMode["None"] = 0] = "None";
WriteMode[WriteMode["File"] = 1] = "File";
WriteMode[WriteMode["Stdout"] = 2] = "Stdout";
})(WriteMode || (WriteMode = {}));
class Exporter {
constructor(options) {
this.writeMode = WriteMode.None;
this.outFile = 0;
this.outString = null;
}
writeFile(file) {
this.writeMode = WriteMode.File;
this.outFile = fs.openSync(file, 'w');
this.outString = null;
}
writeStdout() {
this.writeMode = WriteMode.Stdout;
this.outString = '';
this.outFile = 0;
}
closeFile() {
fs.closeSync(this.outFile);
this.outFile = 0;
this.outString = null;
this.writeMode = WriteMode.None;
}
closeStdout() {
this.outString = null;
this.outFile = 0;
this.writeMode = WriteMode.None;
}
p(line = '', indent = 0) {
let tabs = '';
for (let i = 0; i < indent; ++i) {
tabs += '\t';
}
if (this.writeMode === WriteMode.Stdout) {
log.info(tabs + line);
}
else if (this.writeMode === WriteMode.File) {
let data = Buffer.from(tabs + line + '\n');
fs.writeSync(this.outFile, data, 0, data.length, null);
}
else {
throw 'Writing while not actually writing';
}
}
nicePath(from, to, filepath) {
let absolute = filepath;
if (!path.isAbsolute(absolute)) {
absolute = path.resolve(from, filepath);
}
return path.relative(to, absolute);
}
async exportSolution(project, from, to, platform, vrApi, options) {
return new Promise((resolve, reject) => {
reject('Called an abstract function');
});
}
open(project, to) { }
}
exports.Exporter = Exporter;
//# sourceMappingURL=Exporter.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Exporter.js","sourceRoot":"","sources":["../../../kmake/src/Exporters/Exporter.ts"],"names":[],"mappings":";;;AACA,oCAAoC;AACpC,6BAA6B;AAC7B,iCAAiC;AAEjC,IAAK,SAIJ;AAJD,WAAK,SAAS;IACb,yCAAI,CAAA;IACJ,yCAAI,CAAA;IACJ,6CAAM,CAAA;AACP,CAAC,EAJI,SAAS,KAAT,SAAS,QAIb;AAED,MAAsB,QAAQ;IAK7B,YAAY,OAAY;QAJxB,cAAS,GAAc,SAAS,CAAC,IAAI,CAAC;QACtC,YAAO,GAAW,CAAC,CAAC;QACpB,cAAS,GAAW,IAAI,CAAC;IAIzB,CAAC;IAED,SAAS,CAAC,IAAY;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,WAAW;QACV,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IAClB,CAAC;IAED,SAAS;QACR,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,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,EAAE,IAAY,EAAE,EAAU,EAAE,QAAgB,EAAE,KAAU,EAAE,OAAY;QAC1G,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC5C,MAAM,CAAC,6BAA6B,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAgB,EAAE,EAAU,IAAG,CAAC;CACrC;AAnED,4BAmEC"}

View File

@ -0,0 +1,397 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FreeBSDExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const Options_1 = require("kmake/Options");
const Platform_1 = require("kmake/Platform");
const Compiler_1 = require("kmake/Compiler");
const fs = require("kmake/fsextra");
const path = require("path");
const CLionExporter_1 = require("kmake/Exporters/CLionExporter");
class FreeBSDExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
this.clion = new CLionExporter_1.CLionExporter(options);
}
async exportSolution(project, from, to, platform, vrApi, options) {
this.exportMakefile(project, from, to, platform, vrApi, options);
this.exportCodeBlocks(project, from, to, platform, vrApi, options);
this.clion.exportSolution(project, from, to, platform, vrApi, options);
this.exportCompileCommands(project, from, to, platform, vrApi, options);
}
exportMakefile(project, from, to, platform, vrApi, options) {
const cCompiler = Options_1.Options.compiler === Compiler_1.Compiler.GCC ? 'gcc' : 'clang';
const cppCompiler = Options_1.Options.compiler === Compiler_1.Compiler.GCC ? 'g++' : 'clang++';
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')) {
let name = file.toLowerCase();
if (name.indexOf('/') >= 0)
name = name.substr(name.lastIndexOf('/') + 1);
name = name.substr(0, name.lastIndexOf('.'));
if (!objects[name]) {
objects[name] = true;
ofiles[file] = name;
}
else {
while (objects[name]) {
name = name + '_';
}
objects[name] = true;
ofiles[file] = name;
}
}
}
let gchfilelist = '';
let precompiledHeaders = [];
for (let file of project.getFiles()) {
if (file.options && file.options.pch && precompiledHeaders.indexOf(file.options.pch) < 0) {
precompiledHeaders.push(file.options.pch);
}
}
for (let file of project.getFiles()) {
let precompiledHeader = null;
for (let header of precompiledHeaders) {
if (file.file.endsWith(header)) {
precompiledHeader = header;
break;
}
}
if (precompiledHeader !== null) {
// let realfile = path.relative(outputPath, path.resolve(from, file.file));
gchfilelist += path.basename(file.file) + '.gch ';
}
}
let ofilelist = '';
for (let o in objects) {
ofilelist += o + '.o ';
}
this.writeFile(path.resolve(outputPath, 'makefile'));
let incline = '-I./ '; // local directory to pick up the precompiled header hxcpp.h.gch
for (let inc of project.getIncludeDirs()) {
inc = path.relative(outputPath, path.resolve(from, inc));
incline += '-I' + inc + ' ';
}
incline += '-I/usr/local/include'; // Add search dir for FreeBSD
this.p('INC=' + incline);
let libsline = '-static-libgcc -static-libstdc++ -pthread';
/*if (project.cmd) {
libsline += ' -static';
}*/
for (let lib of project.getLibs()) {
libsline += ' -l' + lib;
}
libsline += ' -L/usr/local/lib'; // Add search dir for FreeBSD
this.p('LIB=' + libsline);
let defline = '';
for (const def of project.getDefines()) {
if (def.config && def.config.toLowerCase() === 'debug' && !options.debug) {
continue;
}
if (def.config && def.config.toLowerCase() === 'release' && options.debug) {
continue;
}
defline += '-D' + def.value + ' ';
}
if (!options.debug) {
defline += '-DNDEBUG ';
}
this.p('DEF=' + defline);
this.p();
let cline = '-std=c99 ';
if (project.cStd !== '') {
cline = '-std=' + project.cStd + ' ';
}
if (options.dynlib) {
cline += '-fPIC ';
}
for (let flag of project.cFlags) {
cline += flag + ' ';
}
this.p('CFLAGS=' + cline);
let cppline = '';
if (project.cppStd !== '') {
cppline = '-std=' + project.cppStd + ' ';
}
if (options.dynlib) {
cppline += '-fPIC ';
}
for (let flag of project.cppFlags) {
cppline += flag + ' ';
}
this.p('CPPFLAGS=' + cppline);
let optimization = '';
if (!options.debug)
optimization = '-O2';
else
optimization = '-g';
let executableName = project.getSafeName();
if (project.getExecutableName()) {
executableName = project.getExecutableName();
}
if (options.lib) {
this.p(executableName + '.a: ' + gchfilelist + ofilelist);
}
else if (options.dynlib) {
this.p(executableName + '.so: ' + gchfilelist + ofilelist);
}
else {
this.p(executableName + ': ' + gchfilelist + ofilelist);
}
let cpp = '';
let output = '-o "' + executableName + '"';
if (options.lib) {
output = '-o "' + executableName + '.a"';
}
else if (options.dynlib) {
output = '-shared -o "' + executableName + '.so"';
}
this.p('\t' + (options.lib ? 'ar rcs' : cppCompiler) + ' ' + output + ' ' + cpp + ' ' + optimization + ' ' + ofilelist + ' $(LIB)');
for (let file of project.getFiles()) {
let precompiledHeader = null;
for (let header of precompiledHeaders) {
if (file.file.endsWith(header)) {
precompiledHeader = header;
break;
}
}
if (precompiledHeader !== null) {
let realfile = path.relative(outputPath, path.resolve(from, file.file));
this.p(path.basename(realfile) + '.gch: ' + realfile);
this.p('\t' + cppCompiler + ' ' + cpp + ' ' + optimization + ' $(INC) $(DEF) -c ' + realfile + ' -o ' + path.basename(file.file) + '.gch');
}
}
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 (fileobject.options && fileobject.options.nocompile) {
continue;
}
this.p();
let name = ofiles[file];
let realfile = path.relative(outputPath, path.resolve(from, file));
this.p(name + '.o: ' + realfile);
let compiler = cppCompiler;
let flags = '$(CPPFLAGS)';
if (file.endsWith('.c')) {
compiler = cCompiler;
flags = '$(CFLAGS)';
}
else if (file.endsWith('.s') || file.endsWith('.S')) {
compiler = cCompiler;
flags = '';
}
this.p('\t' + compiler + ' ' + cpp + ' ' + optimization + ' $(INC) $(DEF) ' + flags + ' -c ' + realfile + ' -o ' + name + '.o');
}
}
// project.getDefines()
// project.getIncludeDirs()
this.closeFile();
}
exportCodeBlocks(project, from, to, platform, vrApi, options) {
this.writeFile(path.resolve(to, project.getSafeName() + '.cbp'));
this.p('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>');
this.p('<CodeBlocks_project_file>');
this.p('<FileVersion major="1" minor="6" />', 1);
this.p('<Project>', 1);
this.p('<Option title="' + project.getName() + '" />', 2);
this.p('<Option pch_mode="2" />', 2);
this.p('<Option compiler="gcc" />', 2);
this.p('<Build>', 2);
this.p('<Target title="Debug">', 3);
this.p('<Option output="bin/Debug/' + project.getSafeName() + '" prefix_auto="1" extension_auto="1" />', 4);
if (project.getDebugDir().length > 0)
this.p('<Option working_dir="' + path.resolve(from, project.getDebugDir()) + '" />', 4);
this.p('<Option object_output="obj/Debug/" />', 4);
this.p('<Option type="1" />', 4);
this.p('<Option compiler="gcc" />', 4);
this.p('<Compiler>', 4);
if (project.cppStd !== '') {
this.p('<Add option="-std=' + project.cppStd + '" />', 5);
}
this.p('<Add option="-g" />', 5);
this.p('</Compiler>', 4);
this.p('</Target>', 3);
this.p('<Target title="Release">', 3);
this.p('<Option output="bin/Release/' + project.getSafeName() + '" prefix_auto="1" extension_auto="1" />', 4);
if (project.getDebugDir().length > 0)
this.p('<Option working_dir="' + path.resolve(from, project.getDebugDir()) + '" />', 4);
this.p('<Option object_output="obj/Release/" />', 4);
this.p('<Option type="0" />', 4);
this.p('<Option compiler="gcc" />', 4);
this.p('<Compiler>', 4);
if (project.cppStd !== '') {
this.p('<Add option="-std=' + project.cppStd + '" />', 5);
}
this.p('<Add option="-O2" />', 5);
this.p('</Compiler>', 4);
this.p('<Linker>', 4);
this.p('<Add option="-s" />', 5);
this.p('</Linker>', 4);
this.p('</Target>', 3);
this.p('</Build>', 2);
this.p('<Compiler>', 2);
if (project.cppStd !== '') {
this.p('<Add option="-std=' + project.cppStd + '" />', 5);
}
this.p('<Add option="-Wall" />', 3);
for (const def of project.getDefines()) {
this.p('<Add option="-D' + def.value.replace(/\"/g, '\\"') + '" />', 3);
}
for (let inc of project.getIncludeDirs()) {
this.p('<Add directory="' + path.resolve(from, inc) + '" />', 3);
}
this.p('</Compiler>', 2);
this.p('<Linker>', 2);
this.p('<Add option="-pthread" />', 3);
this.p('<Add option="-static-libgcc" />', 3);
this.p('<Add option="-static-libstdc++" />', 3);
/*if (project.cmd) {
this.p('<Add option="-static" />', 3);
}*/
this.p('<Add option="-Wl,-rpath,." />', 3);
for (let lib of project.getLibs()) {
this.p('<Add library="' + lib + '" />', 3);
}
if (platform === Platform_1.Platform.Pi) {
this.p('<Add directory="/opt/vc/lib" />', 3);
}
this.p('</Linker>', 2);
let precompiledHeaders = [];
for (let file of project.getFiles()) {
if (file.options && file.options.pch && precompiledHeaders.indexOf(file.options.pch) < 0) {
precompiledHeaders.push(file.options.pch);
}
}
for (let file of project.getFiles()) {
let precompiledHeader = null;
for (let header of precompiledHeaders) {
if (file.file.endsWith(header)) {
precompiledHeader = header;
break;
}
}
if (file.file.endsWith('.c') || file.file.endsWith('.cc') || file.file.endsWith('.cpp')) {
this.p('<Unit filename="' + path.resolve(from, file.file) + '">', 2);
this.p('<Option compilerVar="CC" />', 3);
this.p('</Unit>', 2);
}
else if (file.file.endsWith('.h')) {
this.p('<Unit filename="' + path.resolve(from, file.file) + '">', 2);
if (precompiledHeader !== null) {
this.p('<Option compile="1" />', 3);
this.p('<Option weight="0" />', 3);
}
this.p('</Unit>', 2);
}
}
this.p('<Extensions>', 2);
this.p('<code_completion />', 3);
this.p('<debugger />', 3);
this.p('</Extensions>', 2);
this.p('</Project>', 1);
this.p('</CodeBlocks_project_file>');
this.closeFile();
}
exportCompileCommands(project, _from, to, platform, vrApi, options) {
let from = path.resolve(process.cwd(), _from);
// TODO : assembly files, precompiled headers and all that stuff
// compile_commands.json is primarily for code completion so those things shouldn't matter too much
this.writeFile(path.resolve(to, 'compile_commands.json'));
let includes = [];
for (let inc of project.getIncludeDirs()) {
includes.push('-I');
includes.push(path.resolve(from, inc));
}
let defines = [];
for (let def of project.getDefines()) {
defines.push('-D');
defines.push(def.value.replace(/\"/g, '\\"'));
}
let libs = [];
for (let lib of project.getLibs()) {
libs.push('-l' + lib);
}
let optimization = options.debug ? '-g' : '-O2';
let objects = {};
let ofiles = {};
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')) {
let name = file.toLowerCase();
if (name.indexOf('/') >= 0)
name = name.substr(name.lastIndexOf('/') + 1);
name = name.substr(0, name.lastIndexOf('.'));
if (!objects[name]) {
objects[name] = true;
ofiles[file] = name;
}
else {
while (objects[name]) {
name = name + '_';
}
objects[name] = true;
ofiles[file] = name;
}
}
}
let commands = [];
for (let fileobject of project.getFiles()) {
let file = fileobject.file;
if (file.endsWith('.c') || file.endsWith('.cpp') || file.endsWith('.cc')) {
let args = [file.endsWith('.c') ? '/usr/bin/clang' : '/usr/bin/clang++', optimization, '-c', '-o', (options.debug ? 'debug' : 'release') + ofiles[file] + '.o'];
if (file.endsWith('.c')) {
args.push('-std=' + (project.cStd !== '' ? project.cStd : 'c99'));
}
else if (file.endsWith('.cpp')) {
args.push('-std=' + (project.cppStd !== '' ? project.cppStd : 'c++11'));
}
if (options.dynlib) {
args.push('-fPIC');
}
args.push(path.resolve(from, file));
let command = {
directory: from,
file: path.resolve(from, file),
output: path.resolve(to, ofiles[file] + '.o'),
arguments: args.concat(includes).concat(defines)
};
commands.push(command);
}
}
/*let linker_args = ['/usr/bin/clang', '-O2', '-static-libgcc', '-static-libstdc++', '-pthread'];
for (let file in ofiles) {
linker_args.push(path.resolve(to, ofiles[file] + '.o'));
}
linker_args.push('-o');
if (options.lib) {
linker_args.push('-o');
linker_args.push(project.getSafeName() + '.a');
}
else if (options.dynlib) {
linker_args.push('-shared');
linker_args.push('-fPIC');
linker_args.push('-o');
linker_args.push(project.getSafeName() + '.so');
}
else {
linker_args.push('-o');
linker_args.push(project.getSafeName());
}
commands.push({
directory: from,
output: linker_args[linker_args.length - 1],
arguments: linker_args.concat(libs)
});*/
this.p(JSON.stringify(commands));
this.closeFile();
}
}
exports.FreeBSDExporter = FreeBSDExporter;
//# sourceMappingURL=FreeBSDExporter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const path = require("path");
class JsonExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
}
async exportSolution(project, from, to, platform, vrApi, options) {
if (options.stdout) {
this.writeStdout();
}
else {
this.writeFile(path.resolve(to, project.getSafeName() + '.json'));
}
this.p('{');
this.p('"includes":', 1);
this.p('[', 1);
for (let i = 0; i < project.getIncludeDirs().length; ++i) {
const inc = path.relative(from, project.getIncludeDirs()[i]);
if (i === project.getIncludeDirs().length - 1) {
this.p('"' + inc.replace(/\\/g, '\\\\') + '"', 2);
}
else {
this.p('"' + inc.replace(/\\/g, '\\\\') + '",', 2);
}
}
this.p('],', 1);
this.p('"libraries":', 1);
this.p('[', 1);
for (let i = 0; i < project.getLibs().length; ++i) {
const lib = project.getLibs()[i];
if (i === project.getLibs().length - 1) {
this.p('"' + lib + '"', 2);
}
else {
this.p('"' + lib + '",', 2);
}
}
this.p('],', 1);
this.p('"defines":', 1);
this.p('[', 1);
for (let i = 0; i < project.getDefines().length; ++i) {
const def = project.getDefines()[i];
if (i === project.getDefines().length - 1) {
this.p('"' + def.value + '"', 2);
}
else {
this.p('"' + def.value + '",', 2);
}
}
this.p('],', 1);
this.p('"files":', 1);
this.p('[', 1);
for (let i = 0; i < project.getFiles().length; ++i) {
const file = project.getFiles()[i].file;
const realfile = path.relative(from, file);
if (i === project.getFiles().length - 1) {
this.p('"' + realfile.replace(/\\/g, '\\\\') + '"', 2);
}
else {
this.p('"' + realfile.replace(/\\/g, '\\\\') + '",', 2);
}
}
this.p('],', 1);
this.p('"kongDirs":', 1);
this.p('[', 1);
for (let i = 0; i < project.getKongDirs().length; ++i) {
const kongDir = project.getKongDirs()[i];
if (i === project.getKongDirs().length - 1) {
this.p('"' + kongDir + '"', 2);
}
else {
this.p('"' + kongDir + '",', 2);
}
}
this.p('],', 1);
this.p('"name": "' + project.getName() + '",', 1);
this.p('"cStd": "' + project.getCStd() + '",', 1);
this.p('"cFlags":', 1);
this.p('[', 1);
for (let i = 0; i < project.cFlags.length; ++i) {
const cFlag = project.cFlags[i];
if (i === project.cFlags.length - 1) {
this.p('"' + cFlag + '"', 2);
}
else {
this.p('"' + cFlag + '",', 2);
}
}
this.p('],', 1);
this.p('"cppStd": "' + project.getCppStd() + '",', 1);
this.p('"cppFlags":', 1);
this.p('[', 1);
for (let i = 0; i < project.cppFlags.length; ++i) {
const cppFlag = project.cppFlags[i];
if (i === project.cppFlags.length - 1) {
this.p('"' + cppFlag + '"', 2);
}
else {
this.p('"' + cppFlag + '",', 2);
}
}
this.p('],', 1);
this.p('"debugDir": "' + project.getDebugDir().replace(/\\/g, '\\\\') + '"', 1);
this.p('}');
if (options.stdout) {
this.closeStdout();
}
else {
this.closeFile();
}
}
}
exports.JsonExporter = JsonExporter;
//# sourceMappingURL=JsonExporter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KompjutaExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
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");
const fs = require("kmake/fsextra");
const path = require("path");
class KompjutaExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
const cFlags = '--target=riscv64-unknown-elf -march=rv64imfdv_zvl1024b -mabi=lp64d -Os -ffreestanding -fno-builtin -ffunction-sections -fdata-sections -nostdlib -mno-relax';
const linkerFlags = '--target=riscv64-unknown-elf -march=rv64imfdv_zvl1024b -mabi=lp64d -Os -ffreestanding -fno-builtin -ffunction-sections -fdata-sections -nostdlib -mno-relax -fuse-ld=lld "-Wl,--no-relax,--gc-sections,-Map,link.map,-T,kompjuta.ld"';
const outputExtension = '.elf';
this.ninja = new NinjaExporter_1.NinjaExporter(options, 'clang', 'clang++', cFlags, cFlags, linkerFlags, outputExtension);
this.make = new MakeExporter_1.MakeExporter(options, 'clang', 'clang++', cFlags, cFlags, linkerFlags, outputExtension);
this.clion = new CLionExporter_1.CLionExporter(options);
this.compileCommands = new CompileCommandsExporter_1.CompilerCommandsExporter(options);
}
async exportSolution(project, from, to, platform, vrApi, options) {
const textData = require('fs').getEmbeddedData();
let outputPath = path.resolve(to, options.buildPath);
fs.ensureDirSync(outputPath);
fs.writeFileSync(path.join(outputPath, 'kompjuta.ld'), textData['kompjuta_kompjuta_ld']);
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);
}
}
exports.KompjutaExporter = KompjutaExporter;
//# sourceMappingURL=KompjutaExporter.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"KompjutaExporter.js","sourceRoot":"","sources":["../../../kmake/src/Exporters/KompjutaExporter.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAEpD,iEAA8D;AAC9D,+DAA4D;AAC5D,iEAA8D;AAC9D,qFAAmF;AACnF,oCAAoC;AACpC,6BAA6B;AAE7B,MAAa,gBAAiB,SAAQ,mBAAQ;IAM7C,YAAY,OAAY;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,MAAM,MAAM,GAAG,6JAA6J,CAAC;QAC7K,MAAM,WAAW,GAAG,sOAAsO,CAAC;QAE3P,MAAM,eAAe,GAAG,MAAM,CAAC;QAE/B,IAAI,CAAC,KAAK,GAAG,IAAI,6BAAa,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAA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,KAAK,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;CACD;AA/BD,4CA+BC"}

View File

@ -0,0 +1,220 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinuxExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const Options_1 = require("kmake/Options");
const Platform_1 = require("kmake/Platform");
const Compiler_1 = require("kmake/Compiler");
const fs = require("kmake/fsextra");
const path = require("path");
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 LinuxExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
let linkerFlags = '-static-libgcc -static-libstdc++ -pthread';
if (Options_1.Options.compiler === Compiler_1.Compiler.MuslGcc || this.getOS().includes('Alpine')) {
linkerFlags += ' -static';
}
let outputExtension = '';
if (options.lib) {
outputExtension = '.a';
}
else if (options.dynlib) {
outputExtension = '.so';
}
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);
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.exportCodeBlocks(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.GCC:
return 'gcc';
case Compiler_1.Compiler.Clang:
return 'clang';
case Compiler_1.Compiler.MuslGcc:
return 'musl-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.GCC:
return 'g++';
case Compiler_1.Compiler.Clang:
return 'clang++';
case Compiler_1.Compiler.MuslGcc:
return 'g++';
case Compiler_1.Compiler.Custom:
return Options_1.Options.cxxPath;
default:
throw 'Unsupported compiler ' + Options_1.Options.compiler;
}
}
getOS() {
try {
const data = fs.readFileSync('/etc/os-release', 'utf8');
const lines = data.split('\n');
let name = null;
for (const line of lines) {
if (line.trim().startsWith('NAME')) {
name = line.split('=')[1];
name = name.substring(1, name.length - 1);
break;
}
}
if (name) {
return name;
}
else {
return 'Unknown';
}
}
catch (error) {
return 'Unknown';
}
}
exportCodeBlocks(project, from, to, platform, vrApi, options) {
this.writeFile(path.resolve(to, project.getSafeName() + '.cbp'));
this.p('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>');
this.p('<CodeBlocks_project_file>');
this.p('<FileVersion major="1" minor="6" />', 1);
this.p('<Project>', 1);
this.p('<Option title="' + project.getName() + '" />', 2);
this.p('<Option pch_mode="2" />', 2);
this.p('<Option compiler="gcc" />', 2);
this.p('<Build>', 2);
this.p('<Target title="Debug">', 3);
let executableName = project.getSafeName();
if (project.getExecutableName()) {
executableName = project.getExecutableName();
}
this.p('<Option output="bin/Debug/' + executableName + '" prefix_auto="1" extension_auto="1" />', 4);
if (project.getDebugDir().length > 0)
this.p('<Option working_dir="' + path.resolve(from, project.getDebugDir()) + '" />', 4);
this.p('<Option object_output="obj/Debug/" />', 4);
this.p('<Option type="1" />', 4);
this.p('<Option compiler="gcc" />', 4);
this.p('<Compiler>', 4);
if (project.cppStd !== '') {
this.p('<Add option="-std=' + project.cppStd + '" />', 5);
}
this.p('<Add option="-g" />', 5);
for (const def of project.getDefines()) {
if (def.config && def.config.toLowerCase() !== 'debug') {
continue;
}
this.p('<Add option="-D' + def.value.replace(/\"/g, '\\"') + '" />', 3);
}
this.p('</Compiler>', 4);
this.p('</Target>', 3);
this.p('<Target title="Release">', 3);
this.p('<Option output="bin/Release/' + executableName + '" prefix_auto="1" extension_auto="1" />', 4);
if (project.getDebugDir().length > 0)
this.p('<Option working_dir="' + path.resolve(from, project.getDebugDir()) + '" />', 4);
this.p('<Option object_output="obj/Release/" />', 4);
this.p('<Option type="0" />', 4);
this.p('<Option compiler="gcc" />', 4);
this.p('<Compiler>', 4);
if (project.cppStd !== '') {
this.p('<Add option="-std=' + project.cppStd + '" />', 5);
}
this.p('<Add option="-O2" />', 5);
for (const def of project.getDefines()) {
if (def.config && def.config.toLowerCase() !== 'release') {
continue;
}
this.p('<Add option="-D' + def.value.replace(/\"/g, '\\"') + '" />', 3);
}
this.p('<Add option="-DNDEBUG" />', 3);
this.p('</Compiler>', 4);
this.p('<Linker>', 4);
this.p('<Add option="-s" />', 5);
this.p('</Linker>', 4);
this.p('</Target>', 3);
this.p('</Build>', 2);
this.p('<Compiler>', 2);
if (project.cppStd !== '') {
this.p('<Add option="-std=' + project.cppStd + '" />', 5);
}
this.p('<Add option="-Wall" />', 3);
for (let inc of project.getIncludeDirs()) {
this.p('<Add directory="' + path.resolve(from, inc) + '" />', 3);
}
this.p('</Compiler>', 2);
this.p('<Linker>', 2);
this.p('<Add option="-pthread" />', 3);
this.p('<Add option="-static-libgcc" />', 3);
this.p('<Add option="-static-libstdc++" />', 3);
/*if (project.cmd) {
this.p('<Add option="-static" />', 3);
}*/
this.p('<Add option="-Wl,-rpath,." />', 3);
const flags = [].concat(project.cFlags, project.cppFlags);
for (const flag of flags) {
this.p('<Add option="' + flag.replace(/\"/g, '\\"') + '" />', 3);
}
for (let lib of project.getLibs()) {
this.p('<Add library="' + lib + '" />', 3);
}
if (platform === Platform_1.Platform.Pi) {
this.p('<Add directory="/opt/vc/lib" />', 3);
}
this.p('</Linker>', 2);
let precompiledHeaders = [];
for (let file of project.getFiles()) {
if (file.options && file.options.pch && precompiledHeaders.indexOf(file.options.pch) < 0) {
precompiledHeaders.push(file.options.pch);
}
}
for (let file of project.getFiles()) {
let precompiledHeader = null;
for (let header of precompiledHeaders) {
if (file.file.endsWith(header)) {
precompiledHeader = header;
break;
}
}
if (file.file.endsWith('.c') || file.file.endsWith('.cc') || file.file.endsWith('.cpp')) {
this.p('<Unit filename="' + path.resolve(from, file.file) + '">', 2);
if (!file.options || !file.options.nocompile) {
this.p('<Option compilerVar="CC" />', 3);
}
this.p('</Unit>', 2);
}
else if (file.file.endsWith('.h')) {
this.p('<Unit filename="' + path.resolve(from, file.file) + '">', 2);
if (precompiledHeader !== null) {
this.p('<Option compile="1" />', 3);
this.p('<Option weight="0" />', 3);
}
this.p('</Unit>', 2);
}
}
this.p('<Extensions>', 2);
this.p('<code_completion />', 3);
this.p('<debugger />', 3);
this.p('</Extensions>', 2);
this.p('</Project>', 1);
this.p('</CodeBlocks_project_file>');
this.closeFile();
}
}
exports.LinuxExporter = LinuxExporter;
//# sourceMappingURL=LinuxExporter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,195 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MakeExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const fs = require("kmake/fsextra");
const path = require("path");
class MakeExporter extends Exporter_1.Exporter {
constructor(options, cCompiler, cppCompiler, cFlags, cppFlags, linkerFlags, outputExtension, libsLine = null) {
super(options);
this.cCompiler = cCompiler;
this.cppCompiler = cppCompiler;
this.cFlags = cFlags;
this.cppFlags = cppFlags;
this.linkerFlags = linkerFlags;
this.outputExtension = outputExtension;
if (libsLine != null) {
this.libsLine = libsLine;
}
}
libsLine(project) {
let libs = '';
for (let lib of project.getLibs()) {
libs += ' -l' + lib;
}
return libs;
}
async exportSolution(project, from, to, platform, vrApi, options) {
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 (fileobject.options && fileobject.options.nocompile) {
continue;
}
let name = file.toLowerCase();
if (name.indexOf('/') >= 0)
name = name.substr(name.lastIndexOf('/') + 1);
name = name.substr(0, name.lastIndexOf('.'));
if (!objects[name]) {
objects[name] = true;
ofiles[file] = name;
}
else {
while (objects[name]) {
name = name + '_';
}
objects[name] = true;
ofiles[file] = name;
}
}
}
let gchfilelist = '';
let precompiledHeaders = [];
for (let file of project.getFiles()) {
if (file.options && file.options.pch && precompiledHeaders.indexOf(file.options.pch) < 0) {
precompiledHeaders.push(file.options.pch);
}
}
for (let file of project.getFiles()) {
let precompiledHeader = null;
for (let header of precompiledHeaders) {
if (file.file.endsWith(header)) {
precompiledHeader = header;
break;
}
}
if (precompiledHeader !== null) {
// let realfile = path.relative(outputPath, path.resolve(from, file.file));
gchfilelist += path.basename(file.file) + '.gch ';
}
}
let ofilelist = '';
for (let o in objects) {
ofilelist += o + '.o ';
}
this.writeFile(path.resolve(outputPath, 'makefile'));
let incline = '-I./ '; // local directory to pick up the precompiled headers
for (let inc of project.getIncludeDirs()) {
inc = path.relative(outputPath, path.resolve(from, inc));
incline += '-I' + inc + ' ';
}
this.p('INC=' + incline);
let linkerline = this.linkerFlags;
linkerline += this.libsLine(project);
linkerline += ' ';
for (let flag of project.linkerFlags) {
linkerline += flag + ' ';
}
this.p('LIB=' + linkerline);
let defline = '';
for (const def of project.getDefines()) {
if (def.config && def.config.toLowerCase() === 'debug' && !options.debug) {
continue;
}
if (def.config && def.config.toLowerCase() === 'release' && options.debug) {
continue;
}
defline += '-D' + def.value.replace(/\"/g, '\\"') + ' ';
}
if (!options.debug) {
defline += '-DNDEBUG ';
}
this.p('DEF=' + defline);
this.p();
let cline = this.cFlags;
if (project.cStd !== '') {
cline = '-std=' + project.cStd + ' ';
}
if (options.dynlib) {
cline += '-fPIC ';
}
for (let flag of project.cFlags) {
cline += flag + ' ';
}
this.p('CFLAGS=' + cline);
let cppline = this.cppFlags;
if (project.cppStd !== '') {
cppline = '-std=' + project.cppStd + ' ';
}
if (options.dynlib) {
cppline += '-fPIC ';
}
for (let flag of project.cppFlags) {
cppline += flag + ' ';
}
this.p('CPPFLAGS=' + cppline);
let optimization = '';
if (!options.debug) {
optimization = '-O2';
}
else
optimization = '-g';
let executableName = project.getSafeName();
if (project.getExecutableName()) {
executableName = project.getExecutableName();
}
let outputname = this.outputExtension === '.html' ? 'index.html' : executableName + this.outputExtension;
this.p(outputname + ': ' + gchfilelist + ofilelist);
let output = '-o "' + outputname + '"';
if (options.dynlib) {
output = '-shared -o "' + executableName + '.so"';
}
if (options.lib) {
this.p('\t' + 'ar rcs ' + output + ' ' + ofilelist);
}
else {
this.p('\t' + this.cppCompiler + ' ' + output + ' ' + optimization + ' ' + ofilelist + ' $(LIB)');
}
for (let file of project.getFiles()) {
let precompiledHeader = null;
for (let header of precompiledHeaders) {
if (file.file.endsWith(header)) {
precompiledHeader = header;
break;
}
}
if (precompiledHeader !== null) {
let realfile = path.relative(outputPath, path.resolve(from, file.file));
this.p('-include ' + path.basename(file.file) + '.d');
this.p(path.basename(realfile) + '.gch: ' + realfile);
this.p('\t' + this.cppCompiler + ' ' + optimization + ' $(INC) $(DEF) -MD -c ' + realfile + ' -o ' + path.basename(file.file) + '.gch');
}
}
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 (fileobject.options && fileobject.options.nocompile) {
continue;
}
this.p();
let name = ofiles[file];
let realfile = path.relative(outputPath, path.resolve(from, file));
this.p('-include ' + name + '.d');
this.p(name + '.o: ' + realfile);
let compiler = this.cppCompiler;
let flags = '$(CPPFLAGS)';
if (file.endsWith('.c')) {
compiler = this.cCompiler;
flags = '$(CFLAGS)';
}
else if (file.endsWith('.s') || file.endsWith('.S')) {
compiler = this.cCompiler;
flags = '';
}
this.p('\t' + compiler + ' ' + optimization + ' $(INC) $(DEF) -MD ' + flags + ' -c ' + realfile + ' -o ' + name + '.o');
}
}
this.closeFile();
}
}
exports.MakeExporter = MakeExporter;
//# sourceMappingURL=MakeExporter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,311 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MesonExporter = void 0;
const Platform_1 = require("kmake/Platform");
const path = require("path");
const Exporter_1 = require("kmake/Exporters/Exporter");
class MesonExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
}
async exportSolution(project, from, to, platform, vrApi, options) {
let name = project.getSafeName();
this.writeFile(path.resolve(to, 'meson.build'));
let includeDirs = [...project.getIncludeDirs()];
let systemOs = '';
if (platform === Platform_1.Platform.Windows || platform === Platform_1.Platform.WindowsApp) {
systemOs = 'windows';
}
else if (platform === Platform_1.Platform.OSX) {
systemOs = 'macos';
}
else if (platform === Platform_1.Platform.iOS) {
systemOs = 'ios';
}
else if (platform === Platform_1.Platform.tvOS) {
systemOs = 'tvos';
}
else if (platform === Platform_1.Platform.Linux) {
systemOs = 'linux';
}
else if (platform === Platform_1.Platform.Android) {
systemOs = 'android';
}
if (includeDirs.length > 0) {
this.p('kore_inc_dirs = include_directories(');
for (let i = 0; i < includeDirs.length; i++) {
const inc = this.nicePath(from, to, includeDirs[i]);
const comma = i === includeDirs.length - 1 ? '' : ',';
this.p(' \'' + inc.replace(/\\/g, '/') + '\'' + comma, 1);
}
this.p(')');
this.p();
}
let defineArgs = [];
if (project.getDefines().length > 0) {
for (const def of project.getDefines()) {
if (def.config && def.config.toLowerCase() === 'debug' && !options.debug) {
continue;
}
if (def.config && def.config.toLowerCase() === 'release' && options.debug) {
continue;
}
defineArgs.push('-D' + def.value);
}
}
if (!options.debug) {
defineArgs.push('-DNDEBUG');
}
if (project.cFlags.length > 0 || defineArgs.length > 0) {
this.p('kore_c_args = [');
for (const flag of project.cFlags) {
this.p(' \'' + flag + '\',', 1);
}
for (const def of defineArgs) {
this.p(' \'' + def + '\',', 1);
}
this.p(']');
this.p();
}
if (project.cppFlags.length > 0 || defineArgs.length > 0) {
this.p('kore_cpp_args = [');
for (const flag of project.cppFlags) {
this.p(' \'' + flag + '\',', 1);
}
for (const def of defineArgs) {
this.p(' \'' + def + '\',', 1);
}
this.p(']');
this.p();
}
let sourceFiles = project.getFiles().filter(file => {
if (file.options && file.options.nocompile) {
return false;
}
for (let exclude of project.excludes) {
if (project.matches(file.file, exclude)) {
console.log(`Excluding file ${file.file} due to exclude pattern: ${exclude}`);
return false;
}
}
const ext = path.extname(file.file).toLowerCase();
let validExtensions = ['.c', '.cpp', '.cc', '.cxx'];
if (platform === Platform_1.Platform.iOS || platform === Platform_1.Platform.OSX || platform === Platform_1.Platform.tvOS) {
validExtensions.push('.m', '.mm');
}
return validExtensions.includes(ext);
});
let metalFiles = project.getFiles().filter(file => {
if (file.options && file.options.nocompile) {
return false;
}
const ext = path.extname(file.file).toLowerCase();
return ext === '.metal';
});
let headerFiles = project.getFiles().filter(file => {
const ext = path.extname(file.file).toLowerCase();
return ['.h', '.hpp', '.hxx'].includes(ext);
});
if (sourceFiles.length > 0) {
this.p('sources = [');
for (const fileObj of sourceFiles) {
const relativePath = this.nicePath(from, to, fileObj.file);
this.p(' \'' + relativePath.replace(/\\/g, '/') + '\',', 1);
}
this.p(']');
this.p();
}
let allFiles = [];
if (sourceFiles.length > 0) {
allFiles.push('sources');
}
if (allFiles.length > 0) {
this.p('target_files = ' + allFiles.join(' + '));
this.p();
}
if (platform === Platform_1.Platform.iOS || platform === Platform_1.Platform.OSX || platform === Platform_1.Platform.tvOS) {
this.p('add_languages(\'objc\', native: false)');
this.p();
if (defineArgs.length > 0) {
this.p('kore_objc_args = [');
this.p(' \'-fobjc-arc\',', 1);
this.p(']');
this.p();
}
}
if (project.getLibs().length > 0) {
this.p('dependencies = [');
for (const lib of project.getLibs()) {
this.p(' dependency(\'' + lib + '\'),', 1);
}
this.p(']');
this.p();
}
if (project.subProjects.length > 0) {
this.p('subproject_targets = [');
for (const subproject of project.subProjects) {
this.p(' \'' + subproject + '\',', 1);
}
this.p(']');
this.p();
}
if ((platform === Platform_1.Platform.iOS || platform === Platform_1.Platform.OSX || platform === Platform_1.Platform.tvOS) && metalFiles.length > 0) {
this.p('metal_compiler = find_program(\'xcrun\')');
this.p();
for (let i = 0; i < metalFiles.length; i++) {
const metalFile = metalFiles[i];
const relativePath = this.nicePath(from, to, metalFile.file);
const baseName = path.basename(metalFile.file, '.metal');
this.p(baseName + '_air = custom_target(\'' + baseName + '_air\',');
this.p(' output: \'' + baseName + '.air\',', 1);
this.p(' input: \'' + relativePath.replace(/\\/g, '/') + '\',', 1);
this.p(' command: [metal_compiler, \'-sdk\', \'macosx\', \'metal\', \'-c\', \'@INPUT@\', \'-o\', \'@OUTPUT@\'],', 1);
this.p(' build_by_default: true', 1);
this.p(')');
this.p();
this.p(baseName + '_metallib = custom_target(\'' + baseName + '_metallib\',');
this.p(' output: \'' + baseName + '.metallib\',', 1);
this.p(' input: ' + baseName + '_air,', 1);
this.p(' command: [metal_compiler, \'-sdk\', \'macosx\', \'metallib\', \'@INPUT@\', \'-o\', \'@OUTPUT@\'],', 1);
this.p(' build_by_default: true', 1);
this.p(')');
this.p();
}
}
let executableName = project.getSafeName();
if (project.getExecutableName()) {
executableName = project.getExecutableName();
}
let targetArgs = [];
if (allFiles.length > 0) {
targetArgs.push('target_files');
}
if (includeDirs.length > 0) {
targetArgs.push('include_directories : kore_inc_dirs');
}
if (project.cFlags.length > 0 || defineArgs.length > 0) {
targetArgs.push('c_args : kore_c_args');
}
if (project.cppFlags.length > 0 || defineArgs.length > 0) {
targetArgs.push('cpp_args : kore_cpp_args');
}
if ((platform === Platform_1.Platform.iOS || platform === Platform_1.Platform.OSX || platform === Platform_1.Platform.tvOS) && defineArgs.length > 0) {
targetArgs.push('objc_args : [kore_objc_args] + kore_c_args');
}
if (project.getLibs().length > 0) {
targetArgs.push('dependencies : dependencies');
}
if (project.subProjects.length > 0) {
targetArgs.push('link_with : subproject_targets');
}
targetArgs.push('install : false');
if (project.linkerFlags.length > 0) {
this.p('link_args = [');
for (const flag of project.linkerFlags) {
this.p(' \'' + flag + '\',', 1);
}
this.p(']');
this.p();
targetArgs.push('link_args : kore_link_args');
}
if (options.lib) {
this.p(executableName + ' = library(\'' + executableName + '\',');
}
else if (options.dynlib) {
this.p(executableName + ' = shared_library(\'' + executableName + '\',');
}
else {
this.p('executable(\'' + executableName + '\',');
}
for (let i = 0; i < targetArgs.length; i++) {
const comma = i === targetArgs.length - 1 ? '' : ',';
this.p(' ' + targetArgs[i] + comma, 1);
}
this.p(')');
this.closeFile();
}
mapCStandard(std) {
switch (std) {
case 'c90':
case 'c89':
case 'iso9899:1990':
return 'c89';
case 'gnu90':
case 'gnu89':
return 'gnu89';
case 'c99':
case 'c9x':
case 'iso9899:1999':
return 'c99';
case 'gnu99':
case 'gnu9x':
return 'gnu99';
case 'c11':
case 'c1x':
case 'iso9899:2011':
return 'c11';
case 'gnu11':
case 'gnu1x':
return 'gnu11';
case 'c17':
case 'c18':
case 'iso9899:2017':
case 'iso9899:2018':
return 'c17';
case 'gnu17':
case 'gnu18':
return 'gnu17';
case 'c2x':
case 'c23':
return 'c2x';
case 'gnu2x':
case 'gnu23':
return 'gnu2x';
default:
return 'c99';
}
}
mapCppStandard(std) {
switch (std) {
case 'c++03':
case 'c++98':
case 'gnu++03':
case 'gnu++98':
return 'c++03';
case 'c++11':
case 'c++0x':
case 'gnu++11':
case 'gnu++0x':
return 'c++11';
case 'c++14':
case 'c++1y':
case 'gnu++14':
case 'gnu++1y':
return 'c++14';
case 'c++17':
case 'c++1z':
case 'gnu++17':
case 'gnu++1z':
return 'c++17';
case 'c++20':
case 'c++2a':
case 'gnu++20':
case 'gnu++2a':
return 'c++20';
case 'c++23':
case 'c++2b':
case 'gnu++23':
case 'gnu++2b':
return 'c++23';
case 'c++26':
case 'c++2c':
case 'gnu++26':
case 'gnu++2c':
return 'c++26';
default:
return 'c++17';
}
}
}
exports.MesonExporter = MesonExporter;
//# sourceMappingURL=MesonExporter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,158 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NinjaExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const fs = require("kmake/fsextra");
const path = require("path");
class NinjaExporter extends Exporter_1.Exporter {
constructor(options, cCompiler, cppCompiler, cFlags, cppFlags, linkerFlags, outputExtension, libsLine = null) {
super(options);
this.cCompiler = cCompiler;
this.cppCompiler = cppCompiler;
this.cFlags = cFlags;
this.cppFlags = cppFlags;
this.linkerFlags = linkerFlags;
this.outputExtension = outputExtension;
if (libsLine != null) {
this.libsLine = libsLine;
}
}
libsLine(project) {
let libs = '';
for (let lib of project.getLibs()) {
libs += ' -l' + lib;
}
return libs;
}
async exportSolution(project, from, to, platform, vrApi, options) {
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 (fileobject.options && fileobject.options.nocompile) {
continue;
}
let name = file.toLowerCase();
if (name.indexOf('/') >= 0)
name = name.substr(name.lastIndexOf('/') + 1);
name = name.substr(0, name.lastIndexOf('.'));
if (!objects[name]) {
objects[name] = true;
ofiles[file] = name;
}
else {
while (objects[name]) {
name = name + '_';
}
objects[name] = true;
ofiles[file] = name;
}
}
}
let ofilelist = '';
for (let o in objects) {
ofilelist += o + '.o ';
}
this.writeFile(path.resolve(outputPath, 'build.ninja'));
this.p('pool link_pool\n depth = 1\n');
let incline = '';
for (let inc of project.getIncludeDirs()) {
inc = path.relative(outputPath, path.resolve(from, inc));
incline += '-I' + inc + ' ';
}
let linkerline = this.linkerFlags;
linkerline += this.libsLine(project);
linkerline += ' ';
for (let flag of project.linkerFlags) {
linkerline += flag + ' ';
}
let defline = '';
for (const def of project.getDefines()) {
if (def.config && def.config.toLowerCase() === 'debug' && !options.debug) {
continue;
}
if (def.config && def.config.toLowerCase() === 'release' && options.debug) {
continue;
}
defline += '-D' + def.value.replace(/\"/g, '\\"') + ' ';
}
if (!options.debug) {
defline += '-DNDEBUG ';
}
let optimization = '';
if (!options.debug) {
optimization = '-O2';
}
else
optimization = '-g';
let cline = this.cCompiler + ' ' + this.cFlags + ' ';
if (project.cStd !== '') {
cline += '-std=' + project.cStd + ' ';
}
if (options.dynlib) {
cline += '-fPIC ';
}
for (let flag of project.cFlags) {
cline += flag + ' ';
}
cline += optimization + ' ';
cline += incline;
cline += defline;
this.p('rule cc\n deps = gcc\n depfile = $out.d\n command = ' + cline + '-MD -MF $out.d -c $in -o $out\n');
let cppline = this.cppCompiler + ' ' + this.cppFlags + ' ';
if (project.cppStd !== '') {
cppline += '-std=' + project.cppStd + ' ';
}
if (options.dynlib) {
cppline += '-fPIC ';
}
for (let flag of project.cppFlags) {
cppline += flag + ' ';
}
cppline += optimization + ' ';
cppline += incline;
cppline += defline;
this.p('rule cxx\n deps = gcc\n depfile = $out.d\n command = ' + cppline + '-MD -MF $out.d -c $in -o $out\n');
if (options.dynlib) {
this.p('rule link\n pool = link_pool\n command = ' + this.cppCompiler + ' -fPIC -shared -o $out ' + optimization + ' $in ' + linkerline);
}
else if (options.lib) {
this.p('rule link\n pool = link_pool\n command = ar rcs -o $out $in');
}
else {
this.p('rule link\n pool = link_pool\n command = ' + this.cppCompiler + ' -o $out ' + optimization + ' $in ' + linkerline);
}
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 (fileobject.options && fileobject.options.nocompile) {
continue;
}
this.p();
let name = ofiles[file];
let realfile = path.relative(outputPath, path.resolve(from, file));
let compiler = 'cxx';
if (file.endsWith('.c')) {
compiler = 'cc';
}
else if (file.endsWith('.s') || file.endsWith('.S')) {
compiler = 'asm';
}
this.p('build ' + name + '.o: ' + compiler + ' ' + realfile);
}
}
this.p();
let executableName = project.getSafeName();
if (project.getExecutableName()) {
executableName = project.getExecutableName();
}
let outputname = this.outputExtension === '.html' ? 'index.html' : executableName + this.outputExtension;
this.p('build ' + outputname + ': link ' + ofilelist);
this.closeFile();
}
}
exports.NinjaExporter = NinjaExporter;
//# sourceMappingURL=NinjaExporter.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,151 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VSCodeExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const Platform_1 = require("kmake/Platform");
const fs = require("kmake/fsextra");
const path = require("path");
const CompileCommandsExporter_1 = require("kmake/Exporters/CompileCommandsExporter");
class VSCodeExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
this.compileCommands = new CompileCommandsExporter_1.CompilerCommandsExporter(options);
}
configName(platform) {
if (platform === Platform_1.Platform.Windows) {
return 'Win32';
}
else if (platform === Platform_1.Platform.Linux) {
return 'Linux';
}
else if (platform === Platform_1.Platform.OSX) {
return 'Mac';
}
else {
return 'unknown platform';
}
}
compilerPath(platform) {
if (platform === Platform_1.Platform.Windows) {
return 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe';
}
else if (platform === Platform_1.Platform.Linux) {
return '/usr/bin/gcc';
}
else if (platform === Platform_1.Platform.OSX) {
return '/usr/bin/clang';
}
else {
return 'unknown platform';
}
}
async exportSolution(project, from, to, platform, vrApi, options) {
fs.ensureDirSync(path.join(from, '.vscode'));
this.writeFile(path.join(from, '.vscode', 'c_cpp_properties.json'));
const defines = [];
for (const define of project.getDefines()) {
defines.push(define.value);
}
const includes = [];
for (const include of project.getIncludeDirs()) {
if (path.isAbsolute(include)) {
includes.push(include);
}
else {
includes.push('${workspaceFolder}/' + include);
}
}
const config = {
name: this.configName(platform),
includePath: includes,
defines: defines,
compilerPath: this.compilerPath(platform),
cStandard: project.cStd,
cppStandard: project.cppStd,
intelliSenseMode: '${default}'
};
if (platform === Platform_1.Platform.Windows) {
config.windowsSdkVersion = '10.0.19041.0';
}
if (platform === Platform_1.Platform.OSX) {
config.macFrameworkPath = ['/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks'];
}
const data = {
configurations: [
config
]
};
this.p(JSON.stringify(data, null, '\t'));
this.closeFile();
this.writeLaunchJson(project, from, to, platform, vrApi, options);
}
writeLaunchJson(project, from, to, platform, vrApi, options) {
const launchJsonPath = path.join(from, '.vscode', 'launch.json');
let data = {
configurations: [],
compounds: []
};
if (fs.existsSync(launchJsonPath)) {
data = JSON.parse(fs.readFileSync(launchJsonPath, { encoding: 'utf8' }));
}
const configurations = [];
for (let config of data.configurations) {
if (!config.name.startsWith('Kore:')) {
configurations.push(config);
}
}
this.writeFile(launchJsonPath);
const koreConfig = {
name: 'Kore: Launch',
type: platform === Platform_1.Platform.Windows ? 'cppvsdbg' : 'cppdbg',
request: 'launch',
program: this.program(project, platform),
cwd: project.getDebugDir(),
preLaunchTask: 'Kore: Debug Build for ' + this.preLaunchTask(platform)
};
if (platform === Platform_1.Platform.Windows) {
// koreConfig.symbolSearchPath = 'C:\\Symbols;C:\\SymbolDir2';
koreConfig.externalConsole = true;
koreConfig.logging = {
moduleLoad: false,
trace: true
};
// koreConfig.visualizerFile = '${workspaceFolder}/my.natvis';
}
else if (platform === Platform_1.Platform.OSX) {
koreConfig.MIMode = 'lldb';
}
configurations.push(koreConfig);
data.configurations = configurations;
this.p(JSON.stringify(data, null, '\t'));
this.closeFile();
this.compileCommands.exportSolution(project, from, to, platform, vrApi, options);
}
program(project, platform) {
if (platform === Platform_1.Platform.OSX) {
return path.join(project.getBasedir(), 'build', 'build', 'Release', project.getSafeName() + '.app', 'Contents', 'MacOS', project.getSafeName());
}
else {
return path.join(project.getDebugDir(), project.getSafeName() + (platform === Platform_1.Platform.Windows ? '.exe' : ''));
}
}
preLaunchTask(platform) {
if (platform === Platform_1.Platform.Windows) {
return 'Windows';
}
else if (platform === Platform_1.Platform.OSX) {
return 'macOS';
}
else if (platform === Platform_1.Platform.Linux) {
return 'Linux';
}
else if (platform === Platform_1.Platform.FreeBSD) {
return 'FreeBSD';
}
else {
return 'Unknown';
}
}
}
exports.VSCodeExporter = VSCodeExporter;
//# sourceMappingURL=VSCodeExporter.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"VSCodeExporter.js","sourceRoot":"","sources":["../../../kmake/src/Exporters/VSCodeExporter.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAEpD,6CAA0C;AAC1C,oCAAoC;AACpC,6BAA6B;AAC7B,qFAAmF;AAEnF,MAAa,cAAe,SAAQ,mBAAQ;IAG3C,YAAY,OAAY;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,eAAe,GAAG,IAAI,kDAAwB,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,UAAU,CAAC,QAAgB;QAC1B,IAAI,QAAQ,KAAK,mBAAQ,CAAC,OAAO,EAAE;YAClC,OAAO,OAAO,CAAC;SACf;aACI,IAAI,QAAQ,KAAK,mBAAQ,CAAC,KAAK,EAAE;YACrC,OAAO,OAAO,CAAC;SACf;aACI,IAAI,QAAQ,KAAK,mBAAQ,CAAC,GAAG,EAAE;YACnC,OAAO,KAAK,CAAC;SACb;aACI;YACJ,OAAO,kBAAkB,CAAC;SAC1B;IACF,CAAC;IAED,YAAY,CAAC,QAAgB;QAC5B,IAAI,QAAQ,KAAK,mBAAQ,CAAC,OAAO,EAAE;YAClC,OAAO,gHAAgH,CAAC;SACxH;aACI,IAAI,QAAQ,KAAK,mBAAQ,CAAC,KAAK,EAAE;YACrC,OAAO,cAAc,CAAC;SACtB;aACI,IAAI,QAAQ,KAAK,mBAAQ,CA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MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;SAChJ;aACI;YACJ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,QAAQ,KAAK,mBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC/G;IACF,CAAC;IAED,aAAa,CAAC,QAAgB;QAC7B,IAAI,QAAQ,KAAK,mBAAQ,CAAC,OAAO,EAAE;YAClC,OAAO,SAAS,CAAC;SACjB;aACI,IAAI,QAAQ,KAAK,mBAAQ,CAAC,GAAG,EAAE;YACnC,OAAO,OAAO,CAAC;SACf;aACI,IAAI,QAAQ,KAAK,mBAAQ,CAAC,KAAK,EAAE;YACrC,OAAO,OAAO,CAAC;SACf;aACI,IAAI,QAAQ,KAAK,mBAAQ,CAAC,OAAO,EAAE;YACvC,OAAO,SAAS,CAAC;SACjB;aACI;YACJ,OAAO,SAAS,CAAC;SACjB;IACF,CAAC;CACD;AAnKD,wCAmKC"}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WasmExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const CompileCommandsExporter_1 = require("kmake/Exporters/CompileCommandsExporter");
const MakeExporter_1 = require("kmake/Exporters/MakeExporter");
const NinjaExporter_1 = require("kmake/Exporters/NinjaExporter");
const Icon = require("kmake/Icon");
const path = require("path");
class WasmExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
this.compileCommands = new CompileCommandsExporter_1.CompilerCommandsExporter(options);
const compiler = 'clang';
const compilerFlags = '--target=wasm32 -nostdlib -matomics -mbulk-memory';
this.make = new MakeExporter_1.MakeExporter(options, compiler, compiler, compilerFlags, compilerFlags, '--target=wasm32 -nostdlib -matomics -mbulk-memory "-Wl,--import-memory,--shared-memory"', '.wasm');
this.ninja = new NinjaExporter_1.NinjaExporter(options, compiler, compiler, compilerFlags, compilerFlags, '--target=wasm32 -nostdlib -matomics -mbulk-memory "-Wl,--import-memory,--shared-memory"', '.wasm');
}
async exportSolution(project, from, to, platform, vrApi, options) {
this.make.exportSolution(project, from, to, platform, vrApi, options);
this.ninja.exportSolution(project, from, to, platform, vrApi, options);
this.compileCommands.exportSolution(project, from, to, platform, vrApi, options);
await Icon.exportIco(project.icon, path.resolve(to, options.buildPath, 'favicon.ico'), from, true);
}
}
exports.WasmExporter = WasmExporter;
//# sourceMappingURL=WasmExporter.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"WasmExporter.js","sourceRoot":"","sources":["../../../kmake/src/Exporters/WasmExporter.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAEpD,qFAAmF;AACnF,+DAA4D;AAC5D,iEAA8D;AAC9D,mCAAmC;AACnC,6BAA6B;AAE7B,MAAa,YAAa,SAAQ,mBAAQ;IAKzC,YAAY,OAAY;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,eAAe,GAAG,IAAI,kDAAwB,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,QAAQ,GAAG,OAAO,CAAC;QACzB,MAAM,aAAa,GAAG,mDAAmD,CAAC;QAC1E,IAAI,CAAC,IAAI,GAAG,IAAI,2BAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,yFAAyF,EAAE,OAAO,CAAC,CAAC;QAC5L,IAAI,CAAC,KAAK,GAAG,IAAI,6BAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,yFAAyF,EAAE,OAAO,CAAC,CAAC;IAC/L,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAgB,EAAE,IAAY,EAAE,EAAU,EAAE,QAAgB,EAAE,KAAU,EAAE,OAAY;QAC1G,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACtE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACvE,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAEjF,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACpG,CAAC;CACD;AArBD,oCAqBC"}

View File

@ -0,0 +1,992 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.XCodeExporter = void 0;
const Exporter_1 = require("kmake/Exporters/Exporter");
const Icon = require("kmake/Icon");
const Platform_1 = require("kmake/Platform");
const fs = require("kmake/fsextra");
const path = require("path");
const child_process = require("child_process");
const crypto = require("crypto");
function uuidv4() {
return crypto.randomUUID();
}
// not quite uuid v5 but close enough
function uuidv5(path, namespace) {
const hash = crypto.createHash('sha1');
hash.update(namespace);
hash.update(path);
const value = hash.digest('hex');
return value.substring(0, 8) + '-' + value.substring(8, 12) + '-' + value.substring(12, 16) + '-' + value.substring(16, 20) + '-' + value.substring(20, 32);
}
function contains(a, b) {
return a.indexOf(b) !== -1;
}
function newId() {
return uuidv4().toUpperCase();
}
function newPathId(path) {
return uuidv5(path, '7448ebd8-cfc8-4f45-8b3d-5df577ceea6d').toUpperCase();
}
function getDir(file) {
if (file.file.indexOf('/') >= 0) {
let dir = file.file.substr(0, file.file.lastIndexOf('/'));
return path.join(file.projectName, path.relative(file.projectDir, dir)).replace(/\\/g, '/');
}
else {
return file.projectName;
}
}
class Directory {
constructor(dirname) {
this.dirname = dirname;
this.id = newPathId(dirname);
}
getName() {
return this.dirname;
}
getLastName() {
if (this.dirname.indexOf('/') < 0)
return this.dirname;
return this.dirname.substr(this.dirname.lastIndexOf('/') + 1);
}
getId() {
return this.id;
}
}
class File {
constructor(filename, dir, options) {
this.filename = filename;
this.dir = dir;
this.buildid = newPathId(dir + filename + '_buildid');
this.fileid = newPathId(dir + filename + '_fileid');
this.options = options;
}
getBuildId() {
return this.buildid;
}
getFileId() {
return this.fileid;
}
isBuildFile() {
const buildFileType = this.filename.endsWith('.c') || this.filename.endsWith('.cpp') || this.filename.endsWith('.m') || this.filename.endsWith('.mm') || this.filename.endsWith('.cc') || this.filename.endsWith('.s') || this.filename.endsWith('S') || this.filename.endsWith('.metal') || this.filename.endsWith('.storyboard');
if (buildFileType) {
if (this.options && this.options.nocompile) {
return false;
}
}
return buildFileType;
}
getName() {
return this.filename;
}
getLastName() {
if (this.filename.indexOf('/') < 0)
return this.filename;
return this.filename.substr(this.filename.lastIndexOf('/') + 1);
}
getDir() {
return this.dir;
}
toString() {
return this.getName();
}
}
class Framework {
constructor(name) {
this.name = name;
this.buildid = newPathId(name + '_buildid');
this.fileid = newPathId(name + '_fileid');
this.localPath = null;
}
toString() {
if (this.name.indexOf('.') < 0)
return this.name + '.framework';
else
return this.name;
}
getBuildId() {
return this.buildid.toString().toUpperCase();
}
getFileId() {
return this.fileid.toString().toUpperCase();
}
}
function findDirectory(dirname, directories) {
for (let dir of directories) {
if (dir.getName() === dirname) {
return dir;
}
}
return null;
}
function addDirectory(dirname, directories) {
let dir = findDirectory(dirname, directories);
if (dir === null) {
dir = new Directory(dirname);
directories.push(dir);
while (dirname.indexOf('/') >= 0) {
dirname = dirname.substr(0, dirname.lastIndexOf('/'));
addDirectory(dirname, directories);
}
}
return dir;
}
class XCodeExporter extends Exporter_1.Exporter {
constructor(options) {
super(options);
}
exportWorkspace(to, project) {
const dir = path.resolve(to, project.getSafeName() + '.xcodeproj', 'project.xcworkspace');
fs.ensureDirSync(dir);
this.writeFile(path.resolve(to, project.getSafeName() + '.xcodeproj', 'project.xcworkspace', 'contents.xcworkspacedata'));
this.p('<?xml version="1.0" encoding="UTF-8"?>');
this.p('<Workspace');
this.p('version = "1.0">');
this.p('<FileRef');
this.p('location = "self:' + project.getSafeName() + '.xcodeproj">');
this.p('</FileRef>');
this.p('</Workspace>');
this.closeFile();
}
open(project, to) {
child_process.spawn('open', [path.resolve(to, project.getSafeName() + '.xcodeproj')], { detached: true, shell: true });
}
async exportSolution(project, from, to, platform, vrApi, options) {
const xdir = path.resolve(to, project.getSafeName() + '.xcodeproj');
fs.ensureDirSync(xdir);
this.exportWorkspace(to, project);
let icons = [];
class IconImage {
constructor(idiom, size, scale, background = undefined) {
this.idiom = idiom;
this.size = size;
this.scale = scale;
this.background = background;
}
}
if (platform === Platform_1.Platform.iOS) {
icons.push(new IconImage('iphone', 20, 2));
icons.push(new IconImage('iphone', 20, 3));
icons.push(new IconImage('iphone', 29, 2));
icons.push(new IconImage('iphone', 29, 3));
icons.push(new IconImage('iphone', 40, 2));
icons.push(new IconImage('iphone', 40, 3));
icons.push(new IconImage('iphone', 60, 2));
icons.push(new IconImage('iphone', 60, 3));
icons.push(new IconImage('ipad', 20, 1));
icons.push(new IconImage('ipad', 20, 2));
icons.push(new IconImage('ipad', 29, 1));
icons.push(new IconImage('ipad', 29, 2));
icons.push(new IconImage('ipad', 40, 1));
icons.push(new IconImage('ipad', 40, 2));
icons.push(new IconImage('ipad', 76, 1));
icons.push(new IconImage('ipad', 76, 2));
icons.push(new IconImage('ipad', 83.5, 2));
icons.push(new IconImage('ios-marketing', 1024, 1, 0x000000ff));
}
else {
icons.push(new IconImage('mac', 16, 1));
icons.push(new IconImage('mac', 16, 2));
icons.push(new IconImage('mac', 32, 1));
icons.push(new IconImage('mac', 32, 2));
icons.push(new IconImage('mac', 128, 1));
icons.push(new IconImage('mac', 128, 2));
icons.push(new IconImage('mac', 256, 1));
icons.push(new IconImage('mac', 256, 2));
icons.push(new IconImage('mac', 512, 1));
icons.push(new IconImage('mac', 512, 2));
}
const iconsdir = path.resolve(to, 'Images.xcassets', 'AppIcon.appiconset');
fs.ensureDirSync(iconsdir);
this.writeFile(path.resolve(to, 'Images.xcassets', 'AppIcon.appiconset', 'Contents.json'));
this.p('{');
this.p('"images" : [', 1);
for (let i = 0; i < icons.length; ++i) {
const icon = icons[i];
this.p('{', 2);
this.p('"idiom" : "' + icon.idiom + '",', 3);
this.p('"size" : "' + icon.size + 'x' + icon.size + '",', 3);
this.p('"filename" : "' + icon.idiom + icon.scale + 'x' + icon.size + '.png",', 3);
this.p('"scale" : "' + icon.scale + 'x"', 3);
if (i === icons.length - 1)
this.p('}', 2);
else
this.p('},', 2);
}
this.p('],', 1);
this.p('"info" : {', 1);
this.p('"version" : 1,', 2);
this.p('"author" : "xcode"', 2);
this.p('}', 1);
this.p('}');
this.closeFile();
// const black = 0xff;
for (let i = 0; i < icons.length; ++i) {
const icon = icons[i];
await Icon.exportPng(project.icon, path.resolve(to, 'Images.xcassets', 'AppIcon.appiconset', icon.idiom + icon.scale + 'x' + icon.size + '.png'), icon.size * icon.scale, icon.size * icon.scale, icon.background, from);
}
let plistname = '';
let files = [];
let directories = [];
for (let fileobject of project.getFiles()) {
let filename = fileobject.file;
if (filename.endsWith('.plist'))
plistname = filename;
let dir = addDirectory(getDir(fileobject), directories);
let file = new File(filename, dir, fileobject.options);
files.push(file);
}
if (plistname.length === 0)
throw 'no plist found';
let frameworks = [];
for (let lib of project.getLibs()) {
frameworks.push(new Framework(lib));
}
let targetOptions = {
bundle: 'tech.kode.$(PRODUCT_NAME:rfc1034identifier)',
version: '1.0',
build: '1',
organizationName: 'the Kore Development Team',
developmentTeam: ''
};
if (project.targetOptions && project.targetOptions.ios) {
let userOptions = project.targetOptions.ios;
if (userOptions.bundle)
targetOptions.bundle = userOptions.bundle;
if (userOptions.version)
targetOptions.version = userOptions.version;
if (userOptions.build)
targetOptions.build = userOptions.build;
if (userOptions.organizationName)
targetOptions.organizationName = userOptions.organizationName;
if (userOptions.developmentTeam)
targetOptions.developmentTeam = userOptions.developmentTeam;
}
const projectId = newPathId('_projectId');
const appFileId = newPathId('_appFileId');
const frameworkBuildId = newPathId('_frameworkBuildId');
const sourceBuildId = newPathId('_sourceBuildId');
const frameworksGroupId = newPathId('_frameworksGroupId');
const productsGroupId = newPathId('_productsGroupId');
const mainGroupId = newPathId('_mainGroupId');
const targetId = newPathId('_targetId');
const nativeBuildConfigListId = newPathId('_nativeBuildConfigListId');
const projectBuildConfigListId = newPathId('_projectBuildConfigListId');
const debugId = newPathId('_debugId');
const releaseId = newPathId('_releaseId');
const nativeDebugId = newPathId('_nativeDebugId');
const nativeReleaseId = newPathId('_nativeReleaseId');
const debugDirFileId = newPathId('_debugDirFileId');
const debugDirBuildId = newPathId('_debugDirBuildId');
const resourcesBuildId = newPathId('_resourcesBuildId');
const iconFileId = newPathId('_iconFileId');
const iconBuildId = newPathId('_iconBuildId');
// var iosIconFileIds = [];
// var iosIconBuildIds = [];
// for (var i = 0; i < iosIconNames.length; ++i) {
// iosIconFileIds.push(newId());
// iosIconBuildIds.push(newId());
// }
this.writeFile(path.resolve(to, project.getSafeName() + '.xcodeproj', 'project.pbxproj'));
this.p('// !$*UTF8*$!');
this.p('{');
this.p('archiveVersion = 1;', 1);
this.p('classes = {', 1);
this.p('};', 1);
this.p('objectVersion = 46;', 1);
this.p('objects = {', 1);
this.p();
this.p('/* Begin PBXBuildFile section */');
for (let framework of frameworks) {
this.p(framework.getBuildId() + ' /* ' + framework.toString() + ' in Frameworks */ = {isa = PBXBuildFile; fileRef = ' + framework.getFileId() + ' /* ' + framework.toString() + ' */; };', 2);
}
this.p(debugDirBuildId + ' /* Deployment in Resources */ = {isa = PBXBuildFile; fileRef = ' + debugDirFileId + ' /* Deployment */; };', 2);
for (let file of files) {
if (file.isBuildFile()) {
this.p(file.getBuildId() + ' /* ' + file.toString() + ' in Sources */ = {isa = PBXBuildFile; fileRef = ' + file.getFileId() + ' /* ' + file.toString() + ' */; };', 2);
}
}
if (!options.lib && !options.dynlib) {
this.p(iconBuildId + ' /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ' + iconFileId + ' /* Images.xcassets */; };', 2);
}
this.p('/* End PBXBuildFile section */');
this.p();
this.p('/* Begin PBXFileReference section */');
let executableName = project.getSafeName();
if (project.getExecutableName()) {
executableName = project.getExecutableName();
}
if (options.lib) {
this.p(appFileId + ' /* ' + project.getSafeName() + '.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "' + executableName + '.a"; sourceTree = BUILT_PRODUCTS_DIR; };', 2);
}
else if (options.dynlib) {
this.p(appFileId + ' /* ' + project.getSafeName() + '.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = "' + executableName + '.dylib"; sourceTree = BUILT_PRODUCTS_DIR; };', 2);
}
else {
this.p(appFileId + ' /* ' + project.getSafeName() + '.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "' + executableName + '.app"; sourceTree = BUILT_PRODUCTS_DIR; };', 2);
}
for (let framework of frameworks) {
if (framework.toString().endsWith('.framework')) {
// Local framework - a directory is specified
if (framework.toString().indexOf('/') >= 0) {
framework.localPath = path.resolve(from, framework.toString());
this.p(framework.getFileId() + ' /* ' + framework.toString() + ' */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ' + framework.toString() + '; path = ' + framework.localPath + '; sourceTree = "<absolute>"; };', 2);
}
// XCode framework
else {
this.p(framework.getFileId() + ' /* ' + framework.toString() + ' */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ' + framework.toString() + '; path = System/Library/Frameworks/' + framework.toString() + '; sourceTree = SDKROOT; };', 2);
}
}
else if (framework.toString().endsWith('.dylib')) {
// Local dylib, e.g. V8 in Krom - a directory is specified
if (framework.toString().indexOf('/') >= 0) {
framework.localPath = path.resolve(from, framework.toString());
this.p(framework.getFileId() + ' /* ' + framework.toString() + ' */ = {isa = PBXFileReference; lastKnownFileType = compiled.mach-o.dylib; name = ' + framework.toString() + '; path = ' + framework.localPath + '; sourceTree = "<absolute>"; };', 2);
}
else {
this.p(framework.getFileId() + ' /* ' + framework.toString() + ' */ = {isa = PBXFileReference; lastKnownFileType = compiled.mach-o.dylib; name = ' + framework.toString() + '; path = usr/lib/' + framework.toString() + '; sourceTree = SDKROOT; };', 2);
}
}
else {
framework.localPath = path.resolve(from, framework.toString());
this.p(framework.getFileId() + ' /* ' + framework.toString() + ' */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = ' + framework.toString() + '; path = ' + framework.localPath + '; sourceTree = "<group>"; };', 2);
}
}
this.p(debugDirFileId + ' /* Deployment */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Deployment; path = "' + path.resolve(from, project.getDebugDir()) + '"; sourceTree = "<group>"; };', 2);
for (let file of files) {
let filetype = 'unknown';
let fileencoding = '';
if (file.getName().endsWith('.storyboard'))
filetype = 'file.storyboard';
if (file.getName().endsWith('.plist'))
filetype = 'text.plist.xml';
if (file.getName().endsWith('.h'))
filetype = 'sourcecode.c.h';
if (file.getName().endsWith('.m'))
filetype = 'sourcecode.c.objc';
if (file.getName().endsWith('.c'))
filetype = 'sourcecode.c.c';
if (file.getName().endsWith('.cpp'))
filetype = 'sourcecode.c.cpp';
if (file.getName().endsWith('.cc'))
filetype = 'sourcecode.c.cpp';
if (file.getName().endsWith('.mm'))
filetype = 'sourcecode.c.objcpp';
if (file.getName().endsWith('.s') || file.getName().endsWith('.S'))
filetype = 'sourcecode.asm';
if (file.getName().endsWith('.metal')) {
filetype = 'sourcecode.metal';
fileencoding = 'fileEncoding = 4; ';
}
if (!file.getName().endsWith('.DS_Store')) {
this.p(file.getFileId() + ' /* ' + file.toString() + ' */ = {isa = PBXFileReference; ' + fileencoding + 'lastKnownFileType = ' + filetype + '; name = "' + file.getLastName() + '"; path = "' + path.resolve(from, file.toString()) + '"; sourceTree = "<group>"; };', 2);
}
}
if (!options.lib && !options.dynlib) {
this.p(iconFileId + ' /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };', 2);
}
this.p('/* End PBXFileReference section */');
this.p();
this.p('/* Begin PBXFrameworksBuildPhase section */');
this.p(frameworkBuildId + ' /* Frameworks */ = {', 2);
this.p('isa = PBXFrameworksBuildPhase;', 3);
this.p('buildActionMask = 2147483647;', 3);
this.p('files = (', 3);
for (let framework of frameworks) {
this.p(framework.getBuildId() + ' /* ' + framework.toString() + ' in Frameworks */,', 4);
}
this.p(');', 3);
this.p('runOnlyForDeploymentPostprocessing = 0;', 3);
this.p('};', 2);
this.p('/* End PBXFrameworksBuildPhase section */');
this.p();
this.p('/* Begin PBXGroup section */');
this.p(mainGroupId + ' = {', 2);
this.p('isa = PBXGroup;', 3);
this.p('children = (', 3);
if (!options.lib && !options.dynlib) {
this.p(iconFileId + ' /* Images.xcassets */,', 4);
}
this.p(debugDirFileId + ' /* Deployment */,', 4);
// p(solutionGroupId + " /* " + solution.getName() + " */,", 4);
for (let dir of directories) {
if (dir.getName().indexOf('/') < 0)
this.p(dir.getId() + ' /* ' + dir.getName() + ' */,', 4);
}
this.p(frameworksGroupId + ' /* Frameworks */,', 4);
this.p(productsGroupId + ' /* Products */,', 4);
this.p(');', 3);
this.p('sourceTree = "<group>";', 3);
this.p('};', 2);
this.p(productsGroupId + ' /* Products */ = {', 2);
this.p('isa = PBXGroup;', 3);
this.p('children = (', 3);
if (options.lib) {
this.p(appFileId + ' /* ' + project.getSafeName() + '.a */,', 4);
}
else if (options.dynlib) {
this.p(appFileId + ' /* ' + project.getSafeName() + '.dynlib */,', 4);
}
else {
this.p(appFileId + ' /* ' + project.getSafeName() + '.app */,', 4);
}
this.p(');', 3);
this.p('name = Products;', 3);
this.p('sourceTree = "<group>";', 3);
this.p('};', 2);
this.p(frameworksGroupId + ' /* Frameworks */ = {', 2);
this.p('isa = PBXGroup;', 3);
this.p('children = (', 3);
for (let framework of frameworks) {
this.p(framework.getFileId() + ' /* ' + framework.toString() + ' */,', 4);
}
this.p(');', 3);
this.p('name = Frameworks;', 3);
this.p('sourceTree = "<group>";', 3);
this.p('};', 2);
for (let dir of directories) {
this.p(dir.getId() + ' /* ' + dir.getName() + ' */ = {', 2);
this.p('isa = PBXGroup;', 3);
this.p('children = (', 3);
for (let dir2 of directories) {
if (dir2 === dir)
continue;
if (dir2.getName().startsWith(dir.getName())) {
if (dir2.getName().substr(dir.getName().length + 1).indexOf('/') < 0)
this.p(dir2.getId() + ' /* ' + dir2.getName() + ' */,', 4);
}
}
for (let file of files) {
if (file.getDir() === dir && !file.getName().endsWith('.DS_Store'))
this.p(file.getFileId() + ' /* ' + file.toString() + ' */,', 4);
}
this.p(');', 3);
if (dir.getName().indexOf('/') < 0) {
this.p('path = ../;', 3);
this.p('name = "' + dir.getLastName() + '";', 3);
}
else
this.p('name = "' + dir.getLastName() + '";', 3);
this.p('sourceTree = "<group>";', 3);
this.p('};', 2);
}
this.p('/* End PBXGroup section */');
this.p();
this.p('/* Begin PBXNativeTarget section */');
this.p(targetId + ' /* ' + project.getSafeName() + ' */ = {', 2);
this.p('isa = PBXNativeTarget;', 3);
this.p('buildConfigurationList = ' + nativeBuildConfigListId + ' /* Build configuration list for PBXNativeTarget "' + project.getSafeName() + '" */;', 3);
this.p('buildPhases = (', 3);
this.p(sourceBuildId + ' /* Sources */,', 4);
this.p(frameworkBuildId + ' /* Frameworks */,', 4);
this.p(resourcesBuildId + ' /* Resources */,', 4);
this.p(');', 3);
this.p('buildRules = (', 3);
this.p(');', 3);
this.p('dependencies = (', 3);
this.p(');', 3);
this.p('name = "' + project.getName() + '";', 3);
this.p('productName = "' + project.getName() + '";', 3);
if (options.lib) {
this.p('productReference = ' + appFileId + ' /* ' + project.getSafeName() + '.a */;', 3);
this.p('productType = "com.apple.product-type.library.static";', 3);
}
else if (options.dynlib) {
this.p('productReference = ' + appFileId + ' /* ' + project.getSafeName() + '.dylib */;', 3);
this.p('productType = "com.apple.product-type.library.dynamic";', 3);
}
else {
this.p('productReference = ' + appFileId + ' /* ' + project.getSafeName() + '.app */;', 3);
this.p('productType = "com.apple.product-type.' + (project.isCmd() ? 'tool' : 'application') + '";', 3);
}
this.p('};', 2);
this.p('/* End PBXNativeTarget section */');
this.p();
this.p('/* Begin PBXProject section */');
this.p(projectId + ' /* Project object */ = {', 2);
this.p('isa = PBXProject;', 3);
this.p('attributes = {', 3);
this.p('LastUpgradeCheck = 1230;', 4);
this.p('ORGANIZATIONNAME = "' + targetOptions.organizationName + '";', 4);
this.p('TargetAttributes = {', 4);
this.p(targetId + ' = {', 5);
this.p('CreatedOnToolsVersion = 6.1.1;', 6);
if (targetOptions.developmentTeam) {
this.p('DevelopmentTeam = ' + targetOptions.developmentTeam + ';', 6);
}
this.p('};', 5);
this.p('};', 4);
this.p('};', 3);
this.p('buildConfigurationList = ' + projectBuildConfigListId + ' /* Build configuration list for PBXProject "' + project.getSafeName() + '" */;', 3);
this.p('compatibilityVersion = "Xcode 3.2";', 3);
this.p('developmentRegion = en;', 3);
this.p('hasScannedForEncodings = 0;', 3);
this.p('knownRegions = (', 3);
this.p('en,', 4);
this.p('Base,', 4);
this.p(');', 3);
this.p('mainGroup = ' + mainGroupId + ';', 3);
this.p('productRefGroup = ' + productsGroupId + ' /* Products */;', 3);
this.p('projectDirPath = "";', 3);
this.p('projectRoot = "";', 3);
this.p('targets = (', 3);
this.p(targetId + ' /* ' + project.getSafeName() + ' */,', 4);
this.p(');', 3);
this.p('};', 2);
this.p('/* End PBXProject section */');
this.p();
if (!options.lib && !options.dynlib) {
this.p('/* Begin PBXResourcesBuildPhase section */');
this.p(resourcesBuildId + ' /* Resources */ = {', 2);
this.p('isa = PBXResourcesBuildPhase;', 3);
this.p('buildActionMask = 2147483647;', 3);
this.p('files = (', 3);
this.p(debugDirBuildId + ' /* Deployment in Resources */,', 4);
this.p(iconBuildId + ' /* Images.xcassets in Resources */,', 4);
this.p(');', 3);
this.p('runOnlyForDeploymentPostprocessing = 0;', 3);
this.p('};', 2);
this.p('/* End PBXResourcesBuildPhase section */');
this.p();
}
this.p('/* Begin PBXSourcesBuildPhase section */');
this.p(sourceBuildId + ' /* Sources */ = {', 2);
this.p('isa = PBXSourcesBuildPhase;', 3);
this.p('buildActionMask = 2147483647;', 3);
this.p('files = (', 3);
for (let file of files) {
if (file.isBuildFile())
this.p(file.getBuildId() + ' /* ' + file.toString() + ' in Sources */,', 4);
}
this.p(');', 3);
this.p('runOnlyForDeploymentPostprocessing = 0;');
this.p('};');
this.p('/* End PBXSourcesBuildPhase section */');
this.p();
// p("/* Begin PBXVariantGroup section */");
// p("E1FC77F013DAA40000D635AE /* InfoPlist.strings */ = {", 2);
// p("isa = PBXVariantGroup;", 3);
// p("children = (", 3);
// p("E1FC77F113DAA40000D635AE /* en */,", 4);
// p(");", 3);
// p("name = InfoPlist.strings;", 3);
// p("sourceTree = \"<group>\";", 3);
// p("};", 2);
// p("E1FC77F913DAA40000D635AE /* MainWindow.xib */ = {", 2);
// p("isa = PBXVariantGroup;", 3);
// p("children = (", 3);
// p("E1FC77FA13DAA40000D635AE /* en */,", 4);
// p(");", 3);
// p("name = MainWindow.xib;", 3);
// p("sourceTree = \"<group>\";", 3);
// p("};", 2);
// p("E1FC780613DAA40000D635AE /* TestViewController.xib */ = {", 2);
// p("isa = PBXVariantGroup;", 3);
// p("children = (", 3);
// p("E1FC780713DAA40000D635AE /* en */,", 4);
// p(");", 3);
// p("name = TestViewController.xib;", 3);
// p("sourceTree = \"<group>\";", 3);
// p("};", 2);
// p("/* End PBXVariantGroup section */");
// p();
this.p('/* Begin XCBuildConfiguration section */');
this.p(debugId + ' /* Debug */ = {', 2);
this.p('isa = XCBuildConfiguration;', 3);
this.p('buildSettings = {', 3);
this.p('ALWAYS_SEARCH_USER_PATHS = NO;', 4);
if (project.cppStd !== '' && project.cppStd !== 'gnu++14') {
this.p('CLANG_CXX_LANGUAGE_STANDARD = "' + project.cppStd + '";', 4);
}
else {
this.p('CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";', 4);
}
this.p('CLANG_CXX_LIBRARY = "compiler-default";', 4);
this.p('CLANG_ENABLE_MODULES = YES;', 4);
this.p('CLANG_ENABLE_OBJC_ARC = YES;', 4);
this.p('CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;', 4);
this.p('CLANG_WARN_BOOL_CONVERSION = YES;', 4);
this.p('CLANG_WARN_COMMA = YES;', 4);
this.p('CLANG_WARN_CONSTANT_CONVERSION = YES;', 4);
this.p('CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;', 4);
this.p('CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;', 4);
this.p('CLANG_WARN_EMPTY_BODY = YES;', 4);
this.p('CLANG_WARN_ENUM_CONVERSION = YES;', 4);
this.p('CLANG_WARN_INFINITE_RECURSION = YES;', 4);
this.p('CLANG_WARN_INT_CONVERSION = YES;', 4);
this.p('CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;', 4);
this.p('CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;', 4);
this.p('CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;', 4);
this.p('CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;', 4);
this.p('CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;', 4);
this.p('CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;', 4);
this.p('CLANG_WARN_STRICT_PROTOTYPES = YES;', 4);
this.p('CLANG_WARN_SUSPICIOUS_MOVE = YES;', 4);
this.p('CLANG_WARN_UNREACHABLE_CODE = YES;', 4);
this.p('CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;', 4);
if (platform === Platform_1.Platform.iOS) {
this.p('"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";', 4);
}
else {
this.p('CODE_SIGN_IDENTITY = "-";', 4);
}
this.p('COPY_PHASE_STRIP = NO;', 4);
this.p('ENABLE_STRICT_OBJC_MSGSEND = YES;', 4);
this.p('ENABLE_TESTABILITY = YES;', 4);
if (project.cStd !== '' && project.cStd !== 'c99') {
this.p('GCC_C_LANGUAGE_STANDARD = "' + project.cStd + '";', 4);
}
else {
this.p('GCC_C_LANGUAGE_STANDARD = "gnu99";', 4);
}
this.p('GCC_DYNAMIC_NO_PIC = NO;', 4);
this.p('GCC_NO_COMMON_BLOCKS = YES;', 4);
this.p('GCC_OPTIMIZATION_LEVEL = 0;', 4);
this.p('GCC_PREPROCESSOR_DEFINITIONS = (', 4);
this.p('"DEBUG=1",', 5);
for (const define of project.getDefines()) {
if (define.config && define.config.toLowerCase() === 'release') {
continue;
}
if (define.value.indexOf('=') >= 0)
this.p('"' + define.value.replace(/\"/g, '\\\\\\"') + '",', 5);
else
this.p(define.value + ',', 5);
}
this.p('"$(inherited)",', 5);
this.p(');', 4);
this.p('GCC_SYMBOLS_PRIVATE_EXTERN = NO;', 4);
this.p('GCC_WARN_64_TO_32_BIT_CONVERSION = YES;', 4);
this.p('GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;', 4);
this.p('GCC_WARN_UNDECLARED_SELECTOR = YES;', 4);
this.p('GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;', 4);
this.p('GCC_WARN_UNUSED_FUNCTION = YES;', 4);
this.p('GCC_WARN_UNUSED_VARIABLE = YES;', 4);
if (platform === Platform_1.Platform.iOS) {
this.p('IPHONEOS_DEPLOYMENT_TARGET = 15.6;', 4);
}
else {
this.p('MACOSX_DEPLOYMENT_TARGET = 11.5;', 4);
}
this.p('MTL_ENABLE_DEBUG_INFO = YES;', 4);
this.p('ONLY_ACTIVE_ARCH = YES;', 4);
if (platform === Platform_1.Platform.iOS) {
this.p('SDKROOT = iphoneos;', 4);
this.p('TARGETED_DEVICE_FAMILY = "1,2";', 4);
}
else {
this.p('SDKROOT = macosx;', 4);
}
this.p('};', 3);
this.p('name = Debug;', 3);
this.p('};', 2);
this.p(releaseId + ' /* Release */ = {', 2);
this.p('isa = XCBuildConfiguration;', 3);
this.p('buildSettings = {', 3);
this.p('ALWAYS_SEARCH_USER_PATHS = NO;', 4);
if (project.cppStd !== '' && project.cppStd !== 'gnu++14') {
this.p('CLANG_CXX_LANGUAGE_STANDARD = "' + project.cppStd + '";', 4);
}
else {
this.p('CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";', 4);
}
this.p('CLANG_CXX_LIBRARY = "compiler-default";', 4);
this.p('CLANG_ENABLE_MODULES = YES;', 4);
this.p('CLANG_ENABLE_OBJC_ARC = YES;', 4);
this.p('CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;', 4);
this.p('CLANG_WARN_BOOL_CONVERSION = YES;', 4);
this.p('CLANG_WARN_COMMA = YES;', 4);
this.p('CLANG_WARN_CONSTANT_CONVERSION = YES;', 4);
this.p('CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;', 4);
this.p('CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;', 4);
this.p('CLANG_WARN_EMPTY_BODY = YES;', 4);
this.p('CLANG_WARN_ENUM_CONVERSION = YES;', 4);
this.p('CLANG_WARN_INFINITE_RECURSION = YES;', 4);
this.p('CLANG_WARN_INT_CONVERSION = YES;', 4);
this.p('CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;', 4);
this.p('CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;', 4);
this.p('CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;', 4);
this.p('CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;', 4);
this.p('CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;', 4);
this.p('CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;', 4);
this.p('CLANG_WARN_STRICT_PROTOTYPES = YES;', 4);
this.p('CLANG_WARN_SUSPICIOUS_MOVE = YES;', 4);
this.p('CLANG_WARN_UNREACHABLE_CODE = YES;', 4);
this.p('CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;', 4);
if (platform === Platform_1.Platform.iOS) {
this.p('"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";', 4);
}
else {
this.p('CODE_SIGN_IDENTITY = "-";', 4);
}
this.p('COPY_PHASE_STRIP = YES;', 4);
if (platform === Platform_1.Platform.OSX) {
this.p('DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";', 4);
}
this.p('ENABLE_NS_ASSERTIONS = NO;', 4);
this.p('ENABLE_STRICT_OBJC_MSGSEND = YES;', 4);
if (project.cStd !== '' && project.cStd !== 'c99') {
this.p('GCC_C_LANGUAGE_STANDARD = "' + project.cStd + '";', 4);
}
else {
this.p('GCC_C_LANGUAGE_STANDARD = "gnu99";', 4);
}
this.p('GCC_NO_COMMON_BLOCKS = YES;', 4);
this.p('GCC_PREPROCESSOR_DEFINITIONS = (', 4);
this.p('NDEBUG,', 5);
for (const define of project.getDefines()) {
if (define.config && define.config.toLowerCase() === 'debug') {
continue;
}
if (define.value.indexOf('=') >= 0)
this.p('"' + define.value.replace(/\"/g, '\\\\\\"') + '",', 5);
else
this.p(define.value + ',', 5);
}
this.p('"$(inherited)",', 5);
this.p(');', 4);
this.p('GCC_WARN_64_TO_32_BIT_CONVERSION = YES;', 4);
this.p('GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;', 4);
this.p('GCC_WARN_UNDECLARED_SELECTOR = YES;', 4);
this.p('GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;', 4);
this.p('GCC_WARN_UNUSED_FUNCTION = YES;', 4);
this.p('GCC_WARN_UNUSED_VARIABLE = YES;', 4);
if (platform === Platform_1.Platform.iOS) {
this.p('IPHONEOS_DEPLOYMENT_TARGET = 15.6;', 4);
}
else {
this.p('MACOSX_DEPLOYMENT_TARGET = 11.5;', 4);
}
this.p('MTL_ENABLE_DEBUG_INFO = NO;', 4);
if (platform === Platform_1.Platform.iOS) {
this.p('SDKROOT = iphoneos;', 4);
this.p('TARGETED_DEVICE_FAMILY = "1,2";', 4);
this.p('VALIDATE_PRODUCT = YES;', 4);
}
else {
this.p('SDKROOT = macosx;', 4);
}
this.p('};', 3);
this.p('name = Release;', 3);
this.p('};', 2);
this.p(nativeDebugId + ' /* Debug */ = {', 2);
this.p('isa = XCBuildConfiguration;', 3);
this.p('buildSettings = {', 3);
if (project.macOSnoArm) {
this.p('ARCHS = x86_64;', 4);
}
if (!options.lib && !options.dynlib) {
this.p('ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;', 4);
}
if (platform === Platform_1.Platform.OSX && (!options.lib && !options.dynlib)) {
this.p('COMBINE_HIDPI_IMAGES = YES;', 4);
}
this.p('FRAMEWORK_SEARCH_PATHS = (', 4);
this.p('"$(inherited)",', 5);
// Search paths to local frameworks
for (let framework of frameworks) {
if (framework.localPath != null)
this.p(framework.localPath.substr(0, framework.localPath.lastIndexOf('/')) + ',', 5);
}
this.p(');', 4);
this.p('HEADER_SEARCH_PATHS = (', 4);
this.p('"$(inherited)",', 5);
this.p('"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",', 5);
for (let projectpath of project.getIncludeDirs())
this.p('"' + path.resolve(from, projectpath).replace(/ /g, '\\\\ ') + '",', 5);
this.p(');', 4);
this.p('LIBRARY_SEARCH_PATHS = (', 4);
for (let framework of frameworks) {
if ((framework.toString().endsWith('.dylib') || framework.toString().endsWith('.a')) && framework.localPath != null) {
this.p(framework.localPath.substr(0, framework.localPath.lastIndexOf('/')) + ',', 5);
}
}
this.p(');', 4);
if (!options.lib && !options.dynlib) {
this.p('INFOPLIST_EXPAND_BUILD_SETTINGS = "YES";', 4);
this.p('INFOPLIST_FILE = "' + path.resolve(from, plistname) + '";', 4);
this.p('LD_RUNPATH_SEARCH_PATHS = (', 4);
this.p('"$(inherited)",', 5);
if (platform === Platform_1.Platform.iOS) {
this.p('"@executable_path/Frameworks",', 5);
}
for (let framework of frameworks) {
if (framework.toString().endsWith('.dylib') && framework.localPath != null) {
this.p(framework.localPath.substr(0, framework.localPath.lastIndexOf('/')) + ',', 5);
}
}
this.p(');', 4);
}
if (project.cFlags.length > 0) {
this.p('OTHER_CFLAGS = (', 4);
for (let cFlag of project.cFlags) {
this.p('"' + cFlag + '",', 5);
}
this.p(');', 4);
}
if (project.cppFlags.length > 0) {
this.p('OTHER_CPLUSPLUSFLAGS = (', 4);
for (let cppFlag of project.cppFlags) {
this.p('"' + cppFlag + '",', 5);
}
this.p(');', 4);
}
if (options.dynlib) {
this.p('DYLIB_COMPATIBILITY_VERSION = 1;', 4);
this.p('DYLIB_CURRENT_VERSION = 1;', 4);
this.p('EXECUTABLE_PREFIX = lib;', 4);
}
else if (options.lib) {
this.p('EXECUTABLE_PREFIX = lib;', 4);
}
if (!options.lib && !options.dynlib) {
this.p('PRODUCT_BUNDLE_IDENTIFIER = "' + targetOptions.bundle + '";', 4);
}
this.p('BUNDLE_VERSION = "' + targetOptions.version + '";', 4);
this.p('BUILD_VERSION = "' + targetOptions.build + '";', 4);
this.p('CODE_SIGN_IDENTITY = "-";', 4);
this.p('PRODUCT_NAME = "$(TARGET_NAME)";', 4);
if (options.lib) {
// this.p('MACH_O_TYPE = staticlib;', 4);
// this.p('STRIP_INSTALLED_PRODUCT = NO;', 4);
this.p('SKIP_INSTALL = YES;', 4);
}
else if (options.dynlib) {
// this.p('MACH_O_TYPE = mh_dylib;', 4);
// this.p('STRIP_STYLE = debugging;', 4);
this.p('SKIP_INSTALL = YES;', 4);
}
this.p('};', 3);
this.p('name = Debug;', 3);
this.p('};', 2);
this.p(nativeReleaseId + ' /* Release */ = {', 2);
this.p('isa = XCBuildConfiguration;', 3);
this.p('buildSettings = {', 3);
if (project.macOSnoArm) {
this.p('ARCHS = x86_64;', 4);
}
if (!options.lib && !options.dynlib) {
this.p('ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;', 4);
}
if (platform === Platform_1.Platform.OSX && (!options.lib && !options.dynlib)) {
this.p('COMBINE_HIDPI_IMAGES = YES;', 4);
}
this.p('"EXCLUDED_SOURCE_FILE_NAMES[arch=*]" = (', 4);
for (let fileobject of project.getFiles()) {
let file = fileobject.file;
if (file.endsWith('.cpp') || file.endsWith('.c') || file.endsWith('.cc') || file.endsWith('.cxx') || file.endsWith('.m') || file.endsWith('.mm')) {
if (fileobject.options && fileobject.options.nocompile) {
this.p('"' + file + '",', 5);
}
}
}
this.p(');', 4);
this.p('FRAMEWORK_SEARCH_PATHS = (', 4);
this.p('"$(inherited)",', 5);
// Search paths to local frameworks
for (let framework of frameworks) {
if (framework.localPath != null)
this.p(framework.localPath.substr(0, framework.localPath.lastIndexOf('/')) + ',', 5);
}
this.p(');', 4);
this.p('HEADER_SEARCH_PATHS = (', 4);
this.p('"$(inherited)",', 5);
this.p('"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",', 5);
for (let p of project.getIncludeDirs())
this.p('"' + path.resolve(from, p).replace(/ /g, '\\\\ ') + '",', 5);
this.p(');', 4);
this.p('LIBRARY_SEARCH_PATHS = (', 4);
for (let framework of frameworks) {
if ((framework.toString().endsWith('.dylib') || framework.toString().endsWith('.a')) && framework.localPath != null) {
this.p(framework.localPath.substr(0, framework.localPath.lastIndexOf('/')) + ',', 5);
}
}
this.p(');', 4);
if (!options.lib && !options.dynlib) {
this.p('INFOPLIST_EXPAND_BUILD_SETTINGS = "YES";', 4);
this.p('INFOPLIST_FILE = "' + path.resolve(from, plistname) + '";', 4);
this.p('LD_RUNPATH_SEARCH_PATHS = (', 4);
this.p('"$(inherited)",', 5);
if (platform === Platform_1.Platform.iOS) {
this.p('"@executable_path/Frameworks",', 5);
}
for (let framework of frameworks) {
if (framework.toString().endsWith('.dylib') && framework.localPath != null) {
this.p(framework.localPath.substr(0, framework.localPath.lastIndexOf('/')) + ',', 5);
}
}
this.p(');', 4);
}
if (project.cFlags.length > 0) {
this.p('OTHER_CFLAGS = (', 4);
for (let cFlag of project.cFlags) {
this.p('"' + cFlag + '",', 5);
}
this.p(');', 4);
}
if (project.cppFlags.length > 0) {
this.p('OTHER_CPLUSPLUSFLAGS = (', 4);
for (let cppFlag of project.cppFlags) {
this.p('"' + cppFlag + '",', 5);
}
this.p(');', 4);
}
if (options.dynlib) {
this.p('DYLIB_COMPATIBILITY_VERSION = 1;', 4);
this.p('DYLIB_CURRENT_VERSION = 1;', 4);
this.p('EXECUTABLE_PREFIX = lib;', 4);
}
else if (options.lib) {
this.p('EXECUTABLE_PREFIX = lib;', 4);
}
if (!options.lib && !options.dynlib) {
this.p('PRODUCT_BUNDLE_IDENTIFIER = "' + targetOptions.bundle + '";', 4);
}
this.p('BUNDLE_VERSION = "' + targetOptions.version + '";', 4);
this.p('BUILD_VERSION = "' + targetOptions.build + '";', 4);
this.p('CODE_SIGN_IDENTITY = "-";', 4);
this.p('PRODUCT_NAME = "$(TARGET_NAME)";', 4);
if (options.lib) {
// this.p('MACH_O_TYPE = staticlib;', 4);
// this.p('STRIP_INSTALLED_PRODUCT = NO;', 4);
this.p('SKIP_INSTALL = YES;', 4);
}
else if (options.dynlib) {
// this.p('MACH_O_TYPE = mh_dylib;', 4);
// this.p('STRIP_STYLE = debugging;', 4);
this.p('SKIP_INSTALL = YES;', 4);
}
this.p('};', 3);
this.p('name = Release;', 3);
this.p('};', 2);
this.p('/* End XCBuildConfiguration section */');
this.p();
this.p('/* Begin XCConfigurationList section */');
this.p(projectBuildConfigListId + ' /* Build configuration list for PBXProject "' + project.getSafeName() + '" */ = {', 2);
this.p('isa = XCConfigurationList;', 3);
this.p('buildConfigurations = (', 3);
this.p(debugId + ' /* Debug */,', 4);
this.p(releaseId + ' /* Release */,', 4);
this.p(');', 3);
this.p('defaultConfigurationIsVisible = 0;', 3);
this.p('defaultConfigurationName = Release;', 3);
this.p('};', 2);
this.p(nativeBuildConfigListId + ' /* Build configuration list for PBXNativeTarget "' + project.getSafeName() + '" */ = {', 2);
this.p('isa = XCConfigurationList;', 3);
this.p('buildConfigurations = (', 3);
this.p(nativeDebugId + ' /* Debug */,', 4);
this.p(nativeReleaseId + ' /* Release */,', 4);
this.p(');', 3);
this.p('defaultConfigurationIsVisible = 0;', 3);
this.p('defaultConfigurationName = Release;', 3);
this.p('};', 2);
this.p('/* End XCConfigurationList section */');
this.p('};', 1);
this.p('rootObject = ' + projectId + ' /* Project object */;', 1);
this.p('}');
this.closeFile();
}
}
exports.XCodeExporter = XCodeExporter;
//# sourceMappingURL=XCodeExporter.js.map

File diff suppressed because one or more lines are too long