6 Cometimentos

7 ficheiros alterados com 122 adições e 158 eliminações
  1. +1
    -2
      .github/ISSUE_TEMPLATE/bug-report.md
  2. +21
    -35
      .github/workflows/build.yml
  3. +50
    -62
      .github/workflows/release.yml
  4. +6
    -0
      .gitignore
  5. +14
    -18
      CMakeLists.txt
  6. +29
    -41
      build_windows.sh
  7. +1
    -0
      cmake/toolchain-mingw32.cmake

+ 1
- 2
.github/ISSUE_TEMPLATE/bug-report.md Ver ficheiro

@@ -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.

+ 21
- 35
.github/workflows/build.yml Ver ficheiro

@@ -10,9 +10,6 @@ on:
paths-ignore:
- '**.md'

env:
BUILD_TYPE: Release

jobs:
build_linux:
runs-on: ubuntu-latest
@@ -21,37 +18,28 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
fetch-depth: 0
- 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 <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Upload TGZ package
uses: actions/upload-artifact@v3
with:
name: TGZ package
path: build/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_*.deb

build_windows:
runs-on: ubuntu-latest
@@ -60,18 +48,16 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
fetch-depth: 0
- 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_*.zip

+ 50
- 62
.github/workflows/release.yml Ver ficheiro

@@ -1,101 +1,89 @@
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
with:
submodules: 'recursive'
fetch-depth: 0

- 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 <NAME>"
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_*.tar.gz

- name: Upload DEB package
uses: actions/upload-artifact@v3
with:
name: Debian package
path: build/aptdec_*.deb

build_windows:
runs-on: ubuntu-latest
needs: [prepare_release]

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
fetch-depth: 0
- 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_*.zip

+ 6
- 0
.gitignore Ver ficheiro

@@ -83,3 +83,9 @@ _deps
*.ogg

build/
winbuild/
winpath/
zlib/
libpng/
libsndfile-*-win64.zip
libsndfile-*-win64/

+ 14
- 18
CMakeLists.txt Ver ficheiro

@@ -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)

+ 29
- 41
build_windows.sh Ver ficheiro

@@ -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 $(find /usr | grep libgcc_s_seh-1.dll | head -n 1) $TEMP_PATH/bin
cp $(find /usr | grep libwinpthread-1.dll | head -n 1) $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

+ 1
- 0
cmake/toolchain-mingw32.cmake Ver ficheiro

@@ -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)


Carregando…
Cancelar
Guardar