Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 47 additions & 17 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 ^
Expand All @@ -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
--------
Expand Down
11 changes: 7 additions & 4 deletions openjdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,13 @@ boolean isExecutableOnPath(executable) {
return executable == name
}
}
for(String folder : System.getenv('PATH').split("" + File.pathSeparatorChar)) {
File[] files = file(folder).listFiles(filter)
if (files != null && files.size() > 0) {
return true
for (String folder : System.getenv('PATH').split("" + File.pathSeparatorChar)) {
// Ignore any empty PATH elements.
if (folder != '') {
File[] files = file(folder).listFiles(filter)
if (files != null && files.size() > 0) {
return true
}
}
}
return false
Expand Down
122 changes: 122 additions & 0 deletions scripts/rebuild_boringssl.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
Usage: $0 [OPTIONS]

--clone Clone BoringSSL git repository if not already present
--update Resync from upstream before building
--clean Clean before building

EOF
exit 0
}

test "$BORINGSSL_HOME" || fail "Please set BORINGSSL_HOME."


CLONE=
UPDATE=
CLEAN=
while [ "$1" ]; do
case "$1" in
--clone)
CLONE=true
;;

--update | --pull)
UPDATE=true
;;

--clean | --fresh)
CLEAN=true
;;

*)
usage
95
;;
esac
shift
done

if [ "$CLONE" ]; then
echo "Cloning BoringSSL from ${UPSTREAM}."

test -d "$BORINGSSL_HOME" && fail "$BORINGSSL_HOME already exists"
PARENT="$(dirname $BORINGSSL_HOME)"
cd "$PARENT" || fail "Cannot access parent directory $PARENT"
git clone "$UPSTREAM" "$BORINGSSL_HOME" || fail "Unable to clone BoringSSL"
UPDATE=
CLEAN=true
fi

cd "$BORINGSSL_HOME" || fail "Cannot access $BORINGSSL_HOME"

if [ "$UPDATE" ]; then
echo "Updating BoringSSL."
git checkout "$MAIN"
git pull
fi

run_cmake() {
local BUILD_DIR="${BORINGSSL_HOME}/$1"
local EXTRA_CMAKE_FLAGS="$2"

if [ "$CLEAN" ]; then
echo "Removing $BUILD_DIR"
rm -rf "$BUILD_DIR"
fi
mkdir -p "$BUILD_DIR" || fail "Unable to create $BUILD_DIR"
cd "$BUILD_DIR" || fail "Unable to access $BUILD_DIR"
echo "Running cmake."
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release $EXTRA_CMAKE_FLAGS \
-GNinja .. || fail "cmake failed."
echo "Building BoringSSL in ${BUILD_DIR}."
ninja
}

case "$(uname -s)" in
Darwin)
run_cmake build.x86 "-DCMAKE_ASM_FLAGS=-Wa,--noexecstack -DCMAKE_OSX_ARCHITECTURES=x86_64"
run_cmake build.arm "-DCMAKE_ASM_FLAGS=-Wa,--noexecstack -DCMAKE_OSX_ARCHITECTURES=arm64"
;;

Linux)
run_cmake build64 "-DCMAKE_ASM_FLAGS=-Wa,--noexecstack"
;;

MINGW64*)
run_cmake build64 "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded"
;;

*)
fail "Please follow the manual build instructions."
;;
esac