]> git.lizzy.rs Git - nothing.git/commitdiff
Separate system and ebisp static libraries
authorrexim <reximkut@gmail.com>
Sat, 2 Feb 2019 20:13:39 +0000 (03:13 +0700)
committerrexim <reximkut@gmail.com>
Sat, 2 Feb 2019 20:13:39 +0000 (03:13 +0700)
15 files changed:
CMakeLists.txt
src/ebisp/expr.c
src/game.c
src/game/level/goals.c
src/game/level/labels.c
src/game/level/player/rigid_rect.c
src/game/level/regions.c
src/game/level/script.c
src/game/level_picker.c
src/str.c [deleted file]
src/str.h [deleted file]
src/system/str.c [new file with mode: 0644]
src/system/str.h [new file with mode: 0644]
src/ui/console_log.c
src/ui/history.c

index 45866f3ace52e6baa5482fea9ebe30d621b1ca99..f581316f2ab3f6140aa150ab0749d1682df02e9e 100644 (file)
@@ -23,112 +23,118 @@ endif()
 
 include_directories(${SDL2_MIXER_INCLUDE_DIR})
 
-add_executable(nothing 
-  src/color.c
-  src/game.c
-  src/game/camera.c
-  src/ui/edit_field.c
-  src/game/level.c
-  src/game/level/background.c
-  src/game/level/boxes.c
-  src/game/level/goals.c
-  src/game/level/labels.c
-  src/game/level/lava.c
-  src/game/level/lava/wavy_rect.c
-  src/game/level/physical_world.c
-  src/game/level/platforms.c
-  src/game/level/player.c
-  src/game/level/player/dying_rect.c
-  src/game/level/player/rigid_rect.c
-  src/game/level/solid.c
-  src/game/sound_samples.c
-  src/game/sprite_font.c
-  src/main.c
-  src/math/mat3x3.c
-  src/math/point.c
-  src/math/rand.c
-  src/math/rect.c
-  src/math/triangle.c
+add_library(system STATIC
+  src/system/line_stream.c
+  src/system/line_stream.h
+  src/system/log.c
+  src/system/log.h
+  src/system/log_script.c
+  src/system/log_script.h
+  src/system/lt.c
+  src/system/lt.h
+  src/system/lt/lt_adapters.c
+  src/system/lt/lt_adapters.h
+  src/system/lt/lt_slot.c
+  src/system/lt/lt_slot.h
+  src/system/nth_alloc.c
+  src/system/nth_alloc.h
+  src/system/stacktrace.c
+  src/system/stacktrace.h
+  src/system/str.c
+  src/system/str.h
+  )
+
+add_library(ebisp STATIC
+  src/ebisp/builtins.c
+  src/ebisp/builtins.h
   src/ebisp/expr.c
+  src/ebisp/expr.h
+  src/ebisp/gc.c
+  src/ebisp/gc.h
   src/ebisp/interpreter.c
+  src/ebisp/interpreter.h
   src/ebisp/parser.c
-  src/ebisp/tokenizer.c
-  src/ebisp/gc.c
+  src/ebisp/parser.h
   src/ebisp/scope.c
-  src/sdl/renderer.c
-  src/system/lt.c
-  src/system/lt/lt_adapters.c
-  src/system/lt/lt_slot.c
-  src/ui/console.c
-  src/ui/console_log.c
-  src/str.c
-  src/ui/history.c
-  src/game/level/regions.c
+  src/ebisp/scope.h
+  src/ebisp/std.c
+  src/ebisp/std.h
+  src/ebisp/tokenizer.c
+  src/ebisp/tokenizer.h
+  )
+
+add_executable(nothing 
+  broadcast_lisp.h
+  src/broadcast.c
+  src/broadcast.h
+  src/color.c
   src/color.h
+  src/game.c
   src/game.h
+  src/game/camera.c
   src/game/camera.h
-  src/ui/edit_field.h
+  src/game/level.c
   src/game/level.h
+  src/game/level/background.c
   src/game/level/background.h
+  src/game/level/boxes.c
   src/game/level/boxes.h
+  src/game/level/goals.c
   src/game/level/goals.h
+  src/game/level/labels.c
   src/game/level/labels.h
+  src/game/level/lava.c
   src/game/level/lava.h
+  src/game/level/lava/wavy_rect.c
   src/game/level/lava/wavy_rect.h
   src/game/level/physical_world.c
+  src/game/level/physical_world.c
+  src/game/level/platforms.c
   src/game/level/platforms.h
+  src/game/level/player.c
   src/game/level/player.h
+  src/game/level/player/dying_rect.c
   src/game/level/player/dying_rect.h
+  src/game/level/player/rigid_rect.c
   src/game/level/player/rigid_rect.h
+  src/game/level/regions.c
+  src/game/level/regions.h
+  src/game/level/rigid_bodies.c
+  src/game/level/rigid_bodies.h
+  src/game/level/script.c
+  src/game/level/script.h
+  src/game/level/solid.c
   src/game/level/solid.h
+  src/game/level_picker.c
+  src/game/level_picker.h
+  src/game/sound_samples.c
   src/game/sound_samples.h
+  src/game/sprite_font.c
   src/game/sprite_font.h
+  src/main.c
+  src/math/extrema.c
+  src/math/extrema.h
+  src/math/mat3x3.c
   src/math/mat3x3.h
   src/math/pi.h
+  src/math/point.c
   src/math/point.h
+  src/math/rand.c
   src/math/rand.h
+  src/math/rect.c
   src/math/rect.h
+  src/math/triangle.c
   src/math/triangle.h
-  src/ebisp/builtins.c
-  src/ebisp/builtins.h
-  src/ebisp/expr.h
-  src/ebisp/gc.h
-  src/ebisp/scope.h
-  src/ebisp/interpreter.h
-  src/ebisp/parser.h
-  src/ebisp/tokenizer.h
+  src/sdl/renderer.c
   src/sdl/renderer.h
-  src/system/lt.h
-  src/system/lt/lt_adapters.h
-  src/system/lt/lt_slot.h
+  src/ui/console.c
   src/ui/console.h
+  src/ui/console_log.c
   src/ui/console_log.h
-  src/str.h
+  src/ui/edit_field.c
+  src/ui/edit_field.h
+  src/ui/history.c
   src/ui/history.h
-  src/game/level/regions.h
-  src/system/line_stream.h
-  src/system/line_stream.c
-  src/game/level/script.h
-  src/game/level/script.c
-  src/system/log.h
-  src/system/log.c
-  src/system/log_script.h
-  src/system/log_script.c
-  src/system/nth_alloc.h
-  src/system/nth_alloc.c
-  src/ebisp/std.h
-  src/ebisp/std.c
-  src/system/stacktrace.h
-  src/system/stacktrace.c
-  src/game/level_picker.h
-  src/game/level_picker.c
-  src/broadcast.c
-  src/broadcast.h
-  broadcast_lisp.h
-  src/game/level/rigid_bodies.h
-  src/game/level/rigid_bodies.c
-  src/math/extrema.h
-  src/math/extrema.c
 )
 
 add_custom_command(
@@ -137,102 +143,25 @@ add_custom_command(
   DEPENDS baker src/broadcast.lisp)
 
 add_executable(repl
-  src/ebisp/builtins.c
-  src/ebisp/builtins.h
-  src/ebisp/expr.c
-  src/ebisp/expr.h
-  src/ebisp/interpreter.c
-  src/ebisp/interpreter.h
-  src/ebisp/parser.c
-  src/ebisp/parser.h
-  src/ebisp/scope.c
-  src/ebisp/scope.h
-  src/ebisp/tokenizer.c
-  src/ebisp/tokenizer.h
   src/ebisp/repl.c
-  src/system/lt.c
-  src/system/lt.h
-  src/system/lt/lt_adapters.c
-  src/system/lt/lt_adapters.h
-  src/system/lt/lt_slot.c
-  src/system/lt/lt_slot.h
-  src/ebisp/gc.h
-  src/ebisp/gc.c
-  src/str.h
-  src/str.c
-  src/system/log.h
-  src/system/log.c
-  src/system/nth_alloc.h
-  src/system/nth_alloc.c
-  src/ebisp/repl_runtime.h
   src/ebisp/repl_runtime.c
-  src/ebisp/std.h
-  src/ebisp/std.c
-  src/system/stacktrace.h
-  src/system/stacktrace.c
   )
+
 add_executable(baker
   src/ebisp/baker.c
-  src/ebisp/parser.c
-  src/ebisp/parser.h
-  src/ebisp/tokenizer.h
-  src/ebisp/tokenizer.c
-  src/ebisp/builtins.h
-  src/ebisp/builtins.c
-  src/ebisp/expr.c
-  src/ebisp/expr.h
-  src/ebisp/gc.c
-  src/ebisp/gc.h
-  src/system/lt.c
-  src/system/lt.h
-  src/system/lt/lt_slot.c
-  src/system/lt/lt_slot.h
-  src/system/stacktrace.h
-  src/system/stacktrace.c
-  src/system/nth_alloc.h
-  src/system/nth_alloc.c
-  src/system/log.h
-  src/system/log.c
-  src/str.h
-  src/str.c
   )
 
 add_executable(nothing_test
-  src/ebisp/builtins.c
-  src/ebisp/builtins.h
-  src/ebisp/expr.c
-  src/ebisp/expr.h
-  src/ebisp/interpreter.c
-  src/ebisp/interpreter.h
-  src/ebisp/parser.c
-  src/ebisp/parser.h
-  src/ebisp/scope.c
-  src/ebisp/scope.h
-  src/ebisp/tokenizer.c
-  src/ebisp/tokenizer.h
-  src/ebisp/gc.h
-  src/ebisp/gc.c
-  src/system/lt.c
-  src/system/lt.h
-  src/system/lt/lt_adapters.c
-  src/system/lt/lt_adapters.h
-  src/system/lt/lt_slot.c
-  src/system/lt/lt_slot.h
-  src/str.h
-  src/str.c
   test/main.c
   test/test.h
   test/tokenizer_suite.h
-  src/system/log.h
-  src/system/log.c
-  src/system/nth_alloc.h
-  src/system/nth_alloc.c
-  src/system/stacktrace.h
-  src/system/stacktrace.c
   )
-target_link_libraries(nothing ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m)
-target_link_libraries(nothing_test ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m)
-target_link_libraries(repl ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m)
+
+target_link_libraries(nothing ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m system ebisp)
+target_link_libraries(nothing_test ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m system ebisp)
+target_link_libraries(repl ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m system ebisp)
+target_link_libraries(ebisp system)
+target_link_libraries(baker m system ebisp)
 
 if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "CLANG"))
   set(CMAKE_C_FLAGS
index 6ada9b92cc8a4a079e080a32b7e75b26d868b801..da04ff6a4c9e6ad2ebfca1f98c419e5b3e13275a 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "ebisp/expr.h"
 #include "ebisp/gc.h"
-#include "str.h"
+#include "system/str.h"
 
 struct Expr atom_as_expr(struct Atom *atom)
 {
index 415c7e8561100387d12aae0d04450b6d75c77b59..977c6906afc7b359ef2489576cdbbc60ab0e61da 100644 (file)
@@ -12,7 +12,7 @@
 #include "system/nth_alloc.h"
 #include "ui/console.h"
 #include "ui/edit_field.h"
-#include "str.h"
+#include "system/str.h"
 #include "ebisp/builtins.h"
 #include "broadcast.h"
 
index 075d59d79b9bec98e5290603e9a81b827b4a07b3..bc0878eda97cb6764ecb7c290037ab714297dbf3 100644 (file)
@@ -5,7 +5,7 @@
 #include "goals.h"
 #include "math/pi.h"
 #include "math/triangle.h"
-#include "str.h"
+#include "system/str.h"
 #include "system/line_stream.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index 9de6d3ca625406b8c893cf62e587758dc6b21c77..bdc18b83e2ea60fcf4b6062e28759dd2ec05f768 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "game/camera.h"
 #include "game/level/labels.h"
-#include "str.h"
+#include "system/str.h"
 #include "system/line_stream.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index 6d6b12abeb67e04a0c915b7cb4dba3fdc093c493..90ebab829e9be0f03b70e52e5ec34e08fa3f9d05 100644 (file)
@@ -7,7 +7,7 @@
 #include "game/level/boxes.h"
 #include "game/level/solid.h"
 #include "rigid_rect.h"
-#include "str.h"
+#include "system/str.h"
 #include "system/line_stream.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index 105cda27b26c7407015f4561476bd60a5cdc5546..47eff251358f5ca85d492ce6d7ac7e09710414ad 100644 (file)
@@ -7,7 +7,7 @@
 #include "player.h"
 #include "regions.h"
 #include "script.h"
-#include "str.h"
+#include "system/str.h"
 #include "system/line_stream.h"
 #include "system/log.h"
 #include "system/lt.h"
index e50e090f3ceaf3d4fe88b9510bacd71712714625..5d8688b5f1978680e9b018f44720c7de03eee152 100644 (file)
@@ -6,7 +6,7 @@
 #include "ebisp/std.h"
 #include "game/level.h"
 #include "script.h"
-#include "str.h"
+#include "system/str.h"
 #include "system/line_stream.h"
 #include "system/log.h"
 #include "system/log_script.h"
index eabc302316754be6f08266f5abc0480d5f5dda6c..89c7e6fee002e621d0a9218cf680dde02646d2a5 100644 (file)
@@ -4,7 +4,7 @@
 #include "system/stacktrace.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
-#include "str.h"
+#include "system/str.h"
 #include "game/level/background.h"
 
 /* TODO(#606): LevelPicker doesn't allow to select any levels */
diff --git a/src/str.c b/src/str.c
deleted file mode 100644 (file)
index 3e4302f..0000000
--- a/src/str.c
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "system/stacktrace.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "system/stacktrace.h"
-
-#include "str.h"
-#include "system/nth_alloc.h"
-
-char *string_duplicate(const char *str,
-                       const char *str_end)
-{
-    if (str_end != NULL && str > str_end) {
-        return NULL;
-    }
-
-    const size_t n = str_end == NULL ? strlen(str) : (size_t) (str_end - str);
-    char *dup_str = nth_alloc(sizeof(char) * (n + 1));
-    if (dup_str == NULL) {
-        return NULL;
-    }
-
-    memcpy(dup_str, str, n);
-    dup_str[n] = '\0';
-
-    return dup_str;
-}
-
-char *trim_endline(char *s)
-{
-    const size_t n = strlen(s);
-
-    if (n == 0) {
-        return s;
-    }
-
-    if (s[n - 1] == '\n') {
-        s[n - 1] = '\0';
-    }
-
-    return s;
-}
-
-char *string_append(char *prefix, const char *suffix)
-{
-    trace_assert(suffix);
-
-    if (prefix == NULL) {
-        return string_duplicate(suffix, NULL);
-    }
-
-    prefix = nth_realloc(prefix, strlen(prefix) + strlen(suffix) + 1);
-    return strcat(prefix, suffix);
-}
diff --git a/src/str.h b/src/str.h
deleted file mode 100644 (file)
index b780bc2..0000000
--- a/src/str.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef STR_H_
-#define STR_H_
-
-#define STRINGIFY(x) STRINGIFY2(x)
-#define STRINGIFY2(x) #x
-
-char *string_duplicate(const char *str,
-                       const char *str_end);
-char *string_append(char *prefix,
-                    const char *suffix);
-char *trim_endline(char *s);
-
-#endif  // STR_H_
diff --git a/src/system/str.c b/src/system/str.c
new file mode 100644 (file)
index 0000000..3e4302f
--- /dev/null
@@ -0,0 +1,54 @@
+#include "system/stacktrace.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "system/stacktrace.h"
+
+#include "str.h"
+#include "system/nth_alloc.h"
+
+char *string_duplicate(const char *str,
+                       const char *str_end)
+{
+    if (str_end != NULL && str > str_end) {
+        return NULL;
+    }
+
+    const size_t n = str_end == NULL ? strlen(str) : (size_t) (str_end - str);
+    char *dup_str = nth_alloc(sizeof(char) * (n + 1));
+    if (dup_str == NULL) {
+        return NULL;
+    }
+
+    memcpy(dup_str, str, n);
+    dup_str[n] = '\0';
+
+    return dup_str;
+}
+
+char *trim_endline(char *s)
+{
+    const size_t n = strlen(s);
+
+    if (n == 0) {
+        return s;
+    }
+
+    if (s[n - 1] == '\n') {
+        s[n - 1] = '\0';
+    }
+
+    return s;
+}
+
+char *string_append(char *prefix, const char *suffix)
+{
+    trace_assert(suffix);
+
+    if (prefix == NULL) {
+        return string_duplicate(suffix, NULL);
+    }
+
+    prefix = nth_realloc(prefix, strlen(prefix) + strlen(suffix) + 1);
+    return strcat(prefix, suffix);
+}
diff --git a/src/system/str.h b/src/system/str.h
new file mode 100644 (file)
index 0000000..b780bc2
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef STR_H_
+#define STR_H_
+
+#define STRINGIFY(x) STRINGIFY2(x)
+#define STRINGIFY2(x) #x
+
+char *string_duplicate(const char *str,
+                       const char *str_end);
+char *string_append(char *prefix,
+                    const char *suffix);
+char *trim_endline(char *s);
+
+#endif  // STR_H_
index 52556f454ed8d8e5b793f1af1b745ede555defbd..81ba9c7db12c64dfad8e68fafd46a87532d223e1 100644 (file)
@@ -6,7 +6,7 @@
 #include "game/sprite_font.h"
 #include "console_log.h"
 #include "math/point.h"
-#include "str.h"
+#include "system/str.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
 
index 9176bcff48293bbd8e0c08a8cebdacc007987001..5e1e86d388ec4e53e5c80dc3405e261c4c3b02c9 100644 (file)
@@ -3,7 +3,7 @@
 #include "system/stacktrace.h"
 
 #include "history.h"
-#include "str.h"
+#include "system/str.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"