This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7fc6610  [build] Use mktemp dir for symlinks of building dirs
7fc6610 is described below

commit 7fc661055d4f1c26d572a29bb437b434c15f87fa
Author: Mingshen Sun <[email protected]>
AuthorDate: Mon Feb 24 21:46:41 2020 -0800

    [build] Use mktemp dir for symlinks of building dirs
---
 cmake/MesaTEEGenVars.cmake     |  7 +++++++
 cmake/scripts/cc_wrapper.sh    |  4 ++--
 cmake/scripts/prep.sh          | 10 +++++-----
 cmake/scripts/rustc_wrapper.sh |  4 ++--
 config/build.rs                |  4 +++-
 services/proto/build.rs        |  5 ++++-
 6 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/cmake/MesaTEEGenVars.cmake b/cmake/MesaTEEGenVars.cmake
index 3cbc624..11746e5 100644
--- a/cmake/MesaTEEGenVars.cmake
+++ b/cmake/MesaTEEGenVars.cmake
@@ -14,6 +14,11 @@ set(MESATEE_AUDITORS_DIR 
${MESATEE_SERVICE_INSTALL_DIR}/auditors)
 set(MESATEE_EXAMPLE_AUDITORS_DIR ${MESATEE_EXAMPLE_INSTALL_DIR}/auditors)
 set(MESATEE_TARGET_DIR ${PROJECT_BINARY_DIR}/target)
 
+execute_process(COMMAND bash -c "mktemp -u -d -t mesatee_symlinks.XXXXXXXXXXXX"
+                OUTPUT_VARIABLE MESATEE_SYMLINKS)
+string(STRIP "${MESATEE_SYMLINKS}" MESATEE_SYMLINKS)
+set(MESATEE_SYMLINKS ${MESATEE_SYMLINKS})
+
 set(THIRD_PARTY_DIR ${PROJECT_SOURCE_DIR}/third_party)
 set(UNTRUSTED_TARGET_DIR ${MESATEE_TARGET_DIR}/untrusted)
 set(UNIX_TARGET_DIR ${MESATEE_TARGET_DIR}/unix)
