diff --git a/chronik/CMakeLists.txt b/chronik/CMakeLists.txt --- a/chronik/CMakeLists.txt +++ b/chronik/CMakeLists.txt @@ -3,8 +3,13 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(Corrosion 0.4.7 REQUIRED) - +include(FetchContent) +FetchContent_Declare( + Corrosion + GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git + GIT_TAG v0.4.7 +) +FetchContent_MakeAvailable(Corrosion) set(REQUIRED_RUST_VERSION "1.72.0") if(Rust_VERSION VERSION_LESS REQUIRED_RUST_VERSION) @@ -82,7 +87,7 @@ add_crate_test_targets(bitcoinsuite) add_crate_test_targets(chronik) -# Compile Rust, generates chronik-lib-static +# Compile Rust, generates chronik-lib corrosion_import_crate( MANIFEST_PATH "chronik-lib/Cargo.toml" FLAGS @@ -90,6 +95,16 @@ ${CHRONIK_FEATURE_FLAGS} ) +set(Rust_TRIPLE + "${Rust_CARGO_TARGET_ARCH}" + "${Rust_CARGO_TARGET_VENDOR}" + "${Rust_CARGO_TARGET_OS}" +) +if (Rust_CARGO_TARGET_ENV) + list(APPEND Rust_TRIPLE "${Rust_CARGO_TARGET_ENV}") +endif() +list(JOIN Rust_TRIPLE "-" Rust_CARGO_TARGET) + # cxx crate generates some source files at this location set(CXXBRIDGE_GENERATED_FOLDER "${CARGO_BUILD_DIR}/${Rust_CARGO_TARGET}/cxxbridge") @@ -97,6 +112,7 @@ "${CXXBRIDGE_GENERATED_FOLDER}/chronik-bridge/src/ffi.rs.cc") set(CHRONIK_LIB_GENERATED_CPP_FILES "${CXXBRIDGE_GENERATED_FOLDER}/chronik-lib/src/ffi.rs.cc") + add_custom_command( OUTPUT ${CHRONIK_BRIDGE_GENERATED_CPP_FILES} @@ -105,7 +121,7 @@ "${CMAKE_COMMAND}" -E env "echo" "Generating cxx bridge files" - DEPENDS chronik-lib-static + DEPENDS $ ) # Chronik-bridge library @@ -135,7 +151,7 @@ ) target_link_libraries(chronik chronik-bridge - chronik-lib-static + chronik-lib ) # Plugins require us to link agains libpython diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -191,20 +191,6 @@ # Cleanup rm -f rustup-init - # Corrosion - curl -sSfL https://api.github.com/repos/corrosion-rs/corrosion/tarball/v0.4.7 -o corrosion.tar.gz - echo "fce6387c5d2ac779bac2818b67a83240dfb3a16c2e51fd8e4bad63a445cd4278 corrosion.tar.gz" | sha256sum -c - tar xzf corrosion.tar.gz - CORROSION_SRC_FOLDER="${PWD}/corrosion-rs-corrosion-8ddd6d5" - CORROSION_BUILD_FOLDER="${CORROSION_SRC_FOLDER}-build" - CORROSION_INSTALL_FOLDER="${PWD}-install" - cmake -S"${CORROSION_SRC_FOLDER}" -B"${CORROSION_BUILD_FOLDER}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${CORROSION_INSTALL_FOLDER}" - cmake --build "${CORROSION_BUILD_FOLDER}" --config Release - cmake --install "${CORROSION_BUILD_FOLDER}" --config Release - # Cleanup - rm -f corrosion.tar.gz - rm -rf "${CORROSION_BUILD_FOLDER}" - # Extend the hosts to include an experimental chronik build. # Despite not being a new host per se, it makes it easy to reuse the same code # and prevent errors. @@ -212,7 +198,7 @@ for i in ${HOSTS[@]}; do HOSTS+=($i-chronik-experimental) CMAKE_TOOLCHAIN_FILE[$i-chronik-experimental]=${CMAKE_TOOLCHAIN_FILE[$i]} - CMAKE_EXTRA_OPTIONS[$i-chronik-experimental]="${CMAKE_EXTRA_OPTIONS[$i]} -DBUILD_BITCOIN_CHRONIK=ON -DCorrosion_DIR=${CORROSION_INSTALL_FOLDER}/lib/cmake/Corrosion" + CMAKE_EXTRA_OPTIONS[$i-chronik-experimental]="${CMAKE_EXTRA_OPTIONS[$i]} -DBUILD_BITCOIN_CHRONIK=ON" done # Extract the release tarball into a dir for each host and build diff --git a/contrib/utils/install-dependencies-bullseye.sh b/contrib/utils/install-dependencies-bullseye.sh --- a/contrib/utils/install-dependencies-bullseye.sh +++ b/contrib/utils/install-dependencies-bullseye.sh @@ -184,16 +184,6 @@ "x86_64-apple-darwin" \ "x86_64-pc-windows-gnu" -# Install corrosion from Github -wget https://api.github.com/repos/corrosion-rs/corrosion/tarball/v0.4.7 -O corrosion.tar.gz -echo "fce6387c5d2ac779bac2818b67a83240dfb3a16c2e51fd8e4bad63a445cd4278 corrosion.tar.gz" | sha256sum -c -tar xzf corrosion.tar.gz -CORROSION_SRC_FOLDER=corrosion-rs-corrosion-8ddd6d5 -CORROSION_BUILD_FOLDER=${CORROSION_SRC_FOLDER}-build -cmake -S${CORROSION_SRC_FOLDER} -B${CORROSION_BUILD_FOLDER} -DCMAKE_BUILD_TYPE=Release -cmake --build ${CORROSION_BUILD_FOLDER} --config Release -cmake --install ${CORROSION_BUILD_FOLDER} --config Release - # Install Electrum ABC test dependencies here=$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")") pip3 install -r "${here}/../../electrum/contrib/requirements/requirements.txt"