summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro W. Sior <aho@sior.be>2023-01-23 20:46:04 +0100
committerAlejandro W. Sior <aho@sior.be>2023-01-23 20:46:04 +0100
commita339cff87fc98859e58df8dbc9f9c15a06ed3530 (patch)
tree8a236d7425191c498c6213bca003859b574d9734
parent165cba8cf353647bfefaa81e035aedbd30c6c7f2 (diff)
cook: bug fixes with argumentsHEADmaster
-rw-r--r--.build7
-rwxr-xr-xcook.py11
-rw-r--r--main.c7
-rw-r--r--test/.build7
-rw-r--r--test/hai.c5
-rw-r--r--test/hai.h5
6 files changed, 29 insertions, 13 deletions
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 <stdio.h>
+#include <test/hai.h>
+
+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 <stdio.h>
-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