mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-01-11 15:38:12 +00:00
waf: add strip_on_install plugin from engine repository
This commit is contained in:
parent
a9d9f475b0
commit
d9c5b04c54
46
scripts/waifulib/strip_on_install.py
Normal file
46
scripts/waifulib/strip_on_install.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
# Modified: Alibek Omarov <a1ba.omarov@gmail.com>
|
||||||
|
# Originally taken from Thomas Nagy's blogpost
|
||||||
|
|
||||||
|
"""
|
||||||
|
Strip executables upon installation
|
||||||
|
"""
|
||||||
|
|
||||||
|
import shutil, os
|
||||||
|
from waflib import Build, Utils, Context, Errors, Logs
|
||||||
|
|
||||||
|
def options(opt):
|
||||||
|
grp = opt.option_groups['install/uninstall options']
|
||||||
|
grp.add_option('--no-strip', dest='no_strip', action='store_true', default=False,
|
||||||
|
help='don\'t strip binaries. You must pass this flag to install command(default: False)')
|
||||||
|
|
||||||
|
def configure(conf):
|
||||||
|
if conf.env.DEST_BINFMT in ['elf', 'mac-o']:
|
||||||
|
conf.find_program('strip')
|
||||||
|
if not conf.env.STRIPFLAGS:
|
||||||
|
conf.env.STRIPFLAGS = os.environ['STRIPFLAGS'] if 'STRIPFLAGS' in os.environ else []
|
||||||
|
|
||||||
|
def copy_fun(self, src, tgt):
|
||||||
|
inst_copy_fun(self, src, tgt)
|
||||||
|
|
||||||
|
if self.generator.bld.options.no_strip:
|
||||||
|
return
|
||||||
|
|
||||||
|
if conf.env.DEST_BINFMT not in ['elf', 'mac-o']: # don't strip unknown formats or PE
|
||||||
|
return
|
||||||
|
|
||||||
|
if getattr(self.generator, 'link_task', None) and self.generator.link_task.outputs[0] in self.inputs:
|
||||||
|
cmd = self.env.STRIP + self.env.STRIPFLAGS + [tgt]
|
||||||
|
try:
|
||||||
|
if not self.generator.bld.progress_bar:
|
||||||
|
c1 = Logs.colors.NORMAL
|
||||||
|
c2 = Logs.colors.CYAN
|
||||||
|
|
||||||
|
Logs.info('%s+ strip %s%s%s', c1, c2, tgt, c2)
|
||||||
|
self.generator.bld.cmd_and_log(cmd, output=Context.BOTH, quiet=Context.BOTH)
|
||||||
|
except Errors.WafError as e:
|
||||||
|
print(e.stdout, e.stderr)
|
||||||
|
|
||||||
|
inst_copy_fun = Build.inst.copy_fun
|
||||||
|
Build.inst.copy_fun = copy_fun
|
||||||
|
|
@ -187,6 +187,9 @@ class Android:
|
|||||||
triplet = self.ndk_triplet() + '-'
|
triplet = self.ndk_triplet() + '-'
|
||||||
return os.path.join(self.gen_gcc_toolchain_path(), 'bin', triplet)
|
return os.path.join(self.gen_gcc_toolchain_path(), 'bin', triplet)
|
||||||
|
|
||||||
|
def gen_binutils_path(self):
|
||||||
|
return os.path.join(self.gen_gcc_toolchain_path(), self.ndk_triplet(), 'bin')
|
||||||
|
|
||||||
def cc(self):
|
def cc(self):
|
||||||
if self.is_host():
|
if self.is_host():
|
||||||
return 'clang'
|
return 'clang'
|
||||||
@ -197,6 +200,11 @@ class Android:
|
|||||||
return 'clang++'
|
return 'clang++'
|
||||||
return self.toolchain_path + ('clang++' if self.is_clang() else 'g++')
|
return self.toolchain_path + ('clang++' if self.is_clang() else 'g++')
|
||||||
|
|
||||||
|
def strip(self):
|
||||||
|
if self.is_host():
|
||||||
|
return 'strip'
|
||||||
|
return os.path.join(self.gen_binutils_path(), 'strip')
|
||||||
|
|
||||||
def system_stl(self):
|
def system_stl(self):
|
||||||
# TODO: proper STL support
|
# TODO: proper STL support
|
||||||
return os.path.abspath(os.path.join(self.ndk_home, 'sources', 'cxx-stl', 'system', 'include'))
|
return os.path.abspath(os.path.join(self.ndk_home, 'sources', 'cxx-stl', 'system', 'include'))
|
||||||
@ -305,6 +313,7 @@ def configure(conf):
|
|||||||
setattr(conf, 'android', android)
|
setattr(conf, 'android', android)
|
||||||
conf.environ['CC'] = android.cc()
|
conf.environ['CC'] = android.cc()
|
||||||
conf.environ['CXX'] = android.cxx()
|
conf.environ['CXX'] = android.cxx()
|
||||||
|
conf.environ['STRIP'] = android.strip()
|
||||||
conf.env.CFLAGS += android.cflags()
|
conf.env.CFLAGS += android.cflags()
|
||||||
conf.env.CXXFLAGS += android.cflags()
|
conf.env.CXXFLAGS += android.cflags()
|
||||||
conf.env.LINKFLAGS += android.linkflags()
|
conf.env.LINKFLAGS += android.linkflags()
|
||||||
|
4
wscript
4
wscript
@ -29,7 +29,7 @@ def options(opt):
|
|||||||
|
|
||||||
opt.recurse('cl_dll dlls')
|
opt.recurse('cl_dll dlls')
|
||||||
|
|
||||||
opt.load('xcompile compiler_cxx compiler_c clang_compilation_database')
|
opt.load('xcompile compiler_cxx compiler_c clang_compilation_database strip_on_install')
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
opt.load('msvc msdev')
|
opt.load('msvc msdev')
|
||||||
opt.load('reconfigure')
|
opt.load('reconfigure')
|
||||||
@ -68,7 +68,7 @@ def configure(conf):
|
|||||||
conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC
|
conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
conf.load('msvc msdev')
|
conf.load('msvc msdev')
|
||||||
conf.load('xcompile compiler_c compiler_cxx')
|
conf.load('xcompile compiler_c compiler_cxx strip_on_install')
|
||||||
|
|
||||||
if conf.env.DEST_OS2 == 'android':
|
if conf.env.DEST_OS2 == 'android':
|
||||||
conf.options.ALLOW64 = True
|
conf.options.ALLOW64 = True
|
||||||
|
Loading…
Reference in New Issue
Block a user