summaryrefslogtreecommitdiff
path: root/cook.py
diff options
context:
space:
mode:
Diffstat (limited to 'cook.py')
-rwxr-xr-xcook.py46
1 files changed, 35 insertions, 11 deletions
diff --git a/cook.py b/cook.py
index 9ff581a..d3b2909 100755
--- a/cook.py
+++ b/cook.py
@@ -1,13 +1,33 @@
#!/usr/bin/python
+# the cook build system 0.1.0
+#
+# Copyright 2023 Alejandro W. Sior
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject
+# to the following conditions:
+
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import subprocess
import sys
import os
from pathlib import Path
-from threading import local
import shutil
import argparse
-from xml.etree.ElementInclude import include
def error(*args):
print(*args, file = sys.stderr)
@@ -229,14 +249,14 @@ class CC(Vec):
def __call__(self, *args, **kwargs):
return self.gen(*args, **kwargs)
- def gen(self, *args, extra_args = [], include_dirs = [], deps = [], **kwargs):
+ def gen(self, *args, extra_args = [], include_dirs = [], dependencies = [], **kwargs):
inputs = File.resolve(args)
- deps = flatten(deps)
+ dependencies = flatten(dependencies)
- include_dirs += [d.include_dirs for d in deps if d.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 += [d.cc_args for d in deps if d.cc_args]
+ extra_args += [d.cc_args for d in dependencies if d.cc_args]
extra_args += include_args
targets = []
@@ -278,12 +298,12 @@ class CExe(Processor):
def __call__(self, *args, **kwargs):
return self.gen(*args, **kwargs)
- def gen(self, name, *args, libs=[], deps = [], extra_args = [], **kwargs):
+ def gen(self, name, *args, libs=[], dependencies = [], extra_args = [], **kwargs):
libs = flatten(libs)
- deps = flatten(deps)
+ dependencies = flatten(dependencies)
- libs += [d.libs for d in deps if d.libs]
- extra_args += [d.ld_args for d in deps if d.ld_args]
+ libs += [d.libs for d in dependencies if d.libs]
+ extra_args += [d.ld_args for d in dependencies if d.ld_args]
# Note: this is bad, perhaps take a "depends" also/instead
# XXX Handling of libraries is temporary
@@ -520,6 +540,10 @@ cook = AttrDict({
'cpp': CppToolchain()
})
+# Set default toolchains
+this.c = cook.c
+this.cpp = cook.cpp
+
pkgconfig = find_program("pkg-config", False)
def subproc(*args, **kwargs):
@@ -601,7 +625,7 @@ def gen_ninja():
return "".join(out)
-parser = argparse.ArgumentParser(description="cook build system")
+parser = argparse.ArgumentParser(description="cook build system 0.1.0")
parser.add_argument("-G", type=str, metavar="backend", help="Backend to generate for: ninja or makefile")
args = parser.parse_args()