aboutsummaryrefslogtreecommitdiff
path: root/examples/vendor/constant_gen/constant_generator.py
diff options
context:
space:
mode:
authorSasha Smundak <asmundak@google.com>2022-09-17 03:07:33 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-09-17 03:07:33 +0000
commit8a99d2b6dff36f04be445f3c5e8f69874da57a04 (patch)
treec87a7c540efe9da13cb94870d8e09efeba88f63f /examples/vendor/constant_gen/constant_generator.py
parent56590b14f8ec08644614fa10ac9cdc17abd8eee9 (diff)
parentdf3b8d7aa1d57f6ee108a023e90860f1e372cb4b (diff)
downloadbazelbuild-rules_license-8a99d2b6dff36f04be445f3c5e8f69874da57a04.tar.gz
Merge remote-tracking branch 'aosp/upstream-main' into notice am: d5f1fc8147 am: 64bd397324 am: 50783bf43b am: e66c3e756d am: df3b8d7aa1
Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-rules_license/+/2189019 Change-Id: Ia6eec35387b885fdb37d7dda99722511a43e093b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'examples/vendor/constant_gen/constant_generator.py')
-rw-r--r--examples/vendor/constant_gen/constant_generator.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/vendor/constant_gen/constant_generator.py b/examples/vendor/constant_gen/constant_generator.py
new file mode 100644
index 0000000..6bd92b2
--- /dev/null
+++ b/examples/vendor/constant_gen/constant_generator.py
@@ -0,0 +1,33 @@
+# Copyright 2020 Google LLC
+#
+# 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
+#
+# https://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.
+
+# Lint as: python3
+"""A trivial tool to turn a string into a C++ constant.
+
+This is not meant to be useful. It is only to provide an example of a tool that
+generates code.
+"""
+
+import sys
+
+
+def main(argv):
+ if len(argv) != 4:
+ raise Exception('usage: constant_generator out_file var_name text')
+ with open(argv[1], 'w') as out:
+ out.write('const char* %s = "%s";\n' % (argv[2], argv[3]))
+
+
+if __name__ == '__main__':
+ main(sys.argv)