Skip to content

Compile each non-test cpp file separately first and link object files #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hlovdal opened this issue Feb 5, 2019 · 1 comment
Open
Labels
enhancement New feature or request rubygem Ruby code is affected

Comments

@hlovdal
Copy link
Contributor

hlovdal commented Feb 5, 2019

This is a feature request. Currently the command to compile a unit test binary is one g++ invocation with all the required cpp files given as arguments in addition to the unit test cpp file. Could you change this so that the non-unit tests cpp files are compiled to object files separately first, and then just linked with the unit test binary? Also before compiling an object file, skip compilation if the object file already exists.

E.g.

foreach (file in cpp_files_arduino and cpp_files)
   obj_file = get_obj_file_name(file)
   if (!exists obj_file)
       compile file

foreach (file in cpp_files_unittest)
    compile file, corresponding_obj_files

This is required in order to support code coverage result accumulated from multiple unit test binaries (see this answer for details). And regardless of code coverage support, this will be a compilation time improvement when there are multiple unit test files because the source files do not have to be compiled multiple times.

@ianfixes ianfixes added enhancement New feature or request rubygem Ruby code is affected not yet Awaits better environmental conditions labels Feb 5, 2019
@ianfixes
Copy link
Collaborator

ianfixes commented Feb 5, 2019

I like the idea of providing code coverage, in the most accurate way possible. I was going to delay this feature a bit, but after sleeping on it I think it can go forward.

My initial reservation was that this feature request is related to a much deeper (and darker) problem to solved: how to generate a build strategy for 3 separate codebases

  1. the arduino unit testing apparatus
  2. any dependencies on Arduino libraries, their subfolders, their subdependencies, etc
  3. the actual library under test

Most Arduino libraries seem to include few if any dependencies on other libraries, so I assume that pure luck is the reason that arduino_ci has been a usable and useful tool when it comes to unit testing. I'm holding out hope that this project will come to some sort of critical mass, at which point the Arduino IDE can do most of the heavy lifting on sorting out build order and argument lists for g++.

But in this case, all that's really happening is doing the same build strategy but converting all the non-unittest files to objects beforehand, then referring to their corresponding .o in the g++ command.

One thing that I'm not handling right now is the idea of files that are not unittests themselves, but common to the unit test files. Aside from that, I will see about doing this.

@ianfixes ianfixes removed the not yet Awaits better environmental conditions label Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rubygem Ruby code is affected
Projects
None yet
Development

No branches or pull requests

2 participants