Browse Source

Merge branch 'master' into redempt

redempt
Andrey Akhmichin 5 years ago
parent
commit
4bb977ea76
  1. 19
      README.md
  2. 93
      cl_dll/Makefile
  3. 190
      dlls/Makefile
  4. 29
      scripts/waifulib/xcompile.py
  5. 15
      waf
  6. 49
      wscript

19
README.md

@ -43,19 +43,12 @@ There're dsp projects for Visual Studio 6 in `cl_dll` and `dlls` directories, bu
TODO TODO
### Linux ### Unix-like
(cd dlls && make) To use waf, you need to install python (2.7 minimum)
(cd cl_dll && make)
### OS X (./waf configure -T release)
(./waf)
Nothing here.
### FreeBSD
(cd dlls && gmake CXX=clang++ CC=clang)
(cd cl_dll && gmake CXX=clang++ CC=clang)
### Android ### Android
@ -68,9 +61,9 @@ To enable building the goldsource compatible client library add GOLDSOURCE_SUPPO
cmake .. -DGOLDSOURCE_SUPPORT=ON cmake .. -DGOLDSOURCE_SUPPORT=ON
or when using make without cmake: or when using waf:
make GOLDSOURCE_SUPPORT=1 ./waf configure -T release --enable-goldsrc-support
Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d. Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d.

93
cl_dll/Makefile

@ -1,93 +0,0 @@
CC?=gcc
CXX?=g++
SRCS+=../dlls/crossbow.cpp
SRCS+=../dlls/crowbar.cpp
SRCS+=../dlls/egon.cpp
SRCS+=./ev_hldm.cpp
SRCS+=../dlls/gauss.cpp
SRCS+=../dlls/handgrenade.cpp
SRCS+=./hl/hl_baseentity.cpp
SRCS+=./hl/hl_events.cpp
SRCS+=./hl/hl_objects.cpp
SRCS+=./hl/hl_weapons.cpp
SRCS+=../dlls/glock.cpp
SRCS+=../dlls/hornetgun.cpp
#SRCS+=../common/interface.cpp
SRCS+=../dlls/mp5.cpp
SRCS+=../dlls/python.cpp
SRCS+=../dlls/rpg.cpp
SRCS+=../dlls/satchel.cpp
SRCS+=../dlls/shotgun.cpp
SRCS+=../dlls/squeakgrenade.cpp
SRCS+=../dlls/tripmine.cpp
#SRCS+=../game_shared/voice_banmgr.cpp
#SRCS+=../game_shared/voice_status.cpp
SRCS+=./ammo.cpp
SRCS+=./ammo_secondary.cpp
SRCS+=./ammohistory.cpp
SRCS+=./battery.cpp
SRCS+=./cdll_int.cpp
SRCS+=./com_weapons.cpp
SRCS+=./death.cpp
SRCS+=./demo.cpp
SRCS+=./entity.cpp
SRCS+=./ev_common.cpp
SRCS+=./events.cpp
SRCS+=./flashlight.cpp
SRCS+=./GameStudioModelRenderer.cpp
SRCS+=./geiger.cpp
SRCS+=./health.cpp
SRCS+=./hud.cpp
SRCS+=./hud_msg.cpp
SRCS+=./hud_redraw.cpp
#SRCS+=./hud_servers.cpp
SRCS+=./hud_spectator.cpp
SRCS+=./hud_update.cpp
SRCS+=./in_camera.cpp
SRCS+=./input.cpp
SRCS+=./input_mouse.cpp
SRCS+=./input_goldsource.cpp
SRCS+=./menu.cpp
SRCS+=./message.cpp
SRCS+=./overview.cpp
SRCS+=./parsemsg.cpp
SRCS_C+=../pm_shared/pm_debug.c
SRCS_C+=../pm_shared/pm_math.c
SRCS_C+=../pm_shared/pm_shared.c
SRCS+=./saytext.cpp
SRCS+=./status_icons.cpp
SRCS+=./statusbar.cpp
SRCS+=./studio_util.cpp
SRCS+=./StudioModelRenderer.cpp
SRCS+=./text_message.cpp
SRCS+=./train.cpp
SRCS+=./tri.cpp
SRCS+=./util.cpp
SRCS+=./view.cpp
SRCS+=./input_xash3d.cpp
SRCS+=./scoreboard.cpp
SRCS+=./MOTD.cpp
INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include
DEFINES = -Wno-write-strings -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL
CFLAGS = -m32
OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o)
LIBS=-lm
ifeq ($(GOLDSOURCE_SUPPORT),1)
DEFINES += -DGOLDSOURCE_SUPPORT
endif
ifeq ($(shell uname -s),Linux)
LIBS += -ldl
endif
%.o : %.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@
%.o : %.cpp
$(CXX) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@
client.so : $(OBJS)
$(CXX) $(CFLAGS) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS)
clean:
$(RM) $(OBJS)

