From 6b0d73177b0b9b3bd0b606d1006183ca0a56928d Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Fri, 30 Jan 2026 16:12:39 +0800 Subject: [PATCH] chore: write github action --- .github/scripts/README.md | 3 ++ .github/scripts/linux.sh | 23 +++++++++++ .github/scripts/macos.sh | 23 +++++++++++ .github/scripts/stb-linux.sh | 2 + .github/scripts/stb-macos.sh | 2 + .github/scripts/stb-windows.bat | 4 ++ .github/scripts/windows.bat | 8 ++-- .github/scripts/yycc-linux.sh | 24 +++++++++++ .github/scripts/yycc-macos.sh | 24 +++++++++++ .github/scripts/yycc-windows.bat | 23 +++++++++++ .github/scripts/zlib-linux.sh | 21 ++++++++++ .github/scripts/zlib-macos.sh | 21 ++++++++++ .github/scripts/zlib-windows.bat | 20 +++++++++ .github/workflows/linux.yml | 69 ++++++++++++++++++++++++++++++++ .github/workflows/macos.yml | 64 +++++++++++++++++++++++++++++ .github/workflows/windows.yml | 25 ++++-------- CMakeLists.txt | 4 +- COMPILE.md | 5 +++ Docs/Doxyfile.in | 7 +--- 19 files changed, 342 insertions(+), 30 deletions(-) create mode 100644 .github/scripts/README.md create mode 100644 .github/scripts/stb-linux.sh create mode 100644 .github/scripts/stb-macos.sh create mode 100644 .github/scripts/stb-windows.bat diff --git a/.github/scripts/README.md b/.github/scripts/README.md new file mode 100644 index 0000000..b6678d8 --- /dev/null +++ b/.github/scripts/README.md @@ -0,0 +1,3 @@ +# GitHub Scripts + +These scripts should be executed at the root directory of each project respectively. diff --git a/.github/scripts/linux.sh b/.github/scripts/linux.sh index e69de29..a129b9b 100644 --- a/.github/scripts/linux.sh +++ b/.github/scripts/linux.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -euo pipefail + +YYCCommonplace_ROOT="${YYCCommonplace_ROOT:?YYCCommonplace_ROOT must be set}" +STB_ROOT="${STB_ROOT:?STB_ROOT must be set}" +ZLIB_ROOT="${ZLIB_ROOT:?ZLIB_ROOT must be set}" + +# Create build directory and enter it +mkdir bin +cd bin +# Create internal build and install directory +mkdir build +mkdir install + +# Build in Release mode +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=23 -DNEMO_BUILD_UNVIRT=ON -DNEMO_BUILD_BALLANCE=ON -DNEMO_BUILD_BMAP=ON -DNEMO_BUILD_BMAPINSPECTOR=ON -DYYCCommonplace_ROOT=$YYCCommonplace_ROOT -DSTB_ROOT=$STB_ROOT -DZLIB_ROOT=$ZLIB_ROOT ../.. +cmake --build . +cmake --install . --prefix=../install +cd .. + +# Back to root directory +cd .. diff --git a/.github/scripts/macos.sh b/.github/scripts/macos.sh index e69de29..a129b9b 100644 --- a/.github/scripts/macos.sh +++ b/.github/scripts/macos.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -euo pipefail + +YYCCommonplace_ROOT="${YYCCommonplace_ROOT:?YYCCommonplace_ROOT must be set}" +STB_ROOT="${STB_ROOT:?STB_ROOT must be set}" +ZLIB_ROOT="${ZLIB_ROOT:?ZLIB_ROOT must be set}" + +# Create build directory and enter it +mkdir bin +cd bin +# Create internal build and install directory +mkdir build +mkdir install + +# Build in Release mode +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=23 -DNEMO_BUILD_UNVIRT=ON -DNEMO_BUILD_BALLANCE=ON -DNEMO_BUILD_BMAP=ON -DNEMO_BUILD_BMAPINSPECTOR=ON -DYYCCommonplace_ROOT=$YYCCommonplace_ROOT -DSTB_ROOT=$STB_ROOT -DZLIB_ROOT=$ZLIB_ROOT ../.. +cmake --build . +cmake --install . --prefix=../install +cd .. + +# Back to root directory +cd .. diff --git a/.github/scripts/stb-linux.sh b/.github/scripts/stb-linux.sh new file mode 100644 index 0000000..181d01d --- /dev/null +++ b/.github/scripts/stb-linux.sh @@ -0,0 +1,2 @@ +# Just directly record self as root directory +set STB_ROOT=$(pwd) diff --git a/.github/scripts/stb-macos.sh b/.github/scripts/stb-macos.sh new file mode 100644 index 0000000..181d01d --- /dev/null +++ b/.github/scripts/stb-macos.sh @@ -0,0 +1,2 @@ +# Just directly record self as root directory +set STB_ROOT=$(pwd) diff --git a/.github/scripts/stb-windows.bat b/.github/scripts/stb-windows.bat new file mode 100644 index 0000000..47679b2 --- /dev/null +++ b/.github/scripts/stb-windows.bat @@ -0,0 +1,4 @@ +@ECHO OFF + +:: Just directly record self as root directory +SET STB_ROOT=%CD% diff --git a/.github/scripts/windows.bat b/.github/scripts/windows.bat index e89058d..a09db6c 100644 --- a/.github/scripts/windows.bat +++ b/.github/scripts/windows.bat @@ -3,16 +3,16 @@ :: Create build directory and enter it MKDIR bin CD bin -:: Create internal build and install directory, then enter it +:: Create internal build and install directory MKDIR build MKDIR install -CD build :: Build with x64 architecture in Release mode -cmake -A x64 -DYYCC_BUILD_TEST=ON -DGTest_ROOT=%GTest_ROOT% -DYYCC_BUILD_BENCHMARK=ON -Dbenchmark_ROOT=%benchmark_ROOT% ../.. +CD build +cmake -A x64 -DCMAKE_CXX_STANDARD=23 -DNEMO_BUILD_UNVIRT=ON -DNEMO_BUILD_BALLANCE=ON -DNEMO_BUILD_BMAP=ON -DNEMO_BUILD_BMAPINSPECTOR=ON -DYYCCommonplace_ROOT=%YYCCommonplace_ROOT% -DSTB_ROOT=%STB_ROOT% -DZLIB_ROOT=%ZLIB_ROOT% ../.. cmake --build . --config Release cmake --install . --prefix=../install --config Release +CD .. :: Back to root directory CD .. -CD .. diff --git a/.github/scripts/yycc-linux.sh b/.github/scripts/yycc-linux.sh index e69de29..d9fbc65 100644 --- a/.github/scripts/yycc-linux.sh +++ b/.github/scripts/yycc-linux.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -euo pipefail + +# Create build directory and enter it +mkdir bin +cd bin +# Create internal build and install directory +mkdir build +mkdir install + +# Build in Release mode +cd build +cmake -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release ../.. +cmake --build . +cmake --install . --prefix=../install +cd .. + +# Record install directory +cd install +set YYCCommonplace_ROOT=$(pwd) +cd .. + +# Back to root directory +cd .. diff --git a/.github/scripts/yycc-macos.sh b/.github/scripts/yycc-macos.sh index e69de29..d9fbc65 100644 --- a/.github/scripts/yycc-macos.sh +++ b/.github/scripts/yycc-macos.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -euo pipefail + +# Create build directory and enter it +mkdir bin +cd bin +# Create internal build and install directory +mkdir build +mkdir install + +# Build in Release mode +cd build +cmake -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release ../.. +cmake --build . +cmake --install . --prefix=../install +cd .. + +# Record install directory +cd install +set YYCCommonplace_ROOT=$(pwd) +cd .. + +# Back to root directory +cd .. diff --git a/.github/scripts/yycc-windows.bat b/.github/scripts/yycc-windows.bat index e69de29..e6568bf 100644 --- a/.github/scripts/yycc-windows.bat +++ b/.github/scripts/yycc-windows.bat @@ -0,0 +1,23 @@ +@ECHO OFF + +:: Create build directory and enter it +MKDIR bin +CD bin +:: Create internal build and install directory +MKDIR build +MKDIR install + +:: Build with x64 architecture in Release mode +CD build +cmake -A x64 -DCMAKE_CXX_STANDARD=23 ../.. +cmake --build . --config Release +cmake --install . --prefix=../install --config Release +CD .. + +:: Record install directory +CD install +SET YYCCommonplace_ROOT=%CD% +CD .. + +:: Back to root directory +CD .. diff --git a/.github/scripts/zlib-linux.sh b/.github/scripts/zlib-linux.sh index e69de29..23280c4 100644 --- a/.github/scripts/zlib-linux.sh +++ b/.github/scripts/zlib-linux.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euo pipefail + +# Create build and install directory +mkdir build +mkdir install + +# Record install directory first because build step require it +cd install +set ZLIB_ROOT=$(pwd) +cd .. + +# Build in Release mode +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=23 -DZLIB_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=$ZLIB_ROOT ../.. +cmake --build . +cmake --install . +cd .. + +# Back to root directory +cd .. diff --git a/.github/scripts/zlib-macos.sh b/.github/scripts/zlib-macos.sh index e69de29..23280c4 100644 --- a/.github/scripts/zlib-macos.sh +++ b/.github/scripts/zlib-macos.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euo pipefail + +# Create build and install directory +mkdir build +mkdir install + +# Record install directory first because build step require it +cd install +set ZLIB_ROOT=$(pwd) +cd .. + +# Build in Release mode +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=23 -DZLIB_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=$ZLIB_ROOT ../.. +cmake --build . +cmake --install . +cd .. + +# Back to root directory +cd .. diff --git a/.github/scripts/zlib-windows.bat b/.github/scripts/zlib-windows.bat index e69de29..f62932e 100644 --- a/.github/scripts/zlib-windows.bat +++ b/.github/scripts/zlib-windows.bat @@ -0,0 +1,20 @@ +@ECHO OFF + +:: Create build and install directory +MKDIR build +MKDIR install + +:: Record install directory first because build step require it +CD install +SET ZLIB_ROOT=%CD% +CD .. + +:: Build with x64 architecture in Release mode +CD build +cmake -A x64 -DCMAKE_CXX_STANDARD=23 -DZLIB_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=%ZLIB_ROOT% ../.. +cmake --build . --config Release +cmake --install . --config Release +CD .. + +:: Back to root directory +CD .. diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e69de29..5d7155f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -0,0 +1,69 @@ +name: LibCmo Linux Build + +on: [workflow_dispatch] + +jobs: + linux-build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Install Dependencies + shell: bash + run: | + sudo apt update + sudo apt install -y build-essential cmake git + - name: Fetch YYCCommonplace + uses: actions/checkout@v4 + with: + repository: 'yyc12345/YYCCommonplace' + ref: 'master' + path: 'extern/YYCCommonplace' + - name: Build YYCCommonplace + shell: bash + run: | + cd extern/YYCCommonplace + chmod +x ../../.github/scripts/yycc-linux.sh + source ../../.github/scripts/yycc-linux.sh + echo "YYCCommonplace_ROOT=$YYCCommonplace_ROOT" >> "$GITHUB_ENV" + cd ../.. + - name: Fetch ZLIB + uses: actions/checkout@v4 + with: + repository: 'madler/zlib' + ref: 'v1.3.1' + path: 'extern/zlib' + - name: Build ZLIB + shell: bash + run: | + cd extern/zlib + chmod +x ../../.github/scripts/zlib-linux.sh + source ../../.github/scripts/zlib-linux.sh + echo "ZLIB_ROOT=$ZLIB_ROOT" >> "$GITHUB_ENV" + cd ../.. + - name: Fetch STB + uses: actions/checkout@v4 + with: + repository: 'nothings/stb' + ref: '2e2bef463a5b53ddf8bb788e25da6b8506314c08' + path: 'extern/stb' + - name: Build STB + shell: bash + run: | + cd extern/stb + chmod +x ../../.github/scripts/stb-linux.sh + source ../../.github/scripts/stb-linux.sh + echo "STB_ROOT=$STB_ROOT" >> "$GITHUB_ENV" + cd ../.. + - name: Build LibCmo + shell: bash + run: | + chmod +x ./.github/scripts/linux.sh + ./.github/scripts/linux.sh + - name: Upload Built Artifact + uses: actions/upload-artifact@v4 + with: + name: LibCmo-linux-build + path: bin/install/* + retention-days: 30 \ No newline at end of file diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index e69de29..2c75584 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -0,0 +1,64 @@ +name: LibCmo macOS Build + +on: [workflow_dispatch] + +jobs: + macos-build: + runs-on: macos-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Fetch YYCCommonplace + uses: actions/checkout@v4 + with: + repository: 'yyc12345/YYCCommonplace' + ref: 'master' + path: 'extern/YYCCommonplace' + - name: Build YYCCommonplace + shell: bash + run: | + cd extern/YYCCommonplace + chmod +x ../../.github/scripts/yycc-macos.sh + source ../../.github/scripts/yycc-macos.sh + echo "YYCCommonplace_ROOT=$YYCCommonplace_ROOT" >> "$GITHUB_ENV" + cd ../.. + - name: Fetch ZLIB + uses: actions/checkout@v4 + with: + repository: 'madler/zlib' + ref: 'v1.3.1' + path: 'extern/zlib' + - name: Build ZLIB + shell: bash + run: | + cd extern/zlib + chmod +x ../../.github/scripts/zlib-macos.sh + source ../../.github/scripts/zlib-macos.sh + echo "ZLIB_ROOT=$ZLIB_ROOT" >> "$GITHUB_ENV" + cd ../.. + - name: Fetch STB + uses: actions/checkout@v4 + with: + repository: 'nothings/stb' + ref: '2e2bef463a5b53ddf8bb788e25da6b8506314c08' + path: 'extern/stb' + - name: Build STB + shell: bash + run: | + cd extern/stb + chmod +x ../../.github/scripts/stb-macos.sh + source ../../.github/scripts/stb-macos.sh + echo "STB_ROOT=$STB_ROOT" >> "$GITHUB_ENV" + cd ../.. + - name: Build LibCmo + shell: bash + run: | + chmod +x ./.github/scripts/macos.sh + ./.github/scripts/macos.sh + - name: Upload Built Artifact + uses: actions/upload-artifact@v4 + with: + name: LibCmo-macos-build + path: bin/install/* + retention-days: 30 \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index bbe0c7b..784c47b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,4 +1,4 @@ -name: YYCC Windows Build +name: LibCmo Windows Build on: [workflow_dispatch] @@ -25,14 +25,9 @@ jobs: - name: Build YYCCommonplace shell: cmd run: | - :: Enter directory cd extern/YYCCommonplace - :: Build library - ..\..\.github\scripts\yycc-windows.bat - :: Fetch install directory - cd install - echo set YYCCommonplace_ROOT=%CD% > ../../envs.bat - cd .. + call ..\..\.github\scripts\yycc-windows.bat + echo set YYCCommonplace_ROOT=%YYCCommonplace_ROOT% > ../envs.bat cd ../.. - name: Fetch ZLIB uses: actions/checkout@v4 @@ -43,14 +38,9 @@ jobs: - name: Build ZLIB shell: cmd run: | - :: Enter directory cd extern/zlib - :: Build library ..\..\.github\scripts\zlib-windows.bat - :: Fetch install directory - cd install - echo set ZLIB_ROOT=%CD% >> ../../envs.bat - cd .. + echo set ZLIB_ROOT=%ZLIB_ROOT% >> ../envs.bat cd ../.. - name: Fetch STB uses: actions/checkout@v4 @@ -61,10 +51,9 @@ jobs: - name: Build STB shell: cmd run: | - :: Enter directory cd extern/stb - :: Fetch install directory - echo set STB_ROOT=%CD% >> ../envs.bat + ..\..\.github\scripts\stb-windows.bat + echo set STB_ROOT=%STB_ROOT% >> ../envs.bat cd ../.. - name: Build LibCmo shell: cmd @@ -77,7 +66,7 @@ jobs: :: Extract saved environment variables call .\extern\envs.bat :: Build Project - .\.github\script\windows.bat + .\.github\scripts\windows.bat - name: Upload Built Artifact uses: actions/upload-artifact@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index f7e8a77..7c612d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,10 @@ project(NeMo # Provide options option(NEMO_BUILD_UNVIRT "Build Unvirt, the console interface operator of LibCmo." ON) -option(NEMO_BUILD_BALLANCE "Build Ballance stuff, including BMap and BMapInspector." OFF) +option(NEMO_BUILD_BALLANCE "Build Ballance artifacts, including BMap and BMapInspector." OFF) option(NEMO_BUILD_BMAP "Build BMap, the example use of LibCmo which can read and write Ballance game map." OFF) option(NEMO_BUILD_BMAPINSPECTOR "Build BMapInspector, the example use of LibCmo which can validate Ballance game map." OFF) -option(NEMO_BUILD_DOC "Build document of LibCmo and all related stuff." OFF) +option(NEMO_BUILD_DOC "Build document of LibCmo." OFF) # Set C++ standards set(CMAKE_CXX_STANDARD 23) diff --git a/COMPILE.md b/COMPILE.md index a8a2215..2913cb5 100644 --- a/COMPILE.md +++ b/COMPILE.md @@ -80,9 +80,14 @@ First, there is a list listing all variables you may configure during compiling. * `NEMO_BUILD_UNVIRT`: Set it to `ON` to build `Unvirt`. `ON` in default. This is an interactive tool for loading, saving Virtools file. It is extremely useful for debugging this project. +* `NEMO_BUILD_BALLANCE`: Set it to `ON` to build Ballance related artifacts. `OFF` in default. +If you disable this, Ballance related artifacts, BMap and BMapInspector, will not be built. * `NEMO_BUILD_BMAP`: Set it to `ON` to build `BMap`. `OFF` in default. It is a dynamic library specific used for loading Ballance map file. If you are coming from my another project [BallanceBlenderPlugin](https://github.com/yyc12345/BallanceBlenderHelper), this is what you need. +* `NEMO_BUILD_BMAPINSPECTOR`: Set it to `ON` to build `BMapInspector`. `OFF` in default. +It is a executable specific used for checking whether given Ballance map file is valid for playing. +Usually you do not need this except you are a mapper in Ballance. * `NEMO_BUILD_DOC`: Set it to `ON` to build documentation. `OFF` in default. It may be useful for the developer who firstly use this project in their own projects. Please note that generated documentation is different in different platforms. diff --git a/Docs/Doxyfile.in b/Docs/Doxyfile.in index c0faa06..c66e638 100644 --- a/Docs/Doxyfile.in +++ b/Docs/Doxyfile.in @@ -943,12 +943,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = @CMAKE_CURRENT_LIST_DIR@/../LibCmo \ - @CMAKE_CURRENT_LIST_DIR@/../Unvirt \ - @CMAKE_CURRENT_LIST_DIR@/../BMap \ - @CMAKE_CURRENT_LIST_DIR@/LibCmo \ - @CMAKE_CURRENT_LIST_DIR@/Unvirt \ - @CMAKE_CURRENT_LIST_DIR@/Bmap +INPUT = @CMAKE_CURRENT_LIST_DIR@/../LibCmo # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses