[PATCH] D108495: [Bazel] Reduce quote escaping

Geoffrey Martin-Noble via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 20 16:33:34 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2bd7c30e5a4e: [Bazel] Reduce quote escaping (authored by GMNGeoffrey).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108495/new/

https://reviews.llvm.org/D108495

Files:
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/config.bzl


Index: utils/bazel/llvm-project-overlay/llvm/config.bzl
===================================================================
--- utils/bazel/llvm-project-overlay/llvm/config.bzl
+++ utils/bazel/llvm-project-overlay/llvm/config.bzl
@@ -6,7 +6,7 @@
 
 def native_arch_defines(arch, triple):
     return [
-        "LLVM_NATIVE_ARCH=\\\"{}\\\"".format(arch),
+        r'LLVM_NATIVE_ARCH=\"{}\"'.format(arch),
         "LLVM_NATIVE_ASMPARSER=LLVMInitialize{}AsmParser".format(arch),
         "LLVM_NATIVE_ASMPRINTER=LLVMInitialize{}AsmPrinter".format(arch),
         "LLVM_NATIVE_DISASSEMBLER=LLVMInitialize{}Disassembler".format(arch),
@@ -14,16 +14,16 @@
         "LLVM_NATIVE_TARGETINFO=LLVMInitialize{}TargetInfo".format(arch),
         "LLVM_NATIVE_TARGETMC=LLVMInitialize{}TargetMC".format(arch),
         "LLVM_NATIVE_TARGETMCA=LLVMInitialize{}TargetMCA".format(arch),
-        "LLVM_HOST_TRIPLE=\\\"{}\\\"".format(triple),
-        "LLVM_DEFAULT_TARGET_TRIPLE=\\\"{}\\\"".format(triple),
+        r'LLVM_HOST_TRIPLE=\"{}\"'.format(triple),
+        r'LLVM_DEFAULT_TARGET_TRIPLE=\"{}\"'.format(triple),
     ]
 
 posix_defines = [
     "LLVM_ON_UNIX=1",
     "HAVE_BACKTRACE=1",
     "BACKTRACE_HEADER=<execinfo.h>",
-    "LTDL_SHLIB_EXT=\\\".so\\\"",
-    "LLVM_PLUGIN_EXT=\\\".so\\\"",
+    r'LTDL_SHLIB_EXT=\".so\"',
+    r'LLVM_PLUGIN_EXT=\".so\"',
     "LLVM_ENABLE_THREADS=1",
     "HAVE_SYSEXITS_H=1",
     "HAVE_UNISTD_H=1",
@@ -60,8 +60,8 @@
     "strdup=_strdup",
 
     # LLVM features
-    "LTDL_SHLIB_EXT=\\\".dll\\\"",
-    "LLVM_PLUGIN_EXT=\\\".dll\\\"",
+    r'LTDL_SHLIB_EXT=\".dll\"',
+    r'LLVM_PLUGIN_EXT=\".dll\"',
 ]
 
 # TODO: We should switch to platforms-based config settings to make this easier
Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
===================================================================
--- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -98,7 +98,7 @@
 genrule(
     name = "version_info_gen",
     outs = ["include/llvm/Config/VersionInfo.h"],
-    cmd = "echo \"#define LLVM_VERSION_INFO \\\"git\\\"\" > $@",
+    cmd = "echo '#define LLVM_VERSION_INFO \"git\"' > $@",
 )
 
 template_rule(
Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===================================================================
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -343,12 +343,13 @@
 genrule(
     name = "basic_version_gen",
     outs = ["include/clang/Basic/Version.inc"],
-    cmd = ("printf " +
-           "\"#define CLANG_VERSION 12.0\n\"" +
-           "\"#define CLANG_VERSION_MAJOR 12\n\"" +
-           "\"#define CLANG_VERSION_MINOR 0\n\"" +
-           "\"#define CLANG_VERSION_PATCHLEVEL 0\n\"" +
-           "\"#define CLANG_VERSION_STRING \\\"git\\\"\n\" > $@"),
+    cmd = (
+        "echo '#define CLANG_VERSION 12.0' >> $@\n" +
+        "echo '#define CLANG_VERSION_MAJOR 12' >> $@\n" +
+        "echo '#define CLANG_VERSION_MINOR 0' >> $@\n" +
+        "echo '#define CLANG_VERSION_PATCHLEVEL 0' >> $@\n" +
+        "echo '#define CLANG_VERSION_STRING \"git\"' >> $@\n"
+    ),
 )
 
 cc_library(
@@ -372,7 +373,7 @@
     # are passed through bazel, it's easier to drop generated files next to
     # the other includes.
     outs = ["include/VCSVersion.inc"],
-    cmd = "echo \"#define CLANG_REVISION \\\"git\\\"\" > $@",
+    cmd = "echo '#define CLANG_REVISION \"git\"' > $@",
 )
 
 # A hacky library to expose some internal headers of the `basic` library to its


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108495.367923.patch
Type: text/x-patch
Size: 3576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210820/1d681c51/attachment.bin>


More information about the llvm-commits mailing list