190
dlls/Makefile

@ -1,190 +0,0 @@
#
# Half-Life Full SDK 2.3 hl_i386.so Makefile for x86 Linux
#
# October 2002 by Leon Hartwig (hartwig@valvesoftware.com)
#
DLLNAME=hl
ARCH=i386
#make sure this is the correct compiler for your system
CC?=gcc
CXX?=g++
DLL_SRCDIR=.
ENGINE_SRCDIR=../engine
COMMON_SRCDIR=../common
WPN_SHARED_SRCDIR=./wpn_shared
PM_SHARED_SRCDIR=../pm_shared
GAME_SHARED_SRCDIR=../game_shared
DLL_OBJDIR=$(DLL_SRCDIR)/obj
WPN_SHARED_OBJDIR=$(WPN_SHARED_SRCDIR)/obj
PM_SHARED_OBJDIR=$(PM_SHARED_SRCDIR)/obj
GAME_SHARED_OBJDIR=$(GAME_SHARED_SRCDIR)/obj
BASE_CFLAGS= -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
-DCLIENT_WEAPONS -DNO_VOICEGAMEMGR
#safe optimization
CFLAGS=$(BASE_CFLAGS) -m32 -w -O1
#full optimization
#CFLAGS=$(BASE_CFLAGS) -w -O1 -m486 -ffast-math -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations \
-malign-loops=2 -malign-jumps=2 -malign-functions=2
#use these when debugging
#CFLAGS=$(BASE_CFLAGS) -g
INCLUDEDIRS=-I. -I$(ENGINE_SRCDIR) -I$(COMMON_SRCDIR) -I$(PM_SHARED_SRCDIR) -I$(GAME_SHARED_SRCDIR)
LDFLAGS=
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared
DO_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) $(INCLUDEDIRS) -o $@ -c $<
DO_CXX=$(CXX) $(CFLAGS) $(SHLIBCFLAGS) $(INCLUDEDIRS) -o $@ -c $<
#############################################################################
# SETUP AND BUILD
# GAME
#############################################################################
$(DLL_OBJDIR)/%.o: $(DLL_SRCDIR)/%.cpp
$(DO_CXX)
$(WPN_SHARED_OBJDIR)/%.o: $(WPN_SHARED_SRCDIR)/%.cpp
$(DO_CXX)
$(GAME_SHARED_OBJDIR)/%.o: $(GAME_SHARED_SRCDIR)/%.cpp
$(DO_CXX)
$(PM_SHARED_OBJDIR)/%.o: $(PM_SHARED_SRCDIR)/%.c
$(DO_CC)
OBJ = \
$(DLL_OBJDIR)/aflock.o \
$(DLL_OBJDIR)/agrunt.o \
$(DLL_OBJDIR)/airtank.o \
$(DLL_OBJDIR)/animating.o \
$(DLL_OBJDIR)/animation.o \
$(DLL_OBJDIR)/apache.o \
$(DLL_OBJDIR)/barnacle.o \
$(DLL_OBJDIR)/barney.o \
$(DLL_OBJDIR)/bigmomma.o \
$(DLL_OBJDIR)/bloater.o \
$(DLL_OBJDIR)/bmodels.o \
$(DLL_OBJDIR)/bullsquid.o \
$(DLL_OBJDIR)/buttons.o \
$(DLL_OBJDIR)/cbase.o \
$(DLL_OBJDIR)/client.o \
$(DLL_OBJDIR)/combat.o \
$(DLL_OBJDIR)/controller.o \
$(DLL_OBJDIR)/crossbow.o \
$(DLL_OBJDIR)/crowbar.o \
$(DLL_OBJDIR)/defaultai.o \
$(DLL_OBJDIR)/doors.o \
$(DLL_OBJDIR)/effects.o \
$(DLL_OBJDIR)/egon.o \
$(DLL_OBJDIR)/explode.o \
$(DLL_OBJDIR)/flyingmonster.o \
$(DLL_OBJDIR)/func_break.o \
$(DLL_OBJDIR)/func_tank.o \
$(DLL_OBJDIR)/game.o \
$(DLL_OBJDIR)/gamerules.o \
$(DLL_OBJDIR)/gargantua.o \
$(DLL_OBJDIR)/gauss.o \
$(DLL_OBJDIR)/genericmonster.o \
$(DLL_OBJDIR)/ggrenade.o \
$(DLL_OBJDIR)/globals.o \
$(DLL_OBJDIR)/gman.o \
$(DLL_OBJDIR)/h_ai.o \
$(DLL_OBJDIR)/h_battery.o \
$(DLL_OBJDIR)/h_cine.o \
$(DLL_OBJDIR)/h_cycler.o \
$(DLL_OBJDIR)/h_export.o \
$(DLL_OBJDIR)/handgrenade.o \
$(DLL_OBJDIR)/hassassin.o \
$(DLL_OBJDIR)/headcrab.o \
$(DLL_OBJDIR)/healthkit.o \
$(DLL_OBJDIR)/hgrunt.o \
$(DLL_OBJDIR)/hornet.o \
$(DLL_OBJDIR)/hornetgun.o \
$(DLL_OBJDIR)/houndeye.o \
$(DLL_OBJDIR)/ichthyosaur.o \
$(DLL_OBJDIR)/islave.o \
$(DLL_OBJDIR)/items.o \
$(DLL_OBJDIR)/leech.o \
$(DLL_OBJDIR)/lights.o \
$(DLL_OBJDIR)/maprules.o \
$(DLL_OBJDIR)/monstermaker.o \
$(DLL_OBJDIR)/monsters.o \
$(DLL_OBJDIR)/monsterstate.o \
$(DLL_OBJDIR)/mortar.o \
$(DLL_OBJDIR)/mp5.o \
$(DLL_OBJDIR)/multiplay_gamerules.o \
$(DLL_OBJDIR)/nihilanth.o \
$(DLL_OBJDIR)/nodes.o \
$(DLL_OBJDIR)/observer.o \
$(DLL_OBJDIR)/osprey.o \
$(DLL_OBJDIR)/pathcorner.o \
$(DLL_OBJDIR)/plane.o \
$(DLL_OBJDIR)/plats.o \
$(DLL_OBJDIR)/player.o \
$(DLL_OBJDIR)/playermonster.o \
$(DLL_OBJDIR)/python.o \
$(DLL_OBJDIR)/rat.o \
$(DLL_OBJDIR)/roach.o \
$(DLL_OBJDIR)/rpg.o \
$(DLL_OBJDIR)/satchel.o \
$(DLL_OBJDIR)/schedule.o \
$(DLL_OBJDIR)/scientist.o \
$(DLL_OBJDIR)/scripted.o \
$(DLL_OBJDIR)/shotgun.o \
$(DLL_OBJDIR)/singleplay_gamerules.o \
$(DLL_OBJDIR)/skill.o \
$(DLL_OBJDIR)/sound.o \
$(DLL_OBJDIR)/soundent.o \
$(DLL_OBJDIR)/spectator.o \
$(DLL_OBJDIR)/squadmonster.o \
$(DLL_OBJDIR)/squeakgrenade.o \
$(DLL_OBJDIR)/subs.o \
$(DLL_OBJDIR)/talkmonster.o \
$(DLL_OBJDIR)/teamplay_gamerules.o \
$(DLL_OBJDIR)/tempmonster.o \
$(DLL_OBJDIR)/tentacle.o \
$(DLL_OBJDIR)/triggers.o \
$(DLL_OBJDIR)/tripmine.o \
$(DLL_OBJDIR)/turret.o \
$(DLL_OBJDIR)/util.o \
$(DLL_OBJDIR)/weapons.o \
$(DLL_OBJDIR)/world.o \
$(DLL_OBJDIR)/xen.o \
$(DLL_OBJDIR)/zombie.o \
$(DLL_OBJDIR)/glock.o \
$(PM_SHARED_OBJDIR)/pm_debug.o \
$(PM_SHARED_OBJDIR)/pm_math.o \
$(PM_SHARED_OBJDIR)/pm_shared.o
# $(GAME_SHARED_OBJDIR)/voice_gamemgr.o
$(DLLNAME)_$(ARCH).$(SHLIBEXT) : neat $(OBJ)
$(CXX) $(CFLAGS) $(SHLIBLDFLAGS) $(LDFLAGS) -o $@ $(OBJ)
neat:
-mkdir $(DLL_OBJDIR)
-mkdir $(WPN_SHARED_OBJDIR)
-mkdir $(GAME_SHARED_OBJDIR)
-mkdir $(PM_SHARED_OBJDIR)
clean:
-rm -f $(OBJ)
-rm -f $(DLLNAME)_$(ARCH).$(SHLIBEXT)
spotless: clean
-rm -r $(DLL_OBJDIR)
-rm -r $(WPN_SHARED_OBJDIR)
-rm -r $(GAME_SHARED_OBJDIR)
-rm -r $(PM_SHARED_OBJDIR)

