esrlabs / bake

C++ build tool
http://esrlabs.github.io/bake
Other
26 stars 11 forks source link

Missing documentation for external files used in unittests(If possible) #151

Closed Tobias891 closed 7 years ago

Tobias891 commented 7 years ago

Environment: Eclipse

When I have two Projects in two different Folders. One for Code and one for Unit Tests. -Code |---SwPart1
----|----M1 -----------|-m1.cpp -----------|-m1.h |---Swpart2 ----|......

  |-SwUnitTests
  |---SwPart1
  |---------M1Test
  |-----------(folders: Mocks etc.)
  | ..................................

I don't wart to copy the files into the M1Test folder. So How can I link them in the UT Project? Tried: -Link source with eclipse -> "Source file 'M1/M1.cpp not found"

-Files "../../../../../../../Code/xx/xx/xx/xx/xx/M1.cpp | .h" IncludeDir "../../../../../../../Code/xx/xx/xx/xx" -> documentation says "All files must be in the same Project. " ->Builds but in the build folder every "../" is one "" folder. The result is, no tool can handle this. (like gcovr: map "build/UT////////Code/xx/xx/xx/xx/xx/M1.o | etc." to C:/x/y/z/code/swPart1/............./M1.cpp

-absolute Path in "Files" and "IncludeDir" -> More people work on the project and some build server use it to -> looks like bad idea and also the output (m1.o etc) is in the Code folder.

Is there any possible solution for this problem?

Thanks Tobias

aschaal commented 7 years ago

Yes, you can do the following (simplified):

M1/Project.meta:

LibraryConfig Lib {
  Files "src/*.cpp"
}

M1Test/Project.meta:

ExecutableConfig UnitTest {
  Dependency M1, config: Lib
  Files "src/*.cpp"
}

You only need to specify where bake shall look for M1. Default is ".." from main project, but you can use "-w" from commandline or a roots.bake file (see http://esrlabs.github.io/bake/commandline/commandline.html). This applies to all builds, not only UT.

Is that enough information?

aschaal commented 7 years ago

It is planned "someday" to completely refactor the docu, so I will close this ticket here.