.vscode/tasks.json - Add 'cmake gen'

Allow the developer to pick either the GN or CMake build. Extract the lengthy string out to a new bash script in <dawn>/tools.

Windows CMake is TODO.

The Tint repo defaulted to using CMake, where as the Dawn repo defaulted to using GN. This gives us the best of both.

Bug: dawn:1339
Change-Id: Ibd5cf2a8f1c6d416b231d3267d68e006aee806be
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86064
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
Ben Clayton 2022-04-07 19:22:21 +00:00 committed by Dawn LUCI CQ
parent 8155b9dada
commit feb42e5231
2 changed files with 117 additions and 7 deletions

45
.vscode/tasks.json vendored
View File

@ -76,17 +76,17 @@
"label": "gn gen", "label": "gn gen",
"type": "shell", "type": "shell",
"linux": { "linux": {
"command": "sh", "command": "./tools/setup-build",
"args": [ "args": [
"-c", "gn",
"gn gen 'out/${input:buildType}' --args=is_debug=$(if [ '${input:buildType}' = 'Debug' ]; then echo 'true'; else echo 'false'; fi) && (rm -fr out/active || true) && ln -s ${input:buildType} out/active", "${input:buildType}",
], ],
}, },
"osx": { "osx": {
"command": "sh", "command": "./tools/setup-build",
"args": [ "args": [
"-c", "gn",
"gn gen 'out/${input:buildType}' --args=is_debug=$(if [ '${input:buildType}' = 'Debug' ]; then echo 'true'; else echo 'false'; fi) && (rm -fr out/active || true) && ln -s ${input:buildType} out/active", "${input:buildType}",
], ],
}, },
"windows": { "windows": {
@ -105,6 +105,39 @@
}, },
"problemMatcher": [], "problemMatcher": [],
}, },
{
"label": "cmake gen",
"type": "shell",
"linux": {
"command": "./tools/setup-build",
"args": [
"cmake",
"${input:buildType}",
],
},
"osx": {
"command": "./tools/setup-build",
"args": [
"cmake",
"${input:buildType}",
],
},
"windows": {
"command": "/C",
"args": [
"echo TODO",
],
"options": {
"shell": {
"executable": "cmd"
},
}
},
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": [],
},
// Rebases the current branch on to origin/main and then calls // Rebases the current branch on to origin/main and then calls
// `gclient sync`. // `gclient sync`.
{ {

77
tools/setup-build Executable file
View File

@ -0,0 +1,77 @@
#!/usr/bin/env bash
# Copyright 2022 The Tint Authors
#
# 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.
set -e # Fail on any error.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/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
BUILD_DIR="${BUILD_SYSTEM}-${BUILD_TYPE}"
function show_usage() {
echo "setup-build [gn|cmake] [debug|release]"
echo
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"
exit 1
}
function generate() {
CMD=$1
pushd "$ROOT_DIR" > /dev/null
${CMD}
rm -fr "out/active" || true
ln -s "$BUILD_DIR" "out/active"
popd > /dev/null
}
case $BUILD_SYSTEM in
"gn")
case $BUILD_TYPE in
"debug")
generate "gn gen out/${BUILD_DIR} --args=is_debug=true"
;;
"release")
generate "gn gen out/${BUILD_DIR}"
;;
*)
echo "invalid build type '${BUILD_TYPE}'"
show_usage
;;
esac
;;
"cmake")
case $BUILD_TYPE in
"debug")
generate "cmake -S . -B out/$BUILD_DIR -GNinja -DCMAKE_BUILD_TYPE=Debug"
;;
"release")
generate "cmake -S . -B out/$BUILD_DIR -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo"
;;
*)
echo "invalid build type '${BUILD_TYPE}'"
show_usage
;;
esac
;;
"--help" | "-help" | "-h")
show_usage
;;
*)
echo "invalid build system '${BUILD_SYSTEM}'"
show_usage
;;
esac