Closed NiklasRosenstein closed 8 years ago
How about passing a second parameter to load_module('compiler', 'c') then C.executable(...) And C.objects(...)
On Wed, Oct 7, 2015, 5:08 AM Niklas Rosenstein notifications@github.com wrote:
The compiler modules should get rule functions that will generate the correct commands to build object files, libraries and executables.
C = load_module('compiler') build_dir = join(project_dir, 'build')
C.cc_objects('Objects', sources = glob(join(projectdir, 'src/*/_.c')), includes = [join(project_dir, 'include')], )
C.cc_executable('Bin', program = 'main', inputs = Objects, )
— Reply to this email directly or view it on GitHub https://github.com/craftr-build/craftr/issues/14.
There might be data in the module that you would want to use when declaring a target, eg. let's say to enable all warnings.
C.cc_objects('Objects',
sources = glob(join(project_dir, 'src/*.c')),
additional_flags = [C.wall],
)
But yes, maybe something like this would be possible instead, but all flags would need to be duplicated on the C
and CXX
objects.
C = load_module('compiler').C
C.objects('Objects',
sources = glob(join(project_dir, 'src/*.c')),
additional_flags = [C.wall],
)
I can imagine that it could become a cleaner implementation using classes and inheritance, though, so thanks for the idea.
As long as setting the flags is obvious and easy seems reasonable. I assume based on what you've written the syntax for other 'compiler's' would be:
Cxx = load_module('compiler').cxx Asm = load_module('compiler').asm ....
Also, is it going to be "easy" for programmers to create there own 'compiler' modules and 'register" them with Creatr?
On Sun, Oct 11, 2015 at 6:41 AM Niklas Rosenstein notifications@github.com wrote:
There might be data in the module that you would want to use when declaring a target, eg. let's say to enable all warnings.
C.cc_objects('Objects', sources = glob(join(project_dir, 'src/*.c')), additional_flags = [C.wall], )
But yes, maybe something like this would be possible instead, but all flags would need to be duplicated on the C and CXX objects.
C = load_module('compiler').C C.objects('Objects', sources = glob(join(project_dir, 'src/*.c')), additional_flags = [C.wall], )
— Reply to this email directly or view it on GitHub https://github.com/craftr-build/craftr/issues/14#issuecomment-147192931.
Whoops Craftr :)
On Sun, Oct 11, 2015 at 6:49 PM Wink Saville wink@saville.com wrote:
As long as setting the flags is obvious and easy seems reasonable. I assume based on what you've written the syntax for other 'compiler's' would be:
Cxx = load_module('compiler').cxx Asm = load_module('compiler').asm ....
Also, is it going to be "easy" for programmers to create there own 'compiler' modules and 'register" them with Creatr?
On Sun, Oct 11, 2015 at 6:41 AM Niklas Rosenstein < notifications@github.com> wrote:
There might be data in the module that you would want to use when declaring a target, eg. let's say to enable all warnings.
C.cc_objects('Objects', sources = glob(join(project_dir, 'src/*.c')), additional_flags = [C.wall], )
But yes, maybe something like this would be possible instead, but all flags would need to be duplicated on the C and CXX objects.
C = load_module('compiler').C C.objects('Objects', sources = glob(join(project_dir, 'src/*.c')), additional_flags = [C.wall], )
— Reply to this email directly or view it on GitHub https://github.com/craftr-build/craftr/issues/14#issuecomment-147192931 .
Almost, yes. Currently it looks like this:
# craftr_module(hello_world)
P = load_module('platform')
Cxx = load_module('compiler').CxxCompiler()
Cxx.detect()
build_dir = join(project_dir, 'build')
Cxx.objects(
'Objects',
sources = glob(join(project_dir, 'source/**/*.cpp')),
)
Cxx.executable(
'Program',
name = join(build_dir, 'main'),
inputs = [Objects],
)
Implemented in c90c4a7.
The minimum would be: release (-O2), debug (-O0 -g), debugoptimized (-O2 -g) but critically the author needs to be able to remove any predefined flags and provide exactly what the author requires. In Meson these are "buildtype's" and one of them is "plain" which sets the "compiler" flags globally always to empty when creating a compiler. I suggest Craftr should allow the flags to be defined as each "compiler" is created and the syntax should allow adding to the defaults or replace the defaults.
My two centavos :)
On Wed, Oct 14, 2015 at 6:33 AM Niklas Rosenstein notifications@github.com wrote:
Closed #14 https://github.com/craftr-build/craftr/issues/14.
— Reply to this email directly or view it on GitHub https://github.com/craftr-build/craftr/issues/14#event-435203796.
The
compiler
modules should get rule functions that will generate the correct commands to build object files, libraries and executables.