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

11
lib/kmake/Architecture.js Normal file
View File

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Architecture = void 0;
exports.Architecture = {
Default: 'default',
arm: 'arm',
arm64: 'arm64',
x86: 'x86',
x64: 'x64'
};
//# sourceMappingURL=Architecture.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Architecture.js","sourceRoot":"","sources":["../../kmake/src/Architecture.ts"],"names":[],"mappings":";;;AAAW,QAAA,YAAY,GAAG;IACzB,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;CACV,CAAC"}

258
lib/kmake/AssetConverter.js Normal file
View File

@ -0,0 +1,258 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AssetConverter = void 0;
const fs = require("kmake/fsextra");
const path = require("path");
const log = require("kmake/log");
const crypto = require("crypto");
class AssetConverter {
constructor(exporter, platform, assetMatchers) {
this.exporter = exporter;
this.platform = platform;
this.assetMatchers = assetMatchers;
}
close() {
if (this.watcher)
this.watcher.close();
}
static replacePattern(pattern, value, fileinfo, options, from) {
let basePath = options.nameBaseDir ? path.join(from, options.nameBaseDir) : from;
let dirValue = path.relative(basePath, fileinfo.dir);
if (basePath.length > 0 && basePath[basePath.length - 1] === path.sep
&& dirValue.length > 0 && dirValue[dirValue.length - 1] !== path.sep) {
dirValue += path.sep;
}
if (options.namePathSeparator) {
dirValue = dirValue.split(path.sep).join(options.namePathSeparator);
}
const dirRegex = dirValue === ''
? /{dir}\//g
: /{dir}/g;
return pattern.replace(/{name}/g, value).replace(/{ext}/g, fileinfo.ext).replace(dirRegex, dirValue);
}
static createExportInfo(fileinfo, keepextension, options, from) {
let nameValue = fileinfo.name;
let destination = fileinfo.name;
if (options.md5sum) {
let data = fs.readFileSync(path.join(fileinfo.dir, fileinfo.base));
let md5sum = crypto.createHash('md5').update(data).digest('hex'); // TODO yield generateMd5Sum(file);
destination += '_' + md5sum;
}
if ((keepextension || options.noprocessing) && (!options.destination || options.destination.indexOf('{ext}') < 0)) {
destination += fileinfo.ext;
}
if (options.destination) {
destination = AssetConverter.replacePattern(options.destination, destination, fileinfo, options, from);
}
if (options.destinationCallback) {
destination = options.destinationCallback(destination);
}
if (keepextension && (!options.name || options.name.indexOf('{ext}') < 0)) {
nameValue += fileinfo.ext;
}
if (options.name) {
nameValue = AssetConverter.replacePattern(options.name, nameValue, fileinfo, options, from);
}
return { name: nameValue, destination: destination };
}
watch(watch, match, temp, options) {
return new Promise((resolve, reject) => {
let ready = false;
let files = [];
this.watcher = fs.watch(match); // , { ignored: /[\/\\]\.(svn|git|DS_Store)/, persistent: watch, followSymlinks: false });
const onFileChange = async (file) => {
const fileinfo = path.parse(file);
let outPath = fileinfo.dir + path.sep + fileinfo.name;
// with subfolders
if (options.destination != null) {
outPath = path.relative(options.baseDir, outPath);
}
else { // flat
outPath = fileinfo.name;
}
log.info('Reexporting ' + outPath + fileinfo.ext);
/*switch (fileinfo.ext) {
case '.png':
case '.jpg':
case '.jpeg':
case '.hdr': {}
await this.exporter.copyImage(this.platform, file, outPath, {}, {});
break;
case '.ogg':
case '.mp3':
case '.flac':
case '.wav': {
await this.exporter.copySound(this.platform, file, outPath, {});
break;
}
case '.mp4':
case '.webm':
case '.mov':
case '.wmv':
case '.avi': {
await this.exporter.copyVideo(this.platform, file, outPath, {});
break;
}
case '.ttf':
await this.exporter.copyFont(this.platform, file, outPath, {});
break;
default:
await this.exporter.copyBlob(this.platform, file, outPath + fileinfo.ext, {});
}
for (let callback of Callbacks.postAssetReexporting) {
callback(outPath + fileinfo.ext);
}*/
};
this.watcher.on('add', (file) => {
if (ready) {
onFileChange(file);
}
else {
files.push(file);
}
});
if (watch) {
this.watcher.on('change', (file) => {
if (ready) {
onFileChange(file);
}
});
}
this.watcher.on('ready', async () => {
ready = true;
let parsedFiles = [];
let cache = {};
let cachePath = path.join(temp, 'cache.json');
if (fs.existsSync(cachePath)) {
cache = JSON.parse(fs.readFileSync(cachePath, 'utf8'));
}
const self = this;
async function convertAsset(file, index) {
let fileinfo = path.parse(file);
log.info('Exporting asset ' + (index + 1) + ' of ' + files.length + ' (' + fileinfo.base + ').');
const ext = fileinfo.ext.toLowerCase();
switch (ext) {
case '.png':
case '.jpg':
case '.jpeg':
case '.hdr': {
/*let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, Options.from);
let images: { files: string[], sizes: number[] };
/*if (options.noprocessing) {
images = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
}
else {
images = await self.exporter.copyImage(self.platform, file, exportInfo.destination, options, cache);
}
if (!options.notinlist) {
parsedFiles.push({ name: exportInfo.name, from: file, type: 'image', files: images.files, file_sizes: images.sizes, original_width: options.original_width, original_height: options.original_height, readable: options.readable });
}*/
break;
}
case '.ogg':
case '.mp3':
case '.flac':
case '.wav': {
/*let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, Options.from);
let sounds: { files: string[], sizes: number[] };
/*if (options.noprocessing) {
sounds = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
}
else {
sounds = await self.exporter.copySound(self.platform, file, exportInfo.destination, options);
}
if (sounds.files.length === 0) {
throw 'Audio file ' + file + ' could not be exported, you have to specify a path to ffmpeg.';
}
if (!options.notinlist) {
parsedFiles.push({ name: exportInfo.name, from: file, type: 'sound', files: sounds.files, file_sizes: sounds.sizes, original_width: undefined, original_height: undefined, readable: undefined });
}*/
break;
}
case '.ttf': {
/*let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, Options.from);
let fonts: { files: string[], sizes: number[] };
if (options.noprocessing) {
fonts = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
}
else {
fonts = await self.exporter.copyFont(self.platform, file, exportInfo.destination, options);
}
if (!options.notinlist) {
parsedFiles.push({ name: exportInfo.name, from: file, type: 'font', files: fonts.files, file_sizes: fonts.sizes, original_width: undefined, original_height: undefined, readable: undefined });
}*/
break;
}
case '.mp4':
case '.webm':
case '.mov':
case '.wmv':
case '.avi': {
/*let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, Options.from);
let videos: { files: string[], sizes: number[] };
if (options.noprocessing) {
videos = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
}
else {
videos = await self.exporter.copyVideo(self.platform, file, exportInfo.destination, options);
}
if (videos.files.length === 0) {
log.error('Video file ' + file + ' could not be exported, you have to specify a path to ffmpeg.');
}
if (!options.notinlist) {
parsedFiles.push({ name: exportInfo.name, from: file, type: 'video', files: videos.files, file_sizes: videos.sizes, original_width: undefined, original_height: undefined, readable: undefined });
}*/
break;
}
default: {
/*let exportInfo = AssetConverter.createExportInfo(fileinfo, true, options, Options.from);
let blobs = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
if (!options.notinlist) {
parsedFiles.push({ name: exportInfo.name, from: file, type: 'blob', files: blobs.files, file_sizes: blobs.sizes, original_width: undefined, original_height: undefined, readable: undefined });
}*/
break;
}
}
}
/*if (this.options.parallelAssetConversion !== 0) {
let todo = files.map((file, index) => {
return async () => {
await convertAsset(file, index);
};
});
let processes = this.options.parallelAssetConversion === -1
? require('os').cpus().length - 1
: this.options.parallelAssetConversion;
await Throttle.all(todo, {
maxInProgress: processes,
});
}
else {*/
let index = 0;
for (let file of files) {
await convertAsset(file, index);
index += 1;
}
//}
fs.ensureDirSync(temp);
fs.writeFileSync(cachePath, JSON.stringify(cache), { encoding: 'utf8' });
resolve(parsedFiles);
});
});
}
async run(watch, temp) {
let files = [];
for (let matcher of this.assetMatchers) {
files = files.concat(await this.watch(watch, matcher.match, temp, matcher.options));
}
return files;
}
}
exports.AssetConverter = AssetConverter;
//# sourceMappingURL=AssetConverter.js.map

File diff suppressed because one or more lines are too long

9
lib/kmake/AudioApi.js Normal file
View File

@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AudioApi = void 0;
exports.AudioApi = {
Default: 'default',
DirectSound: 'directsound',
WASAPI: 'wasapi'
};
//# sourceMappingURL=AudioApi.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"AudioApi.js","sourceRoot":"","sources":["../../kmake/src/AudioApi.ts"],"names":[],"mappings":";;;AAAW,QAAA,QAAQ,GAAG;IACrB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,MAAM,EAAE,QAAQ;CAChB,CAAC"}

38
lib/kmake/Block.js Normal file
View File

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Block = void 0;
const fs = require("fs");
class Block {
constructor(out, indentation) {
this.out = out;
this.indentation = indentation;
}
indent() {
++this.indentation;
}
unindent() {
--this.indentation;
}
tag(name, value) {
this.p('<' + name + '>' + value + '</' + name + '>');
}
tagStart(name) {
this.p('<' + name + '>');
this.indent();
}
tagEnd(name) {
this.unindent();
this.p('</' + name + '>');
}
p(line) {
if (line === undefined)
line = '';
let tabs = '';
for (let i = 0; i < this.indentation; ++i)
tabs += '\t';
let data = Buffer.from(tabs + line + '\n');
fs.writeSync(this.out, data, 0, data.length, null);
}
}
exports.Block = Block;
//# sourceMappingURL=Block.js.map

