Skip to content

Commit

Permalink
Update libloot to v0.24.5
Browse files Browse the repository at this point in the history
Build libloot from source to avoid issues with runtime dependencies not being available on different GitHub Actions runners.
  • Loading branch information
Ortham committed Jan 13, 2025
1 parent d56177b commit fdb69e5
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 49 deletions.
46 changes: 38 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,26 @@ jobs:
linux:
runs-on: ubuntu-20.04

env:
ICU_MAJOR_VERSION: 71
LIBLOOT_VERSION: 0.24.5

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set libloot install path
run: echo "LIBLOOT_INSTALL_PATH=${{ github.workspace }}/libloot-${{ env.LIBLOOT_VERSION }}-install" >> $GITHUB_ENV

- name: libloot cache
id: libloot-cache
uses: actions/cache@v4
with:
path: ${{ env.LIBLOOT_INSTALL_PATH }}
# Key includes ICU major version because libloot links against it as a shared library.
key: ${{ runner.os }}-libloot-${{ env.LIBLOOT_VERSION }}-icu-${{ env.ICU_MAJOR_VERSION }}

- name: Get descriptive version
id: get-version
shell: bash
Expand All @@ -32,23 +47,38 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y --no-upgrade \
g++-10 \
cbindgen \
libboost-dev \
libtbb-dev
- name: Get ICU
id: get-icu
run: |
wget https://github.com/unicode-org/icu/releases/download/release-71-1/icu4c-71_1-Ubuntu20.04-x64.tgz
tar -xf icu4c-71_1-Ubuntu20.04-x64.tgz
wget https://github.com/unicode-org/icu/releases/download/release-${ICU_MAJOR_VERSION}-1/icu4c-${ICU_MAJOR_VERSION}_1-Ubuntu20.04-x64.tgz
tar -xf icu4c-${ICU_MAJOR_VERSION}_1-Ubuntu20.04-x64.tgz
ICU_INSTALL_PATH="${{ github.workspace }}/icu/usr/local"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ICU_INSTALL_PATH/lib" >> "$GITHUB_ENV"
echo "root=$ICU_INSTALL_PATH" >> $GITHUB_OUTPUT
- name: Download and build libloot
run: |
wget https://github.com/loot/libloot/archive/$LIBLOOT_VERSION.tar.gz
tar -xf $LIBLOOT_VERSION.tar.gz
mkdir libloot-$LIBLOOT_VERSION/build
cd libloot-$LIBLOOT_VERSION/build
cmake .. -DICU_ROOT="${{ steps.get-icu.outputs.root }}" -DLIBLOOT_BUILD_TESTS=OFF -DLIBLOOT_INSTALL_DOCS=OFF -DCMAKE_INSTALL_PREFIX="$LIBLOOT_INSTALL_PATH"
echo "root=${{ github.workspace }}/icu/usr/local" >> $GITHUB_OUTPUT
cmake --build . --target loot --config Release
cmake --install . --config Release
if: steps.libloot-cache.outputs.cache-hit != 'true'

- name: Run CMake
run: |
mkdir build
cd build
export CXX="g++-10" CC="gcc-10"
cmake .. -DCPACK_PACKAGE_VERSION="${{ steps.get-version.outputs.version }}" -DICU_ROOT="${{ steps.get-icu.outputs.root }}"
cmake .. -DICU_ROOT="${{ steps.get-icu.outputs.root }}" -DCMAKE_PREFIX_PATH="${{ env.LIBLOOT_INSTALL_PATH }}" -DCPACK_PACKAGE_VERSION="${{ steps.get-version.outputs.version }}"
make all
- name: Build archive
Expand Down Expand Up @@ -88,7 +118,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -A Win32 -DCPACK_PACKAGE_VERSION="${{ steps.get-version.outputs.version }}"
cmake .. -G "Visual Studio 16 2019" -A x64 -DCPACK_PACKAGE_VERSION="${{ steps.get-version.outputs.version }}"
cmake --build . --config ${{ env.MSVC_CONFIG }}
- name: Build archive
Expand All @@ -98,7 +128,7 @@ jobs:
cd build
cpack -C ${{ env.MSVC_CONFIG }}
VERSION="${{ steps.get-version.outputs.version }}"
echo "filename=metadata-validator-${VERSION}-win32.7z" >> $GITHUB_OUTPUT
echo "filename=metadata-validator-${VERSION}-win64.7z" >> $GITHUB_OUTPUT
- name: Upload archive
uses: actions/upload-artifact@v3
Expand Down
48 changes: 39 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,26 @@ jobs:
runs-on: ubuntu-20.04
needs: create_release

