summaryrefslogtreecommitdiff
path: root/build.c
diff options
context:
space:
mode:
Diffstat (limited to 'build.c')
-rw-r--r--build.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/build.c b/build.c
index 9938016..b69c3c2 100644
--- a/build.c
+++ b/build.c
@@ -30,7 +30,7 @@ typedef struct module
} module_t;
static const module_t known[] = {
- {"font", ""}, {"toml", ""}, {"tile", ""}, {"pack", ""}, {"ui", "font"}, {"debug", "font assets"},
+ {"font", ""}, {"toml", ""}, {"fs", ""}, {"tile", ""}, {"pack", ""}, {"ui", "font"}, {"debug", "font assets"},
{"assets", "pack"}, {"image", ""}, {"audio", ""}, {"mic", ""}, {"sound", "audio"}, {"model", "assets"},
{"2d", ""}, {"fx", "2d"}, {"particles", ""}, {"picture", "2d"}, {"rm", ""}, {"rmmap", ""}, {"rmtile", ""},
{"rmdraw", "rmmap rmtile"}, {"rmfield", "rmmap"}, {"rmplugin", ""}, {"rmdata", "battle party save"},
@@ -118,7 +118,7 @@ static void usage(void)
fprintf(stderr, "modules: ");
for (i = 0; i < KNOWN; i++) fprintf(stderr, " %s", known[i].name);
fprintf(stderr, "\nplatforms: native linux bsd windows\n");
- fprintf(stderr, "targets: all run clean tools pack examples\n");
+ fprintf(stderr, "targets: all run clean tools pack examples konedit\n");
exit(1);
}
@@ -609,6 +609,8 @@ static void targetRun(void)
static const char *toolNames[] = {"konpack", "konmodel", "mzsurvey", "mzscript", "kons2c", "mzmap", "mzdata"};
+static const char *editorName = "konedit";
+
static const char *examples[] = {"modelview", "sound", "ui", "platform", "dialog", "script", "corridor", "hills", "sectorview"};
/* only is the name of one example, or NULL for all of them */
@@ -634,6 +636,30 @@ static void targetExamples(const char *only)
runJobs();
}
+/* the editor is a program of its own with the modules it needs, so asking for it adds them */
+static void targetEditor(void)
+{
+ const char *all[OBJECTS_MAX + 16];
+ int n = 0, k;
+
+ queueObjects(0);
+ queueCompile("editor/konedit.c", objPath(editorName), 0, NULL);
+ runJobs();
+ all[n++] = objPath(editorName);
+ for (k = 0; k < objectCount; k++) all[n++] = objects[k];
+ queueLink(exePath(editorName), all, (size_t)n, 1);
+ runJobs();
+}
+
+static int isEditorTarget(const char *t)
+{
+ size_t d = strlen(objdir);
+
+ if (strcmp(t, editorName) == 0) return 1;
+ if (strncmp(t, objdir, d) != 0 || t[d] != 0x2f) return 0;
+ return strcmp(t + d + 1, editorName) == 0 || strcmp(t + d + 1, "konedit.exe") == 0;
+}
+
/* a program made straight from some files, with the headers they read checked too. the converters do not link the engine */
static void queueTool(const char *name, const char **sources, size_t count, const KonCmd *flags, int withEngineFlags, int withMath)
{
@@ -783,6 +809,7 @@ static void targetClean(void)
removeFile(exePath(PROGRAM));
for (i = 0; i < sizeof(toolNames) / sizeof(toolNames[0]); i++) removeFile(exePath(toolNames[i]));
for (i = 0; i < sizeof(examples) / sizeof(examples[0]); i++) removeFile(exePath(examples[i]));
+ removeFile(exePath(editorName));
removeFile(kon_fmt("%s/data.kpk", objdir));
removeFile(kon_fmt("%s/assets.lst", objdir));
}
@@ -811,6 +838,10 @@ static int targetFile(const char *t)
return 1;
}
}
+ if (strcmp(name, editorName) == 0) {
+ targetEditor();
+ return 1;
+ }
if (strcmp(name, PROGRAM) == 0) {
targetAll();
return 1;
@@ -868,6 +899,9 @@ int main(int argc, char **argv)
}
}
if (targetCount == 0) targets[targetCount++] = "all";
+ for (i = 0; i < targetCount; i++) {
+ if (isEditorTarget(targets[i])) addModuleList("ui,font,toml,fs");
+ }
maxJobs = jobsAsked > 0 ? jobsAsked : kon_cpuCount();
setup();
@@ -887,6 +921,7 @@ int main(int argc, char **argv)
else if (strcmp(t, "tools") == 0) targetTools();
else if (strcmp(t, "pack") == 0) targetPack();
else if (strcmp(t, "examples") == 0) targetExamples(NULL);
+ else if (strcmp(t, editorName) == 0) targetEditor();
else if (!targetFile(t)) {
fprintf(stderr, "build: unknown target '%s'\n", t);
usage();