#include "../external/cbs/cbs.c"
#include "../external/cbsfile.c"
-#define CLRAYLIB LIST("-I../external/raylib/src/")
+#ifdef FONT
+#include <err.h>
+#include <stdlib.h>
+
+#include "raylib.h"
+#endif
+
+#define CFRAYLIB "-I../external/raylib/src/"
#ifdef DYNAMICLIBS
#define LIBEXT DYEXT
#define LLRAYLIB NONE
#define RLLIB "../external/raylib/raylib" LIBEXT
#define CBSLIB "../external/cbs/cbs" LIBEXT
+#ifdef FONT
static void buildcolors(void) {
int quit, txtfd, codefd;
char *txt, *code, *p;
}
static void buildfont(void) {
- char **c, **l;
- pid_t cpid;
+ char *ttf, *code;
+ Font font;
- c = cflags;
- l = lflags;
+ ttf = "../assets/font.ttf";
+ code = "font.c";
- cflags = CLRAYLIB;
- compile("buildfont");
+ SetTraceLogLevel(LOG_WARNING);
+ InitWindow(0, 0, "");
- lflags = LLRAYLIB;
- load('x', "buildfont", LIST("buildfont", RLLIB));
-
- if ((cpid = fork()) == -1) err(EXIT_FAILURE, "Unable to fork");
- else if (cpid == 0) run("buildfont", LIST("buildfont"), "run", "buildfont");
- await(cpid, "run", "buildfont");
+ if (!ExportFontAsCode(font = LoadFontEx(ttf, 48, NULL, 95), code))
+ errx(EXIT_FAILURE, "Unable to generate `%s' from `%s'", code, ttf);
- cflags = c;
- lflags = l;
+ UnloadFont(font);
}
+#endif
int main(void) {
- build("./");
+#ifndef FONT
+ cflags = LIST("-DFONT", CFRAYLIB);
+ compile("build");
+
+ lflags = LLRAYLIB;
+ load('x', "build", LIST("build", RLLIB));
+
+ run("!build", LIST("build"), "run", "build");
+#else
+ compile("build");
+ load('x', "build", LIST("build"));
buildcolors();
buildfont();
buildfiles((struct cbsfile []){{"../bin/simplexpm", LLRAYLIB, 'x'},
{"colors", NONE},
- {"main", CLRAYLIB},
+ {"main", LIST(CFRAYLIB)},
{"options", NONE},
- {"xpm", CLRAYLIB},
+ {"xpm", LIST(CFRAYLIB)},
{CBSLIB},
{RLLIB},
{NULL}});
+#endif
return EXIT_SUCCESS;
}
+++ /dev/null
-#include <err.h>
-#include <stdlib.h>
-
-#include "raylib.h"
-
-int main(void) {
- char *ttf, *code;
- Font font;
-
- ttf = "../assets/font.ttf";
- code = "font.c";
-
- SetTraceLogLevel(LOG_WARNING);
- InitWindow(0, 0, "");
-
- if (!ExportFontAsCode(font = LoadFontEx(ttf, 48, NULL, 95), code))
- errx(EXIT_FAILURE, "Unable to generate `%s' from `%s'", code, ttf);
-
- UnloadFont(font);
-
- return EXIT_SUCCESS;
-}
if (IsFileDropped()) {
files = LoadDroppedFiles();
- if (xpm) RL_FREE(xpm);
+ if (xpm) free(xpm);
xpm = allocate(FILENAME_MAX);
strcpy(xpm, files.paths[0]);
UnloadDroppedFiles(files);
}
if (xpm) free(xpm);
-
- UnloadTexture(*texture);
+ if (texture) UnloadTexture(*texture);
CloseWindow();
return EXIT_SUCCESS;