Skip to content

Commit

Permalink
update build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansson committed May 20, 2020
1 parent ae1cc92 commit 700c1c5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build/ninja/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def initialize_toolchain(self):
else:
self.hostarchname = 'windows-x86'
elif self.host.is_linux():
localarch = subprocess.check_output(['uname', '-m']).strip()
localarch = toolchain.check_output(['uname', '-m'])
if localarch == 'x86_64':
self.hostarchname = 'linux-x86_64'
else:
Expand Down
25 changes: 13 additions & 12 deletions build/ninja/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def initialize(self, project, archs, configs, includepaths, dependlibs, libpaths
#Base flags
self.cflags = ['-D' + project.upper() + '_COMPILE=1',
'-funit-at-a-time', '-fstrict-aliasing', '-fvisibility=hidden', '-fno-stack-protector',
'-fno-math-errno','-ffinite-math-only', '-funsafe-math-optimizations',
'-fomit-frame-pointer', '-fno-math-errno','-ffinite-math-only', '-funsafe-math-optimizations',
'-fno-trapping-math', '-ffast-math']
self.cwarnflags = ['-W', '-Werror', '-pedantic', '-Wall', '-Weverything',
'-Wno-padded', '-Wno-documentation-unknown-command',
Expand Down Expand Up @@ -250,15 +250,15 @@ def build_xcode_toolchain(self):
self.linkflags += ['-isysroot', '$sysroot']
self.cflags += ['-fembed-bitcode-marker']

platformpath = subprocess.check_output(['xcrun', '--sdk', sdk, '--show-sdk-platform-path']).strip()
platformpath = toolchain.check_output(['xcrun', '--sdk', sdk, '--show-sdk-platform-path'])
localpath = platformpath + "/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"

self.sysroot = subprocess.check_output(['xcrun', '--sdk', sdk, '--show-sdk-path']).strip()
self.sysroot = toolchain.check_output(['xcrun', '--sdk', sdk, '--show-sdk-path'])

self.ccompiler = "PATH=" + localpath + " " + subprocess.check_output(['xcrun', '--sdk', sdk, '-f', 'clang']).strip()
self.archiver = "PATH=" + localpath + " " + subprocess.check_output(['xcrun', '--sdk', sdk, '-f', 'libtool']).strip()
self.ccompiler = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'clang'])
self.archiver = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'libtool'])
self.linker = deploytarget + " " + self.ccompiler
self.lipo = "PATH=" + localpath + " " + subprocess.check_output(['xcrun', '--sdk', sdk, '-f', 'lipo']).strip()
self.lipo = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'lipo'])

self.mflags += list(self.cflags) + ['-fobjc-arc', '-fno-objc-exceptions', '-x', 'objective-c']
self.cflags += ['-x', 'c']
Expand Down Expand Up @@ -345,13 +345,11 @@ def make_cconfigflags(self, config, targettype):
if config == 'debug':
flags += ['-DBUILD_DEBUG=1']
elif config == 'release':
flags += ['-DBUILD_RELEASE=1']
flags += ['-DBUILD_RELEASE=1', '-O3', '-funroll-loops']
elif config == 'profile':
flags += ['-DBUILD_PROFILE=1']
flags += ['-DBUILD_PROFILE=1', '-O3', '-funroll-loops']
elif config == 'deploy':
flags += ['-DBUILD_DEPLOY=1']
if config != 'debug':
flags += ['-O3', '-fomit-frame-pointer', '-funroll-loops', '-flto']
flags += ['-DBUILD_DEPLOY=1', '-O3', '-funroll-loops']
return flags

def make_ararchflags(self, arch, targettype):
Expand Down Expand Up @@ -392,6 +390,9 @@ def make_linkconfigflags(self, config, targettype, variables):
else:
if targettype == 'sharedlib':
flags += ['-shared', '-fPIC']
if config != 'debug':
if targettype == 'bin' or targettype == 'sharedlib':
flags += ['-flto']
return flags

def make_linkarchlibs(self, arch, targettype):
Expand Down Expand Up @@ -479,7 +480,7 @@ def link_variables(self, config, arch, targettype, variables):
localframeworks += list(variables['frameworks'])
if len(localframeworks) > 0:
localvariables += [('frameworks', self.make_frameworks(list(localframeworks)))]

libpaths = []
if 'libpaths' in variables:
libpaths = variables['libpaths']
Expand Down
9 changes: 7 additions & 2 deletions build/ninja/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
import android
import xcode


def check_output(args):
import subprocess
return subprocess.check_output(args).decode().strip()

def supported_toolchains():
return ['msvc', 'gcc', 'clang', 'intel']

Expand Down Expand Up @@ -380,10 +385,10 @@ def build_sources(self, writer, nodetype, multitype, module, sources, binfile, b
sourcevariables = (variables or {}).copy()
sourcevariables.update({
'includepaths': self.depend_includepaths + self.prefix_includepaths(list(includepaths))})
if not libs and dependlibs != None:
if not libs:
libs = []
if dependlibs != None:
libs = (dependlibs or []) + libs
libs = [] + (dependlibs or []) + libs
nodevariables = (variables or {}).copy()
nodevariables.update({
'libs': libs,
Expand Down
10 changes: 5 additions & 5 deletions build/ninja/xcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def build_toolchain(self):
sdk = 'iphoneos'
deploytarget = 'IPHONEOS_DEPLOYMENT_TARGET=' + self.deploymenttarget

platformpath = subprocess.check_output(['xcrun', '--sdk', sdk, '--show-sdk-platform-path']).strip()
platformpath = toolchain.check_output(['xcrun', '--sdk', sdk, '--show-sdk-platform-path'])
localpath = platformpath + "/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"

self.plist = "PATH=" + localpath + " " + subprocess.check_output(['xcrun', '--sdk', sdk, '-f', 'plutil']).strip()
self.xcassets = "PATH=" + localpath + " " + subprocess.check_output(['xcrun', '--sdk', sdk, '-f', 'actool']).strip()
self.xib = "PATH=" + localpath + " " + subprocess.check_output(['xcrun', '--sdk', sdk, '-f', 'ibtool']).strip()
self.dsymutil = "PATH=" + localpath + " " + subprocess.check_output(['xcrun', '--sdk', sdk, '-f', 'dsymutil']).strip()
self.plist = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'plutil'])
self.xcassets = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'actool'])
self.xib = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'ibtool'])
self.dsymutil = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'dsymutil'])

self.plistcmd = 'build/ninja/plist.py --exename $exename --prodname $prodname --bundle $bundleidentifier --target $target --deploymenttarget $deploymenttarget --output $outpath $in'
if self.target.is_macos():
Expand Down

0 comments on commit 700c1c5

Please sign in to comment.