Split C and C++ libraries, so that you can use C++ compiler flags. Build with

C++17.
This commit is contained in:
David Given
2023-10-24 22:00:09 +02:00
parent 44fc532d63
commit ca6b90f8c1
9 changed files with 54 additions and 25 deletions

View File

@@ -11,6 +11,7 @@ from build.ab import (
stripext,
)
from os.path import *
from types import SimpleNamespace
def cfileimpl(self, name, srcs, deps, suffix, commands, label, kind, cflags):
@@ -81,17 +82,7 @@ def findsources(name, srcs, deps, cflags, filerule):
return objs
@Rule
def clibrary(
self,
name,
srcs: Targets = [],
deps: Targets = [],
hdrs: TargetsMap = {},
cflags=[],
commands=["$(AR) cqs {outs[0]} {ins}"],
label="LIB",
):
def libraryimpl(self, name, srcs, deps, hdrs, cflags, commands, label, kind):
if not srcs and not hdrs:
raise ABException(
"clibrary contains no sources and no exported headers"
@@ -124,6 +115,8 @@ def clibrary(
hdrouts += [dest]
i = i + 1
if not hasattr(self, "clibrary"):
self.clibrary = SimpleNamespace()
if srcs:
hr = None
if hdrcs:
@@ -141,7 +134,7 @@ def clibrary(
srcs,
deps + ([f"{name}_hdrs"] if hr else []),
cflags + ([f"-I{hr.normalrule.objdir}"] if hr else []),
cfile,
kind,
)
normalrule(
@@ -168,6 +161,38 @@ def clibrary(
self.clibrary.cflags = ["-I" + r.normalrule.objdir]
@Rule
def clibrary(
self,
name,
srcs: Targets = [],
deps: Targets = [],
hdrs: TargetsMap = {},
cflags=[],
commands=["$(AR) cqs {outs[0]} {ins}"],
label="LIB",
):
return libraryimpl(
self, name, srcs, deps, hdrs, cflags, commands, label, cfile
)
@Rule
def cxxlibrary(
self,
name,
srcs: Targets = [],
deps: Targets = [],
hdrs: TargetsMap = {},
cflags=[],
commands=["$(AR) cqs {outs[0]} {ins}"],
label="LIB",
):
return libraryimpl(
self, name, srcs, deps, hdrs, cflags, commands, label, cxxfile
)
def programimpl(
self, name, srcs, deps, cflags, ldflags, commands, label, filerule, kind
):