dascandy / evoke

Magic build tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Library is built instead of executable

PenguinLemma opened this issue · comments

Describe the bug
I tried to build using Evoke a project that already has the structure required, as far as I understood. Structure is the following:

  • include/catch2/catch.h
  • src
    • main.cpp
    • several header files
  • test
    • main_tests.cpp
    • several classes (header + cpp)

In the case of the tests, an executable is created in bin, as I expected. In the case of src folder, although, Evoke decides to build a library. I would assume it should be an executable, given that main.cpp is a leaf node (not included anywhere else).

Of course, it could be that it's not a bug but that the project structure or my understanding of how library/executable build cases are chosen is wrong. In the second case, maybe I can help once I understand it better by adding some examples or clarification to the documentation.

To Reproduce
Steps to reproduce the behavior:

  1. Run git clone https://github.com/PenguinLemma/glancy.git in an empty folder.
  2. Run evoke -v from the same directory that git clone was run.

I could provide a simpler example, if necessary (I haven't tried it yet, though).

Expected behavior
A clear and concise description of what you expected to happen. Even if it's very obvious to you from the error it still helps us not accidentally fix the problem in another direction.

Screenshots/Logs
You can find the log after running evoke -v here:
log.txt

System (please complete the following information):

  • OS: Ubuntu 18.04
  • Compiler: GCC
  • Version: 7.4
  • Usage: command line

test folder is also a component, which use main as a library.
try split main component into two part, a library and a executable using the previous library.
the library can have a test folder, but the executable can't.

Thank you for your quick answer @hl4!

I'll try again once I'm back at home, changing the structure and isolating the main.cpp as a component itself (putting the tests inside the other component(s) - where the headers that are right now inside src will be).

If I understand correctly, then, for a component to be built as an executable, it can't contain a test folder, isn't it? Or is it that in the case of having a test folder then all files included from the tests should be part of a library already (for example, if the header included is a class and there is a .cpp file containing the implementations).

Thanks again! I will get back as soon as I try what you suggested.

I finally could put some time to fix this. I actually ended re-estructuring my code quite a lot and to be honest, it's a big improvement!

You can see the new structure here.

One thing that calls my attention is that when I build some of the simple projects I created just to test things related to evoke I get no error or warning, but when building glancy I get the following console output:

Building for gcc
Unknown header: windows.h
Unknown header: sys/sysctl.h
Unknown header: Foundation/Foundation.h
Unknown header: objc/runtime.h
Unknown header: AfxWin.h
Unknown header: crtdbg.h
Unknown header: cfloat

It's a bit strange that it would even check for the windows header... Could it be that I'm including something that I shouldn't? Is that intended to happen? (see system information in the first comment).

Thanks in advance!

These are all headers from Catch2, which you've checked into your repository.

The Evoke rule for deciding if you get a library is if anything (at all!) includes a header from your component. If anything needs to link to you, then you must be a library, otherwise you must be an executable. So far I've found this to lead to better componentization and not to be too restrictive.