1
lib/kmake/Block.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"Block.js","sourceRoot":"","sources":["../../kmake/src/Block.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AAEzB,MAAa,KAAK;IAIjB,YAAY,GAAW,EAAE,WAAmB;QAC3C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAChC,CAAC;IAED,MAAM;QACL,EAAE,IAAI,CAAC,WAAW,CAAC;IACpB,CAAC;IAED,QAAQ;QACP,EAAE,IAAI,CAAC,WAAW,CAAC;IACpB,CAAC;IAED,GAAG,CAAC,IAAY,EAAE,KAAa;QAC9B,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,QAAQ,CAAC,IAAY;QACpB,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;IAED,MAAM,CAAC,IAAY;QAClB,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,CAAC,CAAC,IAAY;QACb,IAAI,IAAI,KAAK,SAAS;YAAE,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YAAE,IAAI,IAAI,IAAI,CAAC;QACxD,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;QAC3C,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;CACD;AAtCD,sBAsCC"}

74
lib/kmake/ClCompile.js Normal file
View File

@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClCompile = void 0;
const Block_1 = require("./Block");
const Platform_1 = require("./Platform");
function toLine(options) {
let line = '';
for (let option of options) {
line += option + ';';
}
return line;
}
class ClCompile extends Block_1.Block {
constructor(out, indentation, platform, configuration, includes, defines) {
super(out, indentation);
this.platform = platform;
this.includes = includes;
this.defines = defines;
this.minimalRebuild = false;
// PS3
this.userPreprocessorDefinitions = '';
// Xbox360
this.functionLevelLinking = false;
this.stringPooling = false;
this.prefast = false;
this.favorSize = false;
this.fastCap = false;
this.warningLevel = 3;
this.optimization = false;
this.runtimeLibrary = 'MultiThreadedDebug';
this.multiProcessorCompilation = true;
this.objectFileName = '$(IntDir)\\build\\%(RelativeDir)';
this.generateDebugInformation = false;
// this.configuration = configuration;
switch (platform) {
case Platform_1.Platform.WindowsApp:
this.includes.push('$(ProjectDir)');
this.includes.push('$(IntermediateOutputPath)');
this.includes.push('%(AdditionalIncludeDirectories)');
this.defines.push('_UNICODE');
this.defines.push('UNICODE');
this.defines.push('%(PreprocessorDefinitions)');
break;
default:
break;
}
}
print() {
let defineLine = toLine(this.defines);
let includeLine = toLine(this.includes);
this.tagStart('ClCompile');
this.tag('AdditionalIncludeDirectories', includeLine);
if (this.platform === Platform_1.Platform.Windows) {
this.tag('WarningLevel', 'Level' + this.warningLevel);
this.tag('Optimization', this.optimization ? 'Enabled' : 'Disabled');
this.tag('PreprocessorDefinitions', defineLine);
this.tag('RuntimeLibrary', this.runtimeLibrary);
this.tag('MultiProcessorCompilation', this.multiProcessorCompilation ? 'true' : 'false');
this.tag('MinimalRebuild', this.minimalRebuild ? 'true' : 'false');
this.tag('ObjectFileName', this.objectFileName);
this.tag('SDLCheck', 'true');
}
else if (this.platform === Platform_1.Platform.WindowsApp) {
// tag("PreprocessorDefinitions", defineLine);
this.tag('PrecompiledHeader', 'NotUsing');
this.tag('ObjectFileName', this.objectFileName);
this.tag('DisableSpecificWarnings', '4453');
this.tag('SDLCheck', 'true');
}
this.tagEnd('ClCompile');
}
}
exports.ClCompile = ClCompile;
//# sourceMappingURL=ClCompile.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ClCompile.js","sourceRoot":"","sources":["../../kmake/src/ClCompile.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,yCAAsC;AAEtC,SAAS,MAAM,CAAC,OAAY;IAC3B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,KAA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,CAAC,cAAc,CAAC,CAAC;YAChD,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;SAC7B;aACI,IAAI,IAAI,CAAC,QAAQ,KAAK,mBAAQ,CAAC,UAAU,EAAE;YAC/C,8CAA8C;YAC9C,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;YAC1C,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YAChD,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;YAC5C,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;SAC7B;QACD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC1B,CAAC;CACD;AAnFD,8BAmFC"}

13
lib/kmake/Compiler.js Normal file
View File

@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Compiler = void 0;
var Compiler;
(function (Compiler) {
Compiler["Default"] = "default";
Compiler["GCC"] = "gcc";
Compiler["Clang"] = "clang";
Compiler["MSVC"] = "msvc";
Compiler["MuslGcc"] = "musl-gcc";
Compiler["Custom"] = "custom";
})(Compiler = exports.Compiler || (exports.Compiler = {}));
//# sourceMappingURL=Compiler.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Compiler.js","sourceRoot":"","sources":["../../kmake/src/Compiler.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAOX;AAPD,WAAY,QAAQ;IACnB,+BAAmB,CAAA;IACnB,uBAAW,CAAA;IACX,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,gCAAoB,CAAA;IACpB,6BAAiB,CAAA;AAClB,CAAC,EAPW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAOnB"}

View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Configuration = void 0;
exports.Configuration = {
Debug: 'Debug',
CodeAnalysis: 'CodeAnalysis',
Profile: 'Profile',
Profile_FastCap: 'Profile_FastCap',
Release: 'Release',
Release_LTCG: 'Release_LTCG'
};
//# sourceMappingURL=Configuration.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../kmake/src/Configuration.ts"],"names":[],"mappings":";;;AAAW,QAAA,aAAa,GAAG;IAC1B,KAAK,EAAE,OAAO;IACd,YAAY,EAAE,cAAc;IAC5B,OAAO,EAAE,SAAS;IAClB,eAAe,EAAE,iBAAiB;IAClC,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,cAAc;CAC5B,CAAC"}

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,IAAY,EAAE,EAAU,EAAE,QAAgB,EAAE,KAAU,EAAE,OAAY;QAC1G,IAAI,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QAEjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAEzD,IAAI,YAAY,GAAG,MAAM,CAAC;QAE1B,QAAQ,OAAO,CAAC,MAAM,EAAE;YACvB,KAAK,SAAS,CAAC;YACf,KAAK,OAAO,CAAC;YACb,KAAK,SAAS,CAAC;YACf,KAAK,OAAO,CAAC;YACb,KAAK,SAAS,CAAC;YACf,KAAK,OAAO,CAAC;YACb,KAAK,SAAS,CAAC;YACf,KAAK,OAAO;gBACX,MAAM;YACP,KAAK,SAAS,CAAC;YACf,KAAK,OAAO,CAAC;YACb,KAAK,SAAS,CAAC;YACf,KAAK,OAAO;gBACX,YAAY,GAAG,MAAM,CAAC;gBACtB,MAAM;YACP,KAAK,SAAS,CAAC;YACf,KAAK,OAAO,CAAC;YACb,KAAK,SAAS,CAAC;YACf,KAAK,OAAO;gBACX,YAAY,GAAG,MAAM,CAAC;gBACtB,MAAM;YACP;gBACC,MAAM;SACP;QAED,QAAQ,OAAO,CAAC,IAAI,EAAE;YACrB,KAAK,OAAO,CAAC;YACb,KAAK,OAAO,CAAC;YACb,KAAK,KAAK,CAAC;YACX,KAAK,KAAK,CAAC;YACX,KAAK,OAAO,CAAC;YACb,KAAK,OA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,oBAAoB,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC;QAE3C,IAAI,CAAC,CAAC,CAAC,iBAAiB,GAAG,IAAI,GAAG,mBAAmB,CAAC,CAAC;QAEvD,IAAI,SAAS,GAAG,EAAE,CAAC;QACnB,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE;YAClC,SAAS,IAAI,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;SAC/B;QACD,IAAI,CAAC,CAAC,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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AAS,CAAC,CAAC;QACrD,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAE7B,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAErH,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,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,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,QAAgB;QAClD,IAAI,QAAQ,GAAG,QAAQ,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAC/B,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;SACxC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAgB,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,6B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,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;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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E,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,CAAC,OAAgB,EAAE,QAAgB;QACzC,IAAI,QAAQ,KAAK,mBAAQ,CAAC,GAAG,EAAE;YAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,WAAW,EAAE,GAAG,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

15
lib/kmake/GraphicsApi.js Normal file
View File

@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphicsApi = void 0;
exports.GraphicsApi = {
Default: 'default',
OpenGL: 'opengl',
OpenGL1: 'opengl1',
Direct3D9: 'direct3d9',
Direct3D11: 'direct3d11',
Direct3D12: 'direct3d12',
Metal: 'metal',
Vulkan: 'vulkan',
WebGPU: 'webgpu'
};
//# sourceMappingURL=GraphicsApi.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"GraphicsApi.js","sourceRoot":"","sources":["../../kmake/src/GraphicsApi.ts"],"names":[],"mappings":";;;AAAW,QAAA,WAAW,GAAG;IACxB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CAChB,CAAC"}

74
lib/kmake/Icon.js Normal file
View File

