Skip to content

Commit

Permalink
Add waf, remove unused includes in Android.mk
Browse files Browse the repository at this point in the history
  • Loading branch information
tyabus committed May 31, 2019
1 parent 993eb47 commit 74acae6
Show file tree
Hide file tree
Showing 15 changed files with 1,688 additions and 3 deletions.
51 changes: 51 additions & 0 deletions cl_dll/wscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! /usr/bin/env python
# encoding: utf-8
# a1batross, mittorn, 2018

from waflib import Utils
import os

def options(opt):
# stub
return

def configure(conf):
# stub
return

def build(bld):
source = bld.path.parent.ant_glob([
'pm_shared/*.c'
])

source += [
'cdll_int.cpp', '../game_shared/common.cpp', 'entity.cpp', 'hud.cpp',
'hud_draw.cpp', 'hud_msg.cpp', 'hud_redraw.cpp', 'hud_sbar.cpp',
'hud_update.cpp', 'in_camera.cpp', 'input.cpp', 'input_xash3d.cpp', 'input_mouse.cpp',
'message.cpp', 'parsemsg.cpp', 'saytext.cpp', 'scoreboard.cpp',
'../game_shared/stringlib.cpp', 'StudioModelRenderer.cpp', 'text_message.cpp',
'util.cpp', 'view.cpp'
]

includes = Utils.to_list('. ../common ../engine ../game_shared ../dlls ../pm_shared ')

libs = []

defines = ['CLIENT_DLL']

if bld.env.DEST_OS2 not in ['android']:
install_path = os.path.join(bld.env.GAMEDIR, bld.env.CLIENT_DIR)
else:
install_path = bld.env.PREFIX

bld.shlib(
source = source,
target = 'client',
features = 'c cxx',
includes = includes,
defines = defines,
use = libs,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = 1
)
3 changes: 0 additions & 3 deletions contrib/tyabus/dlls/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ LOCAL_CPPFLAGS := $(LOCAL_CFLAGS)

LOCAL_C_INCLUDES := $(SDL_PATH)/include \
$(LOCAL_PATH)/. \
$(LOCAL_PATH)/wpn_shared \
$(LOCAL_PATH)/../common \
$(LOCAL_PATH)/../engine/common \
$(LOCAL_PATH)/../engine \
$(LOCAL_PATH)/../public \
$(LOCAL_PATH)/../pm_shared \
$(LOCAL_PATH)/../game_shared

Expand Down
47 changes: 47 additions & 0 deletions dlls/wscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#! /usr/bin/env python
# encoding: utf-8
# a1batross, mittorn, 2018

from waflib import Utils
import os

def options(opt):
# stub
return

def configure(conf):
# stub
return

def build(bld):
defines = []
source = bld.path.parent.ant_glob([
'pm_shared/*.c',
])

source += [
'client.cpp', '../game_shared/common.cpp', 'crc.cpp', 'dll_int.cpp', 'game.cpp', 'globals.cpp', 'physics.cpp',
'pr_cmds.cpp', 'pr_edict.cpp', 'pr_exec.cpp', 'pr_message.cpp', 'pr_move.cpp',
'pr_phys.cpp', 'pr_save.cpp', 'pr_world.cpp', 'saverestore.cpp',
'../game_shared/stringlib.cpp', 'util.cpp']

includes = Utils.to_list('. ../common ../engine ../pm_shared ../game_shared')

libs = []

if bld.env.DEST_OS2 not in ['android']:
install_path = os.path.join(bld.env.GAMEDIR, bld.env.SERVER_DIR)
else:
install_path = bld.env.PREFIX

bld.shlib(
source = source,
target = 'server',
features = 'c cxx',
includes = includes,
defines = defines,
use = libs,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = 2
)
65 changes: 65 additions & 0 deletions scripts/waflib/deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Michel Mooij, [email protected]

from waflib import Utils
from waflib import Errors