env:
ICU_MAJOR_VERSION: 71
LIBLOOT_VERSION: 0.24.5

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set libloot install path
run: echo "LIBLOOT_INSTALL_PATH=${{ github.workspace }}/libloot-${{ env.LIBLOOT_VERSION }}-install" >> $GITHUB_ENV

- name: libloot cache
id: libloot-cache
uses: actions/cache@v4
with:
path: ${{ env.LIBLOOT_INSTALL_PATH }}
# Key includes ICU major version because libloot links against it as a shared library.
key: ${{ runner.os }}-libloot-${{ env.LIBLOOT_VERSION }}-icu-${{ env.ICU_MAJOR_VERSION }}

- name: Get descriptive version
id: get-version
shell: bash
Expand All @@ -52,24 +67,39 @@ jobs:
- name: Install APT package dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
g++-10 \
sudo apt-get install -y --no-upgrade \
cbindgen \
libboost-dev \
libtbb-dev
- name: Get ICU
id: get-icu
run: |
wget https://github.com/unicode-org/icu/releases/download/release-71-1/icu4c-71_1-Ubuntu20.04-x64.tgz
tar -xf icu4c-71_1-Ubuntu20.04-x64.tgz
wget https://github.com/unicode-org/icu/releases/download/release-${ICU_MAJOR_VERSION}-1/icu4c-${ICU_MAJOR_VERSION}_1-Ubuntu20.04-x64.tgz
tar -xf icu4c-${ICU_MAJOR_VERSION}_1-Ubuntu20.04-x64.tgz
ICU_INSTALL_PATH="${{ github.workspace }}/icu/usr/local"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ICU_INSTALL_PATH/lib" >> "$GITHUB_ENV"
echo "root=$ICU_INSTALL_PATH" >> $GITHUB_OUTPUT
- name: Download and build libloot
run: |
wget https://github.com/loot/libloot/archive/$LIBLOOT_VERSION.tar.gz
tar -xf $LIBLOOT_VERSION.tar.gz
mkdir libloot-$LIBLOOT_VERSION/build
cd libloot-$LIBLOOT_VERSION/build
cmake .. -DICU_ROOT="${{ steps.get-icu.outputs.root }}" -DLIBLOOT_BUILD_TESTS=OFF -DLIBLOOT_INSTALL_DOCS=OFF -DCMAKE_INSTALL_PREFIX="$LIBLOOT_INSTALL_PATH"
echo "root=${{ github.workspace }}/icu/usr/local" >> $GITHUB_OUTPUT
cmake --build . --target loot --config Release
cmake --install . --config Release
if: steps.libloot-cache.outputs.cache-hit != 'true'