29
scripts/waifulib/xcompile.py

@ -248,6 +248,19 @@ class Android:
if cxx and not self.is_clang() and self.toolchain not in ['4.8','4.9']: if cxx and not self.is_clang() and self.toolchain not in ['4.8','4.9']:
cflags += ['-fno-sized-deallocation'] cflags += ['-fno-sized-deallocation']
def fixup_host_clang_with_old_ndk():
cflags = []
# Clang builtin redefine w/ different calling convention bug
# NOTE: I did not added complex.h functions here, despite
# that NDK devs forgot to put __NDK_FPABI_MATH__ for complex
# math functions
# I personally don't need complex numbers support, but if you want it
# just run sed to patch header
for f in ['strtod', 'strtof', 'strtold']:
cflags += ['-fno-builtin-%s' % f]
return cflags
if self.is_arm(): if self.is_arm():
if self.arch == 'armeabi-v7a': if self.arch == 'armeabi-v7a':
# ARMv7 support # ARMv7 support
@ -256,21 +269,17 @@ class Android:
if not self.is_clang() and not self.is_host(): if not self.is_clang() and not self.is_host():
cflags += [ '-mvectorize-with-neon-quad' ] cflags += [ '-mvectorize-with-neon-quad' ]
if self.is_host() and self.ndk_rev <= ANDROID_NDK_HARDFP_MAX:
cflags += fixup_host_clang_with_old_ndk()
if self.is_hardfp(): if self.is_hardfp():
cflags += ['-D_NDK_MATH_NO_SOFTFP=1', '-mfloat-abi=hard', '-DLOAD_HARDFP', '-DSOFTFP_LINK'] cflags += ['-D_NDK_MATH_NO_SOFTFP=1', '-mfloat-abi=hard', '-DLOAD_HARDFP', '-DSOFTFP_LINK']
if self.is_host():
# Clang builtin redefine w/ different calling convention bug
# NOTE: I did not added complex.h functions here, despite
# that NDK devs forgot to put __NDK_FPABI_MATH__ for complex
# math functions
# I personally don't need complex numbers support, but if you want it
# just run sed to patch header
for f in ['strtod', 'strtof', 'strtold']:
cflags += ['-fno-builtin-%s' % f]
else: else:
cflags += ['-mfloat-abi=softfp'] cflags += ['-mfloat-abi=softfp']
else: else:
if self.is_host() and self.ndk_rev <= ANDROID_NDK_HARDFP_MAX:
cflags += fixup_host_clang_with_old_ndk()
# ARMv5 support # ARMv5 support
cflags += ['-march=armv5te', '-mtune=xscale', '-msoft-float'] cflags += ['-march=armv5te', '-mtune=xscale', '-msoft-float']
elif self.is_x86(): elif self.is_x86():

