c++ - Automatically choosing object files for compilation -


I have recently started to write in C Unit Test ++ project (use). Creating main project is quite simple: I use the GCC -MM and -MD flag to automatically generate dependency to your object files, then I I am linking together for all the object files. Produce is not executable any inspiration.

But as I am writing a unit test, is there any way or the GCC will know which object files are necessary to compile each test? Now, I have a simple solution (if you can call it) is useless as it collects all available object files for all the unit tests, which clearly (in terms of both time and space). Is there any way (make, gcc, SAD, or some need object files to the unit test in a forest) is divine, as how to generate dependency to the original source files ?

It seems that you have two groups of source files: that actually executes your program , and the second is that all unit tests I believe that their own main function of each unit test, and once the unit tests do not even need to call each other.

If all this is true, then you can put all the files from the first group in a static library, and link it to each unit test in that library. The linker will automatically pull the object files from the library, which are essential.

concrete Mekfiil conditions:

  LIBRARY_OBJECTS = ao bo co # etc. UNIT_TESTS = Ul U2 U3 U4 # etc. UNIT_TEST_OBJECTS = $ (UNIT_TESTS: = K O) Libprogram K A: $ (LIBRARY_OBJECTS) $ cr $ $ $? $ (UNIT_TESTS):%:% .o libprogram.a $ (cflgas) -o $ @ $ & lt; -lprogram  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -