Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/workflow/requirements/freebsd-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Install the following packages:
* openssl (optional)
* python39
* libinotify
* ninja (optional, enables building native code with ninja instead of make)
* ninja

```sh
sudo pkg install --yes libunwind icu libinotify lttng-ust krb5 cmake openssl ninja
Expand Down
4 changes: 2 additions & 2 deletions docs/workflow/requirements/linux-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The packages you need to install are shown in the following list:
- `lld`
- `lldb`
- `llvm`
- `ninja-build` (Optional. Enables building native code using `ninja` instead of `make`)
- `ninja-build`
- `pigz` (Optional. Enables parallel gzip compression for tarball creation in `packs` subset)
- `python-is-python3`

Expand Down Expand Up @@ -116,7 +116,7 @@ Install the following packages for the toolchain:
- `lldb`
- `llvm`
- `lttng-ust-devel`
- `ninja-build` (Optional. Enables building native code using `ninja` instead of `make`)
- `ninja-build`
- `openssl-devel`
- `pigz` (Optional. Enables parallel gzip compression for tarball creation in `packs` subset)
- `python`
Expand Down
2 changes: 1 addition & 1 deletion docs/workflow/requirements/macos-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To build the runtime repo, you will also need to install the following dependenc
- `icu4c`
- `pkg-config`
- `python3`
- `ninja` (This one is optional. It is an alternative tool to `make` for building native code)
- `ninja`

You can install them separately, or you can alternatively opt to install *[Homebrew](https://brew.sh/)* and use the `install-dependencies.sh` script provided by the repo, which takes care of everything for you. If you go by this route, once you have *Homebrew* up and running on your machine, run the following command from the root of the repo to download and install all the necessary dependencies at once:

Expand Down
25 changes: 15 additions & 10 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ usage()
echo " --gccx.y Optional argument to build using gcc version x.y."
echo " --portablebuild Optional argument: set to false to force a non-portable build."
echo " --keepnativesymbols Optional argument: set to true to keep native symbols/debuginfo in generated binaries."
echo " --ninja Optional argument: set to true to use Ninja instead of Make to run the native build."
echo " --ninja Optional argument: use Ninja instead of Make (default: true, use --ninja false to disable)."
echo " --pgoinstrument Optional argument: build PGO-instrumented runtime"
echo " --fsanitize Optional argument: Specify native sanitizers to instrument the native build with. Supported values are: 'address'."
echo ""
Expand Down Expand Up @@ -166,6 +166,9 @@ source $scriptroot/common/native/init-os-and-arch.sh

hostArch=$arch

# Default to using Ninja for faster builds (can be overridden with --ninja false)
useNinja=true

# Check if an action is passed in
declare -a actions=("b" "build" "r" "restore" "rebuild" "testnobuild" "sign" "publish" "clean")
actInt=($(comm -12 <(printf '%s\n' "${actions[@]/#/-}" | sort) <(printf '%s\n' "${@/#--/-}" | sort)))
Expand Down Expand Up @@ -496,20 +499,17 @@ while [[ $# -gt 0 ]]; do


-ninja)
if [ -z ${2+x} ]; then
arguments+=("/p:Ninja=true")
if [ -z ${2+x} ] || [[ "$2" == -* ]]; then
useNinja=true
shift 1
else
ninja="$(echo "$2" | tr "[:upper:]" "[:lower:]")"
if [ "$ninja" = true ]; then
arguments+=("/p:Ninja=true")
shift 2
elif [ "$ninja" = false ]; then
shift 2
if [ "$ninja" = false ]; then
arguments+=("/p:Ninja=false")
shift 2
useNinja=false
else
arguments+=("/p:Ninja=true")
shift 1
useNinja=true
fi
fi
;;
Expand Down Expand Up @@ -582,6 +582,11 @@ arguments+=("-tl:false")
# disable line wrapping so that C&P from the console works well
arguments+=("-clp:ForceNoAlign")

# Apply ninja setting
if [[ "$useNinja" == true ]]; then
arguments+=("/p:Ninja=true")
fi

initDistroRid "$os" "$arch" "$crossBuild"

# Disable targeting pack caching as we reference a partially constructed targeting pack and update it later.
Expand Down
25 changes: 19 additions & 6 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ build_native()
pushd "$intermediatesDir"

buildTool="$SCAN_BUILD_COMMAND -o $__BinDir/scan-build-log $buildTool"
echo "Executing $buildTool $target -j $__NumProc"
"$buildTool" $target -j "$__NumProc"
echo "Executing $buildTool -j $__NumProc $target"
"$buildTool" -j "$__NumProc" $target
exit_code="$?"

popd
Expand All @@ -234,8 +234,8 @@ build_native()
# multiple targets. Instead, directly invoke the build tool to build multiple targets in one invocation.
pushd "$intermediatesDir"

echo "Executing $buildTool $target -j $__NumProc"
"$buildTool" $target -j "$__NumProc"
echo "Executing $buildTool -j $__NumProc $target"
"$buildTool" -j "$__NumProc" $target
exit_code="$?"

popd
Expand Down Expand Up @@ -271,7 +271,7 @@ usage()
echo " will use ROOTFS_DIR environment variable if set."
echo "-gcc: optional argument to build using gcc in PATH."
echo "-gccx.y: optional argument to build using gcc version x.y."
echo "-ninja: target ninja instead of GNU make"
echo "-ninja: target ninja instead of GNU make (default: true, use -ninja false to disable)"
echo "-numproc: set the number of build processes."
echo "-targetrid: optional argument that overrides the target rid name."
echo "-portablebuild: pass -portablebuild=false to force a non-portable build."
Expand Down Expand Up @@ -311,6 +311,9 @@ else
__NumProc=1
fi

# Default to using Ninja for faster builds
__UseNinja=1

while :; do
if [[ "$#" -le 0 ]]; then
break
Expand Down Expand Up @@ -412,7 +415,17 @@ while :; do
;;

ninja|-ninja)
__UseNinja=1
if [[ -z "${2+x}" ]] || [[ "$2" == -* ]]; then
__UseNinja=1
else
ninja_arg="$(echo "$2" | tr "[:upper:]" "[:lower:]")"
if [[ "$ninja_arg" == "false" ]]; then
__UseNinja=0
else
__UseNinja=1
fi
shift
fi
;;

numproc|-numproc)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/build-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ __SkipRestore=""
__SourceDir="$__ProjectDir/src"
__StaticAnalyzer=0
__UnprocessedBuildArgs=
__UseNinja=0
__VerboseBuild=0
__CMakeArgs=""
__RequestedBuildComponents=""
Expand Down
1 change: 0 additions & 1 deletion src/tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ __SkipRestore=""
__SkipRestorePackages=0
__SourceDir="$__ProjectDir/src"
__UnprocessedBuildArgs=()
__UseNinja=0
__VerboseBuild=0
__CMakeArgs=""
__Priority=0
Expand Down
Loading