Sync eng/native with runtime (#2789)
authorAdeel Mujahid <3840695+am11@users.noreply.github.com>
Mon, 17 Jan 2022 04:06:26 +0000 (06:06 +0200)
committerGitHub <noreply@github.com>
Mon, 17 Jan 2022 04:06:26 +0000 (20:06 -0800)
eng/native/build-commons.sh
eng/native/configurecompiler.cmake
eng/native/configurepaths.cmake
eng/native/functions.cmake
eng/native/gen-buildsys.sh
eng/native/init-distro-rid.sh
eng/native/naming.props
eng/native/output-toolchain-info.cmake

index 608d06e81eda7aaf56e18fa5fb41f4e84908bc85..8f1a746752a347779d9b11737593afec3483aa4d 100755 (executable)
@@ -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
index a29857451bc79f2a61a68566df9d5e43aabfddea..5a20591cc025bbdf08e11c3b672f9c17640305b7 100644 (file)
@@ -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($<$<COMPILE_LANGUAGE:C,CXX>:/FC>) # use full pathnames in diagnostics
index 19407a40a1957a460f5343f7e2f873701086b473..3f41026eee2ac4be3b0db72c89d6baddc871420c 100644 (file)
@@ -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")
index 66a91ca0af81da9fbd042ad870353f437ba8e359..87b4d15734bf694fa5e4738f4327402dadba5174 100644 (file)
@@ -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 "$<TARGET_FILE_DIR:${targetName}>/${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)
index 730d4dcefa7b2d55d763e188558e1d0e783887c4..550613b16341b57a6a7f741f87cf1eecb6d0ae5d 100755 (executable)
@@ -7,13 +7,11 @@ scriptroot="$( cd -P "$( dirname "$0" )" && pwd )"
 
 if [[ "$#" -lt 4 ]]; then
   echo "Usage..."
-  echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to intermediate directory> <Architecture> <compiler> <compiler major version> <compiler minor version> [build flavor] [ninja] [scan-build] [cmakeargs]"
+  echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to intermediate directory> <Architecture> <compiler> [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.
index 5f6b194600124a6e2529e09a8846ec8efcc0f3db..97fd64708163faf574c11568fe4a2db69c021f56 100644 (file)
@@ -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
index 7a02d6c6c68152db506d736806b8acb45b50d5f2..2f39564569b5e5c767811a806c8c11daba93ba57 100644 (file)
@@ -1,21 +1,21 @@
 <Project>
   <PropertyGroup>
     <StaticLibPrefix>lib</StaticLibPrefix>
+    <ExeSuffix Condition="'$(HostOS)' == 'windows'">.exe</ExeSuffix>
   </PropertyGroup>
 
   <!-- Add path globs specific to native binaries to exclude unnecessary files from packages. -->
   <Choose>
     <When Condition="$(PackageRID.StartsWith('win'))">
       <PropertyGroup>
-        <ExeSuffix>.exe</ExeSuffix>
         <LibSuffix>.dll</LibSuffix>
         <StaticLibSuffix>.lib</StaticLibSuffix>
         <SymbolsSuffix>.pdb</SymbolsSuffix>
       </PropertyGroup>
     </When>
-    <When Condition="$(PackageRID.StartsWith('osx'))">
+    <When Condition="$(PackageRID.StartsWith('osx')) or $(PackageRID.StartsWith('maccatalyst')) or $(PackageRID.StartsWith('ios')) or $(PackageRID.StartsWith('tvos'))">
       <PropertyGroup>
-        <LibPrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibPrefix>
+        <LibPrefix>lib</LibPrefix>
         <LibSuffix>.dylib</LibSuffix>
         <StaticLibSuffix>.a</StaticLibSuffix>
         <SymbolsSuffix>.dwarf</SymbolsSuffix>
@@ -23,7 +23,7 @@
     </When>
     <When Condition="$(PackageRID.StartsWith('android'))">
       <PropertyGroup>
-        <LibPrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibPrefix>
+        <LibPrefix>lib</LibPrefix>
         <LibSuffix>.so</LibSuffix>
         <StaticLibSuffix>.a</StaticLibSuffix>
         <!--symbols included in .so, like Linux, but can be generated externally and if so, uses .debug ext-->
@@ -32,7 +32,7 @@
     </When>
     <Otherwise>
       <PropertyGroup>
-        <LibPrefix Condition=" '$(SkipLibraryPrefixFromUnix)' == '' ">lib</LibPrefix>
+        <LibPrefix>lib</LibPrefix>
         <LibSuffix>.so</LibSuffix>
         <StaticLibSuffix>.a</StaticLibSuffix>
         <SymbolsSuffix>.dbg</SymbolsSuffix>
index 8eed988e598ac08c991cbd02730e977c6fb152e1..fc0033b887bf20d87ba86bb0d5681ce1e192412e 100644 (file)
@@ -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("<toolchain-info>")
 message("<target-triple>${TOOLCHAIN}</target-triple>")
 message("<linker-args>${CMAKE_SHARED_LINKER_FLAGS_INIT}</linker-args>")
 message("<compiler-args>${ADDED_COMPILE_OPTIONS}</compiler-args>")
-message("</toolchain-info>")
\ No newline at end of file
+message("</toolchain-info>")