@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.exportBmp = exports.exportPng24 = exports.exportPng = exports.exportIcns = exports.exportIco = void 0;
const log = require("kmake/log");
const exec = require("kmake/exec");
const cp = require("child_process");
const fs = require("fs");
const path = require("path");
function run(from, to, width, height, format, background, small, callback) {
const exe = path.resolve(__dirname, 'kraffiti' + exec.sys());
let params = ['from=' + from, 'to=' + to, 'format=' + format, 'keepaspect'];
if (width > 0)
params.push('width=' + width);
if (height > 0)
params.push('height=' + height);
if (background !== undefined)
params.push('background=' + background.toString(16));
if (small)
params.push('small');
let child = cp.spawn(exe, params);
child.stdout.on('data', (data) => {
// log.info('kraffiti stdout: ' + data);
});
child.stderr.on('data', (data) => {
log.error('kraffiti stderr: ' + data);
});
child.on('error', (err) => {
log.error('kraffiti error: ' + err);
});
child.on('close', (code) => {
if (code !== 0)
log.error('kraffiti exited with code ' + code);
callback();
});
}
function findIcon(icon, from) {
if (icon && fs.existsSync(path.join(from, icon)))
return path.join(from, icon);
if (fs.existsSync(path.join(from, 'icon.png')))
return path.join(from, 'icon.png');
else
return path.join(__dirname, 'icon.png');
}
async function exportIco(icon, to, from, small) {
return new Promise(resolve => {
run(findIcon(icon, from.toString()), to.toString(), 0, 0, 'ico', undefined, small, resolve);
});
}
exports.exportIco = exportIco;
async function exportIcns(icon, to, from) {
return new Promise(resolve => {
run(findIcon(icon, from.toString()), to.toString(), 0, 0, 'icns', undefined, false, resolve);
});
}
exports.exportIcns = exportIcns;
async function exportPng(icon, to, width, height, background, from) {
return new Promise(resolve => {
run(findIcon(icon, from.toString()), to.toString(), width, height, 'png', background, false, resolve);
});
}
exports.exportPng = exportPng;
async function exportPng24(icon, to, width, height, background, from) {
return new Promise(resolve => {
run(findIcon(icon, from.toString()), to.toString(), width, height, 'png24', background, false, resolve);
});
}
exports.exportPng24 = exportPng24;
async function exportBmp(icon, to, width, height, background, from) {
return new Promise(resolve => {
run(findIcon(icon, from.toString()), to.toString(), width, height, 'bmp', background, false, resolve);
});
}
exports.exportBmp = exportBmp;
//# sourceMappingURL=Icon.js.map

1
lib/kmake/Icon.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../kmake/src/Icon.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,mCAAmC;AACnC,oCAAoC;AACpC,yBAAyB;AACzB,6BAA6B;AAE7B,SAAS,GAAG,CAAC,IAAY,EAAE,EAAU,EAAE,KAAa,EAAE,MAAc,EAAE,MAAc,EAAE,UAAkB,EAAE,KAAc,EAAE,QAAa;IACtI,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAE7D,IAAI,MAAM,GAAG,CAAC,OAAO,GAAG,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,YAAY,CAAC,CAAC;IAC5E,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC;IAC7C,IAAI,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;IAChD,IAAI,UAAU,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,IAAI,KAAK;QAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAElC,KAAK,CAA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MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACzG,CAAC,CAAC,CAAC;AACJ,CAAC;AAJD,kCAIC;AAEM,KAAK,UAAU,SAAS,CAAC,IAAY,EAAE,EAAU,EAAE,KAAa,EAAE,MAAc,EAAE,UAAkB,EAAE,IAAY;IACxH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC5B,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACvG,CAAC,CAAC,CAAC;AACJ,CAAC;AAJD,8BAIC"}

7
lib/kmake/Languages.js Normal file
View File

@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Languages = void 0;
exports.Languages = {
Beef: 'beef',
};
//# sourceMappingURL=Languages.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Languages.js","sourceRoot":"","sources":["../../kmake/src/Languages.ts"],"names":[],"mappings":";;;AAIW,QAAA,SAAS,GAAiB;IACpC,IAAI,EAAE,MAAM;CACZ,CAAC"}

View File

@ -0,0 +1,123 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BeefLang = void 0;
// import * as idl from 'webidl2'; // TODO
const Language_1 = require("./Language");
//import * as path from 'path';
class BeefLang extends Language_1.Language {
constructor() {
super();
}
/*async exportWrapper(tree: idl.IDLRootType[], from: string, to: string, options: any, filename: string): Promise<void> {
let p = filename.split('/');
filename = p[p.length - 1].replace('.idl', '.bf');
console.log(filename);
this.writeFile(path.resolve(to, filename));
this.p('using System;');
this.p('using System.Interop;');
this.p('using System.FFI;');
this.p('\n');
this.p('namespace ' + filename.replace('.bf', '') + '_beef\n{');
let indent = 1;
for (let node of tree) {
let type = node.type.toString();
switch (type) {
case 'enum':
let n = <idl.EnumType> node;
this.p('public enum ' + n.name + ' : int32 {', indent);
indent = 2;
for (let val of n.values) {
this.p(val.value + ',', indent);
}
indent = 1;
this.p('}', indent);
break;
case 'interface':
let struct = <idl.InterfaceType> node;
let ext = struct.inheritance !== null ? ' : ' + struct.inheritance : '';
let structType = 'struct';
for (let mem of struct.members) {
if (mem.type === 'operation') {
let opr = <idl.OperationMemberType> mem;
if (opr.name === struct.name) {
structType = 'class';
break;
}
}
}
if (structType === 'struct')
this.p('[CRepr]', indent);
this.p(structType + ' ' + struct.name + ext + '\n {', indent);
indent = 2;
for (let member of struct.members) {
if (member.type === 'attribute') {
let attr = <idl.AttributeMemberType> member;
let isRef = '';
for (let extr of attr.extAttrs) {
if (extr.name === 'Ref') {isRef = '*'; continue; }
}
let type = this.toLangType(attr.idlType.idlType.toString()) + isRef;
let first = structType === 'struct' ? '' : 'public static extern ';
this.p(first + type + ' ' + attr.name + ';', indent);
}
else if (member.type === 'operation') {
let opr = <idl.OperationMemberType> member;
// Can we even interop operator overloads ?
// for (let extAtr of opr.extAttrs) {
// let op = extAtr.rhs !== null ? extAtr.rhs.value : '';
// console.log(extAtr.name+''+op);
// }
let line = 'public static extern ' + this.toLangType(opr.idlType.idlType.toString()) + ' ' + opr.name + '(';
for (let arg of opr.arguments) {
let isRef = '';
for (let attr of arg.extAttrs) {
if (attr.name === 'Ref') {isRef = '*'; continue; }
line += ' ' + attr.name.toLowerCase();
}
line += ' ' + this.toLangType(arg.idlType.idlType.toString()) + isRef + ' ' + arg.name + ', ';
}
if (opr.arguments.length > 0)
line = line.slice(0, -1).slice(0, -1);
line += ');';
this.p(line, indent);
}
}
indent = 1;
this.p('}', indent);
}
if (type === 'eof') {
break;
}
}
this.p('}');
}*/
toLangType(idlType) {
switch (idlType) {
case 'boolean':
return 'bool';
case 'byte':
return 'char';
case 'DOMString':
return 'char8*';
case 'octet':
return 'uint8';
case 'VoidPtr' || 'any':
return 'void*';
case 'long' || 'int':
return 'c_long';
case 'unsigned short':
return 'c_ushort';
case 'unsigned long':
return 'c_ulong';
case 'long long':
return 'c_longlong';
case 'void' || 'double' || 'float':
return idlType;
default:
return idlType;
}
return '';
}
}
exports.BeefLang = BeefLang;
//# sourceMappingURL=BeefLang.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"BeefLang.js","sourceRoot":"","sources":["../../../kmake/src/Languages/BeefLang.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,yCAAsC;AACtC,+BAA+B;AAE/B,MAAa,QAAS,SAAQ,mBAAQ;IACrC;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkFG;IAEH,UAAU,CAAC,OAAe;QACzB,QAAQ,OAAO,EAAE;YAChB,KAAK,SAAS;gBACb,OAAO,MAAM,CAAC;YACf,KAAK,MAAM;gBACV,OAAO,MAAM,CAAC;YACf,KAAK,WAAW;gBACf,OAAO,QAAQ,CAAC;YACjB,KAAK,OAAO;gBACX,OAAO,OAAO,CAAC;YAChB,KAAK,SAAS,IAAI,KAAK;gBACtB,OAAO,OAAO,CAAC;YAChB,KAAK,MAAM,IAAI,KAAK;gBACnB,OAAO,QAAQ,CAAC;YACjB,KAAK,gBAAgB;gBACpB,OAAO,UAAU,CAAC;YACnB,KAAK,eAAe;gBACnB,OAAO,SAAS,CAAC;YAClB,KAAK,WAAW;gBACf,OAAO,YAAY,CAAC;YACrB,KAAK,MAAM,IAAI,QAAQ,IAAI,OAAO;gBACjC,OAAO,OAAO,CAAC;YAChB;gBACC,OAAO,OAAO,CAAC;SAChB;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD;AApHD,4BAoHC"}

View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Language = void 0;
const fs = require("../fsextra");
//import * as path from 'path';
// import * as idl from 'webidl2'; // TODO
class Language {
constructor() {
}
writeFile(file) {
this.out = fs.openSync(file, 'w');
}
closeFile() {
fs.closeSync(this.out);
}
p(line = '', indent = 0) {
let tabs = '';
for (let i = 0; i < indent; ++i)
tabs += '\t';
let data = Buffer.from(tabs + line + '\n');
fs.writeSync(this.out, data, 0, data.length, null);
}
}
exports.Language = Language;
//# sourceMappingURL=Language.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Language.js","sourceRoot":"","sources":["../../../kmake/src/Languages/Language.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,+BAA+B;AAC/B,0CAA0C;AAE1C,MAAsB,QAAQ;IAG7B;IAEA,CAAC;IAED,SAAS,CAAC,IAAY;QACrB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,SAAS;QACR,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,CAAC,CAAC,OAAe,EAAE,EAAE,SAAiB,CAAC;QACtC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC;YAAE,IAAI,IAAI,IAAI,CAAC;QAC9C,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;QAC3C,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;CASD;AA7BD,4BA6BC"}

30
lib/kmake/Options.js Normal file
View File

