From 165cba8cf353647bfefaa81e035aedbd30c6c7f2 Mon Sep 17 00:00:00 2001 From: "Alejandro W. Sior" Date: Mon, 23 Jan 2023 20:14:07 +0100 Subject: add license --- .build | 11 ++++------- cook.py | 46 +++++++++++++++++++++++++++++++++++----------- test/.build | 6 +++++- 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/.build b/.build index e35e8b6..7f400fa 100644 --- a/.build +++ b/.build @@ -1,8 +1,5 @@ -this.c = cook.c +test = this('test') -this.ld_args = [] -this.deps = [] - -objects = this.c.cc(deps = [this('test')]) - -this.c.exe("vol", objects) +this.c.exe('vol', + test.link +) 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() diff --git a/test/.build b/test/.build index 474ca48..b7c10e0 100644 --- a/test/.build +++ b/test/.build @@ -1 +1,5 @@ -this.source = ['hai.c'] +objects = this.c.cc( + 'hai.c' +) + +this.object = this.c.lib('test', objects) -- cgit v1.2.3