diff --git a/docs/workflow/building/coreclr/osx-instructions.md b/docs/workflow/building/coreclr/osx-instructions.md index ddcaeda8eb3c3..b8a168da5186d 100644 --- a/docs/workflow/building/coreclr/osx-instructions.md +++ b/docs/workflow/building/coreclr/osx-instructions.md @@ -23,9 +23,7 @@ git clone https://github.com/dotnet/runtime CMake ----- -CoreCLR has a dependency on CMake for the build. You can download it from [CMake downloads](http://www.cmake.org/download/). - -Alternatively, you can install CMake from [Homebrew](http://brew.sh/). +CoreCLR has a dependency on CMake for the build. You can install it with [Homebrew](https://brew.sh/). ```sh brew install cmake @@ -33,11 +31,10 @@ brew install cmake ICU --- -ICU (International Components for Unicode) is also required to build and run. It can be obtained via [Homebrew](http://brew.sh/). +ICU (International Components for Unicode) is also required to build and run. It can be obtained via [Homebrew](https://brew.sh/). ```sh brew install icu4c -brew link --force icu4c ``` Build the Runtime and System.Private.CoreLib diff --git a/docs/workflow/requirements/macos-requirements.md b/docs/workflow/requirements/macos-requirements.md index 06d1fb01545d6..82a6610321bb5 100644 --- a/docs/workflow/requirements/macos-requirements.md +++ b/docs/workflow/requirements/macos-requirements.md @@ -23,47 +23,14 @@ Install the following packages: - cmake 3.15.5 or newer - autoconf - automake +- icu4c - libtool +- openssl 1.1 - pkg-config - python3 -- icu4c The lines to install all the packages above using Homebrew. ``` -brew install cmake autoconf automake libtool pkg-config python3 icu4c -brew link --force icu4c -``` - -OpenSSL -------- - -To build the libraries on macOS, you must install and configure links for OpenSSL 1.1. - -```sh -brew install openssl - -# You might need to "link" pkg-config: -brew link pkg-config - -# We need to make the runtime libraries discoverable, as well as make -# pkg-config be able to find the headers and current ABI version. -# -# Ensure the paths we will need exist -mkdir -p /usr/local/lib/pkgconfig - -# The rest of these instructions assume a default Homebrew path of -# `/usr/local/opt/`, with `brew --prefix` returning `/usr/local` -# and `brew --prefix openssl` returning `/usr/local/opt/openssl@1.1`. -# In this case, `brew info openssl` shows: -# `openssl@1.1: stable 1.1.1d (bottled) [keg-only]`. - -# Runtime dependencies -ln -s /usr/local/opt/openssl\@1.1/lib/libcrypto.1.1.dylib /usr/local/lib/ -ln -s /usr/local/opt/openssl\@1.1/lib/libssl.1.1.dylib /usr/local/lib/ - -# Compile-time dependencies (for pkg-config) -ln -s /usr/local/opt/openssl\@1.1/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig/ -ln -s /usr/local/opt/openssl\@1.1/lib/pkgconfig/libssl.pc /usr/local/lib/pkgconfig/ -ln -s /usr/local/opt/openssl\@1.1/lib/pkgconfig/openssl.pc /usr/local/lib/pkgconfig/ +brew install cmake autoconf automake icu4c libtool openssl@1.1 pkg-config python3 ``` diff --git a/eng/install-native-dependencies.sh b/eng/install-native-dependencies.sh index 9670ae590314c..be154811ea7f1 100644 --- a/eng/install-native-dependencies.sh +++ b/eng/install-native-dependencies.sh @@ -15,11 +15,10 @@ elif [ "$1" = "OSX" ]; then if [ "$?" != "0" ]; then exit 1; fi - brew install icu4c openssl autoconf automake libtool pkg-config python3 + brew install autoconf automake icu4c libtool openssl@1.1 pkg-config python3 if [ "$?" != "0" ]; then exit 1; fi - brew link --force icu4c if [ "$?" != "0" ]; then exit 1; fi @@ -29,7 +28,7 @@ elif [ "$1" = "tvOS" ]; then if [ "$?" != "0" ]; then exit 1; fi - brew install openssl autoconf automake libtool pkg-config python3 + brew install autoconf automake libtool openssl@1.1 pkg-config python3 if [ "$?" != "0" ]; then exit 1; fi @@ -39,7 +38,7 @@ elif [ "$1" = "iOS" ]; then if [ "$?" != "0" ]; then exit 1; fi - brew install openssl autoconf automake libtool pkg-config python3 + brew install autoconf automake libtool openssl@1.1 pkg-config python3 if [ "$?" != "0" ]; then exit 1; fi diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index ad9ed3c523047..27381c68d0e35 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -59,6 +59,19 @@ check_prereqs() echo "Please install CMake 3.14.2 or newer from http://www.cmake.org/download/ or https://apt.kitware.com and ensure it is on your path."; exit 1; fi + if [[ "$__HostOS" == "OSX" ]]; then + # Check presence of pkg-config on the path + command -v pkg-config 2>/dev/null || { echo >&2 "Please install pkg-config before running this script, see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/macos-requirements.md"; exit 1; } + + if ! pkg-config openssl ; then + # We export the proper PKG_CONFIG_PATH where openssl was installed by Homebrew + # It's important to _export_ it since build-commons.sh is sourced by other scripts such as build-native.sh + export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig + # We try again with the PKG_CONFIG_PATH in place, if pkg-config still can't find OpenSSL, exit with an error, cmake won't find OpenSSL either + pkg-config openssl || { echo >&2 "Please install openssl before running this script, see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/macos-requirements.md"; exit 1; } + fi + fi + if [[ "$__UseNinja" == 1 ]]; then command -v ninja 2>/dev/null || command -v ninja-build 2>/dev/null || { echo "Unable to locate ninja!"; exit 1; } fi diff --git a/eng/pipelines/common/global-build-job.yml b/eng/pipelines/common/global-build-job.yml index 75d9678fd0425..e0f71a3f128a9 100644 --- a/eng/pipelines/common/global-build-job.yml +++ b/eng/pipelines/common/global-build-job.yml @@ -25,19 +25,12 @@ jobs: variables: ${{ parameters.variables }} steps: - - ${{ if eq(parameters.osGroup, 'OSX') }}: - - script: | - $(setScriptToEchoAndFailOnNonZero) - brew install pkgconfig icu4c openssl autoconf automake libtool pkg-config python3 - brew link --force icu4c - ln -s /usr/local/opt/openssl/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig/ - ln -s /usr/local/opt/openssl/lib/pkgconfig/libssl.pc /usr/local/lib/pkgconfig/ - ln -s /usr/local/opt/openssl/lib/pkgconfig/openssl.pc /usr/local/lib/pkgconfig/ - displayName: Install Build Dependencies - - template: /eng/pipelines/common/clone-checkout-bundle-step.yml - - ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}: + - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}: + - script: sh $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} + displayName: Install Build Dependencies + - script: | du -sh $(Build.SourcesDirectory)/* df -h diff --git a/eng/pipelines/installer/jobs/base-job.yml b/eng/pipelines/installer/jobs/base-job.yml index fd90c6e502da4..413f9c7c70807 100644 --- a/eng/pipelines/installer/jobs/base-job.yml +++ b/eng/pipelines/installer/jobs/base-job.yml @@ -442,7 +442,10 @@ jobs: displayName: 'Libraries artifacts (AllConfigurations)' cleanUnpackFolder: false - - ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}: + - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}: + - script: sh $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} + displayName: Install Build Dependencies + - script: | du -sh $(Build.SourcesDirectory)/* df -h diff --git a/eng/pipelines/libraries/build-job.yml b/eng/pipelines/libraries/build-job.yml index 3f01453db7e3a..f3de87e46401f 100644 --- a/eng/pipelines/libraries/build-job.yml +++ b/eng/pipelines/libraries/build-job.yml @@ -70,19 +70,13 @@ jobs: - ${{ parameters.variables }} steps: - - ${{ if eq(parameters.osGroup, 'OSX') }}: - - script: | - brew install pkgconfig icu4c openssl - brew link --force icu4c - ln -s /usr/local/opt/openssl/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig/ - ln -s /usr/local/opt/openssl/lib/pkgconfig/libssl.pc /usr/local/lib/pkgconfig/ - ln -s /usr/local/opt/openssl/lib/pkgconfig/openssl.pc /usr/local/lib/pkgconfig/ - displayName: Install Build Dependencies - - ${{ if eq(parameters.isOfficialBuild, true) }}: - template: /eng/pipelines/common/restore-internal-tools.yml - - ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}: + - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}: + - script: sh $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} + displayName: Install Build Dependencies + - script: | du -sh $(Build.SourcesDirectory)/* df -h diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt index 60d933dabb9cb..743c501f12486 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt @@ -23,7 +23,7 @@ else() endif() if(NOT OPENSSL_FOUND) - message(FATAL_ERROR "!!! Cannot find libssl and System.Security.Cryptography.Native cannot build without it. Try installing libssl-dev (or the appropriate package for your platform) !!!. See the requirements document for your specific operating system: https://github.com/dotnet/runtime/tree/master/docs/workflow/requirements.") + message(FATAL_ERROR "!!! Cannot find libssl and System.Security.Cryptography.Native cannot build without it. Try installing libssl-dev (on Linux, but this may vary by distro) or openssl (on macOS) !!!. See the requirements document for your specific operating system: https://github.com/dotnet/runtime/tree/master/docs/workflow/requirements.") endif(NOT OPENSSL_FOUND) include_directories(${OPENSSL_INCLUDE_DIR})