@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Options = void 0;
const GraphicsApi_1 = require("kmake/GraphicsApi");
const Architecture_1 = require("kmake/Architecture");
const AudioApi_1 = require("kmake/AudioApi");
const VrApi_1 = require("kmake/VrApi");
const VisualStudioVersion_1 = require("kmake/VisualStudioVersion");
const Compiler_1 = require("kmake/Compiler");
exports.Options = {
precompiledHeaders: false,
intermediateDrive: '',
graphicsApi: GraphicsApi_1.GraphicsApi.Default,
architecture: Architecture_1.Architecture.Default,
audioApi: AudioApi_1.AudioApi.Default,
vrApi: VrApi_1.VrApi.None,
compiler: Compiler_1.Compiler.Default,
ccPath: '',
cxxPath: '',
arPath: '',
stripPath: '',
visualStudioVersion: VisualStudioVersion_1.VisualStudioVersion.VS2022,
followSymbolicLinks: true,
compile: false,
run: false,
cores: 1,
debug: false,
outputIntermediateSpirv: false
};
//# sourceMappingURL=Options.js.map

1
lib/kmake/Options.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"Options.js","sourceRoot":"","sources":["../../kmake/src/Options.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,qDAAkD;AAClD,6CAA0C;AAC1C,uCAAoC;AACpC,mEAAgE;AAChE,6CAA0C;AAE/B,QAAA,OAAO,GAAG;IACpB,kBAAkB,EAAE,KAAK;IACzB,iBAAiB,EAAE,EAAE;IACrB,WAAW,EAAE,yBAAW,CAAC,OAAO;IAChC,YAAY,EAAE,2BAAY,CAAC,OAAO;IAClC,QAAQ,EAAE,mBAAQ,CAAC,OAAO;IAC1B,KAAK,EAAE,aAAK,CAAC,IAAI;IACjB,QAAQ,EAAE,mBAAQ,CAAC,OAAO;IAC1B,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,EAAE;IACb,mBAAmB,EAAE,yCAAmB,CAAC,MAAM;IAC/C,mBAAmB,EAAE,IAAI;IACzB,OAAO,EAAE,KAAK;IACd,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,KAAK;IACZ,uBAAuB,EAAE,KAAK;CAC9B,CAAC"}

24
lib/kmake/Platform.js Normal file
View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Platform = void 0;
exports.Platform = {
Windows: 'windows',
WindowsApp: 'windowsapp',
iOS: 'ios',
OSX: 'osx',
Android: 'android',
Linux: 'linux',
Emscripten: 'emscripten',
Pi: 'pi',
tvOS: 'tvos',
PS4: 'ps4',
XboxOne: 'xboxone',
Switch: 'switch',
Switch2: 'switch2',
XboxSeries: 'xboxseries',
PS5: 'ps5',
FreeBSD: 'freebsd',
Wasm: 'wasm',
Kompjuta: 'kompjuta',
};
//# sourceMappingURL=Platform.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../kmake/src/Platform.ts"],"names":[],"mappings":";;;AAqBW,QAAA,QAAQ,GAAiB;IACnC,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;IACxB,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;CACpB,CAAC"}

802
lib/kmake/Project.js Normal file
View File

