From 8f45346f581b6fceaa4e12813a19a9525b4cee2e Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Mon, 17 Jan 2022 06:06:26 +0200 Subject: [PATCH] Sync eng/native with runtime (#2789) --- eng/native/build-commons.sh | 21 ++++--------------- eng/native/configurecompiler.cmake | 4 ++-- eng/native/configurepaths.cmake | 1 - eng/native/functions.cmake | 28 ++++++++++++++++++++++++++ eng/native/gen-buildsys.sh | 10 +++------ eng/native/init-distro-rid.sh | 2 +- eng/native/naming.props | 10 ++++----- eng/native/output-toolchain-info.cmake | 14 ++++++++++++- 8 files changed, 56 insertions(+), 34 deletions(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 608d06e81..8f1a74675 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -117,7 +117,7 @@ build_native() scan_build=scan-build fi - nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $platformArch $__Compiler \"$__CompilerMajorVersion\" \"$__CompilerMinorVersion\" $__BuildType \"$generator\" $scan_build $cmakeArgs" + nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $platformArch $__Compiler $__BuildType \"$generator\" $scan_build $cmakeArgs" echo "Invoking $nextCommand" eval $nextCommand @@ -304,15 +304,7 @@ while :; do ;; clang*|-clang*) - __Compiler=clang - # clangx.y or clang-x.y - version="$(echo "$lowerI" | tr -d '[:alpha:]-=')" - parts=(${version//./ }) - __CompilerMajorVersion="${parts[0]}" - __CompilerMinorVersion="${parts[1]}" - if [[ -z "$__CompilerMinorVersion" && "$__CompilerMajorVersion" -le 6 ]]; then - __CompilerMinorVersion=0; - fi + __Compiler="$lowerI" ;; cmakeargs|-cmakeargs) @@ -340,12 +332,7 @@ while :; do ;; gcc*|-gcc*) - __Compiler=gcc - # gccx.y or gcc-x.y - version="$(echo "$lowerI" | tr -d '[:alpha:]-=')" - parts=(${version//./ }) - __CompilerMajorVersion="${parts[0]}" - __CompilerMinorVersion="${parts[1]}" + __Compiler="$lowerI" ;; keepnativesymbols|-keepnativesymbols) @@ -454,7 +441,7 @@ if [[ "$__CrossBuild" == 1 ]]; then CROSSCOMPILE=1 export CROSSCOMPILE # Darwin that doesn't use rootfs - if [[ ! -n "$ROOTFS_DIR" && "$platform" != "Darwin" ]]; then + if [[ -z "$ROOTFS_DIR" && "$platform" != "Darwin" ]]; then ROOTFS_DIR="$__RepoRootDir/.tools/rootfs/$__BuildArch" export ROOTFS_DIR fi diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index a29857451..5a20591cc 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -447,7 +447,7 @@ if (CLR_CMAKE_HOST_UNIX) set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0") add_compile_options(-arch arm64) elseif(CLR_CMAKE_HOST_ARCH_AMD64) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") add_compile_options(-arch x86_64) else() clr_unknown_arch() @@ -525,7 +525,7 @@ if (MSVC) # disable C++ RTTI # /GR is added by default by CMake, so remove it manually. - string(REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "/GR " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-") add_compile_options($<$:/FC>) # use full pathnames in diagnostics diff --git a/eng/native/configurepaths.cmake b/eng/native/configurepaths.cmake index 19407a40a..3f41026ee 100644 --- a/eng/native/configurepaths.cmake +++ b/eng/native/configurepaths.cmake @@ -1,7 +1,6 @@ get_filename_component(CLR_REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE) set(CLR_ENG_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}) get_filename_component(CLR_SRC_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/native ABSOLUTE) -get_filename_component(CLR_SRC_LIBS_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/libraries/Native ABSOLUTE) set (CLR_ARTIFACTS_OBJ_DIR "${CLR_REPO_ROOT_DIR}/artifacts/obj") set(VERSION_HEADER_PATH "${CLR_ARTIFACTS_OBJ_DIR}/_version.h") set(VERSION_FILE_PATH "${CLR_ARTIFACTS_OBJ_DIR}/_version.c") diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index 66a91ca0a..87b4d1573 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -75,6 +75,15 @@ function(get_include_directories_asm IncludeDirectories) set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE) endfunction(get_include_directories_asm) +# Adds prefix to paths list +function(addprefix var prefix list) + set(f) + foreach(i ${list}) + set(f ${f} ${prefix}/${i}) + endforeach() + set(${var} ${f} PARENT_SCOPE) +endfunction() + # Finds and returns unwind libs function(find_unwind_libs UnwindLibs) if(CLR_CMAKE_HOST_ARCH_ARM) @@ -367,6 +376,25 @@ function(install_symbol_file symbol_file destination_path) endif() endfunction() +function(install_static_library targetName destination component) + if (NOT "${component}" STREQUAL "${targetName}") + get_property(definedComponents GLOBAL PROPERTY CLR_CMAKE_COMPONENTS) + list(FIND definedComponents "${component}" componentIdx) + if (${componentIdx} EQUAL -1) + message(FATAL_ERROR "The ${component} component is not defined. Add a call to `add_component(${component})` to define the component in the build.") + endif() + add_dependencies(${component} ${targetName}) + endif() + install (TARGETS ${targetName} DESTINATION ${destination} COMPONENT ${component}) + if (WIN32) + set_target_properties(${targetName} PROPERTIES + COMPILE_PDB_NAME "${targetName}" + COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + ) + install (FILES "$/${targetName}.pdb" DESTINATION ${destination} COMPONENT ${component}) + endif() +endfunction() + # install_clr(TARGETS targetName [targetName2 ...] [DESTINATIONS destination [destination2 ...]] [COMPONENT componentName]) function(install_clr) set(multiValueArgs TARGETS DESTINATIONS) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 730d4dcef..550613b16 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -7,13 +7,11 @@ scriptroot="$( cd -P "$( dirname "$0" )" && pwd )" if [[ "$#" -lt 4 ]]; then echo "Usage..." - echo "gen-buildsys.sh [build flavor] [ninja] [scan-build] [cmakeargs]" + echo "gen-buildsys.sh [build flavor] [ninja] [scan-build] [cmakeargs]" echo "Specify the path to the top level CMake file." echo "Specify the path that the build system files are generated in." echo "Specify the target architecture." echo "Specify the name of compiler (clang or gcc)." - echo "Specify the major version of compiler." - echo "Specify the minor version of compiler." echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG." echo "Optionally specify 'scan-build' to enable build with clang static analyzer." echo "Use the Ninja generator instead of the Unix Makefiles generator." @@ -23,12 +21,10 @@ fi build_arch="$3" compiler="$4" -majorVersion="$5" -minorVersion="$6" if [[ "$compiler" != "default" ]]; then nativescriptroot="$( cd -P "$scriptroot/../common/native" && pwd )" - source "$nativescriptroot/init-compiler.sh" "$nativescriptroot" "$build_arch" "$compiler" "$majorVersion" "$minorVersion" + source "$nativescriptroot/init-compiler.sh" "$nativescriptroot" "$build_arch" "$compiler" CCC_CC="$CC" CCC_CXX="$CXX" @@ -43,7 +39,7 @@ scan_build=OFF generator="Unix Makefiles" __UnprocessedCMakeArgs="" -for i in "${@:7}"; do +for i in "${@:5}"; do upperI="$(echo "$i" | tr "[:lower:]" "[:upper:]")" case "$upperI" in # Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO. diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 5f6b19460..97fd64708 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -41,7 +41,7 @@ initNonPortableDistroRid() # We have forced __PortableBuild=0. This is because -portablebuld # has been passed as false. if (( isPortable == 0 )); then - if [ "${ID}" = "rhel" ] || [ "${ID}" = "rocky" ]; then + if [[ "${ID}" == "rhel" || "${ID}" == "rocky" ]]; then # remove the last version digit VERSION_ID="${VERSION_ID%.*}" fi diff --git a/eng/native/naming.props b/eng/native/naming.props index 7a02d6c6c..2f3956456 100644 --- a/eng/native/naming.props +++ b/eng/native/naming.props @@ -1,21 +1,21 @@ lib + .exe - .exe .dll .lib .pdb - + - lib + lib .dylib .a .dwarf @@ -23,7 +23,7 @@ - lib + lib .so .a @@ -32,7 +32,7 @@ - lib + lib .so .a .dbg diff --git a/eng/native/output-toolchain-info.cmake b/eng/native/output-toolchain-info.cmake index 8eed988e5..fc0033b88 100644 --- a/eng/native/output-toolchain-info.cmake +++ b/eng/native/output-toolchain-info.cmake @@ -10,6 +10,18 @@ if (CMAKE_SCRIPT_MODE_FILE) macro(add_definitions) list(APPEND ADDED_COMPILE_OPTIONS ${ARGV}) endmacro() + macro(include_directories) + cmake_parse_arguments(INCLUDE_DIRECTORIES "" "" "SYSTEM" ${ARGN}) + if (INCLUDE_DIRECTORIES_SYSTEM) + foreach(dir ${INCLUDE_DIRECTORIES_SYSTEM}) + list(APPEND ADDED_COMPILE_OPTIONS "-isystem ${dir}") + endforeach() + else() + foreach(arg IN LISTS ARGN) + list(APPEND ADDED_COMPILE_OPTIONS "-I${arg}") + endforeach() + endif() + endmacro() endif() include(${CMAKE_CURRENT_LIST_DIR}/../common/cross/toolchain.cmake) @@ -18,4 +30,4 @@ message("") message("${TOOLCHAIN}") message("${CMAKE_SHARED_LINKER_FLAGS_INIT}") message("${ADDED_COMPILE_OPTIONS}") -message("") \ No newline at end of file +message("") -- 2.34.1