QB64-Phoenix-Edition / QB64pe

The QB64 Phoenix Edition Repository
https://qb64phoenix.com
Other
119 stars 26 forks source link

Allow easily specifying extra compiler flags in QB64 source files #49

Open mkilgore opened 2 years ago

mkilgore commented 2 years ago

This needs some analysis of the best way to do it, but the end idea is that we need a way to provide:

  1. Arbitrary compiler flags for the C++ compiler.
  2. Specify extra library locations
  3. Specify extra header locations
  4. Other stuff?

Note that there's definitely some potential messy stuff here. For one, all the DECLARE LIBRARY logic needs to be investigated to understand better how it works. The naming it allows is very lose and it does a whole lot of work to check common locations for matching .h, .dll, .so, .dylib, etc. files. Perhaps it allows for some of this already, and also I suspect QB64 will need to be able to find these files to work correctly. That last detail is where my second and third point come in - QB64 may need to know about the new locations, rather than just have them in an opaque string that gets tacked onto the compiler lines, so that may necessitate a few separate parameters rather than just one.

Separately, the location of the parameters in the compile string is actually important, which may necessitate multiple parameters - libraries need to be provided to the linker later on after the object files so that the linker knows the symbols needed from the library files. I'm pretty sure Include paths can be listed either at the beginning or the end, but I'm not 100% sure.

Interactions with #40 also need to be considered. Splitting up the output of the C++ source into many separate files that get linked together needs to be a goal, the benefits are large, and simply tacking the flags onto the end of every compile of those files may not make sense.

Perhaps a bit more lofty, it would probably be nice if we could just include arbitrary compile lines to be run at the beginning of the source. I see a decent number of people including regular C/C++ source in header files, which isn't a great approach. It would be pretty nice if we had something like this that people could do instead:

' These introduce extra flags to the compile lines
$compile-add: library: foobar2
$compile-add: include-path: /usr/include/foobar

' These just call the C or C++ compiler with these parameters when you build your .bas source
' That way you could provide separate .c or .cpp files without needing to compile them as a separate step
$compile: CPP: ./foobar.cpp -o ./foobar.o
$compile: C: ./foobar.c -o ./foobar.o
grymmjack commented 2 months ago

From a thread in developer-hideout - bump