Skip to content

Commit

Permalink
[gn build] Start adding build files for LLVM unittests
Browse files Browse the repository at this point in the history
Adds build files for //llvm/unittest/[A-D].

Also teach sync_source_lists_from_cmake.py to not complain about missing
BUILD.gn files for CMakeLists.txt files that just call add_subdirectory()
without calling add_.+_unittest, like e.g.
llvm/unittests/Target/CMakeLists.txt.

(Omits CodeGen/GlobalISel and DebugInfo/PDB because their build files are somewhat interesting, and this patch is already on the larger side.)

Differential Revision: https://reviews.llvm.org/D56212

llvm-svn: 350411
  • Loading branch information
nico committed Jan 4, 2019
1 parent 421c17f commit 2c497b5
Show file tree
Hide file tree
Showing 13 changed files with 317 additions and 3 deletions.
10 changes: 8 additions & 2 deletions llvm/utils/gn/build/sync_source_lists_from_cmake.py
Expand Up @@ -21,9 +21,9 @@ def sync_source_lists():
gn_files = subprocess.check_output(
['git', 'ls-files', '*BUILD.gn']).splitlines()

# Matches e.g. | "foo.cpp",|.
# Matches e.g. | "foo.cpp",|, captures |foo| in group 1.
gn_cpp_re = re.compile(r'^\s*"([^"]+\.(?:cpp|h))",$', re.MULTILINE)
# Matches e.g. | "foo.cpp"|.
# Matches e.g. | foo.cpp|, captures |foo| in group 1.
cmake_cpp_re = re.compile(r'^\s*([A-Za-z_0-9/-]+\.(?:cpp|h))$',
re.MULTILINE)

Expand Down Expand Up @@ -57,12 +57,18 @@ def get_sources(source_re, text):


def sync_unittests():
# Matches e.g. |add_llvm_unittest_with_input_files|.
unittest_re = re.compile(r'^add_\S+_unittest', re.MULTILINE)

