1

Short: How do I use header only libraries with biicode?

Medium: When I try to build a block it includes example directories even though I try to set the dependencies explicitly in the biicode.conf of the published block.

Long: I'm trying to get the unity framework up and running, using biicode.

Unity is great as a unit testing framework for C because you do not need to compile any libraries. If you do your own mocks, you don't even have to run any scripts - there is just a single .c file to include in your compile and you are golden.

I've published the git repo to my biicode block paulbendixen/Unity and since there is no need for any compilation step beyond the c file that accompanies the header that should be included there is nothing else to do.

However, when I include the file, using #include "paulbendixen/Unity/src/unity.h" I get the error when doing bii cpp:build:

Code.c:2:28: fatal error: ProductionCode.h: No such file or directory
#include "ProductionCode.h"

This is in the examples folder and should therefore not be compiled, when I just want to use the unit testing part. Changing the [dependencies] to include unity.h = unity.c unity_internals.h hasn't helped either.

I'm pretty sure the problem should be resolved in the Unity/biicode.conf, but I haven't been able to find a thorough description of this file anywhere.

The simplicity of the Unity library should make it ideal for a build system such as bii, but it seems quite complex to set up.

If it helps, I've used the simple layout and the -r [github for throwtheswitch] option

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
Paul
  • 370
  • 3
  • 12
  • Did you run `bii find`? – wtjones Mar 15 '15 at 19:15
  • the error message says the file ProductionCode.h could not be found by the compiler. In general, this means there is missing an appropriate '-IpathToFile' on the end of the gcc compile statement. According to the bit of documentation I read, that info needs to be part of the biicode.conf file. – user3629249 Mar 15 '15 at 19:25
  • Can you please also point to your github repo? If you made changes, maybe push them to a biicode branch or something. – drodri Mar 15 '15 at 20:50
  • The problem is that the file ProductionCode.h is an example and it shouldn't even be compiled when including just unity.h unity.h only requires unity.c and unity_internal.h which are both in the same directory as unity.h – Paul Mar 15 '15 at 21:15
  • @drodri, the github is linked on the biicode page, since I used -r, I do not own the github profile, but since the only thing you need is to download 3-5 files and include them in the compilation, I hoped it wasn't necessary to fork and track the github repo – Paul Mar 15 '15 at 21:18
  • I am trying to build it, but having trouble, there are some files #included from others like "cmock.h", "one.h", "two.h"... "four.h" and others that are NOT in the codebase, but I cannot find if this unity library is depending on some other external code – drodri Mar 15 '15 at 22:10

1 Answers1

2

It is not that simple. Unity uses Rakefiles to build and run the tests, and they have lots of configuration. What can be done for quickly upload it to biicode is just to ignore the tests and publish just the files. This can be done writing a ignore.bii file with the contents:

docs/*
test/*
examples/*
*test*

Wrt to the biicode.conf, the only configuration necessary are the include paths:

[paths]
    src
    extras/fixture/src

You can check that the manual definition of dependencies is not necessary, if you run $ bii deps --files *unity.h

With these changes, it is possible to publish it. Nothing to build.

Then, to use it in other projects, I have been able to build simple tests:

#include "unity.h"

void testTrue(void){
    TEST_ASSERT(1);
    TEST_ASSERT_TRUE(1);
}

int main() {
  testTrue();
}

Just adding the following to the biicode.conf of the new project:

[requirements]
    diego/unityfork: 0

[includes]
    unity.h: diego/unityfork/src

It would probably be much easier to make biicode run and build the tests without ignoring them if it used the more typical CMake configuration instead of Rakefiles

drodri
  • 5,157
  • 15
  • 21
  • Adding the ignore file really did the trick, I hope this little nugget can help others trying to use libraries that are header only on other peoples githubs. – Paul Mar 16 '15 at 18:17
  • A single thing that is still off though, It seems to be downloading both fixture and base stuff, even though only the base stuff is needed. – Paul Mar 25 '15 at 19:01