Skip to content

Commit

Permalink
Merge pull request #1391 from dmaltsiniotis/feature/package-windows-a…
Browse files Browse the repository at this point in the history
…rtifacts

Auto-package windows binaries on build (and fix a few bugs and warnings)
  • Loading branch information
mossmann authored Mar 7, 2024
2 parents 8486cb2 + 3d83a2f commit 1525b62
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 26 deletions.
68 changes: 43 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:
WIN_FFTW_LIB: -DFFTW_LIBRARIES=C:/vcpkg/installed/x64-windows/lib/fftw3f.lib
WIN_PTHREAD_INC: -DTHREADS_PTHREADS_INCLUDE_DIR=C:/vcpkg/installed/x64-windows/include
WIN_PTHREAD_LIB: -DTHREADS_PTHREADS_WIN32_LIBRARY=C:/vcpkg/installed/x64-windows/lib/pthreadvc3.lib
WIN_CMAKE_TOOLCHAIN: -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake

jobs:
host:
Expand All @@ -27,7 +28,7 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install dependencies (macOS)
run: brew install fftw
Expand All @@ -43,74 +44,91 @@ jobs:
run: vcpkg install --triplet=x64-windows libusb fftw3 pthreads
if: matrix.os == 'windows-latest'

# Build libhackrf and hackrf-tools together
- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/host/build
run: cmake -E make_directory ${{github.workspace}}/host/build

- name: Configure CMake
working-directory: ${{runner.workspace}}/host/build
working-directory: ${{github.workspace}}/host/build
run: cmake $GITHUB_WORKSPACE/host/ -DCMAKE_BUILD_TYPE=Release
if: matrix.os != 'windows-latest'

- name: Configure CMake (Windows)
working-directory: ${{runner.workspace}}/host/build
run: cmake $env:GITHUB_WORKSPACE/host/ $env:WIN_LIBUSB_INC $env:WIN_LIBUSB_LIB $env:WIN_FFTW_INC $env:WIN_FFTW_LIB $env:WIN_PTHREAD_INC $env:WIN_PTHREAD_LIB
working-directory: ${{github.workspace}}/host/build
run: cmake $env:GITHUB_WORKSPACE/host/ $env:WIN_LIBUSB_INC $env:WIN_LIBUSB_LIB $env:WIN_FFTW_INC $env:WIN_FFTW_LIB $env:WIN_PTHREAD_INC $env:WIN_PTHREAD_LIB $env:WIN_CMAKE_TOOLCHAIN
if: matrix.os == 'windows-latest'

- name: Build
working-directory: ${{runner.workspace}}/host/build
working-directory: ${{github.workspace}}/host/build
run: cmake --build . --config Release

# Build libhackrf ONLY
- name: Create Build Environment (libhackrf)
run: cmake -E make_directory ${{runner.workspace}}/host/libhackrf/build
run: cmake -E make_directory ${{github.workspace}}/host/libhackrf/build

- name: Configure CMake (libhackrf)
working-directory: ${{runner.workspace}}/host/libhackrf/build
working-directory: ${{github.workspace}}/host/libhackrf/build
run: cmake $GITHUB_WORKSPACE/host/libhackrf/ -DCMAKE_BUILD_TYPE=Release
if: matrix.os != 'windows-latest'

- name: Configure CMake (libhackrf, Windows)
working-directory: ${{runner.workspace}}/host/libhackrf/build
run: cmake $env:GITHUB_WORKSPACE/host/libhackrf/ $env:WIN_LIBUSB_INC $env:WIN_LIBUSB_LIB $env:WIN_PTHREAD_INC $env:WIN_PTHREAD_LIB
working-directory: ${{github.workspace}}/host/libhackrf/build
run: cmake $env:GITHUB_WORKSPACE/host/libhackrf/ $env:WIN_LIBUSB_INC $env:WIN_LIBUSB_LIB $env:WIN_PTHREAD_INC $env:WIN_PTHREAD_LIB $env:WIN_CMAKE_TOOLCHAIN
if: matrix.os == 'windows-latest'

- name: Build (libhackrf)
working-directory: ${{runner.workspace}}/host/libhackrf/build
working-directory: ${{github.workspace}}/host/libhackrf/build
run: cmake --build . --config Release

- name: Install (libhackrf)
working-directory: ${{runner.workspace}}/host/libhackrf/build
working-directory: ${{github.workspace}}/host/libhackrf/build
run: |
sudo cmake --install . --config Release
if: matrix.os != 'windows-latest'

- name: Install (libhackrf, Windows)
working-directory: ${{runner.workspace}}/host/libhackrf/build
working-directory: ${{github.workspace}}/host/libhackrf/build
run: |
cmake --install . --config Release --prefix=$env:GITHUB_WORKSPACE/install
if: matrix.os == 'windows-latest'