@ -0,0 +1,802 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Project = exports.Define = void 0;
const path = require("path");
const fs = require("kmake/fsextra");
const log = require("kmake/log");
const GraphicsApi_1 = require("kmake/GraphicsApi");
const Architecture_1 = require("kmake/Architecture");
const AudioApi_1 = require("kmake/AudioApi");
const VrApi_1 = require("kmake/VrApi");
const Options_1 = require("kmake/Options");
const Platform_1 = require("kmake/Platform");
const crypto = require("crypto");
function getDefines(platform, rotated) {
let defines = [];
switch (platform) {
case Platform_1.Platform.iOS:
if (rotated)
defines.push('ROTATE90');
break;
case Platform_1.Platform.Android:
if (rotated)
defines.push('ROTATE90');
break;
}
return defines;
}
function contains(array, value) {
for (const element of array) {
if (element === value) {
return true;
}
}
return false;
}
function containsDefine(array, value) {
for (const element of array) {
if (element.value === value.value && element.config === value.config) {
return true;
}
}
return false;
}
function containsFancyDefine(array, value) {
const name = value.value.substring(0, value.value.indexOf('='));
for (const element of array) {
if (element.config === value.config) {
const index = element.value.indexOf('=');
if (index >= 0) {
const otherName = element.value.substring(0, index);
if (name === otherName) {
return true;
}
}
}
}
return false;
}
function isAbsolute(path) {
return (path.length > 0 && path[0] === '/') || (path.length > 1 && path[1] === ':');
}
let projectInProgress = 0;
process.on('exit', (code) => {
if (projectInProgress > 0) {
process.exitCode = 1;
log.error('Error: kfile did not call resolve, no project created.');
}
});
let scriptdir = '.';
// let lastScriptDir = '.';
let cppEnabled = false;
function findKore() {
return Project.koreDir;
}
async function loadProject(directory, parent, options = {}, korefile = null) {
return new Promise((resolve, reject) => {
projectInProgress += 1;
let resolver = async (project) => {
projectInProgress -= 1;
// TODO: This accidentally finds Kha/Backends/KoreHL
/*if (fs.existsSync(path.join(scriptdir, 'Backends'))) {
var libdirs = fs.readdirSync(path.join(scriptdir, 'Backends'));
for (var ld in libdirs) {
var libdir = path.join(scriptdir, 'Backends', libdirs[ld]);
if (fs.statSync(libdir).isDirectory()) {
var korefile = path.join(libdir, korefile);
if (fs.existsSync(korefile)) {
project.addSubProject(await Project.createProject(libdir, scriptdir));
}
}
}
}*/
resolve(project);
};
try {
scriptdir = directory;
if (!korefile) {
if (fs.existsSync(path.resolve(directory, 'kfile.js'))) {
korefile = 'kfile.js';
}
else if (fs.existsSync(path.resolve(directory, 'kincfile.js'))) {
korefile = 'kincfile.js';
}
else if (fs.existsSync(path.resolve(directory, 'korefile.js'))) {
korefile = 'korefile.js';
cppEnabled = true;
}
}
let file = fs.readFileSync(path.resolve(directory, korefile), 'utf8');
let AsyncFunction = Object.getPrototypeOf(async () => { }).constructor;
Project.currentParent = parent;
let project = new AsyncFunction('log', 'Project', 'Platform', 'platform', 'GraphicsApi', 'graphics', 'Architecture', 'arch', 'AudioApi', 'audio', 'VrApi', 'vr', 'cpp', 'require', 'resolve', 'reject', '__dirname', 'Options', 'targetDirectory', 'parentProject', 'findKore', 'findKinc', file)(log, Project, Platform_1.Platform, Project.platform, GraphicsApi_1.GraphicsApi, Options_1.Options.graphicsApi, Architecture_1.Architecture, Options_1.Options.architecture, AudioApi_1.AudioApi, Options_1.Options.audioApi, VrApi_1.VrApi, Options_1.Options.vrApi, cppEnabled, require, resolver, reject, directory, options, Project.to, parent, findKore, findKore).catch((error) => {
log.error(error);
reject();
});
}
catch (error) {
log.error(error);
reject();
}
});
}
class Define {
}
exports.Define = Define;
class Project {
createHash(vscode, json, debug, platform) {
const sha = crypto.createHash('sha1');
const uuid = this.uuid;
this.uuid = '';
sha.update(JSON.stringify(this));
this.uuid = uuid;
sha.update(vscode ? 'true' : 'false');
sha.update(json ? 'true' : 'false');
sha.update(debug ? 'true' : 'false');
sha.update(platform);
return sha.digest('hex');
}
constructor(name) {
this.cppStd = '';
this.cStd = '';
this.cmdArgs = [];
this.cFlags = [];
this.cppFlags = [];
this.linkerFlags = [];
this.icon = null;
this.livePP = null;
this.additionalBackends = [];
this.vsdeploy = false;
this.linkTimeOptimization = true;
this.macOSnoArm = false;
this.noFlatten = true;
this.isStaticLib = false;
this.isDynamicLib = false;
this.kope = false;
this.name = name;
this.parent = Project.currentParent;
this.safeName = name.replace(/[^A-z0-9\-\_]/g, '-');
this.version = '1.0';
this.debugDir = '';
this.basedir = scriptdir;
this.uuid = crypto.randomUUID();
this.files = [];
this.IDLfiles = [];
this.customs = [];
this.javadirs = [];
this.subProjects = [];
this.includeDirs = [];
this.defines = [];
this.libs = [];
this.kongDirs = [];
this.systemDependendLibraries = {};
this.includes = [];
this.excludes = [];
this.cppStd = '';
this.cStd = '';
this.kore = true;
this.targetOptions = {
android: {},
xboxOne: {},
playStation4: {},
switch: {},
switch2: {},
xboxSeriesXS: {},
playStation5: {},
stadia: {},
emscripten: {}
};
this.rotated = false;
this.cmd = false;
this.stackSize = 0;
this.koreProcessed = false;
this.executableName = null;
}
setExecutableName(name) {
this.executableName = name;
}
getExecutableName() {
return this.executableName;
}
addBackend(name) {
this.additionalBackends.push(name);
}
findAdditionalBackends(additionalBackends) {
for (const backend of this.additionalBackends) {
additionalBackends.push(backend);
}
for (let sub of this.subProjects) {
sub.findAdditionalBackends(additionalBackends);
}
}
findKoreProject() {
if (this.name === 'Kore') {
return this;
}
if (this.name === 'Kinc') {
return this;
}
for (let sub of this.subProjects) {
let kore = sub.findKoreProject();
if (kore != null) {
return kore;
}
}
return null;
}
resolveBackends() {
let additionalBackends = [];
this.findAdditionalBackends(additionalBackends);
let kore = this.findKoreProject();
for (const backend of additionalBackends) {
kore.addFile('Backends/' + backend + '/Sources/k3/**', null);
kore.addFile('Backends/' + backend + '/Sources/kinc/**', null);
kore.addFile('Backends/' + backend + '/Sources/GL/**', null);
kore.addFile('Backends/' + backend + '/Sources/Android/**', null);
//if (Options.kope) {
// kore.addFile('Backends/' + backend + '/Sources/kope/**', {nocompile: true});
// kore.addFile('Backends/' + backend + '/Sources/kope/**/*unit.c*', null);
//}
kore.addIncludeDir('Backends/' + backend + '/Sources');
}
}
flattenSubProjects() {
for (let sub of this.subProjects) {
sub.noFlatten = false;
sub.flattenSubProjects();
}
}
flatten() {
this.noFlatten = false;
this.flattenSubProjects();
}
internalFlatten() {
let out = [];
for (let sub of this.subProjects)
sub.internalFlatten();
for (let sub of this.subProjects) {
if (sub.noFlatten) {
out.push(sub);
}
else {
if (sub.kope) {
this.kope = true;
}
if (sub.cppStd !== '') {
this.cppStd = sub.cppStd;
}
if (sub.cStd !== '') {
this.cStd = sub.cStd;
}
if (sub.cmd) {
this.cmd = true;
}
if (sub.vsdeploy) {
this.vsdeploy = true;
}
if (!sub.linkTimeOptimization) {
this.linkTimeOptimization = false;
}
if (sub.macOSnoArm) {
this.macOSnoArm = true;
}
if (this.shaderVersion) {
if (sub.shaderVersion && sub.shaderVersion > this.shaderVersion) {
this.shaderVersion = sub.shaderVersion;
}
}
else if (sub.shaderVersion) {
this.shaderVersion = sub.shaderVersion;
}
if (sub.livePP) {
this.livePP = this.livePP;
}
let subbasedir = sub.basedir;
for (let tkey of Object.keys(sub.targetOptions)) {
const target = sub.targetOptions[tkey];
for (let key of Object.keys(target)) {
const options = this.targetOptions[tkey];
const option = target[key];
if (options[key] == null)
options[key] = option;
// push library properties to current array instead
else if (Array.isArray(options[key]) && Array.isArray(option)) {
for (let value of option) {
if (!options[key].includes(value))
options[key].push(value);
}
}
}
}
for (let d of sub.defines) {
if (d.value.indexOf('=') >= 0) {
if (!containsFancyDefine(this.defines, d)) {
this.defines.push(d);
}
}
else {
if (!containsDefine(this.defines, d)) {
this.defines.push(d);
}
}
}
for (let file of sub.files) {
let absolute = file.file;
if (!path.isAbsolute(absolute)) {
absolute = path.join(subbasedir, file.file);
}
let subFileExist = false;
let subFile = absolute.replace(/\\/g, '/');
for (let mainFile of this.files) {
subFileExist = mainFile.file == subFile;
if (subFileExist) {
break;
}
}
if (subFileExist) {
continue;
}
this.files.push({ file: subFile, options: file.options, projectDir: subbasedir, projectName: sub.name });
}
for (const custom of sub.customs) {
let absolute = custom.file;
if (!path.isAbsolute(absolute)) {
absolute = path.join(subbasedir, custom.file);
}
this.customs.push({ file: absolute.replace(/\\/g, '/'), command: custom.command, output: custom.output });
}
for (let i of sub.includeDirs)
if (!contains(this.includeDirs, path.resolve(subbasedir, i)))
this.includeDirs.push(path.resolve(subbasedir, i));
for (let j of sub.javadirs)
if (!contains(this.javadirs, path.resolve(subbasedir, j)))
this.javadirs.push(path.resolve(subbasedir, j));
for (let k of sub.kongDirs)
if (!contains(this.kongDirs, path.resolve(subbasedir, k)))
this.kongDirs.push(path.resolve(subbasedir, k));
for (let lib of sub.libs) {
if (lib.indexOf('/') < 0 && lib.indexOf('\\') < 0) {
if (!contains(this.libs, lib))
this.libs.push(lib);
}
else {
if (!contains(this.libs, path.resolve(subbasedir, lib)))
this.libs.push(path.resolve(subbasedir, lib));
}
}
for (let system in sub.systemDependendLibraries) {
let libs = sub.systemDependendLibraries[system];
for (let lib of libs) {
if (this.systemDependendLibraries[system] === undefined)
this.systemDependendLibraries[system] = [];
if (!contains(this.systemDependendLibraries[system], this.stringify(path.resolve(subbasedir, lib)))) {
if (!contains(lib, '/') && !contains(lib, '\\'))
this.systemDependendLibraries[system].push(lib);
else
this.systemDependendLibraries[system].push(this.stringify(path.resolve(subbasedir, lib)));
}
}
}
for (let flag of sub.cFlags) {
if (!this.cFlags.includes(flag)) {
this.cFlags.push(flag);
}
}
for (let flag of sub.cppFlags) {
if (!this.cppFlags.includes(flag)) {
this.cppFlags.push(flag);
}
}
for (let flag of sub.linkerFlags) {
if (!this.linkerFlags.includes(flag)) {
this.linkerFlags.push(flag);
}
}
}
}
this.subProjects = out;
}
getName() {
return this.name;
}
getSafeName() {
return this.safeName;
}
getUuid() {
return this.uuid;
}
matches(text, pattern) {
const regexstring = pattern.replace(/\./g, '\\.').replace(/\*\*/g, '.?').replace(/\*/g, '[^/]*').replace(/\?/g, '*');
const regex = new RegExp('^' + regexstring + '$', 'g');
return regex.test(text);
}
matchesAllSubdirs(dir, pattern) {
if (pattern.endsWith('/**')) {
return this.matches(this.stringify(dir), pattern.substr(0, pattern.length - 3));
}
else
return false;
}
stringify(path) {
return path.replace(/\\/g, '/');
}
addCFlag(flag) {
this.cFlags.push(flag);
}
addCFlags() {
for (let i = 0; i < arguments.length; ++i) {
if (typeof arguments[i] === 'string') {
this.addCFlag(arguments[i]);
}
}
}
addCppFlag(flag) {
this.cppFlags.push(flag);
}
addCppFlags() {
for (let i = 0; i < arguments.length; ++i) {
if (typeof arguments[i] === 'string') {
this.addCppFlag(arguments[i]);
}
}
}
addLinkerFlag(flag) {
this.linkerFlags.push(flag);
}
addLinkerFlags() {
for (let i = 0; i < arguments.length; ++i) {
if (typeof arguments[i] === 'string') {
this.addLinkerFlag(arguments[i]);
}
}
}
addFileForReal(file, options) {
for (let index in this.files) {
if (this.files[index].file === file) {
this.files[index] = { file: file, options: options, projectDir: this.basedir, projectName: this.name };
return;
}
}
this.files.push({ file: file, options: options, projectDir: this.basedir, projectName: this.name });
}
searchFiles(current) {
if (current === undefined) {
for (let sub of this.subProjects)
sub.searchFiles(undefined);
this.searchFiles(this.basedir);
for (let includeobject of this.includes) {
if (path.isAbsolute(includeobject.file) && includeobject.file.includes('**')) {
const starIndex = includeobject.file.indexOf('**');
const endIndex = includeobject.file.substring(0, starIndex).replace(/\\/g, '/').lastIndexOf('/');
this.searchFiles(includeobject.file.substring(0, endIndex));
}
if (includeobject.file.startsWith('../')) {
let startNext = '../';
let start = '../';
while (includeobject.file.startsWith(startNext)) {
start = startNext;
startNext += '../';
}
this.searchFiles(path.resolve(this.basedir, start));
}
}
// std::set<std::string> starts;
// for (std::string include : includes) {
// if (!isAbsolute(include)) continue;
// std::string start = include.substr(0, firstIndexOf(include, '*'));
// if (starts.count(start) > 0) continue;
// starts.insert(start);
// searchFiles(Paths::get(start));
// }
return;
}
let files = fs.readdirSync(current);
nextfile: for (let f in files) {
let file = path.join(current, files[f]);
let follow = true;
try {
if (fs.statSync(file).isDirectory()) {
follow = false;
}
}
catch (err) {
follow = false;
}
if (!follow) {
continue;
}
// if (!current.isAbsolute())
file = path.relative(this.basedir, file);
for (let exclude of this.excludes) {
if (this.matches(this.stringify(file), exclude)) {
continue nextfile;
}
}
for (let includeobject of this.includes) {
let include = includeobject.file;
if (isAbsolute(include)) {
let inc = include;
inc = path.relative(this.basedir, inc);
include = inc;
}
if (this.matches(this.stringify(file), this.stringify(include))) {
this.addFileForReal(this.stringify(file), includeobject.options);
}
}
}
let dirs = fs.readdirSync(current);
nextdir: for (let d of dirs) {
let dir = path.join(current, d);
if (d.startsWith('.'))
continue;
let follow = true;
try {
const stats = fs.statSync(dir);
if (!stats.isDirectory()) {
follow = false;
}
if (!Options_1.Options.followSymbolicLinks && stats.isSymbolicLink()) {
follow = false;
}
}
catch (err) {
follow = false;
}
if (!follow) {
continue;
}
for (let exclude of this.excludes) {
if (this.matchesAllSubdirs(path.relative(this.basedir, dir), exclude)) {
continue nextdir;
}
}
this.searchFiles(dir);
}
}
addFile(file, options) {
this.includes.push({ file: file, options: options });
}
addCustomFile(file, command, output) {
this.customs.push({ file, command, output });
}
addFiles() {
let options = undefined;
for (let i = 0; i < arguments.length; ++i) {
if (typeof arguments[i] !== 'string') {
options = arguments[i];
}
}
for (let i = 0; i < arguments.length; ++i) {
if (typeof arguments[i] === 'string') {
this.addFile(arguments[i], options);
}
}
}
addIdlDef() {
for (let i = 0; i < arguments.length; ++i) {
if (typeof arguments[i] === 'string') {
this.IDLfiles.push(arguments[i]);
}
}
}
addJavaDir(dir) {
this.javadirs.push(dir);
}
addJavaDirs() {
for (let i = 0; i < arguments.length; ++i) {
this.addJavaDir(arguments[i]);
}
}
addExclude(exclude) {
this.excludes.push(exclude);
}
addExcludes() {
for (let i = 0; i < arguments.length; ++i) {
this.addExclude(arguments[i]);
}
}
addDefine(value, config = null) {
const define = { value, config };
if (containsDefine(this.defines, define)) {
return;
}
this.defines.push(define);
}
addDefines() {
for (let i = 0; i < arguments.length; ++i) {
this.addDefine(arguments[i]);
}
}
addDefineFor(system, define) {
if (this.systemDependendDefines[system] === undefined)
this.systemDependendDefines[system] = [];
this.systemDependendDefines[system].push(define);
}
addDefinesFor() {
if (this.systemDependendDefines[arguments[0]] === undefined)
this.systemDependendDefines[arguments[0]] = [];
for (let i = 1; i < arguments.length; ++i) {
this.systemDependendDefines[arguments[0]].push(arguments[i]);
}
}
removeDefine(value, config = null) {
this.defines = this.defines.filter((element) => {
if (element.value === value && element.config === config) {
return false;
}
return true;
});
}
addIncludeDir(include) {
if (contains(this.includeDirs, include))
return;
this.includeDirs.push(include);
}
addIncludeDirs() {
for (let i = 0; i < arguments.length; ++i) {
this.addIncludeDir(arguments[i]);
}
}
addLib(lib) {
this.libs.push(lib);
}
addLibs() {
for (let i = 0; i < arguments.length; ++i) {
this.addLib(arguments[i]);
}
}
addLibFor(system, lib) {
if (this.systemDependendLibraries[system] === undefined)
this.systemDependendLibraries[system] = [];
this.systemDependendLibraries[system].push(lib);
}
addLibsFor() {
if (this.systemDependendLibraries[arguments[0]] === undefined)
this.systemDependendLibraries[arguments[0]] = [];
for (let i = 1; i < arguments.length; ++i) {
this.systemDependendLibraries[arguments[0]].push(arguments[i]);
}
}
addKongDir(dir) {
this.kongDirs.push(dir);
this.addDefine('KORE_KONG');
}
addKongDirs() {
for (let i = 0; i < arguments.length; ++i) {
this.addKongDir(arguments[i]);
}
}
getFiles() {
return this.files;
}
getJavaDirs() {
return this.javadirs;
}
getKongDirs() {
return this.kongDirs;
}
getBasedir() {
return this.basedir;
}
getSubProjects() {
return this.subProjects;
}
getIncludeDirs() {
return this.includeDirs;
}
getDefines() {
return this.defines;
}
getLibs() {
return this.libs;
}
getLibsFor(system) {
if (this.systemDependendLibraries[system] === undefined)
return [];
return this.systemDependendLibraries[system];
}
getDebugDir() {
return this.debugDir;
}
setDebugDir(debugDir) {
this.debugDir = path.resolve(this.basedir, debugDir);
if (!fs.existsSync(this.debugDir)) {
throw new Error(`Debug directory ${this.debugDir} does not exist`);
}
}
getCppStd() {
return this.cppStd;
}
setCppStd(std) {
this.cppStd = std;
}
getCStd() {
return this.cStd;
}
setCStd(std) {
this.cStd = std;
}
getParentProjet() {
return this.parent;
}
getRootProject() {
if (!this.parent) {
return this;
}
return this.parent.getRootProject();
}
addLivePP(livePP) {
this.livePP = livePP;
}
async addProject(directory, options = {}, projectFile = null) {
let from = path.isAbsolute(directory) ? directory : path.join(this.basedir, directory);
if (fs.existsSync(from) && fs.statSync(from).isDirectory()) {
const project = await loadProject(from, this, options, projectFile);
if (options.kope) {
project.kope = true;
}
this.subProjects.push(project);
return project;
}
else {
throw 'Project directory ' + from + ' not found';
}
}
static async create(directory, to, platform, korefile, retro, veryretro, options = {}) {
Project.platform = platform;
Project.to = path.resolve(to);
try {
let project = await loadProject(path.resolve(directory), null, options, korefile);
if (retro && project.kore && !project.koreProcessed) {
if (veryretro) {
if (Project.koreDir) {
await project.addProject(Project.koreDir);
}
}
else {
await project.addProject(Project.koreDir);
}
project.flatten();
}
let defines = getDefines(platform, project.isRotated());
for (let define of defines) {
project.addDefine(define);
}
return project;
}
catch (err) {
throw 'Could not create project ' + directory;
}
}
isRotated() {
return this.rotated;
}
isCmd() {
return this.cmd;
}
setRotated() {
this.rotated = true;
}
setCmd() {
this.cmd = true;
}
set cpp(value) {
cppEnabled = value;
}
setMinimumShaderVersion(version) {
this.shaderVersion = version;
}
// deprecated
static createProject() {
log.info('Warning: createProject was removed, see updates.md for instructions.');
return new Promise((resolve, reject) => {
resolve();
});
}
// deprecated
addSubProject() {
}
}
exports.Project = Project;
Project.currentParent = null;
//# sourceMappingURL=Project.js.map

