tools/setup-build: Support x86
Change-Id: I03cc04ac3f8f511be530ccc57055b31574ed3d94 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105560 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
79363cc6cf
commit
138ddcc08c
|
@ -80,6 +80,7 @@
|
||||||
"args": [
|
"args": [
|
||||||
"gn",
|
"gn",
|
||||||
"${input:buildType}",
|
"${input:buildType}",
|
||||||
|
"${input:buildArch}",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"osx": {
|
"osx": {
|
||||||
|
@ -87,6 +88,7 @@
|
||||||
"args": [
|
"args": [
|
||||||
"gn",
|
"gn",
|
||||||
"${input:buildType}",
|
"${input:buildType}",
|
||||||
|
"${input:buildArch}",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"windows": {
|
"windows": {
|
||||||
|
@ -113,6 +115,7 @@
|
||||||
"args": [
|
"args": [
|
||||||
"cmake",
|
"cmake",
|
||||||
"${input:buildType}",
|
"${input:buildType}",
|
||||||
|
"${input:buildArch}",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"osx": {
|
"osx": {
|
||||||
|
@ -120,6 +123,7 @@
|
||||||
"args": [
|
"args": [
|
||||||
"cmake",
|
"cmake",
|
||||||
"${input:buildType}",
|
"${input:buildType}",
|
||||||
|
"${input:buildArch}",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"windows": {
|
"windows": {
|
||||||
|
@ -200,5 +204,15 @@
|
||||||
"default": "Debug",
|
"default": "Debug",
|
||||||
"description": "The type of build",
|
"description": "The type of build",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "buildArch",
|
||||||
|
"type": "pickString",
|
||||||
|
"options": [
|
||||||
|
"native",
|
||||||
|
"x86",
|
||||||
|
],
|
||||||
|
"default": "native",
|
||||||
|
"description": "The build architecture",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,67 +16,169 @@
|
||||||
set -e # Fail on any error.
|
set -e # Fail on any error.
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
|
||||||
ROOT_DIR="$( cd "${SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd )"
|
ROOT_DIR="$( cd "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd )"
|
||||||
BUILD_SYSTEM=$(echo "$1" | tr '[:upper:]' '[:lower:]') # lowercase
|
|
||||||
BUILD_TYPE=$(echo "$2" | tr '[:upper:]' '[:lower:]') # lowercase
|
POSSIBLE_BUILD_SYSTEMS="[gn|cmake]"
|
||||||
BUILD_DIR="${BUILD_SYSTEM}-${BUILD_TYPE}"
|
POSSIBLE_BUILD_TYPES="[debug|release]"
|
||||||
|
POSSIBLE_BUILD_ARCHS="[native|x86]"
|
||||||
|
|
||||||
|
BUILD_SYSTEM=""
|
||||||
|
BUILD_TYPE=""
|
||||||
|
BUILD_ARCH=""
|
||||||
|
|
||||||
function show_usage() {
|
function show_usage() {
|
||||||
echo "setup-build [gn|cmake] [debug|release]"
|
echo "setup-build $POSSIBLE_BUILD_SYSTEMS $POSSIBLE_BUILD_TYPES $POSSIBLE_BUILD_ARCHS"
|
||||||
echo
|
echo
|
||||||
echo "creates a build directory in <dawn>/out using either GN or CMake, then"
|
echo "creates a build directory in <dawn>/out using either GN or CMake, then"
|
||||||
echo "updates the '<dawn>/out/active' symlink to point to the build directory"
|
echo "updates the '<dawn>/out/active' symlink to point to the build directory"
|
||||||
|
if [[ ! -z "$1" ]]; then
|
||||||
|
echo
|
||||||
|
echo "$1"
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_build_system() {
|
||||||
|
if [[ ! -z "$BUILD_SYSTEM" ]]; then
|
||||||
|
echo "conflicting build systems $BUILD_SYSTEM and $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
BUILD_SYSTEM=$1
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_build_type() {
|
||||||
|
if [[ ! -z "$BUILD_TYPE" ]]; then
|
||||||
|
echo "conflicting build types $BUILD_TYPE and $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
BUILD_TYPE=$1
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_build_arch() {
|
||||||
|
if [[ ! -z "$BUILD_ARCH" ]]; then
|
||||||
|
echo "conflicting build architectures $BUILD_ARCH and $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
BUILD_ARCH=$1
|
||||||
|
}
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
lowered_arg=$(echo "$arg" | tr '[:upper:]' '[:lower:]') # lowercase
|
||||||
|
case $lowered_arg in
|
||||||
|
"gn")
|
||||||
|
set_build_system $lowered_arg
|
||||||
|
;;
|
||||||
|
"cmake")
|
||||||
|
set_build_system $lowered_arg
|
||||||
|
;;
|
||||||
|
"debug")
|
||||||
|
set_build_type $lowered_arg
|
||||||
|
;;
|
||||||
|
"release")
|
||||||
|
set_build_type $lowered_arg
|
||||||
|
;;
|
||||||
|
"x86")
|
||||||
|
set_build_arch $lowered_arg
|
||||||
|
;;
|
||||||
|
"native")
|
||||||
|
;;
|
||||||
|
"--help" | "-help" | "-h")
|
||||||
|
show_usage
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
show_usage "unknown argument '$arg'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z "$BUILD_SYSTEM" ]]; then
|
||||||
|
show_usage "build system $POSSIBLE_BUILD_SYSTEMS is required"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$BUILD_TYPE" ]]; then
|
||||||
|
show_usage "build type $POSSIBLE_BUILD_TYPES required"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_DIR="$BUILD_SYSTEM-$BUILD_TYPE"
|
||||||
|
if [[ ! -z "$BUILD_ARCH" ]]; then
|
||||||
|
BUILD_DIR+="-$BUILD_ARCH"
|
||||||
|
fi
|
||||||
|
|
||||||
function generate() {
|
function generate() {
|
||||||
CMD=$1
|
|
||||||
pushd "$ROOT_DIR" > /dev/null
|
pushd "$ROOT_DIR" > /dev/null
|
||||||
mkdir -p "out/$BUILD_DIR"
|
mkdir -p "out/$BUILD_DIR"
|
||||||
rm -fr "out/active" || true
|
rm -fr "out/active" || true
|
||||||
ln -s "$BUILD_DIR" "out/active"
|
ln -s "$BUILD_DIR" "out/active"
|
||||||
${CMD}
|
"$@"
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
case $BUILD_SYSTEM in
|
case $BUILD_SYSTEM in
|
||||||
"gn")
|
"gn")
|
||||||
|
GN_ARGS=""
|
||||||
case $BUILD_TYPE in
|
case $BUILD_TYPE in
|
||||||
"debug")
|
"debug")
|
||||||
generate "gn gen out/active --args=is_debug=true"
|
GN_ARGS+="is_debug=true"
|
||||||
;;
|
;;
|
||||||
"release")
|
"release")
|
||||||
generate "gn gen out/active --args=is_debug=false"
|
GN_ARGS+="is_debug=false"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "invalid build type '${BUILD_TYPE}'"
|
show_usage "invalid build type '$BUILD_TYPE'"
|
||||||
show_usage
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
case $BUILD_ARCH in
|
||||||
|
"")
|
||||||
|
;;
|
||||||
|
"x86")
|
||||||
|
GN_ARGS+=" target_cpu=\"x86\""
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
show_usage "invalid build architecture '$BUILD_ARCH'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
generate "gn" "gen" "out/active" "--args=$GN_ARGS"
|
||||||
;;
|
;;
|
||||||
"cmake")
|
"cmake")
|
||||||
CMAKE_FLAGS=""
|
CMAKE_FLAGS=()
|
||||||
|
CMAKE_FLAGS+=("-DTINT_BUILD_GLSL_WRITER=1")
|
||||||
|
CMAKE_FLAGS+=("-DTINT_BUILD_HLSL_WRITER=1")
|
||||||
|
CMAKE_FLAGS+=("-DTINT_BUILD_MSL_WRITER=1")
|
||||||
|
CMAKE_FLAGS+=("-DTINT_BUILD_SPV_WRITER=1")
|
||||||
|
CMAKE_FLAGS+=("-DTINT_BUILD_WGSL_WRITER=1")
|
||||||
if [[ -x $(command -v ccache) ]]; then
|
if [[ -x $(command -v ccache) ]]; then
|
||||||
CMAKE_FLAGS+="-DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
|
CMAKE_FLAGS+=("-DCMAKE_CXX_COMPILER_LAUNCHER=ccache")
|
||||||
fi
|
fi
|
||||||
case $BUILD_TYPE in
|
case $BUILD_TYPE in
|
||||||
"debug")
|
"debug")
|
||||||
generate "cmake -S . -B out/active -GNinja -DCMAKE_BUILD_TYPE=Debug ${CMAKE_FLAGS}"
|
CMAKE_FLAGS+=("-DCMAKE_BUILD_TYPE=Debug")
|
||||||
;;
|
;;
|
||||||
"release")
|
"release")
|
||||||
generate "cmake -S . -B out/active -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo ${CMAKE_FLAGS}"
|
CMAKE_FLAGS+=("-DCMAKE_BUILD_TYPE=RelWithDebInfo")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "invalid build type '${BUILD_TYPE}'"
|
show_usage "invalid build type '$BUILD_TYPE'"
|
||||||
show_usage
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
case $BUILD_ARCH in
|
||||||
"--help" | "-help" | "-h")
|
"")
|
||||||
show_usage
|
;;
|
||||||
|
"x86")
|
||||||
|
CMAKE_FLAGS+=("-DCMAKE_CXX_FLAGS=-m32")
|
||||||
|
CMAKE_FLAGS+=("-DCMAKE_C_FLAGS=-m32")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
show_usage "invalid build architecture '$BUILD_ARCH'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
generate "cmake" \
|
||||||
|
"-S" "." \
|
||||||
|
"-B" "out/active" \
|
||||||
|
"-GNinja" \
|
||||||
|
"${CMAKE_FLAGS[@]}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "invalid build system '${BUILD_SYSTEM}'"
|
echo "invalid build system '$BUILD_SYSTEM'"
|
||||||
show_usage
|
show_usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue