*.DS_Store
*swp
-*cbs
-bin/
+*build
*.o
-[submodule "external/cbs.d"]
- path = external/cbs.d
- url = git@github.com:trenthuber/cbs.git
- branch = main
[submodule "external/raylib"]
path = external/raylib
- url = git@github.com:raysan5/raylib.git
+ url = https://github.com/raysan5/raylib
branch = main
+[submodule "external/cbs"]
+ path = external/cbs
+ url = https://github.com/trenthuber/cbs
$ git clone https://github.com/trenthuber/simplexpm.git
$ cd simplexpm
$ git submodule update --init
-$ cc -o cbs cbs.c && ./cbs
+$ cc -o build build.c && ./build
```
This will update all submodules (I use [Raylib](https://www.raylib.com) and my own C build system [cbs](https://github.com/trenthuber/cbs.git)) and then build and run the program.
Simply drag and drop XPM files into the window to view them. The window can be resized and the image will scale accordingly.
-To reload the current image press R. To save the current image as a PNG, press S. PNG files are saved to the same folder as the XPM file.
+To reload the current image press `R`. To save the current image as a PNG, press `S`. PNG files are saved to the same folder as the XPM file.
## Unimplemented features
- Not tested for Linux (built on macOS)
--- /dev/null
+*
+!.gitignore
--- /dev/null
+#define SRCPATH "src/"
+#define FONTPATH "fonts/"
+
+#define CFLAGS "-Wall", "-Wextra", "-Wpedantic", "-Iexternal/raylib/src/", "-Ifonts/"
+#define LDFLAGS "-framework", "CoreVideo", \
+ "-framework", "IOKit", \
+ "-framework", "Cocoa", \
+ "-framework", "GLUT", \
+ "-framework", "OpenGL"
+
+#include "external/cbs/cbs.c"
+
+#define HDRS \
+ SRCPATH "parser", \
+ SRCPATH "tokenizer", \
+ SRCPATH "utils", \
+ SRCPATH "xpm_mode" \
+
+#define SRCS SRCPATH "main", HDRS
+
+#define FONTS FONTPATH "source_code_pro_font"
+
+int main(void) {
+ char **srcs, **fonts;
+ int i;
+
+ build(NULL);
+
+ build("external/");
+
+ srcs = CARRAY(SRCS);
+ fonts = CARRAY(FONTS);
+
+ for (i = 0; srcs[i]; ++i) CC(srcs[i], HDRS);
+ for (i = 0; fonts[i]; ++i) CC(fonts[i], fonts[i]);
+
+ // LD('x', "bin/simplexpm", SRCS, FONTS);
+ LD('x', "bin/simplexpm", "lib/libraylib.a", SRCS, FONTS);
+
+ return 0;
+}
+++ /dev/null
-#define CBS_IMPLEMENTATION
-#define CBS_LIBRARY_PATH "./external/cbs.d/cbs.h"
-#include CBS_LIBRARY_PATH
-
-// TODO: Support for Linux
-
-#define CC "cc"
-#define CFLAGS "-Wall", "-Wextra", "-Wpedantic", "-I./external/raylib/src", "-I./fonts"
-#ifdef __MACH__
-#define LDFLAGS "-L./external/raylib/lib", "-lraylib", \
- "-framework", "CoreVideo", \
- "-framework", "IOKit", \
- "-framework", "Cocoa", \
- "-framework", "GLUT", \
- "-framework", "OpenGL"
-#else
-#define LDFLAGS "-L./external/raylib/lib", "-lraylib"
-#endif // __MACH__
-
-int main(int argc, char **argv) {
- cbs_rebuild_self(argv);
- cbs_shift_args(&argc, &argv);
-
- const char *subcommand = cbs_shift_args(&argc, &argv);
- if (subcommand && cbs_string_eq(subcommand, "clean")) {
- Cbs_Cmd cmd = {0};
- cbs_cmd_build(&cmd, "rm", "-rf", "./bin");
- Cbs_File_Paths obj_files = {0};
- cbs_file_paths_build_file_ext(&obj_files, "./src", ".o");
- cbs_cmd_build_file_paths(&cmd, obj_files);
- cbs_cmd_run(&cmd);
- return 0;
- }
-
- cbs_subbuild("./external");
-
- // Generate font data as a C style array
- const char *font_src = "./fonts/source_code_pro_font.c",
- *font_obj = cbs_string_build(cbs_strip_file_ext(font_src), ".o");
- if (cbs_needs_rebuild(font_obj, font_src))
- cbs_run(CC, CFLAGS, "-c", "-o", font_obj, font_src);
-
- cbs_run("mkdir", "-p", "./bin");
- Cbs_File_Paths src_files = {0};
- cbs_file_paths_build_file_ext(&src_files, "./src", ".c");
- cbs_file_paths_for_each (src_file, src_files) {
- const char *obj_file = cbs_string_build(cbs_strip_file_ext(src_file), ".o");
- if (cbs_needs_rebuild(obj_file, src_file, "./src/utils.h"))
- cbs_run(CC, CFLAGS, "-c", "-o", obj_file, src_file);
- }
-
- Cbs_File_Paths obj_files = {0};
- cbs_file_paths_build_file_ext(&obj_files, "./src", ".o");
- cbs_file_paths_build_file_ext(&obj_files, "./fonts", ".o");
- const char *bin_file = "./bin/simplexpm";
- if (cbs_needs_rebuild_file_paths(bin_file, obj_files)) {
- Cbs_Cmd cmd = {0};
- cbs_cmd_build(&cmd, CC, "-o", bin_file);
- cbs_cmd_build_file_paths(&cmd, obj_files);
- cbs_cmd_build(&cmd, LDFLAGS);
- cbs_cmd_run(&cmd);
- }
-
- cbs_run(bin_file);
-
- return 0;
-}
--- /dev/null
+#define SRCPATH "raylib/src/"
+
+#define CFLAGS \
+ "-x", "objective-c", \
+ "-DPLATFORM_DESKTOP", \
+ "-I" SRCPATH "external/glfw/include/"
+#define LDFLAGS ""
+
+#include "cbs/cbs.c"
+
+#define SRCS \
+ SRCPATH "raudio", SRCPATH "rcore", \
+ SRCPATH "rglfw", SRCPATH "rmodels", \
+ SRCPATH "rshapes", SRCPATH "rtext", \
+ SRCPATH "rtextures", SRCPATH "utils"
+
+int main(void) {
+ char **srcs;
+ int i;
+
+ build(NULL);
+
+ srcs = CARRAY(SRCS);
+
+ for (i = 0; srcs[i]; ++i) CC(srcs[i]);
+
+ LD('s', "../lib/raylib", SRCS);
+
+ return 0;
+}
--- /dev/null
+Subproject commit 5bcdae85d8e7f4634b6f06c1f407fb8f1f39b684
+++ /dev/null
-#define CBS_IMPLEMENTATION
-#define CBS_LIBRARY_PATH "./cbs.d/cbs.h"
-#include CBS_LIBRARY_PATH
-
-#define CC "cc"
-
-int main(int argc, char **argv) {
- cbs_rebuild_self(argv);
- cbs_shift_args(&argc, &argv);
-
- const char *raylib_src_dir = "./raylib/src";
- Cbs_File_Paths raylib_src_files = {0}, raylib_obj_files = {0};
- cbs_file_paths_build_file_ext(&raylib_src_files, raylib_src_dir, ".c");
- Cbs_Async_Procs procs = {0};
- Cbs_Cmd cmd = {0};
- cbs_file_paths_for_each(src_file, raylib_src_files) {
- char *obj_file = cbs_string_build(cbs_strip_file_ext(src_file), ".o");
- cbs_file_paths_build(&raylib_obj_files, obj_file);
- if (cbs_needs_rebuild(obj_file, src_file)) {
- cbs_cmd_build(&cmd, CC, "-c");
- if (cbs_string_eq(src_file, cbs_string_build(raylib_src_dir, "/rglfw.c")))
- cbs_cmd_build(&cmd, "-x", "objective-c");
- cbs_cmd_build(&cmd, "-DPLATFORM_DESKTOP",
- cbs_string_build("-I", raylib_src_dir,
- "/external/glfw/include"));
- cbs_cmd_build(&cmd, "-o", obj_file, src_file);
- cbs_cmd_async_run(&procs, &cmd);
- }
- }
- cbs_async_wait(&procs);
-
- cbs_run("mkdir", "-p", "./raylib/lib");
- const char *output_file = "./raylib/lib/libraylib.a";
- if (cbs_needs_rebuild_file_paths(output_file, raylib_obj_files)) {
- cbs_cmd_build(&cmd, "ar", "-r", output_file);
- cbs_cmd_build_file_paths(&cmd, raylib_obj_files);
- cbs_cmd_run(&cmd);
- }
-
- return 0;
-}
+++ /dev/null
-Subproject commit e7e6371478323f76c0ac8a7c5582973377f67ced
--- /dev/null
+*
+!.gitignore