From 8dcd759c62a8e2b2ae9f586d114c5e0e4cefea2a Mon Sep 17 00:00:00 2001 From: Dave Corley <73663882+magicaldave@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:38:55 -0500 Subject: [PATCH] Feat: Add initial CI scripts --- .github/workflows/openmw-mp.yml | 81 +++++++++++++++++++ CI/build_raknet.sh | 11 +++ CI/install_debian_deps.sh | 6 +- CI/make_package.sh | 136 ++++++++++++++++++++++++++++++++ 4 files changed, 231 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/openmw-mp.yml create mode 100755 CI/build_raknet.sh create mode 100755 CI/make_package.sh diff --git a/.github/workflows/openmw-mp.yml b/.github/workflows/openmw-mp.yml new file mode 100644 index 000000000..22c3283ed --- /dev/null +++ b/.github/workflows/openmw-mp.yml @@ -0,0 +1,81 @@ +name: CMake + +on: + push: + branches: + - 'master' + pull_request: + branches: [ master ] + +env: + BUILD_TYPE: Release + GIT_TERMINAL_PROMPT: 0 + +jobs: + Ubuntu: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + + - name: Add OpenMW PPA Dependencies + run: sudo add-apt-repository ppa:openmw/openmw; sudo apt-get update + + - name: Install Building Dependencies + run: sudo CI/install_debian_deps.sh gcc openmw-deps openmw-deps-dynamic + + - name: Build Raknet + run: sudo CI/build_raknet.sh + + - name: Prime ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ matrix.os }}-${{ env.BUILD_TYPE }} + max-size: 1000M + + - name: Configure + run: cmake . -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_UNITTESTS=1 -DCMAKE_INSTALL_PREFIX=install -DBUILD_OPENCS=OFF -DBUILD_ESMTOOL=OFF -DBUILD_BSATOOL=OFF -DBUILD_NIFTEST=OFF -DBUILD_ESSIMPORTER=OFF -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_FLAGS=\"-std=c++14\" -DDESIRED_QT_VERSION=5 -DRakNet_INCLUDES=raknet/include -DRakNet_LIBRARY_DEBUG=raknet/lib/libRakNetLibStatic.a -DRakNet_LIBRARY_RELEASE=raknet/lib/libRakNetLibStatic.a + + - name: Build + run: make -j$(nproc) + + - name: Test + run: ./openmw_test_suite + + - name: Install + shell: bash + run: cmake --install . + + - name: Create Artifact + shell: bash + run: sudo CI/make_package.sh + + - name: Upload Artifact + uses: actions/upload-artifact@v1 + with: + path: tes3mp-build + name: tes3mp_linux + + # MacOS: + # runs-on: macos-latest + + # steps: + # - uses: actions/checkout@v2 + + # - name: Install Building Dependencies + # run: CI/before_install.osx.sh + + # - name: Prime ccache + # uses: hendrikmuhs/ccache-action@v1 + # with: + # key: ${{ matrix.os }}-${{ env.BUILD_TYPE }} + # max-size: 1000M + + # - name: Configure + # run: | + # rm -fr build # remove the build directory + # CI/before_script.osx.sh + # - name: Build + # run: | + # cd build + # make -j $(sysctl -n hw.logicalcpu) package diff --git a/CI/build_raknet.sh b/CI/build_raknet.sh new file mode 100755 index 000000000..2a5b2eeba --- /dev/null +++ b/CI/build_raknet.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +git clone https://github.com/DreamWeave-MP/CrabNet raknet + +cd raknet + +cmake . -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + +make -j3 + +cd - diff --git a/CI/install_debian_deps.sh b/CI/install_debian_deps.sh index 2f905314b..1923ca783 100755 --- a/CI/install_debian_deps.sh +++ b/CI/install_debian_deps.sh @@ -18,11 +18,11 @@ declare -rA GROUPED_DEPS=( libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-iostreams-dev - + libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev libsdl2-dev libqt5opengl5-dev libopenal-dev libunshield-dev libtinyxml-dev - libbullet-dev liblz4-dev libpng-dev libjpeg-dev - ca-certificates + libbullet-dev liblz4-dev libpng-dev libjpeg-dev librecast-dev libluajit-5.1-dev + ca-certificates googletest libgtest-dev libgmock-dev " # TODO: add librecastnavigation-dev when debian is ready diff --git a/CI/make_package.sh b/CI/make_package.sh new file mode 100755 index 000000000..897fb5d1d --- /dev/null +++ b/CI/make_package.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash + +set -e + +PACKAGE_BINARIES=( \ + "tes3mp" \ + "tes3mp-browser" \ + "tes3mp-server" \ + "openmw-launcher" \ + "openmw-wizard" \ + "openmw-iniimporter" \ + ) + +#WARN: Linking libtinyxml shouldn't be needed, no version of openmw uses this and it seems to be something weird caused by GitHub CI. Whether this is a problem is tbd. +LIBRARIES=( \ + "libboost_thread.so" \ + "libboost_system.so" \ + "libboost_filesystem.so" \ + "libboost_program_options.so" \ + "libboost_iostreams.so" \ + "libBulletCollision.so" \ + "libLinearMath-float64.so" \ + "libBulletCollision-float64.so" \ + "libbz2.so" \ + "libLinearMath.so" \ + "libMyGUIEngine.so" \ + "libOpenThreads.so" \ + "libosgAnimation.so" \ + "libosgDB.so" \ + "libosgFX.so" \ + "libosgGA.so" \ + "libosgParticle.so" \ + "libosg.so" \ + "libosgText.so" \ + "libosgUtil.so" \ + "libosgViewer.so" \ + "libosgWidget.so" \ + "libosgShadow.so" \ + "libSDL2" \ + "libts.so" \ + "libtxc_dxtn.so" \ + "libunshield.so" \ + "libuuid.so" \ + "osgPlugins" \ + "libtinfo.so" \ + "liblua5.1.so" \ + "libpng16.so" \ + "libtinyxml.so" \ + ) + +DEFAULTS=( \ + "defaults.bin" \ + "openmw.cfg" \ + "gamecontrollerdb.txt" \ + "tes3mp-client-default.cfg" \ + "tes3mp-server-default.cfg" \ + "tes3mp-credits.md" \ + "tes3mp-changelog.md" \ + "AUTHORS.md" \ + "LICENSE" \ + ) + +mkdir tes3mp-build tes3mp-build/lib/ && mv resources/ tes3mp-build/ && cd tes3mp-build + +for LIB in "${LIBRARIES[@]}"; do + find /lib /usr/lib /usr/local/lib /usr/local/lib64 /lib/x86_64-linux-gnu/ ../raknet/ -name "$LIB*" -exec cp -r --preserve=links "{}" ./lib \; 2> /dev/null || true + echo -ne "$LIB\033[0K\r" +done + +for DEFAULT in "${DEFAULTS[@]}"; do + cp ../"$DEFAULT" . +done + +for BIN in "${PACKAGE_BINARIES[@]}"; do + cp -r ../$BIN . +done + +git clone https://github.com/DreamWeave-MP/CoreScripts.git server/ + + +# Create pre-launch script +cat << 'EOF' > tes3mp-prelaunch +#!/bin/bash + +ARGS="$*" +GAMEDIR="$(cd "$(dirname "$0")"; pwd -P)" +TES3MP_HOME="$HOME/.config/openmw" + +# If there are config files in the home directory, load those +# Otherwise check the package/installation directory and load those +# Otherwise copy them to the home directory +if [[ "$ARGS" = 'tes3mp-server' ]]; then + if [[ -f "$TES3MP_HOME"/tes3mp-server.cfg ]]; then + echo -e "Loading server config from the home directory" + LOADING_FROM_HOME=true + elif [[ -f "$GAMEDIR"/tes3mp-server-default.cfg ]]; then + echo -e "Loading server config from the package directory" + else + echo -e "Server config not found in home and package directory, trying to copy from .example" + cp -f tes3mp-server-default.cfg.example "$TES3MP_HOME"/tes3mp-server.cfg + LOADING_FROM_HOME=true + fi + if [[ $LOADING_FROM_HOME ]]; then + if [[ -d "$TES3MP_HOME"/server ]]; then + echo -e "Loading CoreScripts folder from the home directory" + else + echo -e "CoreScripts folder not found in home directory, copying from package directory" + cp -rf "$GAMEDIR"/server/ "$TES3MP_HOME"/ + sed -i "s|home = .*|home = $TES3MP_HOME/server |g" "$TES3MP_HOME"/tes3mp-server.cfg + fi + fi +else + if [[ -f $TES3MP_HOME/tes3mp-client.cfg ]]; then + echo -e "Loading client config from the home directory" + elif [[ -f tes3mp-client-default.cfg ]]; then + echo -e "Loading client config from the package directory" + else + echo -e "Client config not found in home and package directory, trying to copy from .example" + cp -f "$GAMEDIR"/tes3mp-client-default.cfg.example "$TES3MP_HOME"/tes3mp-client.cfg + fi +fi +EOF + + # Create wrappers + echo -e "\n\nCreating wrappers" + for BINARY in "${PACKAGE_BINARIES[@]}"; do + if [ ! -f "$BINARY" ]; then + echo -e "Binary $BINARY not found" + else + WRAPPER="$BINARY" + BINARY_RENAME="$BINARY.x86_64" + mv "$BINARY" "$BINARY_RENAME" + printf "#!/bin/bash\n\nWRAPPER=\"\$(basename \$0)\"\nGAMEDIR=\"\$(dirname \$0)\"\ncd \"\$GAMEDIR\"\nif test -f ./tes3mp-prelaunch; then bash ./tes3mp-prelaunch \"\$WRAPPER\"; fi\nLD_LIBRARY_PATH=\"./lib\" ./$BINARY_RENAME \"\$@\"" > "$WRAPPER" + fi + done + chmod 755 *