diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 5d1db44..8ddfb07 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -18,17 +18,9 @@ jobs: apk update apk add build-base make git cmake - - name: Compile masp + - name: Compile OpenVCL and examples run: | - git clone https://github.com/fjtrujy/masp.git - cd masp - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PS2DEV" - cmake --build build -j $(getconf _NPROCESSORS_ONLN) - cmake --install build - - - name: Compile OpenVCL - run: | - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PS2DEV" + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PS2DEV" -DBUILD_EXAMPLES=ON cmake --build build -j $(getconf _NPROCESSORS_ONLN) - name: Run OpenVCL tests @@ -39,10 +31,6 @@ jobs: run: | cmake --install build - - name: Build PS2 examples - run: | - make -C examples all - - name: Get short SHA id: slug run: echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT diff --git a/.gitignore b/.gitignore index baf7c69..a584b60 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ openvcl t2-output *.o +*.vo *.elf *.vsm !test/fixtures/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 949bada..ea0d812 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,3 +45,15 @@ include(CTest) if(BUILD_TESTING) add_subdirectory(test) endif() + +# PS2 examples – require PS2SDK environment variable and the PS2 toolchain. +# Enabled automatically when $PS2SDK is set; override with -DBUILD_EXAMPLES=ON/OFF. +if(DEFINED ENV{PS2SDK}) + option(BUILD_EXAMPLES "Build PS2 examples (requires PS2SDK toolchain)" ON) +else() + option(BUILD_EXAMPLES "Build PS2 examples (requires PS2SDK toolchain)" OFF) +endif() + +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..c6d94a5 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,23 @@ +set(_EXAMPLES pdk sprite triangle triangle-gasp triangle_strip) + +foreach(_example IN LISTS _EXAMPLES) + string(REPLACE "-" "_" _target_name "${_example}") + add_custom_target(example_${_target_name} + COMMAND ${CMAKE_MAKE_PROGRAM} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_example} + COMMENT "Building example: ${_example}" + VERBATIM + ) + add_dependencies(example_${_target_name} openvcl) + list(APPEND _EXAMPLE_TARGETS example_${_target_name}) +endforeach() + +# sprite, triangle, triangle-gasp, and triangle_strip all link against libpdk.a +foreach(_dep sprite triangle triangle_gasp triangle_strip) + add_dependencies(example_${_dep} example_pdk) +endforeach() + +add_custom_target(examples ALL + DEPENDS ${_EXAMPLE_TARGETS} + COMMENT "Building all PS2 examples" +) diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..218f0af --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,15 @@ +SUBDIRS = pdk sprite triangle triangle-gasp triangle_strip + +all: + $(MAKE) -C pdk + $(MAKE) -C sprite + $(MAKE) -C triangle + $(MAKE) -C triangle-gasp + $(MAKE) -C triangle_strip + +clean: + $(MAKE) -C pdk clean + $(MAKE) -C sprite clean + $(MAKE) -C triangle clean + $(MAKE) -C triangle-gasp clean + $(MAKE) -C triangle_strip clean diff --git a/fast_nolights.vo b/fast_nolights.vo deleted file mode 100644 index b4ca17f..0000000 Binary files a/fast_nolights.vo and /dev/null differ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8ccdf0f..7e7b7b2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -105,8 +105,20 @@ target_compile_definitions(openvcl_unit_tests PRIVATE # themselves don't need -Isrc because their own #include "Foo.h" directives # resolve via the source file's own directory. Test files reach openvcl # headers via explicit relative paths like #include "../src/Expression.h". +# OpenVclVersion.h is generated by configure_file; reproduce it here so both +# standalone (cmake -S test) and integrated (add_subdirectory) builds work. +# CMAKE_PROJECT_VERSION is the top-level project version when built from root, +# and empty when built standalone (acceptable for test purposes). +set(PROJECT_VERSION "${CMAKE_PROJECT_VERSION}") +configure_file( + "${OPENVCL_ROOT}/src/OpenVclVersion.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/OpenVclVersion.h" + @ONLY +) + target_include_directories(openvcl_unit_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR} ) # The library code was written for an older C++ dialect; silence the warnings diff --git a/fast.vcl b/test/fixtures/fast.vcl similarity index 100% rename from fast.vcl rename to test/fixtures/fast.vcl diff --git a/fast_nolights.vcl b/test/fixtures/fast_nolights.vcl similarity index 100% rename from fast_nolights.vcl rename to test/fixtures/fast_nolights.vcl diff --git a/general.vcl b/test/fixtures/general.vcl similarity index 100% rename from general.vcl rename to test/fixtures/general.vcl diff --git a/general_nospec.vcl b/test/fixtures/general_nospec.vcl similarity index 100% rename from general_nospec.vcl rename to test/fixtures/general_nospec.vcl diff --git a/general_nospec_quad.vcl b/test/fixtures/general_nospec_quad.vcl similarity index 100% rename from general_nospec_quad.vcl rename to test/fixtures/general_nospec_quad.vcl diff --git a/general_nospec_tri.vcl b/test/fixtures/general_nospec_tri.vcl similarity index 100% rename from general_nospec_tri.vcl rename to test/fixtures/general_nospec_tri.vcl diff --git a/general_pv_diff.vcl b/test/fixtures/general_pv_diff.vcl similarity index 100% rename from general_pv_diff.vcl rename to test/fixtures/general_pv_diff.vcl diff --git a/general_pv_diff_quad.vcl b/test/fixtures/general_pv_diff_quad.vcl similarity index 100% rename from general_pv_diff_quad.vcl rename to test/fixtures/general_pv_diff_quad.vcl diff --git a/general_pv_diff_tri.vcl b/test/fixtures/general_pv_diff_tri.vcl similarity index 100% rename from general_pv_diff_tri.vcl rename to test/fixtures/general_pv_diff_tri.vcl diff --git a/general_quad.vcl b/test/fixtures/general_quad.vcl similarity index 100% rename from general_quad.vcl rename to test/fixtures/general_quad.vcl diff --git a/general_tri.vcl b/test/fixtures/general_tri.vcl similarity index 100% rename from general_tri.vcl rename to test/fixtures/general_tri.vcl diff --git a/indexed.vcl b/test/fixtures/indexed.vcl similarity index 100% rename from indexed.vcl rename to test/fixtures/indexed.vcl diff --git a/test/integration/test_cli.cpp b/test/integration/test_cli.cpp index 164571e..4d6591e 100644 --- a/test/integration/test_cli.cpp +++ b/test/integration/test_cli.cpp @@ -1,7 +1,7 @@ #include "test_harness.h" #include "openvcl_runner.h" -#include "../../src/OpenVclVersion.h" +#include "OpenVclVersion.h" #include #include diff --git a/tundra.lua b/tundra.lua deleted file mode 100644 index 46fd26b..0000000 --- a/tundra.lua +++ /dev/null @@ -1,25 +0,0 @@ -local common = { - Env = { - CCOPTS = { "-ansi", "-pedantic", "-Werror", "-g", Config = "*-gcc-*" }, - LIBS = { "stdc++", Config = { "*-clang", "*-gcc-*" } } - } -} - -Build { - Units = function() - Program { - Name = "openvcl", - Sources = { Glob { Dir = "src", Extensions = { ".c", ".cpp", ".h" } } } - } - - Default "openvcl" - end, - SyntaxExtensions = { "tundra.syntax.glob" }, - Configs = { - Config { Name = "macosx-clang", Inherit = common, Tools = { "clang-osx" }, DefaultOnHost = "macosx" }, - Config { Name = "macosx-gcc", Inherit = common, Tools = { "gcc-osx" } }, - Config { Name = "win32-msvc", Inherit = common, Tools = { { "msvc-winsdk"; TargetArch = "x86" } } }, - Config { Name = "win64-msvc", Inherit = common, Tools = { { "msvc-winsdk"; TargetArch = "x64" } } }, - Config { Name = "linux-gcc", Inherit = common, Tools = { "gcc" } }, - }, -}