diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a17282ca..fbea3a82 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest] + #os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] build_type: [Release] c_compiler: [gcc, cl] include: @@ -35,8 +36,14 @@ jobs: - os: ubuntu-latest c_compiler: cl + env: + VULKAN_SDK: "" + VCPKG_ROOT: ${{ github.workspace }}/vcpkg + steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Set reusable strings id: strings @@ -44,40 +51,50 @@ jobs: run: | echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - # configure vcpkg and set vcpkg dir to VCPKG_ROOT - - name: Setup vcpkg - uses: microsoft/vcpkg@master + - name: Preparing vcpkg + uses: actions/checkout@v2 with: - vcpkg-branch: master - vcpkg-directory: ${{ github.workspace }}/vcpkg - vcpkg-keep: true - vcpkg-commit: true - vcpkg-allow-outdated: true - vcpkg-triplets: ${{ matrix.triplets }} - VCPKG_ROOT: ${{ github.workspace }}/vcpkg + repository: microsoft/vcpkg + path: ${{ github.workspace }}/vcpkg + ref: 8b04a7bd93bef991818fc372bb83ce00ec1c1c16 - # install vulkan sdk whatever on windows or linux - - name: Install Vulkan SDK - if: matrix.triplets == 'x64-windows' || matrix.triplets == 'x64-linux' + - name: Configure vcpkg run: | - if [ ${{ matrix.triplets }} == 'x64-windows' ]; then - choco install vulkan-sdk - else - sudo apt-get install libvulkan-dev - fi + cd ${{ github.workspace }}/vcpkg + ./bootstrap-vcpkg.sh - # if windows set VULKAN_SDK to vulkan sdk path - - name: Set VULKAN_SDK - if: matrix.triplets == 'x64-windows' + - name: Prepare Vulkan SDK + uses: humbletim/setup-vulkan-sdk@v1.2.0 + with: + vulkan-query-version: 1.3.204.0 + vulkan-components: Vulkan-Headers, Vulkan-Loader + vulkan-use-cache: true + + # add libsdl2 libsdl2-image + - name: Install dependencies (Linux) + if: matrix.triplets == 'x64-linux' run: | - echo "VULKAN_SDK=C:/Program Files/LunarG/VulkanSDK/ + sudo apt-get install libsdl2-dev libsdl2-image-dev - - name: Configure CMake + - name: Configure CMake (Linux) + if: matrix.triplets == 'x64-linux' run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - --preset=${{ matrix.triplets }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -S ${{ github.workspace }} + cmake -B ${{ steps.strings.outputs.build-output-dir }} \ + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \ + -S ${{ github.workspace }} \ - - name: Build - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + - name: Configure CMake (Windows) + if: matrix.triplets == 'x64-windows' + run: | + cmake -B ${{ steps.strings.outputs.build-output-dir }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -S ${{ github.workspace }} + + - name: Build (Linux) + if: matrix.triplets == 'x64-linux' + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} -- -j 16 + + - name: Build (Windows) + if: matrix.triplets == 'x64-windows' + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} -- /maxcpucount:16 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9011630d..560ef557 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,10 @@ GameResources vcpkg_installed .idea +!third-party/**/*.lib +!third-party/**/*.bin +!third-party/**/*.so + # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs diff --git a/CMakeLists.txt b/CMakeLists.txt index 19fda88d..f053cffd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,10 @@ cmake_minimum_required(VERSION 3.0) message("Unnamed O2 Game Clone Project - CMake Build System") -# check if CXX_COMPILER is not cl.exe then set +# check CMAKE_TOOLCHAIN_FILE +if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) + SET(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "cmake_tool_chain_file") +endif() project(O2Game) @@ -91,21 +94,31 @@ endif() message("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE} ${LIB_INDEX}") if (WIN32) + set(BASS "${PROJECT_SOURCE_DIR}/third-party/lib/${O2GAME_PLATFORM}-windows/${CMAKE_BUILD_TYPE}/bass.lib") + set(BASS_FX "${PROJECT_SOURCE_DIR}/third-party/lib/${O2GAME_PLATFORM}-windows/${CMAKE_BUILD_TYPE}/bass_fx.lib") + set(THIRD_PARTY_LIBS - "${PROJECT_SOURCE_DIR}/third-party/lib/${O2GAME_PLATFORM}-windows/${CMAKE_BUILD_TYPE}/bass.lib" - "${PROJECT_SOURCE_DIR}/third-party/lib/${O2GAME_PLATFORM}-windows/${CMAKE_BUILD_TYPE}/bass_fx.lib" + ${BASS} + ${BASS_FX} ) elseif (UNIX AND NOT APPLE) + set(BASS "${PROJECT_SOURCE_DIR}/third-party/bin/${O2GAME_PLATFORM}-linux/${CMAKE_BUILD_TYPE}/libbass.so") + set(BASS_FX "${PROJECT_SOURCE_DIR}/third-party/bin/${O2GAME_PLATFORM}-linux/${CMAKE_BUILD_TYPE}/libbass_fx.so") + set(THIRD_PARTY_LIBS - "${PROJECT_SOURCE_DIR}/third-party/lib/${O2GAME_PLATFORM}-linux/${CMAKE_BUILD_TYPE}/libbass.so" - "${PROJECT_SOURCE_DIR}/third-party/lib/${O2GAME_PLATFORM}-linux/${CMAKE_BUILD_TYPE}/libbass_fx.so" + ${BASS} + ${BASS_FX} dl pthread m ) endif() +if (NOT EXISTS ${BASS} OR NOT EXISTS ${BASS_FX}) + message(FATAL_ERROR "BASS or BASS_FX not found") +endif() + # check if FREETYPE_LIBRAIES is a list then check first index if optimized if (FREETYPE_LIBRARIES MATCHES ";") list(GET FREETYPE_LIBRARIES ${LIB_INDEX} LIB_FREETYPE) diff --git a/third-party/lib/x64-linux/Debug/libbass.so b/third-party/bin/x64-linux/Debug/libbass.so similarity index 100% rename from third-party/lib/x64-linux/Debug/libbass.so rename to third-party/bin/x64-linux/Debug/libbass.so diff --git a/third-party/lib/x64-linux/Debug/libbass_fx.so b/third-party/bin/x64-linux/Debug/libbass_fx.so similarity index 100% rename from third-party/lib/x64-linux/Debug/libbass_fx.so rename to third-party/bin/x64-linux/Debug/libbass_fx.so diff --git a/third-party/bin/x64-linux/Release/libbass.so b/third-party/bin/x64-linux/Release/libbass.so new file mode 100644 index 00000000..3317ed4c Binary files /dev/null and b/third-party/bin/x64-linux/Release/libbass.so differ diff --git a/third-party/bin/x64-linux/Release/libbass_fx.so b/third-party/bin/x64-linux/Release/libbass_fx.so new file mode 100644 index 00000000..bb23051c Binary files /dev/null and b/third-party/bin/x64-linux/Release/libbass_fx.so differ