Skip to content

Commit

Permalink
Don't link against libplist in GH Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum committed Sep 29, 2022
1 parent c7d9db3 commit e222a69
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-cross-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: sudo apt-get install -y build-essential gcc g++ gdc ninja-build gdc-12-aarch64-linux-gnu dub

- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -Dbuild_sideloadipa=OFF -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/toolchains/rpi-4.cmake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -Dbuild_sideloadipa=OFF -Dlink_libplist_dynamic=ON -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/toolchains/rpi-4.cmake

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
compiler: ldc-latest

- name: Install dependencies
run: sudo apt-get install -y build-essential gcc g++ ninja-build libgtk-3-dev libplist-dev libimobiledevice-dev
run: sudo apt-get install -y build-essential gcc g++ ninja-build libgtk-3-dev libimobiledevice-dev

- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_D_COMPILER=ldc2 -Dbuild_javabindings=ON
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_D_COMPILER=ldc2 -Dbuild_javabindings=ON -Dlink_libplist_dynamic=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
Expand Down Expand Up @@ -55,10 +55,10 @@ jobs:
compiler: ldc-latest

- name: Install dependencies
run: sudo apt-get install -y build-essential gcc g++ ninja-build libplist-dev
run: sudo apt-get install -y build-essential gcc g++ ninja-build

- name: Configure CMake
run: cmake -G Ninja -Dbuild_sideloadipa=OFF -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_D_COMPILER=ldc2
run: cmake -G Ninja -Dbuild_sideloadipa=OFF -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_D_COMPILER=ldc2 -Dlink_libplist_dynamic=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
Expand All @@ -82,10 +82,10 @@ jobs:
compiler: ldc-latest

- name: Install dependencies
run: sudo apt-get install -y build-essential gcc g++ ninja-build libplist-dev
run: sudo apt-get install -y build-essential gcc g++ ninja-build

- name: Configure CMake
run: cmake -G Ninja -Dbuild_sideloadipa=OFF -Dbuild_anisetteserver=OFF -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_D_COMPILER=ldc2
run: cmake -G Ninja -Dbuild_sideloadipa=OFF -Dbuild_anisetteserver=OFF -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_D_COMPILER=ldc2 -Dlink_libplist_dynamic=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config Debug
Expand Down
52 changes: 27 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(Provision D)
option(build_javabindings "Java bindings" OFF)
option(build_sideloadipa "Build Sideload IPA" ON)
option(build_anisetteserver "Build Anisette server" ON)
option(link_libplist_dynamic "Load libplist at runtime" ON)
option(link_libplist_dynamic "Load libplist at runtime" OFF)

include(cmake/dependencies.cmake)

Expand All @@ -17,34 +17,36 @@ find_package(PkgConfig REQUIRED)
add_library(provision STATIC ${PROVISION_D_SOURCES})
target_include_directories(provision PUBLIC ${PROVISION_SOURCE_DIR})

if(NOT CMAKE_CROSSCOMPILING)
pkg_check_modules(plist IMPORTED_TARGET libplist-2.0)

if (NOT plist_FOUND)
pkg_check_modules(plist IMPORTED_TARGET libplist)
endif()
endif()

if (plist_FOUND)
add_library(plist ALIAS PkgConfig::plist)
if (link_libplist_dynamic)
add_library(plist INTERFACE)
target_compile_versions(provision PUBLIC LibPlist)
message("Using libplist. ")
target_compile_versions(plist INTERFACE LibPlistDynamic)
else()
if(NOT CMAKE_CROSSCOMPILING)
pkg_check_modules(plist IMPORTED_TARGET libplist-2.0)

if (link_libplist_dynamic)
target_compile_versions(provision PUBLIC LibPlistDynamic)
if (NOT plist_FOUND)
pkg_check_modules(plist IMPORTED_TARGET libplist)
endif()
endif()
else()
if (build_sideloadipa)
message(FATAL_ERROR "Sideload IPA requires libplist development headers")

if (plist_FOUND)
message("Using libplist. ")
add_library(plist ALIAS PkgConfig::plist)
target_compile_versions(provision PUBLIC LibPlist)
else()
if (build_sideloadipa)
message(FATAL_ERROR "Sideload IPA requires libplist development package. ")
endif()
message(WARNING "Using fallback Property list parser. ")

FetchContent_Declare(
plist_proj
GIT_REPOSITORY https://github.com/hatf0/plist
PATCH_COMMAND ${DUB_DIRECTORY}/CMakeTmp/DubToCMake -s plist
)
FetchContent_MakeAvailable(plist_proj)
endif()
message(WARNING "Using fallback Property list parser. ")

FetchContent_Declare(
plist_proj
GIT_REPOSITORY https://github.com/hatf0/plist
PATCH_COMMAND ${DUB_DIRECTORY}/CMakeTmp/DubToCMake -s plist
)
FetchContent_MakeAvailable(plist_proj)
endif()

# Generate C++ header
Expand Down
2 changes: 1 addition & 1 deletion cmake/cmake-d
9 changes: 5 additions & 4 deletions lib/provision/plist/c.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ version (LibPlist):
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

import core.sys.posix.dlfcn;
import core.stdc.stdarg;
import core.stdc.stdlib;
import std.traits: getSymbolsByUDA, ReturnType, Parameters;

private struct PlistImport {

}

version (LibPlistDynamic) {
import core.sys.posix.dlfcn;
import core.stdc.stdlib;
import std.traits: getSymbolsByUDA, ReturnType, Parameters;

template delegateStorage(string name) {
__gshared void* delegateStorage;
}
Expand Down Expand Up @@ -64,7 +65,7 @@ version (LibPlistDynamic) {
}

pragma(mangle, symbol.mangleof)
extern (C) ReturnType!symbol impl(Parameters!symbol params) {
extern (C) ReturnType!symbol impl(Parameters!symbol params) @(__traits(getAttributes, symbol)) {
return (cast(DelT) del)(params);
}
}
Expand Down

0 comments on commit e222a69

Please sign in to comment.