diff --git a/CMakeLists.txt b/CMakeLists.txt index cd19f39..688d1d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ find_package(Gint 2.5 REQUIRED) # include directories, put your .h files in those folders include_directories(include) include_directories(wren/include) +include_directories("${FXSDK_COMPILER_INSTALL}/include/openlibm") # source files set(SOURCES @@ -21,7 +22,8 @@ set(SOURCES src/ui.c src/battery.c src/syscalls.S - +) +set(SOURCES_WREN wren/src/wren_compiler.c wren/src/wren_core.c wren/src/wren_debug.c @@ -32,6 +34,7 @@ set(SOURCES wren/src/wren_opt_meta.c wren/src/wren_opt_random.c ) + # shared assets set(ASSETS # ... @@ -77,15 +80,21 @@ set(FLAGS # -O3: gotta go fast -Os ) +set(FLAGS_WREN + -std=c99 + -O3 +) -set(ASM_OPTIONS "-x assembler-with-cpp") -set(CMAKE_ASM_FLAGS "${ASM_OPTIONS}") +set(CMAKE_ASM_FLAGS "-x assembler-with-cpp") + +add_library(Wren ${SOURCES_WREN}) +target_compile_options(Wren PRIVATE ${FLAGS_WREN}) fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA) - add_executable(Main ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}}) target_compile_options(Main PRIVATE ${FLAGS}) -target_link_libraries(Main Gint::Gint) + +target_link_libraries(Main Wren Gint::Gint) if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) generate_g1a( diff --git a/src/main.c b/src/main.c index c6ab23e..632c1b5 100644 --- a/src/main.c +++ b/src/main.c @@ -15,8 +15,9 @@ #include "term.h" #include "ui.h" -static void wn_write(WrenVM *vm, const char *text) { term_print(text); } -static void wn_error(WrenVM *vm, WrenErrorType errorType, const char *module, const int line, const char *msg) { +static void wn_write(WrenVM __attribute__((unused)) * vm, const char *text) { term_print(text); } +static void wn_error(WrenVM __attribute__((unused)) * vm, WrenErrorType errorType, const char *module, const int line, + const char *msg) { switch (errorType) { case WREN_ERROR_COMPILE: term_printf("[%s line %d] [Error] %s\n", module, line, msg); @@ -27,10 +28,12 @@ static void wn_error(WrenVM *vm, WrenErrorType errorType, const char *module, co case WREN_ERROR_RUNTIME: term_eprintf("[Runtime Error] %s\n", msg); break; + default: + break; } } -static void *wn_reallocate(void *memory, size_t newSize, void *_) { +static void *wn_reallocate(void *memory, size_t newSize, __attribute__((unused)) void *userData) { if (memory == NULL && newSize == 0) return NULL; @@ -115,7 +118,7 @@ static void check_keyevents(void) { } } -int main(int isappli, int optnum) { +int main(__attribute__((unused)) int isappli, __attribute__((unused)) int optnum) { WrenConfiguration config; wrenInitConfiguration(&config); config.reallocateFn = &wn_reallocate; @@ -125,9 +128,9 @@ int main(int isappli, int optnum) { config.writeFn = &wn_write; config.errorFn = &wn_error; WrenVM *vm = wrenNewVM(&config); - WrenInterpretResult result = wrenInterpret(vm, "my_module", - "System.print(\"I am running in a VM!\")\n" - "System.trigger_error_from_vm()"); + wrenInterpret(vm, "my_module", + "System.print(\"I am running in a VM!\")\n" + "System.trigger_error_from_vm()"); wrenFreeVM(vm); timer_redraw = timer_configure(TIMER_ANY, 31250, GINT_CALL(callback_redraw)); // 32 Hz diff --git a/src/term.c b/src/term.c index 5abedb7..0b15c1e 100644 --- a/src/term.c +++ b/src/term.c @@ -114,7 +114,7 @@ void term_scroll_down(void) { } } -int term_print_opt(const char *str, int fg, int bg) { +static int term_print_opt(const char *str, int fg, int bg) { static int row = 1; static int col = 0; diff --git a/wren/include/wren.h b/wren/include/wren.h index 7845911..03bd792 100644 --- a/wren/include/wren.h +++ b/wren/include/wren.h @@ -299,7 +299,7 @@ typedef enum // Get the current wren version number. // // Can be used to range checks over versions. -WREN_API int wrenGetVersionNumber(); +WREN_API int wrenGetVersionNumber(void); // Initializes [configuration] with all of its default values. // diff --git a/wren/src/wren_vm.c b/wren/src/wren_vm.c index 254d0b0..bb5c277 100644 --- a/wren/src/wren_vm.c +++ b/wren/src/wren_vm.c @@ -36,7 +36,7 @@ static void* defaultReallocate(void* ptr, size_t newSize, void* _) return realloc(ptr, newSize); } -int wrenGetVersionNumber() +int wrenGetVersionNumber(void) { return WREN_VERSION_NUMBER; }