aedi: do not set c/c++ compilers and sdk paths without a platform

default pathlib's path means '.' (the current directory) but not an invalid path
This commit is contained in:
alexey.lysiuk 2021-09-01 11:41:08 +03:00
parent 300b9d4ad3
commit 59b8b2a7e1
4 changed files with 32 additions and 14 deletions

View file

@ -67,13 +67,13 @@ class BuildState:
return self.platform.os_version if self.platform else None
def sdk_path(self) -> Path:
return self.platform.sdk_path if self.platform else Path()
return self.platform.sdk_path if self.platform else None
def c_compiler(self) -> Path:
return self.platform.c_compiler if self.platform else Path()
return self.platform.c_compiler if self.platform else None
def cxx_compiler(self) -> Path:
return self.platform.cxx_compiler if self.platform else Path()
return self.platform.cxx_compiler if self.platform else None
def checkout_git(self, url: str, branch: str = None):
if self.source.exists():

View file

@ -99,8 +99,10 @@ class BuildTarget(Target):
if state.xcode:
return
env['CC'] = str(state.c_compiler())
env['CXX'] = str(state.cxx_compiler())
if c_compiler := state.c_compiler():
env['CC'] = str(c_compiler)
if cxx_compiler := state.cxx_compiler():
env['CXX'] = str(cxx_compiler)
for prefix in ('CPP', 'C', 'CXX', 'OBJC', 'OBJCXX'):
var_name = f'{prefix}FLAGS'
@ -281,9 +283,13 @@ class MakeTarget(BuildTarget):
args = [
self.tool,
'-j', state.jobs,
f'CC={state.c_compiler()}',
f'CXX={state.cxx_compiler()}',
]
if c_compiler := state.c_compiler():
args.append(f'CC={c_compiler}')
if cxx_compiler := state.cxx_compiler():
args.append(f'CXX={cxx_compiler}')
args += state.options.to_list()
work_path = state.build_path / self.src_root
@ -395,8 +401,11 @@ class CMakeTarget(BuildTarget):
args.append('-GXcode')
else:
args.append('-GUnix Makefiles')
args.append(f'-DCMAKE_C_COMPILER={state.c_compiler()}')
args.append(f'-DCMAKE_CXX_COMPILER={state.cxx_compiler()}')
if c_compiler := state.c_compiler():
args.append(f'-DCMAKE_C_COMPILER={c_compiler}')
if cxx_compiler := state.cxx_compiler():
args.append(f'-DCMAKE_CXX_COMPILER={cxx_compiler}')
architecture = state.architecture()
if architecture != machine():

View file

@ -157,6 +157,12 @@ class GlibTarget(BuildTarget):
environment = state.environment
environment['LDFLAGS'] += ' -framework CoreFoundation -framework Foundation'
c_compiler = state.c_compiler()
assert c_compiler
cxx_compiler = state.cxx_compiler()
assert cxx_compiler
cpu = state.architecture()
cpu_family = 'arm' if 'arm64' == cpu else cpu
@ -164,10 +170,10 @@ class GlibTarget(BuildTarget):
with open(cross_file, 'w') as f:
f.write(f'''
[binaries]
c = '{state.c_compiler()}'
cpp = '{state.cxx_compiler()}'
objc = '{state.c_compiler()}'
objcpp = '{state.cxx_compiler()}'
c = '{c_compiler}'
cpp = '{cxx_compiler}'
objc = '{c_compiler}'
objcpp = '{cxx_compiler}'
pkgconfig = '{state.prefix_path}/bin/pkg-config'
strip = '/usr/bin/strip'

View file

@ -217,8 +217,11 @@ class ZipTarget(MakeTarget):
return state.has_source_file('zip.h')
def build(self, state: BuildState):
c_compiler = state.c_compiler()
assert c_compiler
args = [
str(state.c_compiler()),
str(c_compiler),
'-O3', '-I.', '-DUNIX',
'-DBZIP2_SUPPORT', '-DLARGE_FILE_SUPPORT', '-DUNICODE_SUPPORT',
'-DHAVE_DIRENT_H', '-DHAVE_TERMIOS_H',