1
lib/kmake/Project.js.map Normal file

File diff suppressed because one or more lines are too long

410
lib/kmake/ShaderCompiler.js Normal file
View File

@ -0,0 +1,410 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShaderCompiler = exports.CompiledShader = void 0;
const child_process = require("child_process");
const fs = require("kmake/fsextra");
const path = require("path");
const GraphicsApi_1 = require("kmake/GraphicsApi");
const Options_1 = require("kmake/Options");
const Platform_1 = require("kmake/Platform");
const log = require("kmake/log");
class CompiledShader {
constructor() {
this.files = [];
this.inputs = [];
this.outputs = [];
this.uniforms = [];
this.types = [];
this.noembed = false;
}
}
exports.CompiledShader = CompiledShader;
class ShaderCompiler {
constructor(platform, compiler, to, temp, builddir, shaderMatchers) {
if (platform.endsWith('-native'))
platform = platform.substr(0, platform.length - '-native'.length);
if (platform.endsWith('-hl'))
platform = platform.substr(0, platform.length - '-hl'.length);
this.platform = platform;
this.compiler = compiler;
this.type = ShaderCompiler.findType(platform);
this.to = to;
this.temp = temp;
this.builddir = builddir;
this.shaderMatchers = shaderMatchers;
}
close() {
if (this.watcher)
this.watcher.close();
}
static findType(platform) {
switch (platform) {
case Platform_1.Platform.Android:
if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Vulkan || Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Default) {
return 'spirv';
}
else if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.OpenGL) {
return 'essl';
}
else {
throw new Error('Unsupported shader language.');
}
case Platform_1.Platform.Emscripten:
case Platform_1.Platform.Wasm:
case Platform_1.Platform.Pi:
return 'essl';
case Platform_1.Platform.tvOS:
case Platform_1.Platform.iOS:
if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Metal || Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Default) {
return 'metal';
}
else if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.OpenGL) {
return 'essl';
}
else {
throw new Error('Unsupported shader language.');
}
case Platform_1.Platform.Windows:
if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Vulkan) {
return 'spirv';
}
else if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.OpenGL) {
return 'glsl';
}
else if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Direct3D11 || Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Direct3D12 || Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Default) {
return 'd3d11';
}
else if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Direct3D9) {
return 'd3d9';
}
else {
throw new Error('Unsupported shader language.');
}
case Platform_1.Platform.WindowsApp:
return 'd3d11';
case Platform_1.Platform.Linux:
if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Vulkan || Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Default) {
return 'spirv';
}
else if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.OpenGL) {
return 'glsl';
}
else {
throw new Error('Unsupported shader language.');
}
case Platform_1.Platform.OSX:
if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Metal || Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.Default) {
return 'metal';
}
else if (Options_1.Options.graphicsApi === GraphicsApi_1.GraphicsApi.OpenGL) {
return 'glsl';
}
else {
throw new Error('Unsupported shader language.');
}
case Platform_1.Platform.FreeBSD:
return 'glsl';
default:
return platform;
}
}
watch(watch, match, options, recompileAll) {
return new Promise((resolve, reject) => {
let shaders = [];
let ready = false;
this.watcher = fs.watch(match); // chokidar.watch(match, { ignored: /[\/\\]\.(git|DS_Store)/, persistent: watch });
this.watcher.on('add', (filepath) => {
let file = path.parse(filepath);
if (ready) {
switch (file.ext) {
case '.glsl':
if (!file.name.endsWith('.inc') && this.isSupported(file.name)) {
log.info('Compiling ' + file.name);
this.compileShader(filepath, options, recompileAll);
}
break;
}
}
else {
switch (file.ext) {
case '.glsl':
if (!file.name.endsWith('.inc')) {
shaders.push(filepath);
}
break;
}
}
});
if (watch) {
this.watcher.on('change', (filepath) => {
let file = path.parse(filepath);
switch (file.ext) {
case '.glsl':
if (!file.name.endsWith('.inc') && this.isSupported(file.name)) {
log.info('Recompiling ' + file.name);
this.compileShader(filepath, options, recompileAll);
}
break;
}
});
}
this.watcher.on('unlink', (file) => {
});
this.watcher.on('ready', async () => {
ready = true;
let compiledShaders = [];
const self = this;
async function compile(shader, index) {
let parsed = path.parse(shader);
if (self.isSupported(shader)) {
log.info('Compiling shader ' + (index + 1) + ' of ' + shaders.length + ' (' + parsed.base + ').');
let compiledShader = null;
try {
compiledShader = await self.compileShader(shader, options, recompileAll);
}
catch (error) {
log.error('Compiling shader ' + (index + 1) + ' of ' + shaders.length + ' (' + parsed.base + ') failed:');
log.error(error);
return Promise.reject(error);
}
if (compiledShader === null) {
compiledShader = new CompiledShader();
compiledShader.noembed = options.noembed;
// mark variables as invalid, so they are loaded from previous compilation
compiledShader.files = null;
compiledShader.inputs = null;
compiledShader.outputs = null;
compiledShader.uniforms = null;
compiledShader.types = null;
}
if (compiledShader.files != null && compiledShader.files.length === 0) {
// TODO: Remove when krafix has been recompiled everywhere
compiledShader.files.push(parsed.name + '.' + self.type);
}
compiledShader.name = parsed.name; //AssetConverter.createExportInfo(parsed, false, options, Options.from).name;
compiledShaders.push(compiledShader);
}
else {
log.info('Skipping shader ' + (index + 1) + ' of ' + shaders.length + ' (' + parsed.base + ').');
}
++index;
return Promise.resolve();
}
/*if (Options.parallelAssetConversion !== 0) {
let todo = shaders.map((shader, index) => {
return async () => {
await compile(shader, index);
};
});
let processes = Options.parallelAssetConversion === -1
? require('os').cpus().length - 1
: this.options.parallelAssetConversion;
await Throttle.all(todo, {
maxInProgress: processes,
});
}
else {*/
let index = 0;
for (let shader of shaders) {
try {
await compile(shader, index);
}
catch (err) {
reject();
return;
}
index += 1;
}
//}
resolve(compiledShaders);
return;
});
});
}
async run(watch, recompileAll) {
let shaders = [];
for (let matcher of this.shaderMatchers) {
shaders = shaders.concat(await this.watch(watch, matcher.match, matcher.options, recompileAll));
}
return shaders;
}
isSupported(file) {
if (file.endsWith('.frag.glsl') || file.endsWith('.vert.glsl')) {
return true;
}
return this.type !== 'essl' && this.type !== 'agal';
}
compileShader(file, options, recompile) {
return new Promise((resolve, reject) => {
if (!this.compiler)
reject('No shader compiler found.');
if (this.type === 'none') {
resolve(new CompiledShader());
return;
}
let fileinfo = path.parse(file);
let from = file;
let to = path.join(this.to, fileinfo.name + '.' + this.type);
let temp = to + '.temp';
fs.stat(from, (fromErr, fromStats) => {
fs.stat(to, (toErr, toStats) => {
if (options.noprocessing) {
if (!toStats || toStats.mtime.getTime() < fromStats.mtime.getTime()) {
fs.copyFileSync(from, to);
}
let compiledShader = new CompiledShader();
compiledShader.noembed = options.noembed;
resolve(compiledShader);
return;
}
fs.stat(this.compiler, (compErr, compStats) => {
if (!recompile && (fromErr || (!toErr && toStats.mtime.getTime() > fromStats.mtime.getTime() && toStats.mtime.getTime() > compStats.mtime.getTime()))) {
if (fromErr)
log.error('Shader compiler error: ' + fromErr);
resolve(null);
}
else {
if (this.type === 'metal') {
fs.ensureDirSync(path.join(this.builddir, 'Sources'));
let funcname = fileinfo.name;
funcname = funcname.replace(/-/g, '_');
funcname = funcname.replace(/\./g, '_');
funcname += '_main';
fs.writeFileSync(to, '>' + funcname, 'utf8');
to = path.join(this.builddir, 'Sources', fileinfo.name + '.' + this.type);
temp = to;
}
let parameters = [this.type === 'hlsl' ? 'd3d9' : this.type, from, temp, this.temp, this.platform];
// if (Options.shaderversion) {
// parameters.push('--version');
// parameters.push(Options.shaderversion);
// }
if (Options_1.Options.debug) {
parameters.push('--debug');
}
if (options.defines) {
for (let define of options.defines) {
parameters.push('-D' + define);
}
}
if (this.platform === Platform_1.Platform.Emscripten || this.platform === Platform_1.Platform.Android) {
parameters.push('--relax');
}
parameters[1] = path.resolve(parameters[1]);
parameters[2] = path.resolve(parameters[2]);
parameters[3] = path.resolve(parameters[3]);
let child = child_process.spawn(this.compiler, parameters);
let errorLine = '';
let newErrorLine = true;
let errorData = false;
let compiledShader = new CompiledShader();
compiledShader.noembed = options.noembed;
function parseData(data) {
data = data.replace(':\\', '#\\'); // Filter out absolute paths on Windows
let parts = data.split(':');
if (parts.length >= 3) {
if (parts[0] === 'uniform') {
compiledShader.uniforms.push({ name: parts[1], type: parts[2] });
}
else if (parts[0] === 'input') {
compiledShader.inputs.push({ name: parts[1], type: parts[2] });
}
else if (parts[0] === 'output') {
compiledShader.outputs.push({ name: parts[1], type: parts[2] });
}
else if (parts[0] === 'type') {
let type = data.substring(data.indexOf(':') + 1);
let name = type.substring(0, type.indexOf(':'));
let typedata = type.substring(type.indexOf(':') + 2);
typedata = typedata.substr(0, typedata.length - 1);
let members = typedata.split(',');
let memberdecls = [];
for (let member of members) {
let memberparts = member.split(':');
memberdecls.push({ type: memberparts[1], name: memberparts[0] });
}
compiledShader.types.push({ name: name, members: memberdecls });
}
}
else if (parts.length >= 2) {
if (parts[0] === 'file') {
const parsed = path.parse(parts[1].replace('#\\', ':\\'));
let name = parsed.name;
if (parsed.ext !== '.temp')
name += parsed.ext;
compiledShader.files.push(name);
}
}
}
let stdOutString = '';
child.stdout.on('data', (data) => {
stdOutString += data.toString();
});
child.stderr.on('data', (data) => {
let str = data.toString();
for (let char of str) {
if (char === '\n') {
if (errorData) {
parseData(errorLine.trim());
}
else {
log.error(errorLine.trim());
}
errorLine = '';
newErrorLine = true;
errorData = false;
}
else if (newErrorLine && char === '#') {
errorData = true;
newErrorLine = false;
}
else {
errorLine += char;
newErrorLine = false;
}
}
});
child.on('close', (code) => {
if (stdOutString) {
if (code === 0) {
log.info(stdOutString);
}
else {
log.error(stdOutString);
}
}
if (errorLine.trim().length > 0) {
if (errorData) {
parseData(errorLine.trim());
}
else {
log.error(errorLine.trim());
}
}
if (code === 0) {
if (this.type !== 'metal') {
if (compiledShader.files === null || compiledShader.files.length === 0) {
fs.renameSync(temp, to);
}
for (let file of compiledShader.files) {
fs.renameSync(path.join(this.to, file + '.temp'), path.join(this.to, file));
}
}
resolve(compiledShader);
}
else {
process.exitCode = 1;
reject('Shader compiler error.');
}
});
}
});
});
});
});
}
}
exports.ShaderCompiler = ShaderCompiler;
//# sourceMappingURL=ShaderCompiler.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VisualStudioVersion = void 0;
exports.VisualStudioVersion = {
VS2010: 'vs2010',
VS2012: 'vs2012',
VS2013: 'vs2013',
VS2015: 'vs2015',
VS2017: 'vs2017',
VS2019: 'vs2019',
VS2022: 'vs2022',
VS2026: 'vs2026'
};
//# sourceMappingURL=VisualStudioVersion.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"VisualStudioVersion.js","sourceRoot":"","sources":["../../kmake/src/VisualStudioVersion.ts"],"names":[],"mappings":";;;AAAW,QAAA,mBAAmB,GAAG;IAChC,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CAChB,CAAC"}

