From c754663d70cceb118365fc963d1b470469ffa10d Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Sat, 18 Oct 2025 12:17:01 +0100 Subject: [PATCH 1/2] Add script to automate BoringSSL rebuilds. "Knows" the correct arguments for each supported architecture and can automate `git pull` etc. Updated BUILDING.md to document it. Also updated the Windows build instructions as they were for a deprecated version of MSVC. --- BUILDING.md | 64 +++++++++++++----- scripts/rebuild_boringssl.sh | 122 +++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+), 17 deletions(-) create mode 100755 scripts/rebuild_boringssl.sh diff --git a/BUILDING.md b/BUILDING.md index 7ac7f8e98..7cbbb6216 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -22,11 +22,7 @@ Conscrypt requires that you have __Java__, __BoringSSL__ and the __Android SDK__ described below. #### Java -The build uses a version of Gradle which requires a __Java 11__ JRE to run, however to ensure -backward compatibility Conscrypt itself is compiled with a __Java 8__ JDK using Gradle's -recent Java toolchain support. At the least, you will need to install __Java 11__ to run -Gradle, but if you do not also have __Java 8__ then depending on the OS, Gradle will -try and install it automatically. +The build uses a version of Gradle which requires a __Java 11__ JDK. #### Android SDK [Download and install](https://developer.android.com/studio/install.html) the latest Android SDK @@ -62,9 +58,11 @@ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \ ninja ``` +You can also use the `rebuild_boringssl.sh` script (see below) to automate this process. + ##### Building on macOS. When building Conscrypt on macOS it will build libraries for both x86 and ARM, and so BoringSSL -must also be build for each of these. +must also be built for each of these. To build the x86_64 version: ```bash @@ -90,22 +88,34 @@ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \ ninja ``` +You can also use the `rebuild_boringssl.sh` script (see below) to automate this process. ##### Building on Windows -This assumes that you have Microsoft Visual Studio 2017 installed along -with both the Windows 8.1 and 10 SDKs and that your machine is capable of -compiling 64-bit. +This assumes that you have +[Git for Windows](https://gitforwindows.org/) and +[Microsoft Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) +installed. + +You'll also need `nasm`, `cmake` and `ninja` which can be usefully +managed via a package tool such as +[Chocolatey](https://chocolatey.org/). + +Like Visual Studio 2017, Visual Studio 2022 provides a batch file +to set up the correct environment for the compiler which can be invoked +as follows (assuming a default installation): +```bat +call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 +``` -Unlike earlier versions, Visual Studio 2017 doesn't appear to set an -environment variable to simplify building from the command line. The -instructions below assume the default installation of the community -edition. To use another edition or a non-standard install path, you'll -need to modify the paths below as appropriate. +However, Visual Studio 2022 also sets up a _Developer Command Prompt_ +in Windows Terminal which provides a simpler way of getting the +correct compiler environment, defaulting to 64-bit mode. -To build in 64-bit mode, set up with this command line: +After either method, you can run Git for Windows' `bash` to get a +more UNIX like environment with a working compiler. +To build BoringSSL in 64-bit mode from a Command Prompt: ```bat -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 mkdir build64 cd build64 cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ^ @@ -115,7 +125,27 @@ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ^ ninja ``` -32-bit mode is no longer supported. +32-bit mode is no longer supported on Windows. + +If running `bash`, you can use the `rebuild_boringssl` script (see below) +to automate this process. + +##### rebuild_boringssl.sh script + +The script `scripts/rebuild_boringssl.sh` will build or rebuild BoringSSL +with the correct configuration for the current architecture. + +When run with no arguments, the script assumes that `BORINGSSL_HOME` is set +correctly and will re-run `cmake` and `ninja` with the correct arguments. + +The following arguments can be used to modify its behaviour: + +* `--clone` May only be used if `BORINGSSL_HOME` is set but does not +yet exist. Will clone BoringSSL from Github and build it. + +* `--clean` Delete the current build directly and rebuild from scratch. +* `--pull` or `--update` Updates the source tree to the latest revision and +then builds. Note will not clean old builds unless `--clean` is also specified. Coverage -------- diff --git a/scripts/rebuild_boringssl.sh b/scripts/rebuild_boringssl.sh new file mode 100755 index 000000000..1479aba1d --- /dev/null +++ b/scripts/rebuild_boringssl.sh @@ -0,0 +1,122 @@ +#! /bin/bash +# +# Copyright (C) 2025 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Rebuilds BoringSSL from scratch for supported architectures, +# optionally performing a `git pull` first to update it. + + +UPSTREAM="https://github.com/google/boringssl.git" +MAIN="main" + +fail() { + echo "*** FAILED: " $@ + exit 1 +} + +usage() { + cat < Date: Mon, 9 Feb 2026 12:06:19 +0000 Subject: [PATCH 2/2] Remove non-salient BUILDING.md changes. --- BUILDING.md | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 7cbbb6216..cfe228a49 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -22,7 +22,11 @@ Conscrypt requires that you have __Java__, __BoringSSL__ and the __Android SDK__ described below. #### Java -The build uses a version of Gradle which requires a __Java 11__ JDK. +The build uses a version of Gradle which requires a __Java 11__ JRE to run, however to ensure +backward compatibility Conscrypt itself is compiled with a __Java 8__ JDK using Gradle's +recent Java toolchain support. At the least, you will need to install __Java 11__ to run +Gradle, but if you do not also have __Java 8__ then depending on the OS, Gradle will +try and install it automatically. #### Android SDK [Download and install](https://developer.android.com/studio/install.html) the latest Android SDK @@ -62,7 +66,7 @@ You can also use the `rebuild_boringssl.sh` script (see below) to automate this ##### Building on macOS. When building Conscrypt on macOS it will build libraries for both x86 and ARM, and so BoringSSL -must also be built for each of these. +must also be build for each of these. To build the x86_64 version: ```bash @@ -91,31 +95,20 @@ ninja You can also use the `rebuild_boringssl.sh` script (see below) to automate this process. ##### Building on Windows -This assumes that you have -[Git for Windows](https://gitforwindows.org/) and -[Microsoft Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) -installed. - -You'll also need `nasm`, `cmake` and `ninja` which can be usefully -managed via a package tool such as -[Chocolatey](https://chocolatey.org/). - -Like Visual Studio 2017, Visual Studio 2022 provides a batch file -to set up the correct environment for the compiler which can be invoked -as follows (assuming a default installation): -```bat -call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 -``` +This assumes that you have Microsoft Visual Studio 2017 installed along +with both the Windows 8.1 and 10 SDKs and that your machine is capable of +compiling 64-bit. -However, Visual Studio 2022 also sets up a _Developer Command Prompt_ -in Windows Terminal which provides a simpler way of getting the -correct compiler environment, defaulting to 64-bit mode. +Unlike earlier versions, Visual Studio 2017 doesn't appear to set an +environment variable to simplify building from the command line. The +instructions below assume the default installation of the community +edition. To use another edition or a non-standard install path, you'll +need to modify the paths below as appropriate. -After either method, you can run Git for Windows' `bash` to get a -more UNIX like environment with a working compiler. +To build in 64-bit mode, set up with this command line: -To build BoringSSL in 64-bit mode from a Command Prompt: ```bat +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 mkdir build64 cd build64 cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ^ @@ -125,7 +118,7 @@ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ^ ninja ``` -32-bit mode is no longer supported on Windows. +32-bit mode is no longer supported. If running `bash`, you can use the `rebuild_boringssl` script (see below) to automate this process. @@ -133,7 +126,7 @@ to automate this process. ##### rebuild_boringssl.sh script The script `scripts/rebuild_boringssl.sh` will build or rebuild BoringSSL -with the correct configuration for the current architecture. +with the correct configuration for the current host architecture. When run with no arguments, the script assumes that `BORINGSSL_HOME` is set correctly and will re-run `cmake` and `ninja` with the correct arguments.