2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-26 03:39:16 +01:00

waflib: android: cleanup

This commit is contained in:
Alibek Omarov 2019-04-25 04:37:28 +03:00
parent 586a03d431
commit a56fe98dc5
2 changed files with 11 additions and 31 deletions

View File

@ -17,5 +17,6 @@ def build(bld):
srcdir = 'src', srcdir = 'src',
compat = '1.6', compat = '1.6',
name = 'xashdroid-src', name = 'xashdroid-src',
debug = bld.env.D8_DEBUG) debug = bld.env.D8_DEBUG,
target_api = 19)
return return

View File

@ -23,47 +23,31 @@ def get_latest_build_tools(sdk):
dirs.sort(reverse=True) dirs.sort(reverse=True)
return os.path.join(build_tools_path, dirs[0]) return os.path.join(build_tools_path, dirs[0])
#def find_aapt(conf):
# try:
# conf.find_program('aapt2', var='AAPT')
# have_aapt2 = True
# except conf.Errors.ConfigurationError:
# TODO: aapt legacy support
# have_aapt2 = False
# try:
# conf.find_program('aapt', var='AAPT')
# except conf.Errors.ConfigurationError:
# conf.fatal('Can\'t find AAPT program. Check that build-tools are installed correctly')
def load_manifest(path):
# TODO:
return
def configure(conf): def configure(conf):
conf.load('java') conf.load('java')
conf.start_msg('Checking environment variables') conf.start_msg('Checking environment variables')
found = False sdk = None
for i in android_sdk_home_env: for i in android_sdk_home_env:
if i in os.environ: if i in os.environ:
found = True sdk = conf.env.ANDROID_SDK_HOME_ENV = os.environ[i]
conf.env.ANDROID_SDK_HOME_ENV = i
break break
if not found: if not sdk:
conf.fatal('Can\'t find path to SDK. Check if ANDROID_SDK_HOME environment variable is set') conf.fatal('Can\'t find path to SDK. Check if ANDROID_SDK_HOME environment variable is set')
return return
conf.end_msg('ok') conf.end_msg('ok')
sdk = os.environ[conf.env.ANDROID_SDK_HOME_ENV] paths = [ os.path.join(conf.env.ANDROID_SDK_HOME_ENV, 'tools'), get_latest_build_tools(sdk) ]
paths = [ os.path.join(sdk, 'tools'), get_latest_build_tools(sdk) ]
paths += os.environ['PATH'].split(os.pathsep) # just in case we have installed tools paths += os.environ['PATH'].split(os.pathsep) # just in case we have installed tools
for i in ['aapt2', 'd8', 'zipalign', 'apksigner']: for i in ['aapt2', 'd8', 'zipalign', 'apksigner']:
conf.find_program(i, path_list = paths) conf.find_program(i, path_list = paths)
conf.find_program('zip') conf.find_program('zip')
# find_aapt()
# TODO: AAPT legacy support
# TODO: dx support
class aapt2compile(javaw.JTask): class aapt2compile(javaw.JTask):
color = 'GREEN' color = 'GREEN'
@ -149,9 +133,7 @@ def javac(func):
def custom_runnable_status(self): def custom_runnable_status(self):
if not self.inputs: if not self.inputs:
outrdir = self.srcdir[0].ctx.root.make_node(self.env.OUTRDIR) outrdir = self.srcdir[0].ctx.root.make_node(self.env.OUTRDIR)
#print(outrdir.abspath())
self.srcdir.append(outrdir) self.srcdir.append(outrdir)
#print(self.srcdir)
return self.old_runnable_status() return self.old_runnable_status()
class apkdex(Task.Task): class apkdex(Task.Task):
@ -210,9 +192,8 @@ def apply_aapt(self):
outdir.mkdir() outdir.mkdir()
self.outdir = outdir self.outdir = outdir
# TODO: assuming that we have old source hierarchy
srcdir = self.path.find_dir('.') srcdir = self.path.find_dir('.')
sdk = os.environ[self.env.ANDROID_SDK_HOME_ENV] sdk = self.env.ANDROID_SDK_HOME_ENV
self.env.RESDIR = os.path.join(srcdir.abspath(), getattr(self, 'resdir', 'res')) self.env.RESDIR = os.path.join(srcdir.abspath(), getattr(self, 'resdir', 'res'))
self.env.ASSETSDIR = os.path.join(srcdir.abspath(), getattr(self, 'assetsdir', 'assets')) self.env.ASSETSDIR = os.path.join(srcdir.abspath(), getattr(self, 'assetsdir', 'assets'))
@ -223,7 +204,7 @@ def apply_aapt(self):
self.env.OUTRDIR = os.path.join(outdir.abspath(), getattr(self, 'gendir', 'gen')) # build/gen self.env.OUTRDIR = os.path.join(outdir.abspath(), getattr(self, 'gendir', 'gen')) # build/gen
self.env.RESOUTFILE = os.path.join(outdir.abspath(), 'compiled') self.env.RESOUTFILE = os.path.join(outdir.abspath(), 'compiled')
self.env.OUTDIR = outdir.abspath() self.env.OUTDIR = outdir.abspath()
self.env.TARGET_API = getattr(self, 'target_api', 19) # Android 2.3 self.env.TARGET_API = getattr(self, 'target_api', 10) # Android 2.3.3 TODO: parse AndroidManifest.xml to get target API!
self.env.CLASSPATH_ANDROID = os.path.join(sdk, 'platforms', 'android-' + str(self.env.TARGET_API), 'android.jar') self.env.CLASSPATH_ANDROID = os.path.join(sdk, 'platforms', 'android-' + str(self.env.TARGET_API), 'android.jar')
self.aapt2compile_task = self.create_task('aapt2compile') self.aapt2compile_task = self.create_task('aapt2compile')
@ -233,8 +214,6 @@ def apply_aapt(self):
self.aapt2link_task.cwd = outdir self.aapt2link_task.cwd = outdir
self.aapt2link_task.set_run_after(self.aapt2compile_task) self.aapt2link_task.set_run_after(self.aapt2compile_task)
#print(self.env)
@TaskGen.feature('android') @TaskGen.feature('android')
@TaskGen.after_method('apply_java') @TaskGen.after_method('apply_java')
def apply_d8(self): def apply_d8(self):