12
lib/kmake/VrApi.js Normal file
View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VrApi = void 0;
exports.VrApi = {
GearVr: 'gearvr',
Cardboard: 'cardboard',
Oculus: 'oculus',
SteamVR: 'steamvr',
HoloLens: 'hololens',
None: 'none'
};
//# sourceMappingURL=VrApi.js.map

1
lib/kmake/VrApi.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"VrApi.js","sourceRoot":"","sources":["../../kmake/src/VrApi.ts"],"names":[],"mappings":";;;AAAW,QAAA,KAAK,GAAG;IAClB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;CACZ,CAAC"}

14
lib/kmake/exec.js Normal file
View File

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sys = void 0;
const os = require("os");
function sys() {
if (os.platform() === 'win32') {
return '.exe';
}
else {
return '';
}
}
exports.sys = sys;
//# sourceMappingURL=exec.js.map

1
lib/kmake/exec.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../kmake/src/exec.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AAEzB,SAAgB,GAAG;IAClB,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,EAAE;QAC9B,OAAO,MAAM,CAAC;KACd;SACI;QACJ,OAAO,EAAE,CAAC;KACV;AACF,CAAC;AAPD,kBAOC"}

46
lib/kmake/fsextra.js Normal file
View File

@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.copyDirSync = exports.ensureDirSync = exports.watch = exports.Stats = exports.stat = exports.renameSync = exports.chmodSync = exports.copyFileSync = exports.closeSync = exports.writeSync = exports.openSync = exports.readFileSync = exports.writeFileSync = exports.statSync = exports.readdirSync = exports.existsSync = void 0;
const log = require("kmake/log");
const fs_1 = require("fs");
Object.defineProperty(exports, "copyFileSync", { enumerable: true, get: function () { return fs_1.copyFileSync; } });
Object.defineProperty(exports, "existsSync", { enumerable: true, get: function () { return fs_1.existsSync; } });
Object.defineProperty(exports, "readdirSync", { enumerable: true, get: function () { return fs_1.readdirSync; } });
Object.defineProperty(exports, "statSync", { enumerable: true, get: function () { return fs_1.statSync; } });
Object.defineProperty(exports, "writeFileSync", { enumerable: true, get: function () { return fs_1.writeFileSync; } });
Object.defineProperty(exports, "readFileSync", { enumerable: true, get: function () { return fs_1.readFileSync; } });
Object.defineProperty(exports, "openSync", { enumerable: true, get: function () { return fs_1.openSync; } });
Object.defineProperty(exports, "writeSync", { enumerable: true, get: function () { return fs_1.writeSync; } });
Object.defineProperty(exports, "closeSync", { enumerable: true, get: function () { return fs_1.closeSync; } });
Object.defineProperty(exports, "chmodSync", { enumerable: true, get: function () { return fs_1.chmodSync; } });
Object.defineProperty(exports, "renameSync", { enumerable: true, get: function () { return fs_1.renameSync; } });
Object.defineProperty(exports, "stat", { enumerable: true, get: function () { return fs_1.stat; } });
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return fs_1.Stats; } });
Object.defineProperty(exports, "watch", { enumerable: true, get: function () { return fs_1.watch; } });
const path = require("path");
function ensureDirSync(dir) {
try {
if (!(0, fs_1.existsSync)(dir)) {
(0, fs_1.mkdirSync)(dir, { recursive: true });
}
}
catch (err) {
log.error(`Error creating directory ${dir}: ${err}`);
}
}
exports.ensureDirSync = ensureDirSync;
function copyDirSync(from, to) {
ensureDirSync(to);
const files = (0, fs_1.readdirSync)(from);
for (const file of files) {
const stat = (0, fs_1.statSync)(path.join(from, file));
if (stat.isDirectory()) {
copyDirSync(path.join(from, file), path.join(to, file));
}
else {
(0, fs_1.copyFileSync)(path.join(from, file), path.join(to, file));
}
}
}
exports.copyDirSync = copyDirSync;
//# sourceMappingURL=fsextra.js.map

