waf: deploy waf build system

This commit is contained in:
Alibek Omarov 2019-04-25 04:21:38 +03:00
parent 4360676f96
commit 4309604eca
3 changed files with 302 additions and 0 deletions

View file

@ -0,0 +1,33 @@
# encoding: utf-8
# gitversion.py -- waf plugin to get git version
# Copyright (C) 2018 a1batross
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
import os
def get_git_version():
# try grab the current version number from git
version = None
if os.path.exists('.git'):
try:
version = os.popen('git describe --dirty --always').read().strip()
except Exception as e:
pass
if(len(version) == 0):
version = None
return version
def configure(conf):
conf.start_msg('Checking git hash')
conf.env.GIT_VERSION = get_git_version()
conf.end_msg(conf.env.GIT_VERSION if conf.env.GIT_VERSION else 'no')

169
waf vendored Executable file

File diff suppressed because one or more lines are too long

100
wscript Normal file
View file

@ -0,0 +1,100 @@
#! /usr/bin/env python
# encoding: utf-8
# a1batross 2019
from __future__ import print_function
from waflib import Logs
import sys
import os
sys.path.append(os.path.realpath('scripts/waflib'))
# print(sys.path)
import fwgslib
VERSION = '0.99'
APPNAME = 'xash3d-fwgs-android'
top = '.'
class Subproject:
name = ''
options = False # if true options() will be ignored
ignore = False # if true will be ignored, set by user request
def __init__(self, name, options = False):
self.name = name
self.options = options
SUBDIRS = [
# Subproject('xash3d-fwgs', True), # we set multiple hardcoded configurations, so ignore options
Subproject('android')
]
def subdirs():
return map(lambda x: x.name, SUBDIRS)
def options(opt):
grp = opt.add_option_group('Common options')
grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default = None,
help = 'build type: debug, release or none(custom flags)')
grp.add_option('-S', '--skip-subprojects', action='store', dest = 'SKIP_SUBDIRS', default=None,
help = 'don\'t recurse into specified subprojects. Current subdirs: ' + str(subdirs()))
for i in SUBDIRS:
if not os.path.isfile(os.path.join(i.name, 'wscript')):
# HACKHACK: this way we get warning message right in the help
# so this just becomes more noticeable
opt.add_option_group('Cannot find wscript in ' + i.name + '. You probably missed submodule update')
continue
if i.options:
continue
opt.recurse(i.name)
def set_ignored_subdirs(subdirs):
for i in SUBDIRS:
if i.ignore:
continue
if i.name in subdirs:
i.ignore = True
def configure(conf):
conf.start_msg('Build type')
if conf.options.BUILD_TYPE == None:
conf.end_msg('not set', color='RED')
conf.fatal('Please set a build type, for example "--build-type=release"')
elif not conf.options.BUILD_TYPE in ['release', 'debug', 'none']:
conf.end_msg(conf.options.BUILD_TYPE, color='RED')
conf.fatal('Invalid build type. Valid are "debug", "release" or "none"')
conf.end_msg(conf.options.BUILD_TYPE)
# skip some subdirectories, if requested
if conf.options.SKIP_SUBDIRS:
skip_subdirs = conf.options.SKIP_SUBDIRS.split(',')
set_ignored_subdirs(skip_subdirs)
for i in SUBDIRS:
if i.ignore:
continue
conf.setenv(i.name, conf.env) # derive new env from global one
conf.env.ENVNAME = i.name
conf.msg(msg='--> ' + i.name, result='in progress', color='BLUE')
# configure in standalone env
conf.recurse(i.name)
conf.msg(msg='<-- ' + i.name, result='done', color='BLUE')
conf.setenv('')
def build(bld):
for i in SUBDIRS:
if i.ignore:
continue
bld.load_envs()
saveenv = bld.env
bld.env = bld.all_envs[i.name]
bld.recurse(i.name)
bld.env = saveenv