diff --git a/scripts/all-core.sh b/scripts/all-core.sh index 36776a24c..a9070a8e2 100644 --- a/scripts/all-core.sh +++ b/scripts/all-core.sh @@ -188,7 +188,10 @@ pre_initialize_variables () { files_to_back_up="$config_files" if in_mbedtls_repo; then # Files clobbered by in-tree cmake - files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile" + if [ -e Makefile ]; then + files_to_back_up="$files_to_back_up Makefile" + fi + files_to_back_up="$files_to_back_up library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile" fi append_outcome=0 @@ -228,6 +231,12 @@ pre_initialize_variables () { : ${CLANG_EARLIEST:="clang-earliest"} : ${GCC_LATEST:="gcc-latest"} : ${GCC_EARLIEST:="gcc-earliest"} + : ${MAKE_COMMAND:="make"} + + if [ -e "scripts/legacy.make" ]; then + MAKE_COMMAND="${MAKE_COMMAND} -f ./scripts/legacy.make" + fi + # if MAKEFLAGS is not set add the -j option to speed up invocations of make if [ -z "${MAKEFLAGS+set}" ]; then export MAKEFLAGS="-j$(all_sh_nproc)" @@ -366,7 +375,7 @@ EOF cleanup() { if in_mbedtls_repo; then - command make clean + command $MAKE_COMMAND clean fi # Remove CMake artefacts @@ -877,11 +886,11 @@ pre_check_tools () { pre_generate_files() { # since make doesn't have proper dependencies, remove any possibly outdate # file that might be around before generating fresh ones - make neat + $MAKE_COMMAND neat if [ $QUIET -eq 1 ]; then - make generated_files >/dev/null + $MAKE_COMMAND generated_files >/dev/null else - make generated_files + $MAKE_COMMAND generated_files fi } @@ -920,7 +929,7 @@ pseudo_component_error_test () { # Expected error: '! grep -q . tests/scripts/all.sh -> 1' not grep -q . "$0" # Expected error: 'make unknown_target -> 2' - make unknown_target + $MAKE_COMMAND unknown_target false "this should not be executed" } diff --git a/scripts/all-helpers.sh b/scripts/all-helpers.sh index c1421f0d2..cf903c152 100644 --- a/scripts/all-helpers.sh +++ b/scripts/all-helpers.sh @@ -122,7 +122,7 @@ helper_libtestdriver1_make_main() { # we need flags both with and without the LIBTESTDRIVER1_ prefix loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' ) loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )" - make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -I../tests/include -I../framework/tests/include -I../tests -I../../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS" "$@" + $MAKE_COMMAND CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -I../tests/include -I../framework/tests/include -I../tests -I../../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS" "$@" } ################################################################ @@ -265,9 +265,9 @@ helper_armc6_build_test() msg "build: ARM Compiler 6 ($FLAGS)" - make clean + $MAKE_COMMAND clean ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ - WARNING_CFLAGS='-Werror -xc -std=c99' make lib + WARNING_CFLAGS='-Werror -xc -std=c99' $MAKE_COMMAND lib msg "size: ARM Compiler 6 ($FLAGS)" "$ARMC6_FROMELF" -z library/*.o diff --git a/scripts/apidoc_full.sh b/scripts/apidoc_full.sh index 902a515c6..d16f55c7b 100755 --- a/scripts/apidoc_full.sh +++ b/scripts/apidoc_full.sh @@ -22,6 +22,8 @@ if in_mbedtls_repo; then if ! in_3_6_branch; then CRYPTO_CONFIG_H='tf-psa-crypto/include/psa/crypto_config.h' fi + CONFIG_BAK=${CONFIG_H}.bak + cp -p $CONFIG_H $CONFIG_BAK fi if in_tf_psa_crypto_repo; then @@ -37,21 +39,29 @@ if in_tf_psa_crypto_repo || (in_mbedtls_repo && ! in_3_6_branch); then cp -p $CRYPTO_CONFIG_H $CRYPTO_CONFIG_BAK fi -if in_mbedtls_repo; then - CONFIG_BAK=${CONFIG_H}.bak - cp -p $CONFIG_H $CONFIG_BAK +if in_mbedtls_repo && in_3_6_branch; then scripts/config.py realfull make apidoc - mv $CONFIG_BAK $CONFIG_H -elif in_tf_psa_crypto_repo; then +else scripts/config.py realfull - TF_PSA_CRYPTO_ROOT_DIR=$PWD + ROOT_DIR=$PWD rm -rf doxygen/build-apidoc-full mkdir doxygen/build-apidoc-full cd doxygen/build-apidoc-full - cmake -DCMAKE_BUILD_TYPE:String=Check -DGEN_FILES=ON $TF_PSA_CRYPTO_ROOT_DIR - make tfpsacrypto-apidoc - cd $TF_PSA_CRYPTO_ROOT_DIR + cmake -DCMAKE_BUILD_TYPE:String=Check -DGEN_FILES=ON $ROOT_DIR + if in_mbedtls_repo; then + cmake --build . --target mbedtls-apidoc + else + cmake --build . --target tfpsacrypto-apidoc + fi + cd $ROOT_DIR + # The documentation is built in the source tree thus we can delete the + # build tree. + rm -rf doxygen/build-apidoc-full +fi + +if in_mbedtls_repo; then + mv $CONFIG_BAK $CONFIG_H fi if in_tf_psa_crypto_repo || (in_mbedtls_repo && ! in_3_6_branch); then diff --git a/scripts/check_names.py b/scripts/check_names.py index e2b6b8a73..d8605f689 100755 --- a/scripts/check_names.py +++ b/scripts/check_names.py @@ -810,7 +810,7 @@ class TFPSACryptoCodeParser(CodeParser): check=True ) subprocess.run( - ["make"], + ["cmake", "--build", "."], env=my_environment, universal_newlines=True, stdout=subprocess.PIPE, @@ -971,15 +971,17 @@ class MBEDTLSCodeParser(CodeParser): ) my_environment = os.environ.copy() my_environment["CFLAGS"] = "-fno-asynchronous-unwind-tables" - # Run make clean separately to lib to prevent unwanted behavior when - # make is invoked with parallelism. + + source_dir = os.getcwd() + build_dir = tempfile.mkdtemp() + os.chdir(build_dir) subprocess.run( - ["make", "clean"], + ["cmake", "-DGEN_FILES=ON", source_dir], universal_newlines=True, check=True ) subprocess.run( - ["make", "lib"], + ["cmake", "--build", "."], env=my_environment, universal_newlines=True, stdout=subprocess.PIPE, @@ -988,17 +990,21 @@ class MBEDTLSCodeParser(CodeParser): ) # Perform object file analysis using nm - symbols = self.parse_symbols_from_nm([ - "library/libmbedcrypto.a", - "library/libmbedtls.a", - "library/libmbedx509.a" - ]) + if build_tree.is_mbedtls_3_6(): + symbols = self.parse_symbols_from_nm([ + "library/libmbedcrypto.a", + "library/libmbedtls.a", + "library/libmbedx509.a" + ]) + else: + symbols = self.parse_symbols_from_nm([ + "library/libtfpsacrypto.a", + "library/libmbedtls.a", + "library/libmbedx509.a" + ]) - subprocess.run( - ["make", "clean"], - universal_newlines=True, - check=True - ) + os.chdir(source_dir) + shutil.rmtree(build_dir) except subprocess.CalledProcessError as error: self.log.debug(error.output) raise error diff --git a/scripts/doxygen.sh b/scripts/doxygen.sh index 7d051ed1e..c7c465c99 100755 --- a/scripts/doxygen.sh +++ b/scripts/doxygen.sh @@ -30,7 +30,7 @@ if grep -E "(warning|error):" doc.filtered; then exit 1; fi -if in_mbedtls_repo; then +if in_mbedtls_repo && in_3_6_branch; then make apidoc_clean fi