diff --git a/iceoryx-sys/build.rs b/iceoryx-sys/build.rs index eff7900..2c97196 100644 --- a/iceoryx-sys/build.rs +++ b/iceoryx-sys/build.rs @@ -5,9 +5,10 @@ use std::env; use std::io::{Error, ErrorKind}; -use std::path::Path; use std::process::Command; +const ICEORYX_VERSION: &str = "v2.0.3"; + fn make_and_install(source_dir: &str, build_dir: &str, install_dir: &str) -> std::io::Result<()> { let cmake_install_prefix = format!("-DCMAKE_INSTALL_PREFIX={}", install_dir); let cmake_prefix_path = format!("-DCMAKE_PREFIX_PATH={}", install_dir); @@ -62,32 +63,33 @@ fn make_and_install(source_dir: &str, build_dir: &str, install_dir: &str) -> std Ok(()) } -fn clone_repo(repo: &str, branch: &str, source_dir: &str) -> std::io::Result<()> { - if !Path::new(source_dir).join(".git").exists() { - Command::new("git") - .args(&[ - "clone", - repo, - &format!("--branch={}", branch), - "--recursive", - source_dir, - ]) - .output() - .map_err(|out| { - println!("{:?}", out); - out - }) - .map(|out| println!("{:?}", out))?; - } else { - Command::new("git") - .current_dir(source_dir) - .args(&["checkout", branch]) - .output() - .map_err(|out| { - println!("{:?}", out); - out - }) - .map(|out| println!("{:?}", out))?; +fn extract_archive(archive_dir: &str, source_dir: &str, version: &str) -> std::io::Result<()> { + if !Command::new("mkdir") + .args(&["-p", &source_dir]) + .status()? + .success() + { + return Err(Error::new( + ErrorKind::Other, + format!("Could not create source dir for '{}'!", source_dir), + )); + } + + if !Command::new("tar") + .args(&[ + "-xf", + &format!("{}/{}.tar.gz", archive_dir, version), + "-C", + &source_dir, + "--strip-components=1", + ]) + .status()? + .success() + { + return Err(Error::new( + ErrorKind::Other, + format!("Could not extract archive '{}' to '{}'!", version, source_dir), + )); } Ok(()) @@ -95,18 +97,14 @@ fn clone_repo(repo: &str, branch: &str, source_dir: &str) -> std::io::Result<()> fn main() -> std::io::Result<()> { let out_dir = env::var("OUT_DIR").expect("Target output directory"); + let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("Cargo manifest directory"); - let iceoryx_source_dir = format!("{}/{}", out_dir, "iceoryx-git"); + let iceoryx_archive_dir = format!("{}/{}", manifest_dir, "iceoryx-cpp"); + let iceoryx_source_dir = format!("{}/{}/", out_dir, "iceoryx-cpp"); let iceoryx_build_dir = format!("{}/{}", out_dir, "iceoryx-build"); let iceoryx_install_dir = format!("{}/{}", out_dir, "iceoryx-install"); - const ICEORYX_VERSION: &str = "v2.0.2"; - const ICEORYX_GIT_BRANCH: &str = ICEORYX_VERSION; - clone_repo( - "https://github.com/eclipse-iceoryx/iceoryx.git", - ICEORYX_GIT_BRANCH, - &iceoryx_source_dir, - )?; + extract_archive(&iceoryx_archive_dir, &iceoryx_source_dir, ICEORYX_VERSION)?; make_and_install( &iceoryx_source_dir, diff --git a/iceoryx-sys/iceoryx-cpp/update-iceoryx-cpp.sh b/iceoryx-sys/iceoryx-cpp/update-iceoryx-cpp.sh new file mode 100755 index 0000000..56c70a4 --- /dev/null +++ b/iceoryx-sys/iceoryx-cpp/update-iceoryx-cpp.sh @@ -0,0 +1,147 @@ +#! /bin/bash + +shopt -s expand_aliases + +# colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +CYAN='\033[0;36m' +COLOR_OFF='\033[0m' + +GIT_TOPLEVEL=$(git rev-parse --show-toplevel) +ICEORYX_CPP_BASE_DIR=$GIT_TOPLEVEL/iceoryx-sys/iceoryx-cpp +ICEORYX_TAG="v0.0.0" + +DO_BUILD_ONLY=false +DO_PREPARATORY_WORK=false +DO_RELEASE=false + +OPTION_COUNTER=0 +while (( "$#" )); do + ((OPTION_COUNTER+=1)) + if [[ $OPTION_COUNTER -gt 1 ]]; then + echo -e "${RED}Error:${COLOR_OFF} Too many arguments specified! Try '--help' for more information." + exit -1 + fi + + case $1 in + -h|--help) + echo "Script to update bundled iceoryx C++ source archive" + echo "" + echo "Usage: update-iceoryx-cpp.sh [option]" + echo "Only one option at a time is allowed!" + echo "Options:" + echo " -t, --tag Updates the bundled source archive with" + echo " the given " + echo " -h, --help Prints this help" + echo "" + echo "Example:" + echo " update-iceoryx-cpp.sh --tag v2.0.0" + exit 0 + ;; + -t|--tag) + if [[ $# -ne 2 ]]; then + echo -e "${RED}Error:${COLOR_OFF} No parameter specified! Try '--help' for more information." + fi + ICEORYX_TAG="$2" + + shift 2 + ;; + *) + echo "Invalid argument '$1'. Try '--help' for options." + exit -1 + ;; + esac +done + +if [[ $OPTION_COUNTER -eq 0 ]]; then + echo -e "${RED}Error:${COLOR_OFF} No arguments specified! Try '--help' for more information." + exit -1 +fi + +#################### +# cd into base dir # +#################### + +cd $ICEORYX_CPP_BASE_DIR + +echo -e "${CYAN}Info:${COLOR_OFF} Entering '$(pwd)'" + +####################### +# Remove old archives # +####################### + +echo -e "${CYAN}Info:${COLOR_OFF} Removing old archives with the naming pattern 'v*.tar.gz*'" + +rm -rf v*\.tar\.gz* + +####################### +# Downloading archive # +####################### + +ICEORYX_ARCHIVE="${ICEORYX_TAG}.tar.gz" +ICEORYX_ARCHIVE_LINK="https://github.com/eclipse-iceoryx/iceoryx/archive/refs/tags/${ICEORYX_ARCHIVE}" + +echo -e "${CYAN}Info:${COLOR_OFF} Fetching '${ICEORYX_ARCHIVE_LINK}'" + +wget ${ICEORYX_ARCHIVE_LINK} --quiet --show-progress + +if [ $? -ne 0 ]; then + echo -e "${RED}Error:${COLOR_OFF} Could not fetch '${ICEORYX_ARCHIVE_LINK}'" + exit -1 +fi + +########################## +# Extracting new archive # +########################## + +echo -e "${CYAN}Info:${COLOR_OFF} Extracting new source archive to '${ICEORYX_TAG}'" + +mkdir -p ${ICEORYX_TAG} +tar -xf ${ICEORYX_ARCHIVE} -C ${ICEORYX_TAG} --strip-components=1 --atime-preserve=replace + +################# +# Strip archive # +################# + +echo -e "${CYAN}Info:${COLOR_OFF} Stripping source archive from unnecessary files" + +rm -rf ${ICEORYX_TAG}/.clang-format +rm -rf ${ICEORYX_TAG}/.clang-tidy +rm -rf ${ICEORYX_TAG}/.codecov.yml +rm -rf ${ICEORYX_TAG}/.gitattributes +rm -rf ${ICEORYX_TAG}/.github +rm -rf ${ICEORYX_TAG}/.gitignore +rm -rf ${ICEORYX_TAG}/cmake +rm -rf ${ICEORYX_TAG}/doc +rm -rf ${ICEORYX_TAG}/iceoryx_binding_c +rm -rf ${ICEORYX_TAG}/iceoryx_dds +rm -rf ${ICEORYX_TAG}/iceoryx_examples +rm -rf ${ICEORYX_TAG}/iceoryx_integrationtest +rm -rf ${ICEORYX_TAG}/iceoryx_meta +rm -rf ${ICEORYX_TAG}/mkdocs.yml +rm -rf ${ICEORYX_TAG}/tools + +rm -rf ${ICEORYX_TAG}/iceoryx_hoofs/test +rm -rf ${ICEORYX_TAG}/iceoryx_posh/test +# restore modified timestamp to prevent changes in archive checksum for repetitive updates to the same tag +touch -r ${ICEORYX_TAG}/VERSION ${ICEORYX_TAG}/iceoryx_hoofs +touch -r ${ICEORYX_TAG}/VERSION ${ICEORYX_TAG}/iceoryx_posh +touch -r ${ICEORYX_TAG}/VERSION ${ICEORYX_TAG} + +####################### +# Re-compress archive # +####################### + +echo -e "${CYAN}Info:${COLOR_OFF} Re-compressing '${ICEORYX_TAG}' into '${ICEORYX_ARCHIVE}'" + +tar -czf ${ICEORYX_ARCHIVE} ${ICEORYX_TAG} + +########################## +# Remove extracted archive # +########################## + +echo -e "${CYAN}Info:${COLOR_OFF} Removing extracted file" + +rm -rf ${ICEORYX_TAG} diff --git a/iceoryx-sys/iceoryx-cpp/v2.0.3.tar.gz b/iceoryx-sys/iceoryx-cpp/v2.0.3.tar.gz new file mode 100644 index 0000000..834f0cd Binary files /dev/null and b/iceoryx-sys/iceoryx-cpp/v2.0.3.tar.gz differ