# Build hackrf-tools ONLY
- name: Create Build Environment (hackrf-tools)
run: cmake -E make_directory ${{runner.workspace}}/host/hackrf-tools/build
run: cmake -E make_directory ${{github.workspace}}/host/hackrf-tools/build

- name: Configure CMake (hackrf-tools)
working-directory: ${{runner.workspace}}/host/hackrf-tools/build
working-directory: ${{github.workspace}}/host/hackrf-tools/build
run: cmake $GITHUB_WORKSPACE/host/hackrf-tools/ -DCMAKE_BUILD_TYPE=Release
if: matrix.os != 'windows-latest'

- name: Configure CMake (hackrf-tools, Windows)
working-directory: ${{runner.workspace}}/host/hackrf-tools/build
working-directory: ${{github.workspace}}/host/hackrf-tools/build
run: |
cmake $env:GITHUB_WORKSPACE/host/hackrf-tools/ $env:WIN_FFTW_INC $env:WIN_FFTW_LIB -DLIBHACKRF_INCLUDE_DIR=$env:GITHUB_WORKSPACE/install/include/libhackrf -DLIBHACKRF_LIBRARIES=$env:GITHUB_WORKSPACE/install/bin/hackrf.lib
cmake $env:GITHUB_WORKSPACE/host/hackrf-tools/ $env:WIN_FFTW_INC $env:WIN_FFTW_LIB -DLIBHACKRF_INCLUDE_DIR="$env:GITHUB_WORKSPACE/install/include/libhackrf" -DLIBHACKRF_LIBRARIES="$env:GITHUB_WORKSPACE/install/bin/hackrf.lib" $env:WIN_CMAKE_TOOLCHAIN
if: matrix.os == 'windows-latest'

- name: Build (hackrf-tools)
working-directory: ${{runner.workspace}}/host/hackrf-tools/build
working-directory: ${{github.workspace}}/host/hackrf-tools/build
run: cmake --build . --config Release
# This step should work on Windows too, but currently MSVC fails to find
# hackrf.h, despite us having installed it and specified its location in
# the previous steps above.

- name: Install (hackrf-tools)
working-directory: ${{github.workspace}}/host/hackrf-tools/build
run: sudo cmake --install . --config Release
if: matrix.os != 'windows-latest'

- name: Install (hackrf-tools, Windows)
working-directory: ${{github.workspace}}/host/hackrf-tools/build
run: cmake --install . --config Release --prefix=$env:GITHUB_WORKSPACE/install
if: matrix.os == 'windows-latest'

# Publish the contents of install/bin (which should be the combination libhackrf and host-tools) for Windows
- name: Publish Artifacts (Windows)
uses: actions/upload-artifact@v4
with:
name: hackrf-tools-windows
path: ${{github.workspace}}/install/bin
if: matrix.os == 'windows-latest'

firmware:
strategy:
matrix:
Expand All @@ -122,7 +140,7 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true

Expand All @@ -144,15 +162,15 @@ jobs:
run: make

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/firmware/build
run: cmake -E make_directory ${{github.workspace}}/firmware/build

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/firmware/build
working-directory: ${{github.workspace}}/firmware/build
run: cmake $GITHUB_WORKSPACE/firmware/ -DCMAKE_BUILD_TYPE=Release -DBOARD=${{ matrix.board }}

- name: Build
working-directory: ${{runner.workspace}}/firmware/build
working-directory: ${{github.workspace}}/firmware/build
shell: bash
run: cmake --build . --config Release

2 changes: 1 addition & 1 deletion .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- check: 'firmware/hackrf_usb'
exclude: ''
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run clang-format-action
uses: jidicula/[email protected]
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.srec
host/build/
host/**/build
install/

# Operating system spew
.DS_Store
Expand Down
7 changes: 7 additions & 0 deletions host/hackrf-tools/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ foreach(tool ${TOOLS})
target_link_libraries(${tool} ${TOOLS_LINK_LIBS})
install(TARGETS ${tool} RUNTIME DESTINATION ${INSTALL_DEFAULT_BINDIR})
endforeach(tool)

if( ${WIN32} )
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/"
DESTINATION ${INSTALL_DEFAULT_BINDIR}
FILES_MATCHING
PATTERN "fftw*.dll")
endif( ${WIN32} )
6 changes: 6 additions & 0 deletions host/libhackrf/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ if( ${WIN32} )
DESTINATION bin
COMPONENT sharedlibs
)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/"
DESTINATION bin
FILES_MATCHING
PATTERN "libusb*.dll"
PATTERN "pthread*.dll"
)
install(TARGETS hackrf-static
DESTINATION bin
COMPONENT staticlibs
Expand Down

0 comments on commit 1525b62

Please sign in to comment.