added options to tibia and made cmd-make flexible
This commit is contained in:
parent
09c4410076
commit
f128116871
@ -9,10 +9,14 @@ else
|
||||
BINDIR = ${PREFIX}/bin
|
||||
endif
|
||||
|
||||
MAIN_DIR := $(or $(MAIN_DIR),src)
|
||||
DATA_DIR := $(or $(DATA_DIR),src)
|
||||
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
|
||||
|
||||
CC = gcc
|
||||
|
||||
CFLAGS = -O3 -Wall -Wpedantic -Wextra
|
||||
CFLAGS_ALL = -I${TINYWAV_DIR} -I${MIDI_PARSER_DIR}/include -fPIC ${CFLAGS} ${CFLAGS_EXTRA}
|
||||
CFLAGS_ALL = -I${DATA_DIR} -I${PLUGIN_DIR} -I${TINYWAV_DIR} -I${MIDI_PARSER_DIR}/include -fPIC ${CFLAGS} ${CFLAGS_EXTRA}
|
||||
|
||||
LDFLAGS =
|
||||
LDFLAGS_ALL = ${LDFLAGS} ${LDFLAGS_EXTRA}
|
||||
@ -26,19 +30,19 @@ ifeq ($(UNAME_S), Darwin)
|
||||
build/${PROGRAM}: build/tmp/x86_64 build/tmp/arm64
|
||||
lipo -create -output $@ $^
|
||||
|
||||
build/tmp/x86_64: src/main.c src/data.h src/plugin.h ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build/tmp
|
||||
${CC} src/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} -arch x86_64
|
||||
build/tmp/x86_64: ${MAIN_DIR}/main.c ${DATA_DIR}/data.h ${PLUGIN_DIR}/plugin.h ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build/tmp
|
||||
${CC} ${MAIN_DIR}/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} -arch x86_64
|
||||
|
||||
build/tmp/arm64: src/main.c src/data.h src/plugin.h ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build/tmp
|
||||
${CC} src/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} -arch arm64
|
||||
build/tmp/arm64: ${MAIN_DIR}/main.c ${DATA_DIR}/data.h ${PLUGIN_DIR}/plugin.h ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build/tmp
|
||||
${CC} ${MAIN_DIR}/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} -arch arm64
|
||||
|
||||
build/tmp:
|
||||
mkdir -p $@
|
||||
|
||||
else
|
||||
|
||||
build/${PROGRAM}: src/main.c src/data.h src/plugin.h ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build
|
||||
${CC} src/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL}
|
||||
build/${PROGRAM}: ${MAIN_DIR}/main.c ${DATA_DIR}/data.h ${PLUGIN_DIR}/plugin.h ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build
|
||||
${CC} ${MAIN_DIR}/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL}
|
||||
|
||||
endif
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
BUNDLE_NAME := {{=it.product.bundleName}}
|
||||
CFLAGS_EXTRA := {{=it.make && it.make.cflags ? it.make.cflags : ""}} {{=it.cmd_make.cflags ? it.cmd_make.cflags : ""}}
|
||||
LDFLAGS_EXTRA := {{=it.make && it.make.ldflags ? it.make.ldflags : ""}} {{=it.cmd_make.ldflags ? it.cmd_make.ldflags : ""}}
|
||||
MAIN_DIR := {{=it.cmd_make && it.cmd_make.mainDir ? it.cmd_make.mainDir : (it.make && it.make.mainDir ? it.make.mainDir : "")}}
|
||||
DATA_DIR := {{=it.cmd_make && it.cmd_make.dataDir ? it.cmd_make.dataDir : (it.make && it.make.dataDir ? it.make.dataDir : "")}}
|
||||
PLUGIN_DIR := {{=it.cmd_make && it.cmd_make.pluginDir ? it.cmd_make.pluginDir : (it.make && it.make.pluginDir ? it.make.pluginDir : "")}}
|
||||
TINYWAV_DIR := {{=it.cmd_make.tinywavDir}}
|
||||
MIDI_PARSER_DIR := {{=it.cmd_make.midiParserDir}}
|
||||
|
63
tibia
63
tibia
@ -1,21 +1,50 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
if (process.argv.length != 5) {
|
||||
console.log("Usage: tibia file1.json,file2.json,...filen.json template outDirectory");
|
||||
function usage() {
|
||||
console.log("Usage:");
|
||||
console.log(" tibia file1.json,file2.json,...filen.json template outDirectory");
|
||||
console.log(" tibia --common template outDirectory");
|
||||
console.log(" tibia --data file1.json,file2.json,...filen.json template outDirectory");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var jsonFiles, template, outputDir, outputCommon, outputData;
|
||||
if (process.argv[2] == "--common") {
|
||||
if (process.argv.length != 5)
|
||||
usage();
|
||||
jsonFiles = [];
|
||||
template = process.argv[3];
|
||||
outputDir = process.argv[4];
|
||||
outputCommon = true;
|
||||
outputData = false;
|
||||
} else if (process.argv[2] == "--data") {
|
||||
if (process.argv.length != 6)
|
||||
usage();
|
||||
jsonFiles = process.argv[3].split(",");
|
||||
template = process.argv[4];
|
||||
outputDir = process.argv[5];
|
||||
outputCommon = false;
|
||||
outputData = true;
|
||||
} else {
|
||||
if (process.argv.length != 5)
|
||||
usage();
|
||||
jsonFiles = process.argv[2].split(",");
|
||||
template = process.argv[3];
|
||||
outputDir = process.argv[4];
|
||||
outputCommon = true;
|
||||
outputData = true;
|
||||
}
|
||||
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
var jsonFiles = process.argv[2].split(",");
|
||||
var template = process.argv[3];
|
||||
var outputDir = process.argv[4];
|
||||
|
||||
var schema = JSON.parse(fs.readFileSync(__dirname + path.sep + "schema.json", { encoding: "utf-8" }));
|
||||
var Ajv = require("ajv");
|
||||
var ajv = new Ajv();
|
||||
var ajvValidate = ajv.compile(schema);
|
||||
var ajvValidate;
|
||||
if (outputData) {
|
||||
var schema = JSON.parse(fs.readFileSync(__dirname + path.sep + "schema.json", { encoding: "utf-8" }));
|
||||
var Ajv = require("ajv");
|
||||
var ajv = new Ajv();
|
||||
ajvValidate = ajv.compile(schema);
|
||||
}
|
||||
|
||||
var data = {};
|
||||
for (var i = 0; i < jsonFiles.length; i++) {
|
||||
@ -24,10 +53,12 @@ for (var i = 0; i < jsonFiles.length; i++) {
|
||||
data[k] = d[k];
|
||||
}
|
||||
|
||||
var ajvValid = ajvValidate(data);
|
||||
if (!ajvValid) {
|
||||
console.log(ajvValidate.errors);
|
||||
process.exit(1);
|
||||
if (outputData) {
|
||||
var ajvValid = ajvValidate(data);
|
||||
if (!ajvValid) {
|
||||
console.log(ajvValidate.errors);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
var doT = require("dot");
|
||||
@ -52,6 +83,8 @@ var api = {
|
||||
},
|
||||
|
||||
generateFileFromTemplateFile: function (templateFile, outFile, data) {
|
||||
if (!outputData)
|
||||
return;
|
||||
var dir = outputDir + path.sep + path.dirname(outFile);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
var t = doT.template(fs.readFileSync(template + path.sep + templateFile, { encoding: "utf-8" }));
|
||||
@ -59,6 +92,8 @@ var api = {
|
||||
},
|
||||
|
||||
copyFile: function (inFile, outFile) {
|
||||
if (!outputCommon)
|
||||
return;
|
||||
var dir = outputDir + path.sep + path.dirname(outFile);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.copyFileSync(template + path.sep + inFile, outputDir + path.sep + outFile);
|
||||
|
Loading…
Reference in New Issue
Block a user