mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Use Ninja build system when available
When Ninja is installed, use it instead of Make for native builds and for Android cross-builds.
This commit is contained in:
parent
60aa8c793d
commit
bbc2c642c9
3 changed files with 17 additions and 2 deletions
|
|
@ -48,6 +48,11 @@ cd $BUILD_ROOT
|
|||
|
||||
CMAKE_ARGS=()
|
||||
|
||||
# If Ninja is installed, prefer it to Make
|
||||
if [ -x "$(command -v ninja)" ]; then
|
||||
CMAKE_ARGS+=("-GNinja")
|
||||
fi
|
||||
|
||||
# Use locally built protoc because we'll build libprotobuf for the
|
||||
# target architecture and need an exact version match.
|
||||
CMAKE_ARGS+=("-DCAFFE2_CUSTOM_PROTOC_EXECUTABLE=$CAFFE2_ROOT/build_host_protoc/bin/protoc")
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@ CMAKE_ARGS=()
|
|||
CMAKE_ARGS+=("-DCMAKE_INSTALL_PREFIX=$BUILD_ROOT")
|
||||
CMAKE_ARGS+=("-Dprotobuf_BUILD_TESTS=OFF")
|
||||
|
||||
# If Ninja is installed, prefer it to Make
|
||||
if [ -x "$(command -v ninja)" ]; then
|
||||
CMAKE_ARGS+=("-GNinja")
|
||||
fi
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
--other-flags)
|
||||
|
|
@ -45,7 +50,7 @@ fi
|
|||
cmake "$CAFFE2_ROOT/third_party/protobuf/cmake" ${CMAKE_ARGS[@]}
|
||||
|
||||
if [ "$(uname)" == 'Darwin' ]; then
|
||||
make "-j$(sysctl -n hw.ncpu)" install
|
||||
cmake --build . -- "-j$(sysctl -n hw.ncpu)" install
|
||||
else
|
||||
make "-j$(nproc)" install
|
||||
cmake --build . -- "-j$(nproc)" install
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ CAFFE2_ROOT="$( cd "$(dirname "$0")"/.. ; pwd -P)"
|
|||
|
||||
CMAKE_ARGS=()
|
||||
|
||||
# If Ninja is installed, prefer it to Make
|
||||
if [ -x "$(command -v ninja)" ]; then
|
||||
CMAKE_ARGS+=("-GNinja")
|
||||
fi
|
||||
|
||||
# Use ccache if available (this path is where Homebrew installs ccache symlinks)
|
||||
if [ "$(uname)" == 'Darwin' ]; then
|
||||
CCACHE_WRAPPER_PATH=/usr/local/opt/ccache/libexec
|
||||
|
|
|
|||
Loading…
Reference in a new issue