Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0f98b19..9781b97 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,36 +1,64 @@
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "trigger"'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_COMMIT_BRANCH
- if: '$CI_COMMIT_TAG !~ /^phabricator\//'
stages:
- build
.build:
stage: build
image: docker.io/ubuntu:24.04
script:
- apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
- - DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends rustup build-essential g++ libolm-dev libboost-json-dev wget cmake ca-certificates catch2 corrosion
+ - DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends rustup build-essential g++ libolm-dev libboost-json-dev wget cmake ca-certificates catch2
- rustup default stable
+ - |
+ if [ -z "$CUSTOM_CORROSION_VERSION" ]; then
+ DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends corrosion || exit 1
+ else
+ wget -Ocorrosion.tar.gz https://github.com/corrosion-rs/corrosion/archive/refs/tags/"$CUSTOM_CORROSION_VERSION".tar.gz && \
+ tar -xf corrosion.tar.gz && \
+ cd corrosion-* && \
+ mkdir build && cd build && \
+ cmake .. && \
+ make -j$(($(nproc) / 2)) && \
+ make install && \
+ cd ../.. && \
+ rm -rf corrosion-* corrosion.tar.gz || exit 1
+ fi
- mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE="$BUILD_TYPE"
- make -j$(($(nproc) / 2))
- CTEST_OUTPUT_ON_FAILURE=ON make test
build:release:
extends:
- .build
before_script:
- BUILD_TYPE=Release
build:debug:
extends:
- .build
before_script:
- BUILD_TYPE=Debug
+
+build-corrosion0.6.1:release:
+ extends:
+ - .build
+ before_script:
+ - BUILD_TYPE=Release
+ - CUSTOM_CORROSION_VERSION=v0.6.1
+
+build-corrosion0.6.1:debug:
+ extends:
+ - .build
+ before_script:
+ - BUILD_TYPE=Debug
+ - CUSTOM_CORROSION_VERSION=v0.6.1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0a1954..e55ba01 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,71 +1,79 @@
cmake_minimum_required(VERSION 3.23)
project(vodozemac-bindings)
include(GNUInstallDirs)
include(CTest)
find_package(Perl REQUIRED)
find_package(Corrosion REQUIRED)
+set(BUILD_OUTPUT_DIR "${CMAKE_BINARY_DIR}/cargo/build/${Rust_CARGO_TARGET}")
+if("${Corrosion_VERSION}" VERSION_GREATER_EQUAL 0.6)
+ # From Corrosion.cmake
+ string(SHA1 cargo_path_hash "${CMAKE_SOURCE_DIR}/cpp/Cargo.toml")
+ string(SUBSTRING "${cargo_path_hash}" 0 5 cargo_path_hash)
+ set(BUILD_OUTPUT_DIR "${CMAKE_BINARY_DIR}/cargo/cpp_${cargo_path_hash}/${Rust_CARGO_TARGET}")
+endif()
+
# corrosion_import_crate requires that lib.rs exist, so we must generate it right now when configuring
message(STATUS "Generating lib.rs")
execute_process(COMMAND "${PERL_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/cpp/inject-maybe"
"${CMAKE_SOURCE_DIR}/cpp/src/lib.rs.in" "${CMAKE_BINARY_DIR}/vodozemac.lib.rs"
ERROR_FILE "${CMAKE_BINARY_DIR}/vodozemac.lib.rs.log"
COMMAND_ERROR_IS_FATAL ANY)
# Use a temporary file and copy it into place to avoid unnecessarily updating it
configure_file("${CMAKE_BINARY_DIR}/vodozemac.lib.rs" "${CMAKE_SOURCE_DIR}/cpp/src/lib.rs" COPYONLY)
corrosion_import_crate(MANIFEST_PATH cpp/Cargo.toml)
add_library(vodozemac-shared SHARED)
add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/vodozemac-dummy.cpp"
COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_BINARY_DIR}/vodozemac-dummy.cpp" VERBATIM)
# copy the header. if we install the lib.rs.h directly, we will install a symlink.
add_custom_target(vodezemac-header ALL
- "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_BINARY_DIR}/cargo/build/${Rust_CARGO_TARGET}/cxxbridge/vodozemac/src/lib.rs.h" "${CMAKE_BINARY_DIR}/vodozemac.h"
+ "${CMAKE_COMMAND}" -E copy_if_different "${BUILD_OUTPUT_DIR}/cxxbridge/vodozemac/src/lib.rs.h" "${CMAKE_BINARY_DIR}/vodozemac.h"
VERBATIM
BYPRODUCTS "${CMAKE_BINARY_DIR}/vodozemac.h"
DEPENDS vodozemac-static
)
set(vodozemac_HEADERS "${CMAKE_BINARY_DIR}/vodozemac.h")
target_sources(
vodozemac-shared
PRIVATE "${CMAKE_BINARY_DIR}/vodozemac-dummy.cpp"
)
set_target_properties(vodozemac-shared
PROPERTIES
LINKER_LANGUAGE CXX
OUTPUT_NAME vodozemac
EXPORT_NAME vodozemac
VERSION 1.0.0
SOVERSION 4
)
target_link_libraries(vodozemac-shared PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,vodozemac-static>")
target_include_directories(vodozemac-shared INTERFACE
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
install(FILES ${vodozemac_HEADERS} TYPE INCLUDE RENAME vodozemac.h)
install(TARGETS vodozemac-shared EXPORT vodozemacTargets LIBRARY)
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/vodozemac)
install(
EXPORT vodozemacTargets
NAMESPACE vodozemac::
DESTINATION ${ConfigPackageLocation}
)
install(
FILES cmake/vodozemacConfig.cmake
DESTINATION ${ConfigPackageLocation})
if(BUILD_TESTING)
find_package(Catch2 REQUIRED)
find_package(Boost REQUIRED COMPONENTS json)
find_package(Olm REQUIRED)
add_subdirectory(cpp/tests)
endif()

File Metadata

Mime Type
text/x-diff
Expires
Wed, Nov 18, 2:49 AM (22 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1840017
Default Alt Text
(5 KB)

Event Timeline