def get_deps(bld, target):
'''Returns a list of (nested) targets on which this target depends.
:param bld: a *waf* build instance from the top level *wscript*
:type bld: waflib.Build.BuildContext
:param target: task name for which the dependencies should be returned
:type target: str
:returns: a list of task names on which the given target depends
'''
try:
tgen = bld.get_tgen_by_name(target)
except Errors.WafError:
return []
else:
uses = Utils.to_list(getattr(tgen, 'use', []))
deps = uses[:]
for use in uses:
deps += get_deps(bld, use)
return list(set(deps))


def get_tgens(bld, names):
'''Returns a list of task generators based on the given list of task
generator names.
:param bld: a *waf* build instance from the top level *wscript*
:type bld: waflib.Build.BuildContext
:param names: list of task generator names
:type names: list of str
:returns: list of task generators
'''
tgens=[]
for name in names:
try:
tgen = bld.get_tgen_by_name(name)
except Errors.WafError:
pass
else:
tgens.append(tgen)
return list(set(tgens))


def get_targets(bld):
'''Returns a list of user specified build targets or None if no specific
build targets has been selected using the *--targets=* command line option.
:param bld: a *waf* build instance from the top level *wscript*.
:type bld: waflib.Build.BuildContext
:returns: a list of user specified target names (using --targets=x,y,z) or None
'''
if bld.targets == '':
return None
targets = bld.targets.split(',')
for target in targets:
targets += get_deps(bld, target)
return targets

56 changes: 56 additions & 0 deletions scripts/waflib/force_32bit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# encoding: utf-8
# force_32bit.py -- force compiler to create 32-bit code
# 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.

from fwgslib import get_flags_by_compiler

# Input:
# BIT32_MANDATORY(optional) -- fail if 32bit mode not available
# BIT32_ALLOW64(optional) -- ignore all checks, just set DEST_SIZEOF_VOID_P to 8
# Output:
# DEST_SIZEOF_VOID_P -- an integer, equals sizeof(void*) on target

def check_32bit(ctx, msg):
try:
ctx.check_cc(
fragment='''int main( void )
{
int check[sizeof(void*) == 4 ? 1: -1];
return 0;
}''',
msg = msg)
except ctx.errors.ConfigurationError:
return False
return True

def configure(conf):
if getattr(conf.env, 'BIT32_ALLOW64'):
conf.env.DEST_SIZEOF_VOID_P = 8
else:
if check_32bit(conf, 'Checking if \'{0}\' can target 32-bit'.format(conf.env.COMPILER_CC)):
conf.env.DEST_SIZEOF_VOID_P = 4
else:
flags = ['-m32']
# Think different.
if(conf.env.DEST_OS == 'darwin'):
flags = ['-arch', 'i386']
env_stash = conf.env
conf.env.append_value('LINKFLAGS', flags)
conf.env.append_value('CFLAGS', flags)
conf.env.append_value('CXXFLAGS', flags)
if check_32bit(conf, '...trying with additional flags'):
conf.env.DEST_SIZEOF_VOID_P = 4
else:
conf.env.DEST_SIZEOF_VOID_P = 8
conf.env = env_stash
if getattr(conf.env, 'BIT32_MANDATORY') and conf.env.DEST_SIZEOF_VOID_P == 8:
conf.fatal('Compiler can\'t create 32-bit code!')
Binary file added scripts/waflib/force_32bit.pyc
Binary file not shown.
30 changes: 30 additions & 0 deletions scripts/waflib/fwgslib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# encoding: utf-8
# fwgslib.py -- utils for Waf build system by FWGS
# 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_flags_by_compiler(flags, compiler):
out = []
if compiler in flags:
out += flags[compiler]
elif 'default' in flags:
out += flags['default']
return out

def get_flags_by_type(flags, type, compiler):
out = []
if 'common' in flags:
out += get_flags_by_compiler(flags['common'], compiler)
if type in flags:
out += get_flags_by_compiler(flags[type], compiler)
return out
Binary file added scripts/waflib/fwgslib.pyc
Binary file not shown.
Loading

0 comments on commit 74acae6

Please sign in to comment.