# FIXME: Add 'llvm' here once it's complete.
checked = [ 'clang', 'lld' ]
for c in checked:
for root, _, _ in os.walk(os.path.join(c, 'unittests')):
cmake_file = os.path.join(root, 'CMakeLists.txt')
if not os.path.exists(cmake_file):
continue
if not unittest_re.search(open(cmake_file).read()):
continue # Skip CMake files that just add subdirectories.
gn_file = os.path.join('llvm/utils/gn/secondary', root, 'BUILD.gn')
if not os.path.exists(gn_file):
print('missing GN file %s for unittest CMake file %s' %
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/gn/secondary/llvm/test/BUILD.gn
Expand Up @@ -241,6 +241,7 @@ group("test") {
"//llvm/tools/sanstats",
"//llvm/tools/verify-uselistorder",
"//llvm/tools/yaml2obj",
"//llvm/unittests",
"//llvm/utils/FileCheck",
"//llvm/utils/TableGen:llvm-tblgen",
"//llvm/utils/count",
Expand All @@ -261,7 +262,6 @@ group("test") {
]
}

# FIXME: dep on "//llvm/unittests" once it exists
# FIXME: llvm_build_examples
testonly = true
}
Expand Down
79 changes: 79 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/ADT/BUILD.gn
@@ -0,0 +1,79 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("ADTTests") {
# ADT is a headers-only library so there's no //llvm/lib/ADT to depend on.
# Also see note in //llvm/lib/Support/BUILD.gn.
deps = [
# Some tests include files from IR, but there's no library dependency.
"//llvm/include/llvm/IR:public_tablegen",
"//llvm/lib/Support",
]
sources = [
"APFloatTest.cpp",
"APIntTest.cpp",
"APSIntTest.cpp",
"AnyTest.cpp",
"ArrayRefTest.cpp",
"BitVectorTest.cpp",
"BitmaskEnumTest.cpp",
"BreadthFirstIteratorTest.cpp",
"BumpPtrListTest.cpp",
"DAGDeltaAlgorithmTest.cpp",
"DeltaAlgorithmTest.cpp",
"DenseMapTest.cpp",
"DenseSetTest.cpp",
"DepthFirstIteratorTest.cpp",
"EquivalenceClassesTest.cpp",
"FoldingSet.cpp",
"FunctionExtrasTest.cpp",
"FunctionRefTest.cpp",
"HashingTest.cpp",
"IListBaseTest.cpp",
"IListIteratorTest.cpp",
"IListNodeBaseTest.cpp",
"IListNodeTest.cpp",
"IListSentinelTest.cpp",
"IListTest.cpp",
"ImmutableListTest.cpp",
"ImmutableMapTest.cpp",
"ImmutableSetTest.cpp",
"IntEqClassesTest.cpp",
"IntervalMapTest.cpp",
"IntrusiveRefCntPtrTest.cpp",
"IteratorTest.cpp",
"MakeUniqueTest.cpp",
"MapVectorTest.cpp",
"MappedIteratorTest.cpp",
"OptionalTest.cpp",
"PackedVectorTest.cpp",
"PointerEmbeddedIntTest.cpp",
"PointerIntPairTest.cpp",
"PointerSumTypeTest.cpp",
"PointerUnionTest.cpp",
"PostOrderIteratorTest.cpp",
"PriorityWorklistTest.cpp",
"RangeAdapterTest.cpp",
"SCCIteratorTest.cpp",
"STLExtrasTest.cpp",
"ScopeExitTest.cpp",
"SequenceTest.cpp",
"SetVectorTest.cpp",
"SimpleIListTest.cpp",
"SmallPtrSetTest.cpp",
"SmallSetTest.cpp",
"SmallStringTest.cpp",
"SmallVectorTest.cpp",
"SparseBitVectorTest.cpp",
"SparseMultiSetTest.cpp",
"SparseSetTest.cpp",
"StatisticTest.cpp",
"StringExtrasTest.cpp",
"StringMapTest.cpp",
"StringRefTest.cpp",
"StringSwitchTest.cpp",
"TinyPtrVectorTest.cpp",
"TripleTest.cpp",
"TwineTest.cpp",
"VariadicFunctionTest.cpp",
]
}
37 changes: 37 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn
@@ -0,0 +1,37 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("AnalysisTests") {
deps = [
"//llvm/lib/Analysis",
"//llvm/lib/AsmParser",
"//llvm/lib/IR",
"//llvm/lib/Support",
]
sources = [
"AliasAnalysisTest.cpp",
"AliasSetTrackerTest.cpp",
"BasicAliasAnalysisTest.cpp",
"BlockFrequencyInfoTest.cpp",
"BranchProbabilityInfoTest.cpp",
"CFGTest.cpp",
"CGSCCPassManagerTest.cpp",
"CallGraphTest.cpp",
"DivergenceAnalysisTest.cpp",
"GlobalsModRefTest.cpp",
"LazyCallGraphTest.cpp",
"LoopInfoTest.cpp",
"MemoryBuiltinsTest.cpp",
"MemorySSATest.cpp",
"OrderedBasicBlockTest.cpp",
"OrderedInstructionsTest.cpp",
"PhiValuesTest.cpp",
"ProfileSummaryInfoTest.cpp",
"ScalarEvolutionTest.cpp",
"SparsePropagation.cpp",
"TBAATest.cpp",
"TargetLibraryInfoTest.cpp",
"UnrollAnalyzerTest.cpp",
"ValueLatticeTest.cpp",
"ValueTrackingTest.cpp",
]
}
12 changes: 12 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/AsmParser/BUILD.gn
@@ -0,0 +1,12 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("AsmParserTests") {
deps = [
"//llvm/lib/AsmParser",
"//llvm/lib/IR",
"//llvm/lib/Support",
]
sources = [
"AsmParserTest.cpp",
]
}
66 changes: 66 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/BUILD.gn
@@ -0,0 +1,66 @@
import("//llvm/lib/Target/targets.gni")

