From: Nico Weber Date: Fri, 4 Jan 2019 17:14:55 +0000 (+0000) Subject: [gn build] Start adding build files for LLVM unittests X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d02210fd4f75512e55df605ff27e68accca8d05b;p=llvm [gn build] Start adding build files for LLVM unittests 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350411 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/gn/build/sync_source_lists_from_cmake.py b/utils/gn/build/sync_source_lists_from_cmake.py index f5d92ce0bba..03cba7ad396 100755 --- a/utils/gn/build/sync_source_lists_from_cmake.py +++ b/utils/gn/build/sync_source_lists_from_cmake.py @@ -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) @@ -57,12 +57,18 @@ def sync_source_lists(): 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' % diff --git a/utils/gn/secondary/llvm/test/BUILD.gn b/utils/gn/secondary/llvm/test/BUILD.gn index 48e6e3e2fb0..f282c7ffdbd 100644 --- a/utils/gn/secondary/llvm/test/BUILD.gn +++ b/utils/gn/secondary/llvm/test/BUILD.gn @@ -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", @@ -261,7 +262,6 @@ group("test") { ] } - # FIXME: dep on "//llvm/unittests" once it exists # FIXME: llvm_build_examples testonly = true } diff --git a/utils/gn/secondary/llvm/unittests/ADT/BUILD.gn b/utils/gn/secondary/llvm/unittests/ADT/BUILD.gn new file mode 100644 index 00000000000..611df36fd0f --- /dev/null +++ b/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", + ] +} diff --git a/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn b/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn new file mode 100644 index 00000000000..2b9b38d2ef2 --- /dev/null +++ b/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", + ] +} diff --git a/utils/gn/secondary/llvm/unittests/AsmParser/BUILD.gn b/utils/gn/secondary/llvm/unittests/AsmParser/BUILD.gn new file mode 100644 index 00000000000..7cc4a546ca1 --- /dev/null +++ b/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", + ] +} diff --git a/utils/gn/secondary/llvm/unittests/BUILD.gn b/utils/gn/secondary/llvm/unittests/BUILD.gn new file mode 100644 index 00000000000..38147d24574 --- /dev/null +++ b/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 +} diff --git a/utils/gn/secondary/llvm/unittests/BinaryFormat/BUILD.gn b/utils/gn/secondary/llvm/unittests/BinaryFormat/BUILD.gn new file mode 100644 index 00000000000..7b2b78e4390 --- /dev/null +++ b/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", + ] +} diff --git a/utils/gn/secondary/llvm/unittests/Bitcode/BUILD.gn b/utils/gn/secondary/llvm/unittests/Bitcode/BUILD.gn new file mode 100644 index 00000000000..9cb78946e82 --- /dev/null +++ b/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", + ] +} diff --git a/utils/gn/secondary/llvm/unittests/CodeGen/BUILD.gn b/utils/gn/secondary/llvm/unittests/CodeGen/BUILD.gn new file mode 100644 index 00000000000..b67631b4642 --- /dev/null +++ b/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", + ] +} diff --git a/utils/gn/secondary/llvm/unittests/DebugInfo/CodeView/BUILD.gn b/utils/gn/secondary/llvm/unittests/DebugInfo/CodeView/BUILD.gn new file mode 100644 index 00000000000..913de50c7e6 --- /dev/null +++ b/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", + ] +} diff --git a/utils/gn/secondary/llvm/unittests/DebugInfo/DWARF/BUILD.gn b/utils/gn/secondary/llvm/unittests/DebugInfo/DWARF/BUILD.gn new file mode 100644 index 00000000000..1c22a4ba1dd --- /dev/null +++ b/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", + ] +} diff --git a/utils/gn/secondary/llvm/unittests/DebugInfo/MSF/BUILD.gn b/utils/gn/secondary/llvm/unittests/DebugInfo/MSF/BUILD.gn new file mode 100644 index 00000000000..6c9bc06ab4c --- /dev/null +++ b/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", + ] +} diff --git a/utils/gn/secondary/llvm/unittests/Demangle/BUILD.gn b/utils/gn/secondary/llvm/unittests/Demangle/BUILD.gn new file mode 100644 index 00000000000..c7eedfbe715 --- /dev/null +++ b/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", + ] +}