From ff19b2823c3f57ba80334eafbc1b0c05519c9de5 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Sat, 21 Jan 2023 22:35:27 +0000 Subject: [PATCH] Packaging fixes --- .github/ISSUE_TEMPLATE/bug-report.md | 3 +- .github/workflows/build.yml | 54 +++++--------- .github/workflows/release.yml | 108 ++++++++++++--------------- CMakeLists.txt | 32 ++++---- build_windows.sh | 70 +++++++---------- cmake/toolchain-mingw32.cmake | 1 + 6 files changed, 111 insertions(+), 157 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index d51896d..41036f7 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -11,7 +11,7 @@ assignees: '' A clear description of what the bug is. **To Reproduce** -Steps to reproduce the behaviour. +Steps to reproduce the behavior. **Expected behaviour** A clear description of what you expected to happen. @@ -21,4 +21,3 @@ A link to the audio that caused the problem. **Build information** The commit of aptdec you are running (check with `git rev-parse HEAD`), make sure it's up to date before opening this issue. -And whether you are using GNU automake or CMake. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf809e6..8960cb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,9 +10,6 @@ on: paths-ignore: - '**.md' -env: - BUILD_TYPE: Release - jobs: build_linux: runs-on: ubuntu-latest @@ -23,35 +20,25 @@ jobs: submodules: 'recursive' - name: Install dependencies - # The user does not run as root run: sudo apt-get install cmake git gcc libsndfile-dev libpng-dev - - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands - run: cmake -E make_directory ${{runner.workspace}}/build + - name: Configure cmake + run: cmake -B build -DCMAKE_BUILD_TYPE=Release - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system - shell: bash - working-directory: ${{runner.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + - name: Build and package + run: cmake --build build -j$(nproc) && cmake --build build --target package - - name: Build - working-directory: ${{runner.workspace}}/build - shell: bash - # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE + - name: Upload TGZ package + uses: actions/upload-artifact@v3 + with: + name: TGZ package + path: build/aptdec/aptdec_*.tar.gz - - name: Upload compilied binary - uses: actions/upload-artifact@v2 + - name: Upload DEB package + uses: actions/upload-artifact@v3 with: - name: aptdec_lin64 - path: ${{runner.workspace}}/build/aptdec + name: Debian package + path: build/aptdec/aptdec_*.deb build_windows: runs-on: ubuntu-latest @@ -62,16 +49,13 @@ jobs: submodules: 'recursive' - name: Install dependencies - # The user does not run as root - run: sudo apt install wget cmake make mingw-w64 git unzip libsndfile-dev + run: sudo apt install cmake git mingw-w64 unzip - name: Run build script - shell: bash - working-directory: ${{runner.workspace}} - run: cd $GITHUB_WORKSPACE && ./build_windows.sh $BUILD_TYPE + run: ./build_windows.sh $BUILD_TYPE - - name: Upload compilied binary - uses: actions/upload-artifact@v2 + - name: Upload ZIP package + uses: actions/upload-artifact@v3 with: - name: aptdec-win64.zip - path: ${{runner.workspace}}/aptdec/winbuild/aptdec-1.7.0.zip + name: ZIP package + path: build/aptdec/aptdec_*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b49e8d2..1f7dce4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,35 +1,44 @@ -name: Build +name: Build (release) on: push: tags: - 'v*' -env: - BUILD_TYPE: Release - jobs: - prepare_release: + create_release: runs-on: ubuntu-latest - outputs: - upload_url: ${{ steps.create_release.outputs.upload_url }} + needs: [ build_linux, build_windows ] steps: + - name: Download TGZ package + uses: actions/download-artifact@v3 + with: + name: TGZ package + + - name: Download DEB package + uses: actions/download-artifact@v3 + with: + name: DEB package + + - name: Download ZIP package + uses: actions/download-artifact@v3 + with: + name: ZIP package + + - name: Test + run: ls -la + - name: Create Release - uses: actions/create-release@v1 - id: create_release + uses: softprops/action-gh-release@v1 with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - body: A release wow - draft: false - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + files: | + aptdec_$GITHUB_REF_NAME.x86_64.tar.gz + aptdec_$GITHUB_REF_NAME.x86_64.deb + aptdec_$GITHUB_REF_NAME.amd64.zip build_linux: runs-on: ubuntu-latest - needs: [prepare_release] steps: - uses: actions/checkout@v3 @@ -37,44 +46,28 @@ jobs: submodules: 'recursive' - name: Install dependencies - # The user does not run as root run: sudo apt-get install cmake git gcc libsndfile-dev libpng-dev - - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands - run: cmake -E make_directory ${{runner.workspace}}/build - - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system - shell: bash - working-directory: ${{runner.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE - - - name: Build - working-directory: ${{runner.workspace}}/build - shell: bash - # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE - - - name: Upload binary - uses: actions/upload-release-asset@v1 + - name: Configure cmake + run: cmake -B build -DCMAKE_BUILD_TYPE=Release + + - name: Build and package + run: cmake --build build -j$(nproc) && cmake --build build --target package + + - name: Upload TGZ package + uses: actions/upload-artifact@v3 with: - upload_url: ${{ needs.prepare_release.outputs.upload_url }} - asset_path: ./${{runner.workspace}}/aptdec/build/aptdec - asset_name: aptdec_lin64 - asset_content_type: application/x-executable - env: - GITHUB_TOKEN: ${{ github.token }} + name: TGZ package + path: build/aptdec/aptdec_*.tar.gz + - name: Upload DEB package + uses: actions/upload-artifact@v3 + with: + name: Debian package + path: build/aptdec/aptdec_*.deb build_windows: runs-on: ubuntu-latest - needs: [prepare_release] steps: - uses: actions/checkout@v3 @@ -82,20 +75,13 @@ jobs: submodules: 'recursive' - name: Install dependencies - # The user does not run as root - run: sudo apt install wget cmake make mingw-w64 git unzip libsndfile-dev + run: sudo apt install cmake git mingw-w64 unzip - name: Run build script - shell: bash - working-directory: ${{runner.workspace}} - run: cd $GITHUB_WORKSPACE && ./build_windows.sh $BUILD_TYPE + run: ./build_windows.sh $BUILD_TYPE - - name: Upload zip - uses: actions/upload-release-asset@v1 + - name: Upload ZIP package + uses: actions/upload-artifact@v3 with: - upload_url: ${{ needs.prepare_release.outputs.upload_url }} - asset_path: ./${{runner.workspace}}/aptdec/winbuild/aptdec-1.7.0.zip - asset_name: aptdec_win64.zip - asset_content_type: application/zip - env: - GITHUB_TOKEN: ${{ github.token }} + name: ZIP package + path: build/aptdec/aptdec_*.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index 843a97d..e5f3a09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ include(GNUInstallDirs) # aptdec-cli find_package(PNG) find_path(SNDFILE_INCLUDE_DIR sndfile.h) -find_library(SNDFILE_LIBRARIES NAMES sndfile libsndfile PATH) +find_library(SNDFILE_LIBRARIES NAMES sndfile libsndfile) if(PNG_FOUND AND SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIR) set(APTDEC_CLI_SOURCE_FILES @@ -43,6 +43,10 @@ if(PNG_FOUND AND SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIR) target_link_libraries(aptdec-cli PRIVATE m) target_compile_options(aptdec-cli PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) endif() + + install(TARGETS aptdec-cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + file(GLOB LUTS luts/*.png) + install(FILES ${LUTS} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/aptdec/luts) else() message(WARNING "Not building aptdec-cli as some/all required dependencies are missing, libaptdec will still be built") endif() @@ -72,32 +76,24 @@ else() target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) endif() +install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aptdec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + # Packaging set(CPACK_PACKAGE_VERSION "${VERSION}") set(CPACK_PACKAGE_NAME "aptdec") set(CPACK_PACKAGE_CONTACT "Xerbo (xerbo@protonmail.com)") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder") set(CPACK_PACKAGE_DESCRIPTION "Aptdec is a FOSS library/program that decodes images transmitted by the NOAA POES weather satellites. These satellites transmit constantly (among other things) medium resolution (4km/px) images of the earth over a analog mode called APT.") +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) -if(NOT WIN32) - set(CPACK_GENERATOR "DEB;TGZ") - set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}") -else() - #set(CPACK_GENERATOR "ZIP;NSIS") - set(CPACK_GENERATOR "ZIP") - set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") - - if (TARGET aptdec) - file(GLOB_RECURSE DLLS *.dll) - install(FILES ${DLLS} DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif() -endif() +if(WIN32) + file(GLOB DLLS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/*.dll) + install(FILES ${DLLS} DESTINATION ${CMAKE_INSTALL_BINDIR}) -if(TARGET aptdec-cli) - install(TARGETS aptdec RUNTIME DESTINATION bin) + set(CPACK_GENERATOR "ZIP") +else() + set(CPACK_GENERATOR "DEB;TGZ") endif() -install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aptdec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - include(CPack) diff --git a/build_windows.sh b/build_windows.sh index 5d9558f..987c11e 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -1,54 +1,42 @@ #!/usr/bin/env bash # Cross compile for Windows from Linux - -TEMP_PATH="$(pwd)/winpath" set -e -# Compile and build zlib -if [ -d "zlib" ]; then - cd zlib && git pull -else - git clone https://github.com/madler/zlib && cd zlib +TEMP_PATH="$(pwd)/winpath" +BUILD_DIR="winbuild" + +# Build zlib from source +if [ ! -d "zlib" ]; then + git clone -b v1.2.13 https://github.com/madler/zlib && cd zlib + cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH + cmake --build build -j$(nproc) + cmake --build build --target install + cd .. fi -mkdir -p build && cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH .. -make -j4 -make install -cd ../.. - -# Clone and build ligpng -if [ -d "libpng" ]; then - cd libpng && git pull -else - git clone https://github.com/glennrp/libpng && cd libpng +# Build libpng from source +if [ ! -d "libpng" ]; then + git clone -b v1.6.39 https://github.com/glennrp/libpng && cd libpng + cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH + cmake --build build -j$(nproc) + cmake --build build --target install + cd .. fi -mkdir -p build && cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH .. -make -j4 -make install -cd ../.. - # Download libsndfile -if [ ! -d "libsndfile-1.0.29-win64" ]; then - wget https://github.com/erikd/libsndfile/releases/download/v1.0.29/libsndfile-1.0.29-win64.zip - unzip libsndfile-1.0.29-win64.zip +if [ ! -d libsndfile-1.2.0-win64 ]; then + wget https://github.com/libsndfile/libsndfile/releases/download/1.2.0/libsndfile-1.2.0-win64.zip + unzip libsndfile-1.2.0-win64.zip + cp "libsndfile-1.2.0-win64/bin/sndfile.dll" $TEMP_PATH/bin + cp "libsndfile-1.2.0-win64/include/sndfile.h" $TEMP_PATH/include + cp "libsndfile-1.2.0-win64/lib/sndfile.lib" $TEMP_PATH/lib fi -cp "libsndfile-1.0.29-win64/bin/sndfile.dll" $TEMP_PATH/bin/sndfile.dll -cp "libsndfile-1.0.29-win64/include/sndfile.h" $TEMP_PATH/include/sndfile.h -cp "libsndfile-1.0.29-win64/lib/sndfile.lib" $TEMP_PATH/lib/sndfile.lib - -# Copy DLL's into root for CPack -cp $TEMP_PATH/bin/*.dll ../ -buildtype="Debug" -if [[ "$1" == "Release" ]]; then - buildtype="Release" -fi +# Copy required GCC libs +cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libgcc_s_seh-1.dll $TEMP_PATH/bin +cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll $TEMP_PATH/bin # Build aptdec -mkdir -p winbuild && cd winbuild -cmake -DCMAKE_BUILD_TYPE=$buildtype -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH .. -make -j 4 -make package +cmake -B $BUILD_DIR -DCMAKE_BUILD_TYPE=$1 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH +cmake --build $BUILD_DIR -j$(nproc) +cmake --build $BUILD_DIR --target package diff --git a/cmake/toolchain-mingw32.cmake b/cmake/toolchain-mingw32.cmake index b316fd3..de03f7e 100644 --- a/cmake/toolchain-mingw32.cmake +++ b/cmake/toolchain-mingw32.cmake @@ -1,5 +1,6 @@ # the name of the target operating system SET(CMAKE_SYSTEM_NAME Windows) +SET(CMAKE_SYSTEM_PROCESSOR amd64) # which compilers to use for C and C++ SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)