- name: Run CMake
run: |
mkdir build
cd build
export CXX="g++-10" CC="gcc-10"
cmake .. -DCPACK_PACKAGE_VERSION="${{ steps.get-version.outputs.version }}" -DICU_ROOT="${{ steps.get-icu.outputs.root }}"
cmake .. -DICU_ROOT="${{ steps.get-icu.outputs.root }}" -DCMAKE_PREFIX_PATH="${{ env.LIBLOOT_INSTALL_PATH }}" -DCPACK_PACKAGE_VERSION="${{ steps.get-version.outputs.version }}"
make all
- name: Build archive
Expand Down Expand Up @@ -113,7 +143,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -A Win32 -DCPACK_PACKAGE_VERSION="${{ steps.get-version.outputs.version }}"
cmake .. -G "Visual Studio 16 2019" -A x64 -DCPACK_PACKAGE_VERSION="${{ steps.get-version.outputs.version }}"
cmake --build . --config ${{ env.MSVC_CONFIG }}
- name: Build archive
Expand All @@ -123,7 +153,7 @@ jobs:
cd build
cpack -C ${{ env.MSVC_CONFIG }}
VERSION="${{ steps.get-version.outputs.version }}"
echo "filename=metadata-validator-${VERSION}-win32.7z" >> $GITHUB_OUTPUT
echo "filename=metadata-validator-${VERSION}-win64.7z" >> $GITHUB_OUTPUT
- name: Upload Archive
uses: actions/upload-release-asset@v1
Expand Down
69 changes: 37 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,36 @@ configure_file("${CMAKE_SOURCE_DIR}/src/version.cpp.in"
##############################

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
find_package(ICU 71.1 EXACT REQUIRED COMPONENTS data uc)
find_package(ICU REQUIRED COMPONENTS data uc)
find_package(TBB REQUIRED)
find_package(libloot REQUIRED CONFIG)
else()
find_package(libloot CONFIG)
endif()

if(NOT DEFINED LIBLOOT_URL)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32")
set(LIBLOOT_URL "https://github.com/loot/libloot/releases/download/0.21.0/libloot-0.21.0-win32.7z")
set(LIBLOOT_HASH "SHA256=b7ea3369e4eae60be38c3d7f7b9194e8d6284e78dc862d13f0644b990b44011a")
else()
set(LIBLOOT_URL "https://github.com/loot/libloot/releases/download/0.21.0/libloot-0.21.0-win64.7z")
set(LIBLOOT_HASH "SHA256=7a1ed5a5b9ecec748f2dde43d73786f25b844874e116d86ddb603ede5933b5db")
endif()
if(libloot_FOUND)
get_target_property(LIBLOOT_INCLUDE_DIRS libloot::loot INTERFACE_INCLUDE_DIRECTORIES)
set(LIBLOOT_SHARED_LIBRARY $<TARGET_LINKER_FILE:libloot::loot>)
else()
if(NOT DEFINED LIBLOOT_URL)
set(LIBLOOT_URL "https://github.com/loot/libloot/releases/download/0.24.5/libloot-0.24.5-win64.7z")
set(LIBLOOT_HASH "SHA256=b0c9599256e95eb0a0299cd2d9f9088e15e08b25949ad71dcc377c1298d5630c")
else()
set(LIBLOOT_URL "https://github.com/loot/libloot/releases/download/0.21.0/libloot-0.21.0-Linux.tar.xz")
set(LIBLOOT_HASH "SHA256=2ce58a64380ef436ea5d01fa647ee6cfeb23f76b2468162bf099f4de07e31ea3")
file(TO_CMAKE_PATH "${LIBLOOT_URL}" LIBLOOT_URL)
endif()
endif()

ExternalProject_Add(libloot
PREFIX "external"
URL ${LIBLOOT_URL}
URL_HASH ${LIBLOOT_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
ExternalProject_Get_Property(libloot SOURCE_DIR)
set(LIBLOOT_INCLUDE_DIRS "${SOURCE_DIR}/include")
set(LIBLOOT_STATIC_LIBRARY "${SOURCE_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}loot${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(LIBLOOT_SHARED_LIBRARY "${SOURCE_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}loot${CMAKE_SHARED_LIBRARY_SUFFIX}")
ExternalProject_Add(libloot
PREFIX "external"
URL ${LIBLOOT_URL}
URL_HASH ${LIBLOOT_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
ExternalProject_Get_Property(libloot SOURCE_DIR)
set(LIBLOOT_INCLUDE_DIRS "${SOURCE_DIR}/include")
set(LIBLOOT_STATIC_LIBRARY "${SOURCE_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}loot${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(LIBLOOT_SHARED_LIBRARY "${SOURCE_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}loot${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()

##############################
# General Settings
Expand All @@ -82,21 +82,26 @@ set(VALIDATOR_SOURCE "${CMAKE_BINARY_DIR}/generated/version.cpp"
##############################

# Build validator.
add_executable (metadata_validator ${VALIDATOR_SOURCE} ${VALIDATOR_HEADERS})
add_dependencies (metadata_validator libloot)
add_executable(metadata_validator ${VALIDATOR_SOURCE} ${VALIDATOR_HEADERS})

target_include_directories(metadata_validator PRIVATE "${CMAKE_SOURCE_DIR}/src")
if(libloot_FOUND)
target_link_libraries(metadata_validator PRIVATE libloot::loot)
else()
add_dependencies(metadata_validator libloot)

target_include_directories(metadata_validator SYSTEM PRIVATE
${LIBLOOT_INCLUDE_DIRS})
target_include_directories(metadata_validator SYSTEM PRIVATE
${LIBLOOT_INCLUDE_DIRS})

target_link_libraries(metadata_validator PRIVATE ${LIBLOOT_STATIC_LIBRARY})
endif()

target_include_directories(metadata_validator PRIVATE "${CMAKE_SOURCE_DIR}/src")

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_compile_definitions(metadata_validator PRIVATE UNICODE _UNICODE)
target_compile_options(metadata_validator PRIVATE "/permissive-" "/W4")

target_link_libraries(metadata_validator PRIVATE ${LIBLOOT_STATIC_LIBRARY})
else()
target_link_libraries(metadata_validator PRIVATE ${LIBLOOT_SHARED_LIBRARY} pthread stdc++fs ICU::data ICU::uc TBB::tbb)
target_link_libraries(metadata_validator PRIVATE pthread stdc++fs ICU::data ICU::uc TBB::tbb)
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
Expand Down

0 comments on commit fdb69e5

Please sign in to comment.