diff options
| author | Alejandro Sior <aho@sior.be> | 2022-08-06 12:22:34 +0200 |
|---|---|---|
| committer | Alejandro Sior <aho@sior.be> | 2022-08-06 12:22:34 +0200 |
| commit | 25027ef496681ff6f45386f98f9b81b465659e5b (patch) | |
| tree | ee256c42033129f9475d41c77b40d9d78438e936 /cook.py | |
| parent | 67df19f642d56a05f9a5ef7154e8c358a184ae40 (diff) | |
cook: warn when instanciating default toolchains with non-default arguments
Diffstat (limited to 'cook.py')
| -rwxr-xr-x | cook.py | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -1,11 +1,15 @@ #!/usr/bin/python +import sys import os from pathlib import Path from threading import local import shutil import argparse +def error(*args): + print(*args, file = sys.stderr) + def find_program(prog, required=True): path = shutil.which(prog) if path == None and required: @@ -253,7 +257,7 @@ class CExe(Processor): return super().gen(name, *args, extra_args = extra_args) -def CCStyleToolchain(name, ccname, arname, suffix="", c_args=[], ld_args=[]): +def CCStyleToolchain(name, gccname, arname, suffix="", c_args=[], ld_args=[]): ccname = name + suffix exename = name + "exe" + suffix libname = name + "lib" + suffix @@ -262,7 +266,7 @@ def CCStyleToolchain(name, ccname, arname, suffix="", c_args=[], ld_args=[]): c_args = " ".join(flatten(c_args)) ld_args = " ".join(flatten(ld_args)) - gcc = find_program(ccname) + gcc = find_program(gccname) ar = find_program(arname) cc = CC( @@ -314,15 +318,19 @@ CTOOLCHAINS = { 'clang': ClangToolchain, 'gcc': GccToolchain } - + def CToolchain(name="system", suffix="", c_args=[], ld_args=[]): + if suffix == "" and (c_args != [] or ld_args != []): + error("warning: instanciating default toolchain %s with non-default arguments" % (name)) + error("note: to fix this, add a suffix") + if name != "system": if not name in CTOOLCHAINS: raise Exception("No such C toolchain available") return CTOOLCHAINS[name](suffix, c_args, ld_args) - + for t in CTOOLCHAINS.values(): try: return t(suffix, c_args, ld_args) @@ -332,7 +340,7 @@ def CToolchain(name="system", suffix="", c_args=[], ld_args=[]): raise Exception("No C toolchain found on system") global cc, exe, lib, shlib -cc, exe, lib, shlib = CToolchain("clang") +cc, exe, lib, shlib = CToolchain() def find_one(names): for name in names: |
