From ec10ff9f1eaf849bfb703c011eba317264537660 Mon Sep 17 00:00:00 2001 From: David Konsumer Date: Wed, 10 Jul 2024 17:34:21 -0700 Subject: [PATCH] improving build --- CMakeLists.txt | 159 ++----------------------------- DEPS.md | 8 -- README.md | 68 +++++-------- docs/cart/colorbars.null0 | Bin 12327 -> 12327 bytes docs/cart/draw.null0 | Bin 12197 -> 12197 bytes docs/cart/filesystem.null0 | Bin 13250 -> 13250 bytes docs/cart/flappybird.null0 | Bin 1179576 -> 1179576 bytes docs/cart/hello.null0 | Bin 12065 -> 12065 bytes docs/cart/input.null0 | Bin 52056 -> 52056 bytes docs/cart/justlog.null0 | Bin 12102 -> 12102 bytes docs/cart/sound.null0 | Bin 103299 -> 103299 bytes docs/cart/tracker.null0 | Bin 17222 -> 17222 bytes host/CMakeLists.txt | 26 ++--- null0_api/CMakeLists.txt | 9 +- package.json | 8 +- test/CMakeLists.txt | 15 --- test/test_colors.c | 71 -------------- test/test_sound.c | 39 -------- tools/cmake/FindSDL2.cmake | 10 +- tools/cmake/FindSDL2_mixer.cmake | 10 +- tools/cmake/Findnull0.cmake | 157 ++++++++++++++++++++++++++++++ tools/cmake/Findphysfs.cmake | 10 +- tools/cmake/Findpntr.cmake | 9 +- tools/cmake/Findpntr_app.cmake | 10 +- tools/cmake/Findraylib.cmake | 12 +-- tools/cmake/Findwamr.cmake | 9 +- 26 files changed, 231 insertions(+), 399 deletions(-) delete mode 100755 DEPS.md delete mode 100755 test/CMakeLists.txt delete mode 100755 test/test_colors.c delete mode 100755 test/test_sound.c create mode 100644 tools/cmake/Findnull0.cmake 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 c9396d7388039e5c993fc1df8d4e1d553512c58e..2e64482db5cd235d3cfa044b901fdb9b4e9332aa 100644 GIT binary patch delta 47 zcmZ3Uusne$z?+#xgn@y9gF&NbB98*Qw?=;&5N|Y|ttP9y5?TnbANE03|65 A&Hw-a delta 47 zcmZ3Uusne$z?+#xgn@y9gJDa~L>>ipk&k_8K)lg-wm#FAoXHpT^_YR&$&3bS09B(8 ASpWb4 diff --git a/docs/cart/draw.null0 b/docs/cart/draw.null0 index ea5538407dc853fe8f401a054b59552dddbb60b0..672f8648cc7ffb05d812c030fc1d306f6e25dc38 100644 GIT binary patch delta 47 zcmZ1)zcijFz?+#xgn@y9gF&NbB98*Qw?=;&5N|Y=)MwJ@ne3;p#|-37uGd!s02fyb AK>z>% delta 47 zcmZ1)zcijFz?+#xgn@y9gJDa~L>>ipk&k_8K)lgdQlDu{&SXD*J!T+xa=pG907uad A%m4rY diff --git a/docs/cart/filesystem.null0 b/docs/cart/filesystem.null0 index 89edc4fc23c6a7965093b16074411dfbf08469cc..dab295a56c43c3bdc3c840d70336ecdb8d115e21 100644 GIT binary patch delta 47 zcmX?}Fg8054(< AK>z>% delta 47 zcmX?>ipk&k_8K)liTff3V|oXMibddxuXWH;j)0AJh> A%m4rY diff --git a/docs/cart/flappybird.null0 b/docs/cart/flappybird.null0 index 347f8db4d60714d61232c82a6c1df667dcd63890..96d94106a543269c4fe73b8d4b0d988e8cb44088 100644 GIT binary patch delta 113 zcmdn--+jk_cb))mW)=|!1_llWjh=}-3hdq*{b@klXxwVd*lNtwYRuef%+hMi+G@Ejbf;6xc;R_N4)Fqj9S-W2-S!t1)w{F-xm4YpXF^ zt1)}4F-NO0XR9$+t1)-0F;A;8Z>uq1t1*A8vA|Yi!HOSDTXLqa{UNBwB=T|k#Q%cA L+dupeJi!J43rHi$ diff --git a/docs/cart/hello.null0 b/docs/cart/hello.null0 index 797953da8153e9767d5375295119af7abec84f49..98b703d92cc179e4654b5ee274ad15392a1bd8de 100644 GIT binary patch delta 47 zcmZ1&w=j+;z?+#xgn@y9gF&NbB98*Qw?=;&5N|Y|s>h_!Gx?OB9y5?T`L~`L03>w{ Ar~m)} delta 47 zcmZ1&w=j+;z?+#xgn@y9gJDa~L>>ipk&k_8K)lg-svgspoXMy3^q7I%$-ni~095Y~ AGXMYp diff --git a/docs/cart/input.null0 b/docs/cart/input.null0 index 9358f7e18defbc3f3c12b7c3c6c79e27a1e08901..e947c569d61621ff947863b1eafaac93d7e442a8 100644 GIT binary patch delta 50 zcmcaHjrqnjW}X0VW)=|!1_llWjh=}-3hdq*{b@kF(YX5kEOE! E0CEfvn*aa+ delta 57 zcmcaHjrqnjW}X0VW)=|!1_lm>Ejbf;6xc;R_N4*wM&s^dOj~j$A2_DRB=T{x;c4N? N3r_NF7Ci3G0st?J6+{34 diff --git a/docs/cart/justlog.null0 b/docs/cart/justlog.null0 index dce8b61fc5d7832e9f07420380dff6e482b7f43f..1642b8a3d098daa1749bedb025ee00f19141f174 100644 GIT binary patch delta 47 zcmX>WcPx%4z?+#xgn@y9gF&NbB98*Qw?=;&5N|ZzrN^YvGx@!q9y5?TSwUY705d)f AVgLXD delta 47 zcmX>WcPx%4z?+#xgn@y9gJDa~L>>ipk&k_8K)lg-mmbrWoXPL?^q7I%$qM>v0Asih A?EnA( diff --git a/docs/cart/sound.null0 b/docs/cart/sound.null0 index 1556313d663e7359971596790e9808bdfca99c5a..340c549ea26e98f9e840e9434b6c5b0423e33ad4 100644 GIT binary patch delta 58 zcmZo(&ept~jVHjHnMH(wfq{cTqh}(I0=u_He;N=s8gDgbbe_bd(KEeb5~Ch7P-xm@ MMuq7oCo%2<0J@A30RR91 delta 58 zcmZo(&ept~jVHjHnMH(wfq{czOU^_d1$L2-eQ7}4XuQ>!(RmWnmYnGolNj}wL_SXc NKZ#Ls`pHR*y8r@g6a4@H diff --git a/docs/cart/tracker.null0 b/docs/cart/tracker.null0 index 9d53c0c6adcc136030cb5f3903398858e32a3ba1..2c1d1b5e96a8f8428deb774ea394c716e8468d17 100644 GIT binary patch delta 49 zcmX@s#(1oakte{LnMH(wfq{cTqh}(I0=u_He;N>PG>&s((&(8y*-4KX$enz|sR;l- C^$s@x delta 49 zcmX@s#(1oakte{LnMH(wfq{czOU^_d1$L2-eQ7|v(KybDX-m%J$xeFAK