aboutsummaryrefslogtreecommitdiff
path: root/flags
diff options
context:
space:
mode:
authorSam Delmerico <delmerico@google.com>2022-11-08 11:43:09 -0500
committerSam Delmerico <delmerico@google.com>2022-11-09 16:59:39 -0500
commiteddd60eb440eecc10e23232fa9f0c78b1704ac04 (patch)
tree1b3ad5208a5a29e16381babfa3b7b0f47e5bbb6e /flags
parent3c9b24d9c7179895ca705fa5f957a69a5a00686e (diff)
downloadbazel-eddd60eb440eecc10e23232fa9f0c78b1704ac04.tar.gz
add support for WITH_TIDY, ALLOW_LOCAL_TIDY_TRUE
Bug: 257292095 Test: WITH_TIDY=1 b build -s //packages/modules/adb:adb_test Test: ALLOW_LOCAL_TIDY_TRUE=1 b build -s //packages/modules/adb:adb_test Change-Id: I7990b53c9d167e50b9eb4a507fae1b4004d106a7
Diffstat (limited to 'flags')
-rw-r--r--flags/BUILD.bazel0
-rw-r--r--flags/cc/tidy/BUILD.bazel13
-rw-r--r--flags/common.bzl25
3 files changed, 37 insertions, 1 deletions
diff --git a/flags/BUILD.bazel b/flags/BUILD.bazel
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/flags/BUILD.bazel
diff --git a/flags/cc/tidy/BUILD.bazel b/flags/cc/tidy/BUILD.bazel
index 4bd8966b..e3d40f71 100644
--- a/flags/cc/tidy/BUILD.bazel
+++ b/flags/cc/tidy/BUILD.bazel
@@ -15,11 +15,22 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
-load("@bazel_skylib//rules:common_settings.bzl", "string_flag", "string_list_flag")
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag", "string_list_flag")
load("@env//:env.bzl", "env")
+load("//build/bazel/flags:common.bzl", "is_env_true")
package(default_visibility = ["//visibility:public"])
+bool_flag(
+ name = "with_tidy",
+ build_setting_default = is_env_true(env.get("WITH_TIDY")),
+)
+
+bool_flag(
+ name = "allow_local_tidy_true",
+ build_setting_default = is_env_true(env.get("ALLOW_LOCAL_TIDY_TRUE")),
+)
+
_with_tidy_flags = env.get("WITH_TIDY_FLAGS", None)
string_list_flag(
diff --git a/flags/common.bzl b/flags/common.bzl
new file mode 100644
index 00000000..270e1f9c
--- /dev/null
+++ b/flags/common.bzl
@@ -0,0 +1,25 @@
+"""
+Copyright (C) 2022 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.
+"""
+
+def is_env_true(value):
+ """return the truthiness of the value of an environment variable
+
+ Args:
+ value (str): the environment variable value to test
+ Returns:
+ if the value is truthy
+ """
+ return value != None and value.lower() in ["1", "y", "yes", "on", "true"]