This is an archive of the discontinued LLVM Phabricator instance.

[test-suite] Simplified test executable name generation.
ClosedPublic

Authored by tra on May 31 2016, 4:19 PM.

Details

Summary

This makes it possible to further customize build process for particular
target in the user's CMake files.

  • Documented some of the variables controlling test generation.
  • test_suite_add_executable has been renamed to llvm_test_executable()
  • removed 'mainsource' parameter
  • return generated executable names, if user needs them
  • Set include paths for current build/source dirs for each test we generate.

    Note: previously iinclude path was set globally each time llvm_multisource() was invoked. It looked unintentional. Now it's set per executable and no longer applies to subdirectories. As far as I can tell, testsuite still builds. Please let me know if we do want/need to add include paths per directory on llvm_multisource() invocation.

Diff Detail

Repository
rL LLVM

Event Timeline

tra updated this revision to Diff 59145.May 31 2016, 4:19 PM
tra retitled this revision from to [test-suite] Simplified test executable name generation..
tra updated this object.
tra added a reviewer: MatzeB.
tra added a subscriber: llvm-commits.
MatzeB added inline comments.Jun 8 2016, 1:41 PM
cmake/modules/SingleMultiSource.cmake
27–31 ↗(On Diff #59145)

Passing function results through global variable is ugly.
The cmake way to handle function results would be to have an additional (possibly optional) parameter that names the variable where we write the result to. That way you can at least see the connection at the call site.

138 ↗(On Diff #59145)

This would have needed a PARENT_SCOPE flag to actually work. Though I still recommend against using well known variable names to pass the result along.

147–148 ↗(On Diff #59145)

Why did you move this into llvm_test_executable()? It wasn't present for singlesource tests before. It also would have been a nice test to use the returned target name inside llvm_multisource() and apply target_include_directories() on that.

178 ↗(On Diff #59145)

see above.

tra added inline comments.Jun 8 2016, 2:20 PM
cmake/modules/SingleMultiSource.cmake
27–31 ↗(On Diff #59145)

OK.

138 ↗(On Diff #59145)

llvm_*source() are macros, so is llvm_test_excutable therefore PARENT_SCOPE is not needed here.

147–148 ↗(On Diff #59145)

I was trying to make default compilation flags identical for both llvm_*source() variants.
I can easily move it back to llvm_multisource, if you prefer.

tra updated this revision to Diff 60405.Jun 10 2016, 2:53 PM
tra updated this object.

Addressed MatzeB@'s comments

llvm_test_executable tweaks:
now accepts TARGETS parameter with a name of variable to append names of generated targets.
Global llvm_target_prefix is gone. Instead llvm_test_executable now accept PREFIX
parameter to prepend to executable name if we need to avoid name clashes.

MatzeB accepted this revision.Jun 14 2016, 4:19 PM
MatzeB edited edge metadata.

LGTM, with one more comment below:

cmake/modules/SingleMultiSource.cmake
202–204 ↗(On Diff #60405)

Shouldn't this be like:

llvm_test_executable(${executable} ${sources} TARGETS ${target})
target_include_directories(${target} ...)
This revision is now accepted and ready to land.Jun 14 2016, 4:19 PM
tra updated this revision to Diff 69598.Aug 29 2016, 11:44 AM
tra edited edge metadata.

Rebased on top of recent HEAD.

tra updated this revision to Diff 69599.Aug 29 2016, 12:10 PM

Addressed MatzeB@'s comment.

Record target name right after we've created it.
Check whether we've created a target before using it to add include directories.

tra updated this revision to Diff 70062.Sep 1 2016, 1:17 PM
tra marked an inline comment as done.
  • prefix local variables in macros.
  • check whether we've created a target before using it.
  • reset TARGET_VAR variable in llvm_test_executable, so end-user does not have to.
  • return target info from llvm_multisource. It was previously clobbered.

@MatzeB - I'd appreciate if you could take another look.

tra updated this revision to Diff 70441.Sep 6 2016, 11:47 AM

Use unique prefix for variables set by cmake_parse_arguments() so we don't clobber them by accident.
Updated Bitcode/simd_ops to use TARGET_VAR to figure out target name.

This revision was automatically updated to reflect the committed changes.