From baad15c4e9f301682aa97e2b4b9f87b640c5f2f8 Mon Sep 17 00:00:00 2001 From: xtremeqg Date: Fri, 25 Oct 2024 03:39:50 +0300 Subject: [PATCH] init --- .github/workflows/build.yml | 361 ++++++++++++++++++++++++++++++++++++ mingw.cmake | 9 + 2 files changed, 370 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 mingw.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ecddee7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,361 @@ +on: [push] +jobs: + zlib-mingw32: + runs-on: ubuntu-latest + steps: + - name: Install mingw-w64 + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends mingw-w64 + - name: Checkout + uses: actions/checkout@v4 + - name: Checkout zlib + uses: actions/checkout@v4 + with: + repository: madler/zlib + ref: master + path: zlib + - name: Configure zlib + run: | + CMAKE_TOOLCHAIN_FILE=${{github.workspace}}/mingw.cmake \ + CMAKE_BUILD_TYPE=Release cmake \ + -B ${{github.workspace}}/zlib/build \ + -S ${{github.workspace}}/zlib + - name: Build zlib + run: cmake --build ${{github.workspace}}/zlib/build --config Release + - name: Configure minizip + run: | + cp ${{github.workspace}}/zlib/build/zconf.h ${{github.workspace}}/zlib/ + cd ${{github.workspace}}/zlib/contrib/minizip && autoreconf -fvi + cd ${{github.workspace}}/zlib/contrib/minizip && CFLAGS="-m32 -march=x86-64" ./configure --host=i686-w64-mingw32 + - name: Build minizip + run: | + make -C ${{github.workspace}}/zlib/contrib/minizip + - name: Package files + run: | + mkdir -p ${{github.workspace}}/zlib/build/include/minizip + cp ${{github.workspace}}/zlib/contrib/minizip/.libs/libminizip.a ${{github.workspace}}/zlib/build/ + cp ${{github.workspace}}/zlib/*.h ${{github.workspace}}/zlib/build/include/ + cp ${{github.workspace}}/zlib/contrib/minizip/*.h ${{github.workspace}}/zlib/build/include/minizip/ + cp ${{github.workspace}}/zlib/build/zconf.h ${{github.workspace}}/zlib/build/include/ + mv ${{github.workspace}}/zlib/build/libzlibstatic.a ${{github.workspace}}/zlib/build/libz.a + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: zlib-mingw32 + path: | + ${{github.workspace}}/zlib/build/include + ${{github.workspace}}/zlib/build/libz.a + ${{github.workspace}}/zlib/build/libminizip.a + enet-mingw32: + runs-on: ubuntu-latest + steps: + - name: Install mingw-w64 + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends mingw-w64 + - name: Checkout + uses: actions/checkout@v4 + - name: Checkout enet + uses: actions/checkout@v4 + with: + repository: lsalzman/enet + ref: master + path: enet + - name: Configure + run: | + CMAKE_TOOLCHAIN_FILE=${{github.workspace}}/mingw.cmake \ + CMAKE_BUILD_TYPE=Release cmake \ + -B ${{github.workspace}}/enet/build \ + -S ${{github.workspace}}/enet + - name: Build + run: cmake --build ${{github.workspace}}/enet/build --config Release + - name: Package files + run: + cp -r ${{github.workspace}}/enet/include ${{github.workspace}}/enet/build/ + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: enet-mingw32 + path: | + ${{github.workspace}}/enet/build/include + ${{github.workspace}}/enet/build/libenet.a + spng-mingw32: + runs-on: ubuntu-latest + needs: zlib-mingw32 + steps: + - name: Install mingw-w64 + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends mingw-w64 + - name: Checkout + uses: actions/checkout@v4 + - name: Checkout libspng + uses: actions/checkout@v4 + with: + repository: randy408/libspng + ref: master + path: libspng + - name: Download zlib + uses: actions/download-artifact@v4 + with: + name: zlib-mingw32 + path: ${{github.workspace}}/zlib + - name: Configure + run: | + CMAKE_TOOLCHAIN_FILE=${{github.workspace}}/mingw.cmake \ + CMAKE_BUILD_TYPE=Release SPNG_SHARED=OFF BUILD_EXAMPLES=OFF cmake \ + -B ${{github.workspace}}/libspng/build \ + -S ${{github.workspace}}/libspng \ + -DZLIB_INCLUDE_DIR=${{github.workspace}}/zlib/include \ + -DZLIB_LIBRARY=${{github.workspace}}/zlib/libz.a + - name: Build + run: cmake --build ${{github.workspace}}/libspng/build --config Release + - name: Package files + run: | + mkdir -p ${{github.workspace}}/libspng/build/include/ + cp ${{github.workspace}}/libspng/spng/*.h ${{github.workspace}}/libspng/build/include/ + mv ${{github.workspace}}/libspng/build/libspng_static.a ${{github.workspace}}/libspng/build/libspng.a + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: spng-mingw32 + path: | + ${{github.workspace}}/libspng/build/include/*.h + ${{github.workspace}}/libspng/build/libspng.a + + centijson-mingw32: + runs-on: ubuntu-latest + steps: + - name: Install mingw-w64 + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends mingw-w64 + - name: Checkout + uses: actions/checkout@v4 + - name: Checkout centijson + uses: actions/checkout@v4 + with: + repository: mity/centijson + ref: master + path: centijson + - name: Configure + run: | + CMAKE_TOOLCHAIN_FILE=${{github.workspace}}/mingw.cmake \ + CMAKE_BUILD_TYPE=Release cmake \ + -B ${{github.workspace}}/centijson/build \ + -S ${{github.workspace}}/centijson + - name: Build + run: cmake --build ${{github.workspace}}/centijson/build --config Release + - name: Package files + run: | + mkdir -p ${{github.workspace}}/centijson/build/include/ + cp ${{github.workspace}}/centijson/src/*.h ${{github.workspace}}/centijson/build/include/ + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: centijson-mingw32 + path: | + ${{github.workspace}}/centijson/build/include + ${{github.workspace}}/centijson/build/libjson.a + astronomy-mingw32: + runs-on: ubuntu-latest + steps: + - name: Install mingw-w64 + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends mingw-w64 + - name: Checkout + uses: actions/checkout@v4 + - name: Checkout astronomy + uses: actions/checkout@v4 + with: + repository: cosinekitty/astronomy + ref: master + path: astronomy + - name: Build + run: | + mkdir -p ${{github.workspace}}/astronomy/build + i686-w64-mingw32-gcc -m32 -march=x86-64 -c \ + -I ${{github.workspace}}/astronomy/source/c \ + -o ${{github.workspace}}/astronomy/build/astronomy.o \ + ${{github.workspace}}/astronomy/source/c/astronomy.c + i686-w64-mingw32-ar crs \ + ${{github.workspace}}/astronomy/build/libastronomy.a \ + ${{github.workspace}}/astronomy/build/astronomy.o + - name: Package files + run: | + mkdir -p ${{github.workspace}}/astronomy/build/include/ + cp ${{github.workspace}}/astronomy/source/c/*.h ${{github.workspace}}/astronomy/build/include/ + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: astronomy-mingw32 + path: | + ${{github.workspace}}/astronomy/build/include + ${{github.workspace}}/astronomy/build/libastronomy.a + tomlc99-mingw32: + runs-on: ubuntu-latest + steps: + - name: Install mingw-w64 + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends mingw-w64 + - name: Checkout + uses: actions/checkout@v4 + - name: Checkout tomlc99 + uses: actions/checkout@v4 + with: + repository: cktan/tomlc99 + ref: master + path: tomlc99 + - name: Build + run: | + CC=i686-w64-mingw32-gcc CFLAGS="-m32 -march=x86-64" make -C ${{github.workspace}}/tomlc99 libtoml.a + - name: Package files + run: | + mkdir -p ${{github.workspace}}/tomlc99/build/include/ + cp ${{github.workspace}}/tomlc99/*.h ${{github.workspace}}/tomlc99/build/include/ + cp ${{github.workspace}}/tomlc99/libtoml.a ${{github.workspace}}/tomlc99/build/ + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: tomlc99-mingw32 + path: | + ${{github.workspace}}/tomlc99/build/include + ${{github.workspace}}/tomlc99/build/libtoml.a + ffmpeg-mingw32: + runs-on: ubuntu-latest + steps: + - name: Install mingw-w64 + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends mingw-w64 + - name: Checkout + uses: actions/checkout@v4 + - name: Checkout ffmpeg + uses: actions/checkout@v4 + with: + repository: FFmpeg/FFmpeg + ref: master + path: ffmpeg + - name: Configure + run: | + cd ${{github.workspace}}/ffmpeg && ./configure \ + --disable-x86asm \ + --disable-programs \ + --disable-doc \ + --disable-devices \ + --disable-everything \ + --disable-filters \ + --disable-static \ + --disable-avdevice \ + --disable-swscale \ + --disable-postproc \ + --disable-avfilter \ + --disable-network \ + --disable-dwt \ + --disable-lsp \ + --disable-faan \ + --disable-iamf \ + --disable-pixelutils \ + --disable-debug \ + --enable-shared \ + --enable-small \ + --enable-decoder=smacker \ + --enable-decoder=smackaud \ + --enable-demuxer=smacker \ + --enable-protocol=file \ + --arch=i686 \ + --target-os=mingw32 \ + --cross-prefix=i686-w64-mingw32- \ + --enable-cross-compile + - name: Build + run: | + make -C ${{github.workspace}}/ffmpeg \ + libavformat/libavformat.a \ + libavcodec/libavcodec.a \ + libavutil/libavutil.a \ + libswresample/libswresample.a + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ffmpeg-mingw32 + path: | + ${{github.workspace}}/ffmpeg/libavformat/*.h + ${{github.workspace}}/ffmpeg/libavformat/libavformat.a + ${{github.workspace}}/ffmpeg/libavcodec/*.h + ${{github.workspace}}/ffmpeg/libavcodec/libavcodec.a + ${{github.workspace}}/ffmpeg/libavutil/*.h + ${{github.workspace}}/ffmpeg/libavutil/libavutil.a + ${{github.workspace}}/ffmpeg/libswresample/*.h + ${{github.workspace}}/ffmpeg/libswresample/libswresample.a + release: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + needs: + - zlib-mingw32 + - centijson-mingw32 + - astronomy-mingw32 + - enet-mingw32 + - spng-mingw32 + - tomlc99-mingw32 + - ffmpeg-mingw32 + steps: + - name: Download zlib + uses: actions/download-artifact@v4 + with: + name: zlib-mingw32 + path: ${{github.workspace}}/zlib + - name: Download centijson + uses: actions/download-artifact@v4 + with: + name: centijson-mingw32 + path: ${{github.workspace}}/centijson + - name: Download astronomy + uses: actions/download-artifact@v4 + with: + name: astronomy-mingw32 + path: ${{github.workspace}}/astronomy + - name: Download enet + uses: actions/download-artifact@v4 + with: + name: enet-mingw32 + path: ${{github.workspace}}/enet + - name: Download spng + uses: actions/download-artifact@v4 + with: + name: spng-mingw32 + path: ${{github.workspace}}/spng + - name: Download tomlc99 + uses: actions/download-artifact@v4 + with: + name: tomlc99-mingw32 + path: ${{github.workspace}}/tomlc99 + - name: Download ffmpeg + uses: actions/download-artifact@v4 + with: + name: ffmpeg-mingw32 + path: ${{github.workspace}}/ffmpeg + - name: Create tarballs + run: | + tar czf ${{github.workspace}}/zlib-mingw32.tar.gz -C ${{github.workspace}}/zlib . + tar czf ${{github.workspace}}/centijson-mingw32.tar.gz -C ${{github.workspace}}/centijson . + tar czf ${{github.workspace}}/astronomy-mingw32.tar.gz -C ${{github.workspace}}/astronomy . + tar czf ${{github.workspace}}/enet-mingw32.tar.gz -C ${{github.workspace}}/enet . + tar czf ${{github.workspace}}/spng-mingw32.tar.gz -C ${{github.workspace}}/spng . + tar czf ${{github.workspace}}/tomlc99-mingw32.tar.gz -C ${{github.workspace}}/tomlc99 . + tar czf ${{github.workspace}}/ffmpeg-mingw32.tar.gz -C ${{github.workspace}}/ffmpeg . + - name: Release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GA_TEST_TOKEN }} + make_latest: true + files: | + ${{github.workspace}}/zlib-mingw32.tar.gz + ${{github.workspace}}/centijson-mingw32.tar.gz + ${{github.workspace}}/astronomy-mingw32.tar.gz + ${{github.workspace}}/enet-mingw32.tar.gz + ${{github.workspace}}/spng-mingw32.tar.gz + ${{github.workspace}}/tomlc99-mingw32.tar.gz + ${{github.workspace}}/ffmpeg-mingw32.tar.gz diff --git a/mingw.cmake b/mingw.cmake new file mode 100644 index 0000000..b70bbc8 --- /dev/null +++ b/mingw.cmake @@ -0,0 +1,9 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX i686-w64-mingw32) +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) +set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)