@@ -113,6 +118,7 @@ set(MESATEE_COMMON_ENVS
     MESATEE_TARGET_DIR=${MESATEE_TARGET_DIR}
     MESATEE_CFG_DIR=${PROJECT_SOURCE_DIR}
     MESATEE_BUILD_CFG_DIR=${PROJECT_SOURCE_DIR}
+    MESATEE_SYMLINKS=${MESATEE_SYMLINKS}
     SGX_SDK=${SGX_SDK}
     SGX_MODE=${SGX_MODE}
     ENCLAVE_OUT_DIR=${ENCLAVE_OUT_DIR}
@@ -148,3 +154,4 @@ message("SGX_MODE=${SGX_MODE}")
 message("RUSTUP_TOOLCHAIN=${RUSTUP_TOOLCHAIN}")
 message("DCAP=${DCAP}")
 message("BUILD TYPE=${TARGET}")
+message("MESATEE_SYMLINKS=${MESATEE_SYMLINKS}")
diff --git a/cmake/scripts/cc_wrapper.sh b/cmake/scripts/cc_wrapper.sh
index 18b3d03..a07f967 100755
--- a/cmake/scripts/cc_wrapper.sh
+++ b/cmake/scripts/cc_wrapper.sh
@@ -1,9 +1,9 @@
 #!/bin/bash
 set -e
-REQUIRED_ENVS=("MESATEE_PROJECT_ROOT" "MESATEE_BUILD_ROOT" "CMAKE_C_COMPILER")
+REQUIRED_ENVS=("MESATEE_PROJECT_ROOT" "MESATEE_BUILD_ROOT" "MESATEE_SYMLINKS" 
"CMAKE_C_COMPILER")
 for var in "${REQUIRED_ENVS[@]}"; do
     [ -z "${!var}" ] && echo "Please set ${var}" && exit -1
 done
 
 # Tell gcc/clang to remap absolute src paths to make enclaves' signature more 
reproducible
-exec "${CMAKE_C_COMPILER}" "$@" 
-fdebug-prefix-map=${MESATEE_PROJECT_ROOT}=/tmp/mesatee_symlinks/mesatee_src 
-fdebug-prefix-map=${MESATEE_BUILD_ROOT}=/tmp/mesatee_symlinks/mesatee_build
+exec "${CMAKE_C_COMPILER}" "$@" 
-fdebug-prefix-map=${MESATEE_PROJECT_ROOT}=${MESATEE_SYMLINKS}/mesatee_src 
-fdebug-prefix-map=${MESATEE_BUILD_ROOT}=${MESATEE_SYMLINKS}/mesatee_build
diff --git a/cmake/scripts/prep.sh b/cmake/scripts/prep.sh
index cc7d1c0..57428f4 100755
--- a/cmake/scripts/prep.sh
+++ b/cmake/scripts/prep.sh
@@ -6,7 +6,7 @@ REQUIRED_ENVS=("CMAKE_SOURCE_DIR" "CMAKE_BINARY_DIR"
 "CMAKE_AR" "SGX_UNTRUSTED_CFLAGS" "SGX_TRUSTED_CFLAGS" "MT_SCRIPT_DIR"
 "MESATEE_SERVICE_INSTALL_DIR" "MESATEE_EXAMPLE_INSTALL_DIR" 
"MESATEE_BIN_INSTALL_DIR"
 "MESATEE_CLI_INSTALL_DIR" "MESATEE_DCAP_INSTALL_DIR" "MESATEE_LIB_INSTALL_DIR" 
"MESATEE_TEST_INSTALL_DIR"
-"MESATEE_AUDITORS_DIR" "MESATEE_EXAMPLE_AUDITORS_DIR" "DCAP"
+"MESATEE_AUDITORS_DIR" "MESATEE_EXAMPLE_AUDITORS_DIR" "DCAP" "MESATEE_SYMLINKS"
 )
 
 for var in "${REQUIRED_ENVS[@]}"; do
@@ -32,10 +32,10 @@ cp -r ${CMAKE_SOURCE_DIR}/tests/fixtures/ 
${MESATEE_TEST_INSTALL_DIR}
 ln -f -s ${MESATEE_TEST_INSTALL_DIR}/fixtures 
${MESATEE_SERVICE_INSTALL_DIR}/fixtures
 cp -r ${CMAKE_SOURCE_DIR}/tests/scripts/ ${MESATEE_TEST_INSTALL_DIR}
 # create the following symlinks to make remapped paths accessible and avoid 
repeated building
-mkdir -p /tmp/mesatee_symlinks
-ln -snf ${HOME}/.cargo /tmp/mesatee_symlinks/cargo_home
-ln -snf ${CMAKE_SOURCE_DIR} /tmp/mesatee_symlinks/mesatee_src
-ln -snf ${CMAKE_BINARY_DIR} /tmp/mesatee_symlinks/mesatee_build
+mkdir -p ${MESATEE_SYMLINKS}
+ln -snf ${HOME}/.cargo ${MESATEE_SYMLINKS}/cargo_home
+ln -snf ${CMAKE_SOURCE_DIR} ${MESATEE_SYMLINKS}/mesatee_src
+ln -snf ${CMAKE_BINARY_DIR} ${MESATEE_SYMLINKS}/mesatee_build
 # cleanup sgx_unwind/libunwind
 (cd ${CMAKE_SOURCE_DIR}/third_party/crates-sgx/ && git clean -fdx 
vendor/sgx_unwind/libunwind/)
 if git submodule status | egrep -q '^[-]|^[+]'; then echo 'INFO: Need to 
reinitialize git submodules' && git submodule update --init --recursive; fi
diff --git a/cmake/scripts/rustc_wrapper.sh b/cmake/scripts/rustc_wrapper.sh
index 815666a..59987f4 100755
--- a/cmake/scripts/rustc_wrapper.sh
+++ b/cmake/scripts/rustc_wrapper.sh
@@ -1,9 +1,9 @@
 #!/bin/bash
 set -e
-REQUIRED_ENVS=("MESATEE_PROJECT_ROOT" "MESATEE_BUILD_ROOT")
+REQUIRED_ENVS=("MESATEE_PROJECT_ROOT" "MESATEE_BUILD_ROOT" "MESATEE_SYMLINKS")
 for var in "${REQUIRED_ENVS[@]}"; do
     [ -z "${!var}" ] && echo "Please set ${var}" && exit -1
 done
 
 # Tell rustc to remap absolute src paths to make enclaves' signature more 
reproducible
-exec rustc "$@" 
--remap-path-prefix=${HOME}/.cargo=/tmp/mesatee_symlinks/cargo_home 
--remap-path-prefix=${MESATEE_PROJECT_ROOT}=/tmp/mesatee_symlinks/mesatee_src 
--remap-path-prefix=${MESATEE_BUILD_ROOT}=/tmp/mesatee_symlinks/mesatee_build
+exec rustc "$@" 
--remap-path-prefix=${HOME}/.cargo=${MESATEE_SYMLINKS}/cargo_home 
--remap-path-prefix=${MESATEE_PROJECT_ROOT}=${MESATEE_SYMLINKS}/mesatee_src 
--remap-path-prefix=${MESATEE_BUILD_ROOT}=${MESATEE_SYMLINKS}/mesatee_build
diff --git a/config/build.rs b/config/build.rs
index 06d3331..74fe5c1 100644
--- a/config/build.rs
+++ b/config/build.rs
@@ -16,11 +16,13 @@ fn main() {
     println!("cargo:rerun-if-changed=config_gen/templates/config.j2");
     println!("cargo:rerun-if-changed=build.config.toml");
     println!("cargo:rerun-if-changed=build.rs");
+    let target_dir = 
Path::new(&env::var("MESATEE_SYMLINKS").expect("MESATEE_SYMLINKS"))
+        .join("mesatee_build/target/config_gen");
     let c = Command::new("cargo")
         .args(&[
             "run",
             "--target-dir",
-            "/tmp/config_gen/target",
+            &target_dir.to_string_lossy(),
             "--manifest-path",
             "config_gen/Cargo.toml",
             "--",
diff --git a/services/proto/build.rs b/services/proto/build.rs
index 205fc4a..c77e4d9 100644
--- a/services/proto/build.rs
+++ b/services/proto/build.rs
@@ -16,6 +16,7 @@
 // under the License.
 
 use std::env;
+use std::path::Path;
 use std::process::Command;
 use std::str;
 
@@ -39,11 +40,13 @@ fn main() {
         println!("cargo:rerun-if-changed={}", pf);
     }
 
+    let target_dir = 
Path::new(&env::var("MESATEE_SYMLINKS").expect("MESATEE_SYMLINKS"))
+        .join("mesatee_build/target/proto_gen");
     let c = Command::new("cargo")
         .args(&[
             "run",
             "--target-dir",
-            "/tmp/proto_gen/target",
+            &target_dir.to_string_lossy(),
             "--manifest-path",
             "./proto_gen/Cargo.toml",
             "--",


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to