From a339cff87fc98859e58df8dbc9f9c15a06ed3530 Mon Sep 17 00:00:00 2001 From: "Alejandro W. Sior" Date: Mon, 23 Jan 2023 20:46:04 +0100 Subject: cook: bug fixes with arguments --- .build | 7 ++++++- cook.py | 11 +++++++++-- main.c | 7 +++++++ test/.build | 7 +++---- test/hai.c | 5 ++--- test/hai.h | 5 ++--- 6 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 main.c diff --git a/.build b/.build index 7f400fa..37bce4d 100644 --- a/.build +++ b/.build @@ -1,5 +1,10 @@ +this.include_dirs = [this.cwd()] + test = this('test') +this.objects = this.c.cc.gen('main.c', include_dirs=this.include_dirs) + this.c.exe('vol', - test.link + this.objects, + test.objects ) diff --git a/cook.py b/cook.py index d3b2909..51db323 100755 --- a/cook.py +++ b/cook.py @@ -252,10 +252,13 @@ class CC(Vec): def gen(self, *args, extra_args = [], include_dirs = [], dependencies = [], **kwargs): inputs = File.resolve(args) dependencies = flatten(dependencies) - + + include_dirs = [e for e in include_dirs] include_dirs += [d.include_dirs for d in dependencies if d.include_dirs] include_dirs = File.resolve(include_dirs) include_args = [self.mkinc(str(x)) for x in include_dirs] + + extra_args = [e for e in extra_args] extra_args += [d.cc_args for d in dependencies if d.cc_args] extra_args += include_args @@ -301,8 +304,11 @@ class CExe(Processor): def gen(self, name, *args, libs=[], dependencies = [], extra_args = [], **kwargs): libs = flatten(libs) dependencies = flatten(dependencies) - + + libs = [e for e in libs] libs += [d.libs for d in dependencies if d.libs] + + extra_args = [e for e in extra_args] extra_args += [d.ld_args for d in dependencies if d.ld_args] # Note: this is bad, perhaps take a "depends" also/instead @@ -533,6 +539,7 @@ _root = CMod(None, "") global this this = _root +this.cwd = Path.cwd global cook cook = AttrDict({ diff --git a/main.c b/main.c new file mode 100644 index 0000000..afee021 --- /dev/null +++ b/main.c @@ -0,0 +1,7 @@ +#include +#include + +int main() { + printf("%d\n", hai()); + return 0; +} diff --git a/test/.build b/test/.build index b7c10e0..ded9352 100644 --- a/test/.build +++ b/test/.build @@ -1,5 +1,4 @@ -objects = this.c.cc( - 'hai.c' +this.objects = this.c.cc.gen( + 'hai.c', + include_dirs = this.include_dirs ) - -this.object = this.c.lib('test', objects) diff --git a/test/hai.c b/test/hai.c index 7791fbb..752cd40 100644 --- a/test/hai.c +++ b/test/hai.c @@ -1,6 +1,5 @@ #include -int main() { - printf("Hello world!\n"); - return 0; +int hai() { + return 42; } diff --git a/test/hai.h b/test/hai.h index da27064..00eba1a 100644 --- a/test/hai.h +++ b/test/hai.h @@ -1,4 +1,3 @@ -void hai(); +int hai(); - -// test \ No newline at end of file +// test -- cgit v1.2.3