15
waf vendored

File diff suppressed because one or more lines are too long

49
wscript

@ -40,6 +40,9 @@ def options(opt):
grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False, grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False,
help = 'enable polyhedral optimization if possible [default: %default]') help = 'enable polyhedral optimization if possible [default: %default]')
grp.add_option('--enable-magx', action = 'store_true', dest = 'MAGX', default = False,
help = 'enable targetting for MotoMAGX phones [default: %default]')
opt.load('xcompile compiler_cxx compiler_c clang_compilation_database strip_on_install') opt.load('xcompile compiler_cxx compiler_c clang_compilation_database strip_on_install')
if sys.platform == 'win32': if sys.platform == 'win32':
@ -58,13 +61,16 @@ def configure(conf):
conf.load('fwgslib reconfigure') conf.load('fwgslib reconfigure')
enforce_pic = True # modern defaults
valid_build_types = ['fastnative', 'fast', 'release', 'debug', 'nooptimize', 'sanitize', 'none']
conf.load('fwgslib reconfigure')
conf.start_msg('Build type') conf.start_msg('Build type')
if conf.options.BUILD_TYPE == None: if conf.options.BUILD_TYPE == None:
conf.end_msg('not set', color='RED') conf.end_msg('not set', color='RED')
conf.fatal('Please set a build type, for example "-T release"') conf.fatal('Please set a build type, for example "-T release"')
elif not conf.options.BUILD_TYPE in ['fast', 'release', 'debug', 'nooptimize', 'sanitize', 'none']: elif not conf.options.BUILD_TYPE in valid_build_types:
conf.end_msg(conf.options.BUILD_TYPE, color='RED') conf.end_msg(conf.options.BUILD_TYPE, color='RED')
conf.fatal('Invalid build type. Valid are "debug", "release" or "none"') conf.fatal('Invalid build type. Valid are: %s' % valid_build_types.join(', '))
conf.end_msg(conf.options.BUILD_TYPE) conf.end_msg(conf.options.BUILD_TYPE)
# -march=native should not be used # -march=native should not be used
@ -83,10 +89,30 @@ def configure(conf):
conf.load('msvc msdev') conf.load('msvc msdev')
conf.load('xcompile compiler_c compiler_cxx strip_on_install') conf.load('xcompile compiler_c compiler_cxx strip_on_install')
try:
conf.env.CC_VERSION[0]
except IndexError:
conf.env.CC_VERSION = (0, )
if conf.env.DEST_OS == 'android': if conf.env.DEST_OS == 'android':
conf.options.GOLDSRC = False conf.options.GOLDSRC = False
conf.env.SERVER_NAME = 'server' # can't be any other name, until specified conf.env.SERVER_NAME = 'server' # can't be any other name, until specified
conf.env.MAGX = conf.options.MAGX
if conf.options.MAGX:
enforce_pic = False
if enforce_pic:
# Every static library must have fPIC
if conf.env.DEST_OS != 'win32' and '-fPIC' in conf.env.CFLAGS_cshlib:
conf.env.append_unique('CFLAGS_cstlib', '-fPIC')
conf.env.append_unique('CXXFLAGS_cxxstlib', '-fPIC')
else:
conf.env.CFLAGS_cshlib.remove('-fPIC')
conf.env.CXXFLAGS_cxxshlib.remove('-fPIC')
conf.env.CFLAGS_MACBUNDLE.remove('-fPIC')
conf.env.CXXFLAGS_MACBUNDLE.remove('-fPIC')
# We restrict 64-bit builds ONLY for Win/Linux/OSX running on Intel architecture # We restrict 64-bit builds ONLY for Win/Linux/OSX running on Intel architecture
# Because compatibility with original GoldSrc # Because compatibility with original GoldSrc
if conf.env.DEST_OS in ['win32', 'linux', 'darwin'] and conf.env.DEST_CPU in ['x86_64']: if conf.env.DEST_OS in ['win32', 'linux', 'darwin'] and conf.env.DEST_CPU in ['x86_64']:
@ -114,10 +140,19 @@ def configure(conf):
# disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP # disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP
'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'], 'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'],
'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden'], 'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden'],
'gcc': ['-g', '-fvisibility=hidden'] 'gcc': ['-g']
}, },
'fast': { 'fast': {
'msvc': ['/O2', '/Oy'], #todo: check /GL /LTCG 'msvc': ['/O2', '/Oy'],
'gcc': {
'3': ['-O3', '-Os', '-funsafe-math-optimizations', '-fomit-frame-pointer'],
'default': ['-Ofast', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer']
},
'clang': ['-Ofast'],
'default': ['-O3']
},
'fastnative': {
'msvc': ['/O2', '/Oy'],
'gcc': ['-Ofast', '-march=native', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'], 'gcc': ['-Ofast', '-march=native', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'],
'clang': ['-Ofast', '-march=native'], 'clang': ['-Ofast', '-march=native'],
'default': ['-O3'] 'default': ['-O3']
@ -162,8 +197,8 @@ def configure(conf):
'-Werror=declaration-after-statement' '-Werror=declaration-after-statement'
] ]
linkflags = conf.get_flags_by_type(linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC) linkflags = conf.get_flags_by_type(linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC, conf.env.CC_VERSION[0])
cflags = conf.get_flags_by_type(compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC) cflags = conf.get_flags_by_type(compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC, conf.env.CC_VERSION[0])
# Here we don't differentiate C or C++ flags # Here we don't differentiate C or C++ flags
if conf.options.LTO: if conf.options.LTO:
@ -207,7 +242,7 @@ def configure(conf):
if conf.check_cc(header_name='tgmath.h', mandatory=False): if conf.check_cc(header_name='tgmath.h', mandatory=False):
tgmath_usable = conf.check_cc(fragment='''#include<tgmath.h> tgmath_usable = conf.check_cc(fragment='''#include<tgmath.h>
int main(void){ return (int)sin(2.0f); }''', int main(void){ return (int)sin(2.0f); }''',
msg='Checking if tgmath.h is usable', mandatory=False): msg='Checking if tgmath.h is usable', mandatory=False)
conf.define_cond('HAVE_TGMATH_H', tgmath_usable) conf.define_cond('HAVE_TGMATH_H', tgmath_usable)
else: else:
conf.undefine('HAVE_TGMATH_H') conf.undefine('HAVE_TGMATH_H')

Loading…
Cancel
Save