group("unittests") {
deps = [
"ADT:ADTTests",
"Analysis:AnalysisTests",
"AsmParser:AsmParserTests",
"BinaryFormat:BinaryFormatTests",
"Bitcode:BitcodeTests",
"CodeGen:CodeGenTests",

# FIXME: Add.
#"CodeGen/GlobalISel:GlobalISelTests",
"DebugInfo/CodeView:DebugInfoCodeViewTests",
"DebugInfo/DWARF:DebugInfoDWARFTests",
"DebugInfo/MSF:DebugInfoMSFTests",

# FIXME: Add.
#"DebugInfo/PDB:DebugInfoPDBTests",
"Demangle:DemangleTests",

# FIXME: Add more:
#"ExecutionEngine:ExecutionEngineTests",
#"ExecutionEngine/MCJIT:MCJITTests",
#"ExecutionEngine/Orc:OrcJITTests",
#"FuzzMutate:FuzzMutateTests",
#"IR:IRTests",
#"LineEditor:LineEditorTests",
#"MC:MCTests",
#"MI:MITests",
#"Object:ObjectTests",
#"ObjectYAML:ObjectYAMLTests",
#"Option:OptionTests",
#"Passes:PluginsTests",
#"ProfileData:ProfileDataTests",
#"Support:SupportTests",
#"Support/DynamicLibrary:DynamicLibraryTests",
#"Transforms/IPO:IPOTests",
#"Transforms/Scalar:ScalarTests",
#"Transforms/Utils:UtilsTests",
#"XRay:XRayTests",
#"tools/llvm-cfi-verify:CFIVerifyTests",
#"tools/llvm-exegesis:LLVMExegesisTests",
]

# Target-dependend unit tests.
# FIXME: This matches how they are set up in the cmake build,
# but if we disable an arch after building with it on, this
# setup leaves behind stale executables.
# FIXME: Add AArch64, ARM these once the Targets exist.
#if (llvm_build_AArch64) {
#deps += [
#"Target/AArch64:AArch64Tests",
#"tools/llvm-exegesis/AArch64:LLVMExegesisAArch64Tests",
#]
#}
#if (llvm_build_ARM) {
#deps += [ "tools/llvm-exegesis/ARM:LLVMExegesisARMTests" ]
#}
if (llvm_build_X86) {
# FIXME: Add:
#deps += [ "tools/llvm-exegesis/X86:LLVMExegesisX86Tests" ]
}

testonly = true
}
15 changes: 15 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/BinaryFormat/BUILD.gn
@@ -0,0 +1,15 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("BinaryFormatTests") {
deps = [
"//llvm/lib/BinaryFormat",
]
sources = [
"DwarfTest.cpp",
"MachOTest.cpp",
"MsgPackReaderTest.cpp",
"MsgPackTypesTest.cpp",
"MsgPackWriterTest.cpp",
"TestFileMagic.cpp",
]
}
16 changes: 16 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/Bitcode/BUILD.gn
@@ -0,0 +1,16 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("BitcodeTests") {
deps = [
"//llvm/lib/AsmParser",
"//llvm/lib/Bitcode/Reader",
"//llvm/lib/Bitcode/Writer",
"//llvm/lib/IR",
"//llvm/lib/Support",
]
sources = [
"BitReaderTest.cpp",
"BitstreamReaderTest.cpp",
"BitstreamWriterTest.cpp",
]
}
25 changes: 25 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/CodeGen/BUILD.gn
@@ -0,0 +1,25 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("CodeGenTests") {
deps = [
"//llvm/lib/Analysis",
"//llvm/lib/AsmParser",
"//llvm/lib/CodeGen",
"//llvm/lib/CodeGen/AsmPrinter",
"//llvm/lib/CodeGen/SelectionDAG",
"//llvm/lib/IR",
"//llvm/lib/MC",
"//llvm/lib/Support",
"//llvm/lib/Target",
"//llvm/lib/Target:TargetsToBuild",
]
sources = [
"AArch64SelectionDAGTest.cpp",
"DIEHashTest.cpp",
"LowLevelTypeTest.cpp",
"MachineInstrBundleIteratorTest.cpp",
"MachineInstrTest.cpp",
"MachineOperandTest.cpp",
"ScalableVectorMVTsTest.cpp",
]
}
13 changes: 13 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/DebugInfo/CodeView/BUILD.gn
@@ -0,0 +1,13 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("DebugInfoCodeViewTests") {
deps = [
"//llvm/lib/DebugInfo/CodeView",
"//llvm/lib/Testing/Support",
]
sources = [
"RandomAccessVisitorTest.cpp",
"TypeHashingTest.cpp",
"TypeIndexDiscoveryTest.cpp",
]
}
21 changes: 21 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/DebugInfo/DWARF/BUILD.gn
@@ -0,0 +1,21 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("DebugInfoDWARFTests") {
deps = [
"//llvm/lib/CodeGen/AsmPrinter",
"//llvm/lib/DebugInfo/DWARF",
"//llvm/lib/MC",
"//llvm/lib/Object",
"//llvm/lib/ObjectYAML",
"//llvm/lib/Support",
"//llvm/lib/Target:TargetsToBuild",
"//llvm/lib/Testing/Support",
]
sources = [
"DWARFDebugInfoTest.cpp",
"DWARFDebugLineTest.cpp",
"DWARFFormValueTest.cpp",
"DwarfGenerator.cpp",
"DwarfUtils.cpp",
]
}
13 changes: 13 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/DebugInfo/MSF/BUILD.gn
@@ -0,0 +1,13 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("DebugInfoMSFTests") {
deps = [
"//llvm/lib/DebugInfo/MSF",
"//llvm/lib/Testing/Support",
]
sources = [
"MSFBuilderTest.cpp",
"MSFCommonTest.cpp",
"MappedBlockStreamTest.cpp",
]
}
11 changes: 11 additions & 0 deletions llvm/utils/gn/secondary/llvm/unittests/Demangle/BUILD.gn
@@ -0,0 +1,11 @@
import("//llvm/utils/unittest/unittest.gni")

unittest("DemangleTests") {
deps = [
"//llvm/lib/Demangle",
]
sources = [
"ItaniumDemangleTest.cpp",
"PartialDemangleTest.cpp",
]
}

0 comments on commit 2c497b5

Please sign in to comment.