Skip to content

Commit

Permalink
Merge pull request #30 from Inokinoki/fix-build-on-freebsd
Browse files Browse the repository at this point in the history
Use qefi v0.4.0 to build on FreeBSD
  • Loading branch information
Inokinoki authored Nov 15, 2024
2 parents 0d8e013 + a28863b commit fd4f560
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/cmake-freebsd-amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build on FreeBSD
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
name: Build
runs-on: ubuntu-22.04
strategy:
matrix:
os-version: ['13.2', '14.1']
# Don't abort runners if a single one fails
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
submodules: true
# Configure and build
- uses: vmactions/freebsd-vm@v1
with:
release: ${{ matrix.os-version}}
usesh: true
prepare: |
pkg install -y cmake qt5
run: |
uname -a
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=/usr
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
32 changes: 6 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,46 +61,26 @@ else()
)
endif()

# Find and link efivar/win32 API
find_package(PkgConfig)
if(PkgConfig_FOUND)
pkg_check_modules(EFIVAR efivar>=0.15)
if(NOT DEFINED EFIVAR_FOUND)
# Find and link efivar<0.15
pkg_check_modules(EFIVAR efivar)
if(EFIVAR_FOUND)
# Consider it as an old lib (without mode and return non-zero)
# TODO(Inoki): to check https://github.com/rhboot/efivar/commit/7bd2e309aeec210509d215c803a762725591ccc7
add_definitions(-DEFIVAR_WITHOUT_MODE)
endif()
endif()
endif()

if(APP_DATA_DUMMY_BACKEND)
# Use the directory under QStandardPaths::AppDataLocation for test purpose
message("Use dummy backend for EFI operations")
add_definitions(-DEFIVAR_APP_DATA_DUMMY)
elseif(EFIVAR_FOUND)
message("Use libefivar for EFI operations")
include_directories(QEFIEntryManager ${EFIVAR_INCLUDE_DIRS})
target_link_libraries(QEFIEntryManager PRIVATE ${EFIVAR_LIBRARIES})
elseif(WIN32)
message("Use Windows API for EFI operations")
else()
message(FATAL_ERROR "No EFI utility found, please make sure you have libefivar installed")
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
# Link with FreeBSD system-level libefivar and geom
# see source code of usr.sbin/efibootmgr/Makefile and usr.sbin/efivar/Makefile
target_link_libraries(QEFIEntryManager PUBLIC efivar geom)
endif()
message("Use qefivar implementations for EFI operations")
endif()

if(USE_EFIVAR_OLD_API)
add_definitions(-DEFIVAR_OLD_API)
endif()

target_include_directories(QEFIEntryManager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/qefivar)
if(PATCH_FREEBSD_EFIVAR)
# Patch efivar 0.15 build for FreeBSD
# TODO(Inoki): check 0.15 build
add_definitions(-DEFIVAR_FREEBSD_PATCH)
target_link_libraries(QEFIEntryManager PRIVATE geom)
endif()

# Make a CMAKE project config file in QEFI, the libefivar should be linked automatically
target_link_libraries(QEFIEntryManager PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
Expand Down
2 changes: 1 addition & 1 deletion qefivar

0 comments on commit fd4f560

Please sign in to comment.