diff --git a/CMakeLists.txt b/CMakeLists.txt index c4d82f8..398631e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,162 +8,17 @@ project(null0 ) include(FetchContent) -set(FETCHCONTENT_QUIET 0) +# set(FETCHCONTENT_QUIET OFF) set(CMAKE_BUILD_TYPE Release) -set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) +cmake_policy(SET CMP0077 NEW) +cmake_policy(SET CMP0135 NEW) + set(BUILD_SHARED_LIBS OFF) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake") -# These options will change what is built, and what libraries are used - -if(EMSCRIPTEN) - option(CARTS "Build Demo Null0 Carts" FALSE) -else() - option(SDL "Use SDL in hosts (Choose SDL or RAYLIB)" TRUE) - option(RAYLIB "Use Raylib in hosts (Choose SDL or RAYLIB)" FALSE) - option(CARTS "Build Demo Null0 Carts" TRUE) -endif() - -option(TESTS "Unit tests" FALSE) -option(LIBRETRO "Build Null0 libretro Host" FALSE) -option(HOST "Build Null0 Host" TRUE) - -# this is used to output options -macro(message_bool _NAME _VALUE) - if(${_VALUE}) - message(STATUS " ${_NAME}: enabled") - else() - message(STATUS " ${_NAME}: disabled") - endif() -endmacro() - -if (LIBRETRO) - set(PNTR_APP_LIBRETRO ON) -endif() - -# wamr is used in libretro & native runtimes -if ((HOST OR LIBRETRO) AND NOT EMSCRIPTEN) - find_package(wamr REQUIRED) -endif() - -# check some invalid combos - -if(EMSCRIPTEN AND LIBRETRO) - message(FATAL_ERROR "Do not build libretro core in emscripten. It will not turn out right.") -endif() - -if (NOT EMSCRIPTEN AND (NOT (SDL OR RAYLIB))) - message(FATAL_ERROR "You must set SDL or RAYLIB.") -endif() - -if (SDL AND RAYLIB) - message(FATAL_ERROR "You must set SDL or RAYLIB, not both.") -endif() - -# shared defines for the API -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/null0_api/src) - -# core API will be built with any runtime -if (LIBRETRO OR HOST OR TESTS) - if (SDL) - - # SDL - set(SDL_SHARED FALSE) - set(SDL2_SHARED FALSE) - set(SDL_STATIC TRUE) - set(SDL_TEST FALSE) - set(SDL_TESTS FALSE) - set(INTERFACE_SDL2_SHARED false) - set(SDL2_DISABLE_UNINSTALL TRUE) - set(SDL2_DISABLE_INSTALL TRUE) - set(SDL_INSTALL_TESTS FALSE) - set(SDL2_LIBRARIES SDL2::SDL2-static) - #set(SDL2_LIBRARIES SDL2::SDL2 SDL2::SDL2main) - - # SDL_mixer - set(SDL2MIXER_VORBIS STB) - set(SDL2MIXER_INSTALL OFF) - set(SDL2MIXER_DEPS_SHARED OFF) - set(SDL2MIXER_VENDORED OFF) - set(SDL2MIXER_SAMPLES OFF) - set(SDL2MIXER_CMD OFF) - set(SDL2MIXER_FLAC OFF) - set(SDL2MIXER_MOD OFF) - set(SDL2MIXER_MP3 OFF) - set(SDL2MIXER_MIDI_NATIVE OFF) - set(SDL2MIXER_OPUS OFF) - set(SDL2MIXER_OPUS_SHARED OFF) - set(SDL2MIXER_MIDI_FLUIDSYNTH OFF) - set(SDL2MIXER_MP3_MPG123 OFF) - set(SDL2MIXER_MP3_DRMP3 OFF) - set(SDL2MIXER_MOD_XMP OFF) - set(SDL2MIXER_MOD_MODPLUG OFF) - set(SDL2MIXER_FLAC_DRFLAC OFF) - set(SDL2MIXER_FLAC_LIBFLAC OFF) - set(SDL2MIXER_VORBIS_VORBISFILE OFF) - set(SDL2MIXER_WAVPACK OFF) - set(SDL2MIXER_SAMPLES_INSTALL OFF) - set(SDL2MIXER_BUILD_SHARED_LIBS OFF) - - find_package(SDL2 REQUIRED) - find_package(SDL2_mixer REQUIRED) - - add_definitions(-DPNTR_APP_SDL -DPNTR_PIXELFORMAT_ARGB) - include_directories(${SDL2_INCLUDE_DIR}/..) - endif() - - if (RAYLIB) - find_package(raylib REQUIRED) - add_definitions(-DPNTR_APP_RAYLIB -DPNTR_PIXELFORMAT_RGBA) - endif() - - if (EMSCRIPTEN) - add_definitions(-DPNTR_APP_WEB -DPNTR_PIXELFORMAT_RGBA) - endif() - - set(PHYSFS_ARCHIVE_7Z FALSE) - set(PHYSFS_ARCHIVE_GRP FALSE) - set(PHYSFS_ARCHIVE_HOG FALSE) - set(PHYSFS_ARCHIVE_ISO9660 FALSE) - set(PHYSFS_ARCHIVE_MVL FALSE) - set(PHYSFS_ARCHIVE_QPAK FALSE) - set(PHYSFS_ARCHIVE_SLB FALSE) - set(PHYSFS_ARCHIVE_VDF FALSE) - set(PHYSFS_ARCHIVE_CSM FALSE) - set(PHYSFS_ARCHIVE_WAD FALSE) - set(PHYSFS_BUILD_STATIC TRUE) - set(PHYSFS_BUILD_SHARED FALSE) - set(PHYSFS_BUILD_TEST FALSE) - set(PHYSFS_BUILD_DOCS FALSE) - set(PHYSFS_DISABLE_INSTALL TRUE) - set(PHYSFS_TARGETNAME_UNINSTALL "phys-uninstall") - - find_package(pntr REQUIRED) - find_package(pntr_app REQUIRED) - find_package(physfs REQUIRED) - add_subdirectory(null0_api) -endif() - -if (HOST) - add_subdirectory(host) -endif() - -if (CARTS) - add_subdirectory(cart/c) -endif() - -if (TESTS) - add_subdirectory(test) -endif() - +# CARTS=ON/OFF +# HOST_TYPE=OFF/WEB/RAYLIB/SDL/RETRO -message(STATUS "Null0 will built with the following options:") -message_bool("Web host" HOST AND EMSCRIPTEN) -message_bool("Native host" HOST AND (NOT EMSCRIPTEN)) -message_bool("Libretro host" LIBRETRO) -message_bool("Example carts" CARTS) -message_bool("Unit tests" TESTS) -message_bool("Hosts use Raylib" RAYLIB) -message_bool("Hosts use SDL" SDL) +find_package(null0 REQUIRED) diff --git a/DEPS.md b/DEPS.md deleted file mode 100755 index 2d6da8a..0000000 --- a/DEPS.md +++ /dev/null @@ -1,8 +0,0 @@ -I could lock in versions in cmake, but it should mostly work with latest versions of things. - -Just in case, here are the git-hashes used: - -- physfs: `31209b7` -- pntr: `5e90f33` -- pntr_app: `48119e9` -- wamr: `0ceffe7` diff --git a/README.md b/README.md index 7f3d85f..bf5edaf 100755 --- a/README.md +++ b/README.md @@ -66,66 +66,44 @@ You will need cmake, ninja & emscripten installed. ### more on cmake -You can tune how you build things by using cmake directly: +I like ninja, in the tasks above, because it builds a bit faster, but it's optional, if yuou use cmake directly. -``` -# config -cmake -B build - -# build runtime -cmake --build build +Essentially, there are 2 options: -# run with cart -./build/host/null0 ./build/cart/c/input.null0 +- `CARTS` - Should carts be built? +- `HOST_TYPE` - What sort of host are you building (OFF/WEB/RAYLIB/SDL/RETRO) -# configure for web -emcmake cmake -B wbuild +You can only build 1 `HOST_TYPE` at a time. `CARTS` can be paired with any `HOST_TYPE`, but not `WEB`, and `WEB` requires emscripten (and should probably be built in a seperate root.) -# build web runtime -emmake make -C wbuild -``` - -These cmake-flags will effect the build: - -``` -// Build Null0 libretro Host (don't do this in web-build) -LIBRETRO:BOOL=OFF +#### examples -// Build Null0 Host (web or native) -HOST:BOOL=ON +There are 2 steps: configure & build. -// Use SDL in hosts -SDL:BOOL=ON - -// Build Null0 raylib Host -RAYLIB:BOOL=OFF +```sh +# configure without ninja (plain make) build only carts +cmake -B build -DCARTS=ON -DHOST_TYPE=OFF -// Build Demo Null0 Carts -CARTS:BOOL=ON +# configure for ninja, build only carts +cmake -GNinja -B build -DCARTS=ON -DHOST_TYPE=OFF -// Unit tests -TESTS:BOOL=OFF -``` +# configure for ninja, build only raylib host +cmake -GNinja -B build -DCARTS=OFF -DHOST_TYPE=RAYLIB -You can set them like this: +# configure for ninja, build only SDL host +cmake -GNinja -B build -DCARTS=OFF -DHOST_TYPE=SDL -``` -# don't build demo carts, use defaults -cmake -B build -DCARTS=0 +# configure for ninja, build only libretro-core +cmake -GNinja -B build -DCARTS=OFF -DHOST_TYPE=RETRO -# don't buid anything but the carts (since LIBRETRO and TESTS is off by default) -cmake -B build -DHOST=0 +# configure for ninja, build only web-host (in wbuild/) +emcmake cmake -GNinja -B wbuild -# just build unit-tests -cmake -B build -DHOST=0 -DTESTS=1 -DCARTS=0 +# after configure, build build cmake --build build -./build/test/test_colors +# after configure, build wbuild (for web) +cmake --build wbuild -# just build carts -cmake -B build -DHOST=0 -DTESTS=0 -DCARTS=1 -cmake --build build -``` ## todo diff --git a/docs/cart/colorbars.null0 b/docs/cart/colorbars.null0 index c9396d7..2e64482 100644 Binary files a/docs/cart/colorbars.null0 and b/docs/cart/colorbars.null0 differ diff --git a/docs/cart/draw.null0 b/docs/cart/draw.null0 index ea55384..672f864 100644 Binary files a/docs/cart/draw.null0 and b/docs/cart/draw.null0 differ diff --git a/docs/cart/filesystem.null0 b/docs/cart/filesystem.null0 index 89edc4f..dab295a 100644 Binary files a/docs/cart/filesystem.null0 and b/docs/cart/filesystem.null0 differ diff --git a/docs/cart/flappybird.null0 b/docs/cart/flappybird.null0 index 347f8db..96d9410 100644 Binary files a/docs/cart/flappybird.null0 and b/docs/cart/flappybird.null0 differ diff --git a/docs/cart/hello.null0 b/docs/cart/hello.null0 index 797953d..98b703d 100644 Binary files a/docs/cart/hello.null0 and b/docs/cart/hello.null0 differ diff --git a/docs/cart/input.null0 b/docs/cart/input.null0 index 9358f7e..e947c56 100644 Binary files a/docs/cart/input.null0 and b/docs/cart/input.null0 differ diff --git a/docs/cart/justlog.null0 b/docs/cart/justlog.null0 index dce8b61..1642b8a 100644 Binary files a/docs/cart/justlog.null0 and b/docs/cart/justlog.null0 differ diff --git a/docs/cart/sound.null0 b/docs/cart/sound.null0 index 1556313..340c549 100644 Binary files a/docs/cart/sound.null0 and b/docs/cart/sound.null0 differ diff --git a/docs/cart/tracker.null0 b/docs/cart/tracker.null0 index 9d53c0c..2c1d1b5 100644 Binary files a/docs/cart/tracker.null0 and b/docs/cart/tracker.null0 differ diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 2c022a1..62583e9 100755 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -1,13 +1,15 @@ -add_executable(${PROJECT_NAME} src/main.c) - -if(NOT EMSCRIPTEN) - add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) - target_link_libraries(${PROJECT_NAME} null0_api vmlib) +if (NULL0_HOST_TYPE_RETRO) + add_library(${PROJECT_NAME}_libretro src/main.c) + target_link_libraries(${PROJECT_NAME}_libretro null0_api vmlib) +else() + if (NULL0_HOST_TYPE_SDL OR NULL0_HOST_TYPE_RAYLIB OR NULL0_HOST_TYPE_WEB) + add_executable(${PROJECT_NAME} src/main.c) + if(NULL0_HOST_TYPE_WEB) + set(CMAKE_EXECUTABLE_SUFFIX ".mjs") + target_link_options(${PROJECT_NAME} PRIVATE -sFORCE_FILESYSTEM -sEXPORTED_RUNTIME_METHODS=FS,stringToUTF8 -sEXPORTED_FUNCTIONS=@${CMAKE_CURRENT_SOURCE_DIR}/functions.txt) + target_link_libraries(${PROJECT_NAME} null0_api) + else() + target_link_libraries(${PROJECT_NAME} null0_api vmlib) + endif() + endif() endif() - -if(EMSCRIPTEN) - set(CMAKE_EXECUTABLE_SUFFIX ".mjs") - target_link_options(${PROJECT_NAME} PRIVATE -sFORCE_FILESYSTEM -sEXPORTED_RUNTIME_METHODS=FS,stringToUTF8 -sEXPORTED_FUNCTIONS=@${CMAKE_CURRENT_SOURCE_DIR}/functions.txt) -endif() - -target_link_libraries(${PROJECT_NAME} null0_api) diff --git a/null0_api/CMakeLists.txt b/null0_api/CMakeLists.txt index 207a6be..278b60d 100755 --- a/null0_api/CMakeLists.txt +++ b/null0_api/CMakeLists.txt @@ -1,16 +1,13 @@ add_library(null0_api src/main.c src/sfx_gen.c) -# TODO: check for emscripten - -if (RAYLIB) +if (NULL0_HOST_TYPE_RAYLIB) target_link_libraries(null0_api raylib pntr pntr_app physfs-static) endif() -if (SDL) - message("SDL libs: ${SDL2_LIBRARIES} ${SDL2_MIXER_LIBRARIES} ${SDL2_IMAGE_LIBRARIES}") +if (NULL0_HOST_TYPE_SDL) target_link_libraries(null0_api ${SDL2_LIBRARIES} pntr pntr_app physfs-static) endif() -if (EMSCRIPTEN) +if (NULL0_HOST_TYPE_WEB) target_link_libraries(null0_api pntr pntr_app physfs-static) endif() \ No newline at end of file diff --git a/package.json b/package.json index f259a7d..4161f41 100755 --- a/package.json +++ b/package.json @@ -7,10 +7,10 @@ "scripts": { "clean": "rimraf build wbuild docs/cart docs/wasm", "start": "npm run build:site && live-server docs", - "build:retro": "cmake -GNinja -B build -DLIBRETRO=1 -DHOST=0 -DTESTS=0 -DCARTS=0 && cmake --build build", - "build:carts": "cmake -GNinja -B build -DLIBRETRO=0 -DHOST=0 -DTESTS=0 -DCARTS=1 && cmake --build build", - "build:host": "cmake -GNinja -B build -DLIBRETRO=0 -DHOST=1 -DTESTS=0 -DCARTS=0 && cmake --build build", - "build:web": "emcmake cmake -DLIBRETRO=0 -DHOST=1 -DTESTS=0 -DCARTS=0 -GNinja -B wbuild && cmake --build wbuild", + "build:retro": "cmake -GNinja -B build -DCARTS=OFF -DHOST_TYPE=RETRO && cmake --build build", + "build:carts": "cmake -GNinja -B build -DCARTS=ON -DHOST_TYPE=OFF && cmake --build build", + "build:host": "cmake -GNinja -B build -DCARTS=OFF -DHOST_TYPE=RAYLIB && cmake --build build", + "build:web": "emcmake cmake -GNinja -B wbuild && cmake --build wbuild", "build:site": "npm run build:carts && npm run build:web && mkdir -p docs/wasm docs/cart && cp wbuild/host/null0.* docs/wasm && cp build/cart/c/*.null0 docs/cart" }, "keywords": [], diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100755 index 1103cbd..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -add_executable(test_colors test_colors.c) -add_executable(test_sound test_sound.c) - -if (RAYLIB) - target_link_libraries(test_colors raylib pntr pntr_app) - target_link_libraries(test_sound raylib pntr pntr_app) -endif() - -if (SDL) - target_link_libraries(test_colors ${SDL2_LIBRARIES} pntr pntr_app) - target_link_libraries(test_sound ${SDL2_LIBRARIES} pntr pntr_app) -endif() - - - diff --git a/test/test_colors.c b/test/test_colors.c deleted file mode 100755 index 009bae6..0000000 --- a/test/test_colors.c +++ /dev/null @@ -1,71 +0,0 @@ -// this is a native implementation of colorbars cart, to ensure they match - -#define PNTR_IMPLEMENTATION -#define PNTR_APP_IMPLEMENTATION - -#include "pntr_app.h" - -pntr_color colors[27]; - -bool Init(pntr_app* app) { - colors[0] = PNTR_LIGHTGRAY; - colors[1] = PNTR_GRAY; - colors[2] = PNTR_DARKGRAY; - colors[3] = PNTR_YELLOW; - colors[4] = PNTR_GOLD; - colors[5] = PNTR_ORANGE; - colors[6] = PNTR_PINK; - colors[7] = PNTR_RED; - colors[8] = PNTR_MAROON; - colors[9] = PNTR_GREEN; - colors[10] = PNTR_LIME; - colors[11] = PNTR_DARKGREEN; - colors[12] = PNTR_SKYBLUE; - colors[13] = PNTR_BLUE; - colors[14] = PNTR_DARKBLUE; - colors[15] = PNTR_PURPLE; - colors[16] = PNTR_VIOLET; - colors[17] = PNTR_DARKPURPLE; - colors[18] = PNTR_BEIGE; - colors[19] = PNTR_BROWN; - colors[20] = PNTR_DARKBROWN; - colors[21] = PNTR_WHITE; - colors[22] = PNTR_BLACK; - colors[24] = PNTR_BLANK; - colors[25] = PNTR_MAGENTA; - colors[26] = PNTR_RAYWHITE; - - return true; -} - -bool Update(pntr_app* app, pntr_image* screen) { - pntr_clear_background(screen, PNTR_BLACK); - - int x; - int c = 0; - for (x = 10; x < (28 * 10); x += 10) { - pntr_draw_rectangle_fill(screen, x + 13, 5, 8, 5, PNTR_WHITE); - pntr_draw_rectangle_fill(screen, x + 15, 15, 5, 210, colors[c++]); - pntr_draw_rectangle_fill(screen, x + 13, 230, 8, 5, PNTR_WHITE); - } - - return true; -} - -void Close(pntr_app* app) { -} - -void Event(pntr_app* app, pntr_app_event* event) { -} - -pntr_app Main(int argc, char* argv[]) { - return (pntr_app){ - .width = 320, - .height = 240, - .title = "null0", - .init = Init, - .update = Update, - .close = Close, - .event = Event, - .fps = 60}; -} \ No newline at end of file diff --git a/test/test_sound.c b/test/test_sound.c deleted file mode 100755 index cb33fcf..0000000 --- a/test/test_sound.c +++ /dev/null @@ -1,39 +0,0 @@ -#define PNTR_IMPLEMENTATION -#define PNTR_ENABLE_DEFAULT_FONT -#define PNTR_APP_IMPLEMENTATION - -#include "pntr_app.h" - -pntr_font* font; -pntr_sound* sound; - -bool Init(pntr_app* app) { - font = pntr_load_font_default(); - sound = pntr_load_sound("cart/c/sound/assets/apache.ogg"); - pntr_play_sound(sound, true); - return true; -} - -bool Update(pntr_app* app, pntr_image* screen) { - pntr_clear_background(screen, PNTR_BLACK); - pntr_draw_text(screen, font, "You should hear sound.", 80, 110, PNTR_WHITE); - return true; -} - -void Close(pntr_app* app) { -} - -void Event(pntr_app* app, pntr_app_event* event) { -} - -pntr_app Main(int argc, char* argv[]) { - return (pntr_app){ - .width = 320, - .height = 240, - .title = "null0", - .init = Init, - .update = Update, - .close = Close, - .event = Event, - .fps = 60}; -} \ No newline at end of file diff --git a/tools/cmake/FindSDL2.cmake b/tools/cmake/FindSDL2.cmake index 0aa48ee..c18f4da 100755 --- a/tools/cmake/FindSDL2.cmake +++ b/tools/cmake/FindSDL2.cmake @@ -1,10 +1,6 @@ -# SDL2 -include(FetchContent) -FetchContent_Declare( - SDL2Source - GIT_REPOSITORY https://github.com/libsdl-org/SDL.git - GIT_TAG release-2.30.2 - GIT_SHALLOW 1 +FetchContent_Declare(SDL2Source + URL https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.30.5.zip ) + FetchContent_MakeAvailable(SDL2Source) #include_directories(${SDL2Source_SOURCE_DIR}) diff --git a/tools/cmake/FindSDL2_mixer.cmake b/tools/cmake/FindSDL2_mixer.cmake index 9b62edf..6878790 100755 --- a/tools/cmake/FindSDL2_mixer.cmake +++ b/tools/cmake/FindSDL2_mixer.cmake @@ -1,10 +1,6 @@ -# SDL2_mixer -include(FetchContent) -FetchContent_Declare( - SDL2MixerSource - GIT_REPOSITORY https://github.com/libsdl-org/SDL_mixer.git - GIT_TAG release-2.8.0 - GIT_SHALLOW 1 +FetchContent_Declare(SDL2MixerSource + URL https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/release-2.8.0.zip ) + FetchContent_MakeAvailable(SDL2MixerSource) #include_directories(${sdl2mixersource_SOURCE_DIR}/include) diff --git a/tools/cmake/Findnull0.cmake b/tools/cmake/Findnull0.cmake new file mode 100644 index 0000000..8140217 --- /dev/null +++ b/tools/cmake/Findnull0.cmake @@ -0,0 +1,157 @@ +# handle different options +# CARTS=ON/OFF +# HOST_TYPE=OFF/WEB/RAYLIB/SDL/RETRO + +if(EMSCRIPTEN) + set(HOST_TYPE "WEB") + set(NULL0_HOST_TYPE_WEB ON) + set(CARTS OFF) +else() + set(NULL0_HOST_TYPE_WEB OFF) + option(CARTS "Build demo-carts" ON) + if(NOT DEFINED HOST_TYPE) + set(HOST_TYPE "RAYLIB") + endif() + if("${HOST_TYPE}" STREQUAL "WEB") + message(FATAL_ERROR "You must build WEB with emscripten (use emcmake)") + endif() +endif() + +message(STATUS "Null0 will built with the following options:") +if(CARTS) + message(STATUS " Example carts: ON") +else() + message(STATUS " Example carts: OFF") +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/null0_api/src) + +if(HOST_TYPE) + message(STATUS " Host: " ${HOST_TYPE}) + + # setup easier booleans + if("${HOST_TYPE}" STREQUAL "RAYLIB") + set(NULL0_HOST_TYPE_RAYLIB ON) + set(NULL0_HOST_TYPE_SDL OFF) + set(NULL0_HOST_TYPE_RETRO OFF) + endif() + + if("${HOST_TYPE}" STREQUAL "SDL") + set(NULL0_HOST_TYPE_RAYLIB OFF) + set(NULL0_HOST_TYPE_SDL ON) + set(NULL0_HOST_TYPE_RETRO OFF) + endif() + + if("${HOST_TYPE}" STREQUAL "WEB") + set(NULL0_HOST_TYPE_RAYLIB OFF) + set(NULL0_HOST_TYPE_SDL OFF) + set(NULL0_HOST_TYPE_RETRO OFF) + endif() + + if("${HOST_TYPE}" STREQUAL "RETRO") + set(NULL0_HOST_TYPE_RAYLIB OFF) + set(NULL0_HOST_TYPE_SDL OFF) + set(NULL0_HOST_TYPE_RETRO ON) + endif() + + option(NULL0_HOST_TYPE_RAYLIB "Build raylib host" ${NULL0_HOST_TYPE_RAYLIB}) + option(NULL0_HOST_TYPE_SDL "Build SDL host" ${NULL0_HOST_TYPE_SDL}) + option(NULL0_HOST_TYPE_RETRO "Build libretro-core host" ${NULL0_HOST_TYPE_RETRO}) + option(NULL0_HOST_TYPE_WEB "Build web-host" ${NULL0_HOST_TYPE_WEB}) + + if(NOT NULL0_HOST_TYPE_WEB AND NOT NULL0_HOST_TYPE_RAYLIB AND NOT NULL0_HOST_TYPE_SDL AND NOT NULL0_HOST_TYPE_RETRO) + message(FATAL_ERROR "Invalid HOST_TYPE: (${HOST_TYPE}) choose OFF, WEB, RAYLIB, SDL, or RETRO") + endif() + + if (NULL0_HOST_TYPE_SDL) + set(SDL_SHARED FALSE) + set(SDL2_SHARED FALSE) + set(SDL_STATIC TRUE) + set(SDL_TEST FALSE) + set(SDL_TESTS FALSE) + set(INTERFACE_SDL2_SHARED FALSE) + set(SDL2_DISABLE_UNINSTALL TRUE) + set(SDL2_DISABLE_INSTALL TRUE) + set(SDL_INSTALL_TESTS FALSE) + set(SDL2_LIBRARIES SDL2::SDL2-static) + #set(SDL2_LIBRARIES SDL2::SDL2 SDL2::SDL2main) + + # SDL_mixer + set(SDL2MIXER_VORBIS STB) + set(SDL2MIXER_INSTALL OFF) + set(SDL2MIXER_DEPS_SHARED OFF) + set(SDL2MIXER_VENDORED OFF) + set(SDL2MIXER_SAMPLES OFF) + set(SDL2MIXER_CMD OFF) + set(SDL2MIXER_FLAC OFF) + set(SDL2MIXER_MOD OFF) + set(SDL2MIXER_MP3 OFF) + set(SDL2MIXER_MIDI_NATIVE OFF) + set(SDL2MIXER_OPUS OFF) + set(SDL2MIXER_OPUS_SHARED OFF) + set(SDL2MIXER_MIDI_FLUIDSYNTH OFF) + set(SDL2MIXER_MP3_MPG123 OFF) + set(SDL2MIXER_MP3_DRMP3 OFF) + set(SDL2MIXER_MOD_XMP OFF) + set(SDL2MIXER_MOD_MODPLUG OFF) + set(SDL2MIXER_FLAC_DRFLAC OFF) + set(SDL2MIXER_FLAC_LIBFLAC OFF) + set(SDL2MIXER_VORBIS_VORBISFILE OFF) + set(SDL2MIXER_WAVPACK OFF) + set(SDL2MIXER_SAMPLES_INSTALL OFF) + set(SDL2MIXER_BUILD_SHARED_LIBS OFF) + + find_package(SDL2 REQUIRED) + find_package(SDL2_mixer REQUIRED) + + add_definitions(-DPNTR_APP_SDL -DPNTR_PIXELFORMAT_ARGB) + include_directories(${SDL2_INCLUDE_DIR}/..) + endif() + + if (NULL0_HOST_TYPE_RAYLIB) + add_definitions(-DPNTR_NO_STB_IMAGE_IMPLEMENTATION) + add_definitions(-DPNTR_NO_STB_IMAGE_WRITE_IMPLEMENTATION) + find_package(raylib REQUIRED) + add_definitions(-DPNTR_APP_RAYLIB -DPNTR_PIXELFORMAT_RGBA) + endif() + + if (NULL0_HOST_TYPE_WEB) + add_definitions(-DPNTR_APP_WEB -DPNTR_PIXELFORMAT_RGBA) + else() + find_package(wamr REQUIRED) + add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) + endif() + + if (NULL0_HOST_TYPE_RETRO) + add_definitions(-DPNTR_APP_LIBRETRO -DPNTR_PIXELFORMAT_RGBA) + endif() + + set(PHYSFS_ARCHIVE_7Z CACHE INTERNAL FALSE) + set(PHYSFS_ARCHIVE_GRP CACHE INTERNAL FALSE) + set(PHYSFS_ARCHIVE_HOG CACHE INTERNAL FALSE) + set(PHYSFS_ARCHIVE_ISO9660 CACHE INTERNAL FALSE) + set(PHYSFS_ARCHIVE_MVL CACHE INTERNAL FALSE) + set(PHYSFS_ARCHIVE_QPAK CACHE INTERNAL FALSE) + set(PHYSFS_ARCHIVE_SLB CACHE INTERNAL FALSE) + set(PHYSFS_ARCHIVE_VDF CACHE INTERNAL FALSE) + set(PHYSFS_ARCHIVE_CSM CACHE INTERNAL FALSE) + set(PHYSFS_ARCHIVE_WAD CACHE INTERNAL FALSE) + set(PHYSFS_BUILD_STATIC TRUE) + set(PHYSFS_BUILD_SHARED CACHE INTERNAL FALSE) + set(PHYSFS_BUILD_TEST CACHE INTERNAL FALSE) + set(PHYSFS_BUILD_DOCS CACHE INTERNAL FALSE) + set(PHYSFS_DISABLE_INSTALL CACHE INTERNAL TRUE) + + find_package(pntr REQUIRED) + find_package(pntr_app REQUIRED) + find_package(physfs REQUIRED) + + add_subdirectory(null0_api) + add_subdirectory(host) +else() + message(STATUS " Host: OFF") +endif() + +if (CARTS) + add_subdirectory(cart/c) +endif() diff --git a/tools/cmake/Findphysfs.cmake b/tools/cmake/Findphysfs.cmake index 2efeaee..96de571 100755 --- a/tools/cmake/Findphysfs.cmake +++ b/tools/cmake/Findphysfs.cmake @@ -1,9 +1,7 @@ -FetchContent_Declare( - physfs - GIT_REPOSITORY https://github.com/icculus/physfs.git - GIT_TAG main - GIT_PROGRESS TRUE - GIT_SHALLOW 1 +FetchContent_Declare(physfs + URL https://github.com/icculus/physfs/archive/refs/heads/master.zip ) +FetchContent_MakeAvailable(physfs) + FetchContent_MakeAvailable(physfs) include_directories(${physfs_SOURCE_DIR}/src) diff --git a/tools/cmake/Findpntr.cmake b/tools/cmake/Findpntr.cmake index fa2c504..20edd99 100755 --- a/tools/cmake/Findpntr.cmake +++ b/tools/cmake/Findpntr.cmake @@ -1,8 +1,5 @@ -# pntr -include(FetchContent) -FetchContent_Declare( - pntr - GIT_REPOSITORY https://github.com/robloach/pntr.git - GIT_TAG 23099c7787754d355400a31edefb166db3d93012 +FetchContent_Declare(pntr + URL https://github.com/RobLoach/pntr/archive/refs/heads/master.zip ) FetchContent_MakeAvailable(pntr) + diff --git a/tools/cmake/Findpntr_app.cmake b/tools/cmake/Findpntr_app.cmake index 35320c0..1efa685 100755 --- a/tools/cmake/Findpntr_app.cmake +++ b/tools/cmake/Findpntr_app.cmake @@ -1,9 +1,5 @@ -FetchContent_Declare( - pntr_app - GIT_REPOSITORY https://github.com/robloach/pntr_app.git - GIT_TAG master - GIT_PROGRESS 1 - GIT_SHALLOW 1 +FetchContent_Declare(pntr_app + URL https://github.com/RobLoach/pntr_app/archive/refs/heads/master.zip ) FetchContent_MakeAvailable(pntr_app) -include_directories(${pntr_app_SOURCE_DIR}/include) \ No newline at end of file +include_directories(${pntr_app_SOURCE_DIR}/include) diff --git a/tools/cmake/Findraylib.cmake b/tools/cmake/Findraylib.cmake index db3e894..3f92d8a 100755 --- a/tools/cmake/Findraylib.cmake +++ b/tools/cmake/Findraylib.cmake @@ -1,12 +1,8 @@ -# raylib -include(FetchContent) -FetchContent_Declare( - raylib - GIT_REPOSITORY https://github.com/raysan5/raylib.git - GIT_TAG 5.0 - GIT_SHALLOW 1 +FetchContent_Declare(raylib + URL https://github.com/raysan5/raylib/archive/refs/tags/5.0.zip ) -FetchContent_GetProperties(raylib) +FetchContent_MakeAvailable(raylib) + if (NOT raylib_POPULATED) set(FETCHCONTENT_QUIET NO) FetchContent_Populate(raylib) diff --git a/tools/cmake/Findwamr.cmake b/tools/cmake/Findwamr.cmake index 21b8453..82e6bdc 100755 --- a/tools/cmake/Findwamr.cmake +++ b/tools/cmake/Findwamr.cmake @@ -5,12 +5,9 @@ set (WAMR_BUILD_AOT 0) set (WAMR_BUILD_LIBC_BUILTIN 1) set (WAMR_BUILD_LIBC_WASI 1) set (WAMR_BUILD_SIMD 1) -FetchContent_Declare( - wamr - GIT_REPOSITORY https://github.com/bytecodealliance/wasm-micro-runtime.git - GIT_TAG main - GIT_PROGRESS 1 - GIT_SHALLOW 1 + +FetchContent_Declare(wamr + URL https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/heads/master.zip ) FetchContent_MakeAvailable(wamr) include (${wamr_SOURCE_DIR}/build-scripts/runtime_lib.cmake) \ No newline at end of file