Skip to content

Commit

Permalink
[Bazel] Reduce quote escaping
Browse files Browse the repository at this point in the history
There's a lot of unnecessary backslashes here that we can avoid to
reduce confusion.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D108495
  • Loading branch information
GMNGeoffrey committed Aug 20, 2021
1 parent 973cb2c commit 2bd7c30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
15 changes: 8 additions & 7 deletions utils/bazel/llvm-project-overlay/clang/BUILD.bazel
Expand Up @@ -343,12 +343,13 @@ exports_files(
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(
Expand All @@ -372,7 +373,7 @@ genrule(
# 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
Expand Down
2 changes: 1 addition & 1 deletion utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
Expand Up @@ -98,7 +98,7 @@ enum_targets_gen(
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(
Expand Down
14 changes: 7 additions & 7 deletions utils/bazel/llvm-project-overlay/llvm/config.bzl
Expand Up @@ -6,24 +6,24 @@

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),
"LLVM_NATIVE_TARGET=LLVMInitialize{}Target".format(arch),
"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",
Expand Down Expand Up @@ -60,8 +60,8 @@ win32_defines = [
"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
Expand Down

0 comments on commit 2bd7c30

Please sign in to comment.