1
lib/kmake/fsextra.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"fsextra.js","sourceRoot":"","sources":["../../kmake/src/fsextra.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2BAiBY;AAqCO,6FArDF,iBAAc,OAqDA;AARd,2FA5CF,eAAY,OA4CA;AACT,4FA5CF,gBAAa,OA4CA;AACd,yFA5CF,aAAU,OA4CA;AACH,8FA5CF,kBAAe,OA4CA;AACd,6FA5CF,iBAAc,OA4CA;AAChB,yFA3CF,aAAU,OA2CA;AACP,0FA3CF,cAAW,OA2CA;AACT,0FA3CF,cAAW,OA2CA;AAET,0FA5CF,cAAW,OA4CA;AACR,2FA5CF,eAAY,OA4CA;AAChB,qFA5CF,SAAM,OA4CA;AACH,sFA5CF,UAAO,OA4CA;AAEL,sFA5CF,UAAO,OA4CA;AA1CjB,6BAA6B;AAE7B,SAAS,aAAa,CAAC,GAAW;IACjC,IAAI;QACH,IAAI,CAAC,IAAA,eAAY,EAAC,GAAG,CAAC,EAAE;YACvB,IAAA,cAAW,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;SACtC;KACD;IACD,OAAO,GAAG,EAAE;QACX,GAAG,CAAC,KAAK,CAAC,4BAA4B,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC;KACrD;AACF,CAAC;AAgCA,sCAAa;AA9Bd,SAAS,WAAW,CAAC,IAAY,EAAE,EAAU;IAC5C,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,MAAM,KAAK,GAAG,IAAA,gBAAa,EAAC,IAAI,CAAC,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACzB,MAAM,IAAI,GAAG,IAAA,aAAU,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAC/C,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;YACvB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;SACxD;aACI;YACJ,IAAA,iBAAc,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;SAC3D;KACD;AACF,CAAC;AAmBA,kCAAW"}

38
lib/kmake/init.js Normal file
View File

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = void 0;
const fs = require("fs");
const path = require("path");
function run(name, from) {
const projectfile = 'kfile.js';
if (!fs.existsSync(path.join(from, projectfile))) {
fs.writeFileSync(path.join(from, projectfile), 'let project = new Project(\'New Project\');\n'
+ '\n'
+ 'await project.addProject(\'Kore\');\n'
+ '\n'
+ 'project.addFile(\'Sources/**\');\n'
+ 'project.setDebugDir(\'Deployment\');\n'
+ '\n'
+ 'project.flatten();\n'
+ '\n'
+ 'resolve(project);\n', { encoding: 'utf8' });
}
if (!fs.existsSync(path.join(from, 'Sources'))) {
fs.mkdirSync(path.join(from, 'Sources'));
}
let friendlyName = name;
friendlyName = friendlyName.replace(/ /g, '_');
friendlyName = friendlyName.replace(/-/g, '_');
if (!fs.existsSync(path.join(from, 'Sources', 'main.c'))) {
let mainsource = '\n'
+ 'int kickstart(int argc, char** argv) {\n'
+ '\treturn 0;\n'
+ '}\n';
fs.writeFileSync(path.join(from, 'Sources', 'main.c'), mainsource, { encoding: 'utf8' });
}
if (!fs.existsSync(path.join(from, 'Deployment'))) {
fs.mkdirSync(path.join(from, 'Deployment'));
}
}
exports.run = run;
//# sourceMappingURL=init.js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AAS,EAAE,QAAQ,CAAC,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;KACzF;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE;QAClD,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;KAC5C;AACF,CAAC;AApCD,kBAoCC"}

33
lib/kmake/log.js Normal file
View File

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.error = exports.info = exports.set = void 0;
let myInfo = function (text, newline) {
if (newline) {
console.log(text);
}
else {
process.stdout.write(text);
}
};
let myError = function (text, newline) {
if (newline) {
console.error(text);
}
else {
process.stderr.write(text);
}
};
function set(log) {
myInfo = log.info;
myError = log.error;
}
exports.set = set;
function info(text, newline = true) {
myInfo(text, newline);
}
exports.info = info;
function error(text, newline = true) {
myError(text, newline);
}
exports.error = error;
//# sourceMappingURL=log.js.map

1
lib/kmake/log.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../kmake/src/log.ts"],"names":[],"mappings":";;;AAAA,IAAI,MAAM,GAAG,UAAU,IAAY,EAAE,OAAgB;IACpD,IAAI,OAAO,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KAClB;SACI;QACJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KAC3B;AACF,CAAC,CAAC;AAEF,IAAI,OAAO,GAAG,UAAU,IAAY,EAAE,OAAgB;IACrD,IAAI,OAAO,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACpB;SACI;QACJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KAC3B;AACF,CAAC,CAAC;AAEF,SAAgB,GAAG,CAAC,GAAQ;IAC3B,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC;IAClB,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC;AACrB,CAAC;AAHD,kBAGC;AAED,SAAgB,IAAI,CAAC,IAAY,EAAE,UAAmB,IAAI;IACzD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACvB,CAAC;AAFD,oBAEC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAmB,IAAI;IAC1D,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACxB,CAAC;AAFD,sBAEC"}

1112
lib/kmake/main.js Normal file

File diff suppressed because it is too large Load Diff

1
lib/kmake/main.js.map Normal file

File diff suppressed because one or more lines are too long

79
lib/kmake/server.js Normal file
View File

@ -0,0 +1,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = void 0;
const fs = require("fs");
const http = require("http");
const log = require("kmake/log");
const path = require("path");
async function run(options, loglog) {
log.set(loglog);
log.info('Running server on ' + options.port + '...');
const server = http.createServer((request, response) => {
let baseDir = 'build/release';
if (options.debug) {
baseDir = 'build/debug';
}
let filePath = baseDir + request.url;
if (request.url === '/') {
filePath = baseDir + '/index.html';
}
const extname = path.extname(filePath);
let contentType = 'text/html';
switch (extname) {
case '.js':
contentType = 'text/javascript';
break;
case '.css':
contentType = 'text/css';
break;
case '.json':
contentType = 'application/json';
break;
case '.png':
contentType = 'image/png';
break;
case '.jpg':
contentType = 'image/jpg';
break;
case '.wav':
contentType = 'audio/wav';
break;
case '.wasm':
contentType = 'application/wasm';
break;
}
log.info('Reading file ' + filePath + '.');
fs.readFile(filePath, (error, content) => {
response.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
response.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
if (error) {
if (error.code == 'ENOENT') {
log.info('File ' + filePath + ' not found.');
fs.readFile('./404.html', (error, content) => {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
});
}
else {
response.writeHead(500);
response.end('Error: ' + error.code + ' ..\n');
response.end();
}
}
else {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
}
});
});
server.on('error', (e) => {
if (e.name === 'EADDRINUSE') {
log.error('Error: Port ' + options.port + ' is already in use.');
log.error('Please close the competing program (maybe another instance of kmake?)');
log.error('or switch to a different port using the --port argument.');
}
});
server.listen(options.port);
}
exports.run = run;
//# sourceMappingURL=server.js.map

1
lib/kmake/server.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../kmake/src/server.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6BAA6B;AAC7B,iCAAiC;AACjC,6BAA6B;AAEtB,KAAK,UAAU,GAAG,CAAC,OAAY,EAAE,MAAW;IAClD,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEhB,GAAG,CAAC,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;IAEtD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;QACtD,IAAI,OAAO,GAAG,eAAe,CAAC;QAC9B,IAAI,OAAO,CAAC,KAAK,EAAE;YAClB,OAAO,GAAG,aAAa,CAAC;SACxB;QAED,IAAI,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;QACrC,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,EAAE;YACxB,QAAQ,GAAG,OAAO,GAAG,aAAa,CAAC;SACnC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,WAAW,GAAG,WAAW,CAAC;QAC9B,QAAQ,OAAO,EAAE;YAChB,KAAK,KAAK;gBACT,WAAW,GAAG,iBAAiB,CAAC;gBAChC,MAAM;YACP,KAAK,MAAM;gBACV,WAAW,GAAG,UAAU,CAAC;gBACz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