[PATCH] D107019: [Bazel] Derive targets from file presence as in CMake build

Geoffrey Martin-Noble via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 28 18:40:47 PDT 2021


GMNGeoffrey created this revision.
GMNGeoffrey added a reviewer: chandlerc.
Herald added subscribers: steven.zhang, s.egerton, simoncook, fedor.sergeev, dschuff.
GMNGeoffrey requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

Doesn't include AsmPrinter because the glob for all files starting with
AsmPrinter will give duplicates and a glob for specific named AsmPrinter
already diverges from CMake and (losing the main benefit) and also has
to deal with things like PPC that have is alternately called PPC and
PowerPC. Just doing all targets seems to work fine (and will fail in a
really obvious way if it stops working).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107019

Files:
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel


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
@@ -41,22 +41,14 @@
     targets = llvm_targets,
 )
 
-# TODO(gcmn): We should derive these lists from the presence of CMakeLists.txt
-# files, as is done in the CMake build.
 # List of targets with ASM parsers, filtered to our list of overall targets.
-llvm_target_asm_parsers = [t for t in [
-    "AArch64",
-    "AMDGPU",
-    "ARM",
-    "BPF",
-    "Hexagon",
-    "Lanai",
-    "PowerPC",
-    "RISCV",
-    "Sparc",
-    "WebAssembly",
-    "X86",
-] if t in llvm_targets]
+llvm_target_asm_parsers = [
+    t.split("/")[2]
+    for t in glob([
+        "lib/Target/{}/AsmParser/CMakeLists.txt".format(t)
+        for t in llvm_targets
+    ])
+]
 
 enum_targets_gen(
     name = "asm_parsers_def_gen",
@@ -67,19 +59,13 @@
 )
 
 # List of targets with disassemblers, filtered to our list of overall targets.
-llvm_target_disassemblers = [t for t in [
-    "AArch64",
-    "AMDGPU",
-    "ARM",
-    "BPF",
-    "Hexagon",
-    "Lanai",
-    "PowerPC",
-    "RISCV",
-    "Sparc",
-    "WebAssembly",
-    "X86",
-] if t in llvm_targets]
+llvm_target_disassemblers = [
+    t.split("/")[2]
+    for t in glob([
+        "lib/Target/{}/Disassembler/CMakeLists.txt".format(t)
+        for t in llvm_targets
+    ])
+]
 
 enum_targets_gen(
     name = "disassemblers_def_gen",
@@ -90,9 +76,13 @@
 )
 
 # List of targets with mca, filtered to our list of overall targets.
-llvm_target_mcas = [t for t in [
-    "AMDGPU",
-] if t in llvm_targets]
+llvm_target_mcas = [
+    t.split("/")[2]
+    for t in glob([
+        "lib/Target/{}/MCA/CMakeLists.txt".format(t)
+        for t in llvm_targets
+    ])
+]
 
 enum_targets_gen(
     name = "target_mca_def_gen",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107019.362599.patch
Type: text/x-patch
Size: 1895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210729/a4fae05a/attachment.bin>


More information about the llvm-commits mailing list