userland: start per-directory flags with userland/gcc

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-03-13 00:00:01 +00:00
parent a85ca696c4
commit e32dcb85e9
4 changed files with 45 additions and 17 deletions

View File

@@ -17,6 +17,8 @@ class Main(common.BuildCliFunction):
Build our compiled userland examples.
'''
)
self.default_cstd = 'c11'
self.default_cxxstd = 'c++17'
self.add_argument(
'--has-package',
action='append',
@@ -45,11 +47,12 @@ Default: build all examples that have their package dependencies met, e.g.:
in_path,
out_path,
ccflags,
extra_deps=None,
link=True,
extra_objs=None,
std=None,
ccflags_after=None,
cstd=None,
cxxstd=None,
extra_deps=None,
extra_objs=None,
link=True,
raise_on_failure=True,
thread_limiter=None,
):
@@ -69,15 +72,19 @@ Default: build all examples that have their package dependencies met, e.g.:
do_compile = True
if in_ext == self.env['c_ext']:
cc = self.env['gcc']
if std is None:
std = 'c11'
if cstd is None:
std = self.default_cstd
else:
std = cstd
ccflags.extend([
'-fopenmp', LF,
])
elif in_ext == self.env['cxx_ext']:
cc = self.env['gxx']
if std is None:
std = 'c++17'
if cxxstd is None:
std = self.default_cxxstd
else:
std = cxxstd
else:
do_compile = False
if do_compile:
@@ -121,7 +128,6 @@ Default: build all examples that have their package dependencies met, e.g.:
'-Werror', LF,
'-Wextra', LF,
'-Wno-unused-function', LF,
'-pedantic', LF,
'-ggdb3', LF,
]
if self.env['static']:
@@ -183,6 +189,15 @@ Default: build all examples that have their package dependencies met, e.g.:
dirpath_relative_root
)
os.makedirs(out_dir, exist_ok=True)
ccflags_dir = ccflags.copy()
if dirpath_relative_root_components == ['gcc']:
cstd = 'gnu11'
cxxstd = 'gnu++17'
else:
cstd = self.default_cstd
cxxstd = self.default_cxxstd
# -pedantic complains even if we use -std=gnu11.
ccflags_dir.extend(['-pedantic', LF])
for in_filename in in_filenames:
in_path = os.path.join(path, in_filename)
in_name, in_ext = os.path.splitext(in_filename)
@@ -191,7 +206,7 @@ Default: build all examples that have their package dependencies met, e.g.:
in_name + self.env['userland_build_ext']
)
pkg_key = in_name.split('_')[0]
ccflags_file = ccflags.copy()
ccflags_file = ccflags_dir.copy()
ccflags_after = []
if pkg_key in pkgs:
if pkg_key not in has_packages:
@@ -221,13 +236,15 @@ Default: build all examples that have their package dependencies met, e.g.:
thread = threading.Thread(
target=self._build_one,
kwargs={
'in_path':in_path,
'out_path':out_path,
'ccflags':ccflags_file,
'extra_objs':[common_obj],
'ccflags_after':ccflags_after,
'raise_on_failure':False,
'thread_limiter':thread_limiter,
'in_path': in_path,
'out_path': out_path,
'ccflags': ccflags_file,
'cstd': cstd,
'cxxstd': cxxstd,
'extra_objs': [common_obj],
'ccflags_after': ccflags_after,
'raise_on_failure': False,
'thread_limiter': thread_limiter,
}
)
thread.start()