From e58daf10909506e8616cd9fc66bd7d772792e272 Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 10 May 2019 02:06:07 +0000 Subject: [PATCH] Enable building plugins for android. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5459 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- build_setup.sh | 3 ++- build_wip.sh | 2 +- engine/Makefile | 14 +++++++----- plugins/Makefile | 42 ++++++++++++++++++++++------------- plugins/jabber/jabberclient.c | 2 +- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/build_setup.sh b/build_setup.sh index e6e7cb5fa..8742819ef 100755 --- a/build_setup.sh +++ b/build_setup.sh @@ -37,7 +37,7 @@ TARGETS_LINUX="qcc-rel rel dbg vk-rel plugins-rel plugins-dbg" TARGETS_WINDOWS="sv-rel gl-rel vk-rel mingl-rel m-rel d3d-rel qcc-rel qccgui-scintilla qccgui-dbg gl-dbg sv-dbg plugins-dbg plugins-rel" - +PLUGINS_DROID="qi ezhud irc" PLUGINS_LINUXx86="ode qi ezhud xmpp irc" PLUGINS_LINUXx64="ode qi ezhud xmpp irc" PLUGINS_LINUXx32="qi ezhud xmpp irc" @@ -176,6 +176,7 @@ if [ "$UID" != "0" ]; then echo "PLUGINS_LINUXx64=\"$PLUGINS_LINUXx64\"" >>$FTECONFIG echo "PLUGINS_LINUXx32=\"$PLUGINS_LINUXx32\"" >>$FTECONFIG echo "PLUGINS_LINUXarmhf=\"$PLUGINS_LINUXarmhf\"" >>$FTECONFIG + echo "PLUGINS_DROID=\"$PLUGINS_DROID\"" >>$FTECONFIG fi true diff --git a/build_wip.sh b/build_wip.sh index 141644410..4bd3191dd 100755 --- a/build_wip.sh +++ b/build_wip.sh @@ -158,7 +158,7 @@ if [ "$BUILD_MSVC" != "n" ]; then fi export NATIVE_PLUGINS="qi ezhud xmpp irc" if [ "$BUILD_ANDROID" != "n" ]; then - build "Android" android droid-rel + NATIVE_PLUGINS="$PLUGINS_DROID" build "Android" android droid-rel fi #if [ "$BUILD_WINDOWS" != "n" ]; then # build "NPFTE" npfte npfte-rel diff --git a/engine/Makefile b/engine/Makefile index ea18edb24..e7faddd57 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -6,11 +6,14 @@ STRIPFLAGS=--strip-unneeded --remove-section=.comment CPUOPTIMIZATIONS= +COMPILE_SYS:=$(shell uname -o 2>&1) + #canonicalize the source path. except emscripten warns about that like crazy. *sigh* ifeq ($(FTE_TARGET),web) BASE_DIR:=. else ifeq ($(FTE_TARGET),droid) - BASE_DIR:=. + #android tools suck, but plugins need to find the engine directory. + BASE_DIR:=../engine else BASE_DIR:=$(realpath .) endif @@ -61,7 +64,6 @@ BULLETVER=2.87 RELEASE_DIR=$(BASE_DIR)/release DEBUG_DIR=$(BASE_DIR)/debug PROFILE_DIR=$(BASE_DIR)/profile -COMPILE_SYS:=$(shell uname -o 2>&1) NATIVE_ABSBASE_DIR:=$(realpath $(BASE_DIR)) ifeq ($(COMPILE_SYS),Cygwin) OUT_DIR?=. @@ -2122,10 +2124,10 @@ endif droid-rel: $(MAKE) FTE_TARGET=droid droid/build.xml droid/ftekeystore - $(foreach a, $(DROID_ARCH), $(MAKE) FTE_TARGET=droid m-rel DROID_ARCH=$a; ) + $(foreach a, $(DROID_ARCH), $(MAKE) FTE_TARGET=droid m-rel plugins-rel DROID_ARCH=$a NATIVE_PLUGINS="$(NATIVE_PLUGINS)"; ) -rm -rf droid/libs @$(foreach a, $(DROID_ARCH), mkdir -p droid/libs/$a; ) - -@$(foreach a, $(DROID_ARCH), cp $(RELEASE_DIR)/m_droid-$a/libftedroid.so droid/libs/$a/libftedroid.so; ) + -@$(foreach a, $(DROID_ARCH), cp $(RELEASE_DIR)/m_droid-$a/*.so droid/libs/$a/; ) @cd droid && $(ANT) release ifneq ($(DROID_PACKSU),) @@ -2159,10 +2161,10 @@ droid-opt: #build FTE as a library, then build the java+package (release). also installs it onto the 'current' device. droid-dbg: $(MAKE) FTE_TARGET=droid droid/build.xml - $(foreach a, $(DROID_ARCH), $(MAKE) FTE_TARGET=droid m-dbg DROID_ARCH=$a; ) + $(foreach a, $(DROID_ARCH), $(MAKE) FTE_TARGET=droid m-dbg plugins-dbg DROID_ARCH=$a NATIVE_PLUGINS="$(NATIVE_PLUGINS)"; ) -rm -rf droid/libs @$(foreach a, $(DROID_ARCH), mkdir -p droid/libs/$a; ) - -@$(foreach a, $(DROID_ARCH), cp $(DEBUG_DIR)/m_droid-$a/libftedroid.so droid/libs/$a/libftedroid.so; ) + -@$(foreach a, $(DROID_ARCH), cp $(DEBUG_DIR)/m_droid-$a/*.so droid/libs/$a/; ) @cd droid && $(ANT) debug #&& $(ANT) debug install cp droid/bin/FTEDroid-debug.apk $(DEBUG_DIR)/FTEDroid.apk diff --git a/plugins/Makefile b/plugins/Makefile index 135689732..af353ad76 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -15,6 +15,7 @@ PLUG_LDFLAGS_ZLIB=-L../engine/libs/mingw64-libs -lz PLUG_LDFLAGS_DL= endif +PLUG_PREFIX=$(OUT_DIR)/fteplug_ PLUG_LDFLAGS_DL?=-ldl -static-libgcc PLUG_LDFLAGS?=-L/usr/local/lib -Wl,-R/usr/local/lib -lm PLUG_LDFLAGS_ZLIB?=-lz @@ -65,6 +66,17 @@ ifeq ($(PLUG_NATIVE_EXT),) PLUG_NATIVE_EXT=_ppc.so endif endif +ifeq ($(FTE_TARGET),droid) + #plugins get written to the tmp build dir, to avoid conflicts + PLUG_PREFIX=$(OUT_DIR)/m_droid-$(DROID_ARCH)/fteplug_ + #don't bother with cpu arch postfixes. they'll be in separate directories anyway. + PLUG_NATIVE_EXT=.so + #libresolv has no public api on android... + LIBRESOLV= + #so we know our target. + PLUG_CFLAGS=-DANDROID + PLUG_CXXFLAGS=-DANDROID +endif #fallback PLUG_NATIVE_EXT?=_unk.so @@ -194,9 +206,9 @@ distclean: rm $(AV_BASE)$(AV_VER)-win32.zip rm $(AV_BASE)$(AV_VER)-win64.zip -$(OUT_DIR)/fteplug_ffmpeg$(PLUG_NATIVE_EXT): $(AV_DEP) $(FFMPEG_ZIP) +$(PLUG_PREFIX)ffmpeg$(PLUG_NATIVE_EXT): $(AV_DEP) $(FFMPEG_ZIP) -$(OUT_DIR)/fteplug_ffmpeg$(PLUG_NATIVE_EXT): $(AVPLUG_OBJS) +$(PLUG_PREFIX)ffmpeg$(PLUG_NATIVE_EXT): $(AVPLUG_OBJS) $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -s -o $@ -shared $(PLUG_CFLAGS) $(AV_CFLAGS) $(AVPLUG_OBJS) $(PLUG_DEFFILE) $(PLUG_LDFLAGS) $(AV_LDFLAGS) #small script for ode @@ -218,7 +230,7 @@ $(ODE_LIB): $(OUT_DIR)/../ode-$(ODE_VER).tar.gz cd $(ODE_BASE)ode-$(ODE_VER)/ && ./bootstrap && ./configure --enable-double-precision --disable-demos --without-x --with-pic CC="$(CC) $(PLUG_CXXFLAGS)" CXX="$(CC) $(PLUG_CXXFLAGS)" --host=`$(CC) -dumpmachine` && make ODE_FILES=../engine/common/com_phys_ode.c ../engine/common/mathlib.c plugin.c qvm_api.c $(ODE_LIB) -$(OUT_DIR)/fteplug_ode$(PLUG_NATIVE_EXT): $(ODE_FILES) +$(PLUG_PREFIX)ode$(PLUG_NATIVE_EXT): $(ODE_FILES) $(CC) -flto -s $(BASE_CFLAGS) $(CFLAGS) -Os -DFTEPLUGIN -DODE_STATIC -o $@ -shared $(PLUG_CFLAGS) -I$(ODE_BASE)ode-$(ODE_VER)/include $(ODE_FILES) $(PLUG_DEFFILE) $(PLUG_LDFLAGS) -static-libgcc `$(CC) -print-file-name=libstdc++.a` -lpthread #NATIVE_PLUGINS+=ode @@ -243,22 +255,22 @@ $(BULLET_LIB): $(OUT_DIR)/../bullet3-$(BULLET_VER).tar.gz #./configure --enable-double-precision --disable-demos --without-x CXX="$(CC)" CFLAGS="$(PLUG_CFLAGS)" CXXFLAGS="$(PLUG_CXXFLAGS)" --host=`$(CC) -dumpmachine` && make -$(OUT_DIR)/fteplug_bullet$(PLUG_NATIVE_EXT): bullet/bulletplug.cpp plugin.c qvm_api.c $(BULLET_LIBS) +$(PLUG_PREFIX)bullet$(PLUG_NATIVE_EXT): bullet/bulletplug.cpp plugin.c qvm_api.c $(BULLET_LIBS) $(CXX) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $@ -shared $(PLUG_CFLAGS) $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS) $(BULLET_CFLAGS) #NATIVE_PLUGINS+=bullet -include Makefile.private -$(OUT_DIR)/fteplug_mpq$(PLUG_NATIVE_EXT): mpq/fs_mpq.c mpq/blast.c plugin.c qvm_api.c +$(PLUG_PREFIX)mpq$(PLUG_NATIVE_EXT): mpq/fs_mpq.c mpq/blast.c plugin.c qvm_api.c $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $@ -shared $(PLUG_CFLAGS) -Impq $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS_ZLIB) $(PLUG_LDFLAGS) NATIVE_PLUGINS+=mpq -$(OUT_DIR)/fteplug_xmpp$(PLUG_NATIVE_EXT): jabber/jabberclient.c jabber/jingle.c jabber/sift.c jabber/xml.c plugin.c qvm_api.c ../engine/common/sha1.c emailnot/md5.c +$(PLUG_PREFIX)xmpp$(PLUG_NATIVE_EXT): jabber/jabberclient.c jabber/jingle.c jabber/sift.c jabber/xml.c plugin.c qvm_api.c ../engine/common/sha1.c emailnot/md5.c $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $@ -shared $(PLUG_CFLAGS) -Ijabber $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS) $(LIBRESOLV) NATIVE_PLUGINS+=xmpp -$(OUT_DIR)/fteplug_qi$(PLUG_NATIVE_EXT): qi/qi.c jabber/xml.c plugin.c qvm_api.c +$(PLUG_PREFIX)qi$(PLUG_NATIVE_EXT): qi/qi.c jabber/xml.c plugin.c qvm_api.c $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $@ -shared $(PLUG_CFLAGS) -Ijabber $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS) NATIVE_PLUGINS+=qi @@ -297,27 +309,27 @@ $(OUT_DIR)/cef_$(CEF_VER).zip: cef/$(CEF_NAME)/rel.zip cp cef/$(CEF_NAME)/rel.zip $@ CEF_SOURCES=cef/cef.c plugin.c qvm_api.c -$(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT): $(CEF_SOURCES) $(OUT_DIR)/cef_$(CEF_VER).zip cef/$(CEF_NAME)/include/cef_version.h - $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT) -shared $(PLUG_CFLAGS) -Icef/$(CEF_NAME) $(CEF_SOURCES) $(PLUG_DEFFILE) $(PLUG_LDFLAGS) -Wl,-rpath,. $(PLUG_LDFLAGS_DL) +$(PLUG_PREFIX)cef$(PLUG_NATIVE_EXT): $(CEF_SOURCES) $(OUT_DIR)/cef_$(CEF_VER).zip cef/$(CEF_NAME)/include/cef_version.h + $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $(PLUG_PREFIX)cef$(PLUG_NATIVE_EXT) -shared $(PLUG_CFLAGS) -Icef/$(CEF_NAME) $(CEF_SOURCES) $(PLUG_DEFFILE) $(PLUG_LDFLAGS) -Wl,-rpath,. $(PLUG_LDFLAGS_DL) #NATIVE_PLUGINS+=cef else -.PHONEY: $(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT) -$(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT): +.PHONEY: $(PLUG_PREFIX)cef$(PLUG_NATIVE_EXT) +$(PLUG_PREFIX)cef$(PLUG_NATIVE_EXT): echo cef plugin not supported on this arch endif #irc plugin can still be built as a qvm. -$(OUT_DIR)/fteplug_irc$(PLUG_NATIVE_EXT): irc/ircclient.c plugin.c qvm_api.c +$(PLUG_PREFIX)irc$(PLUG_NATIVE_EXT): irc/ircclient.c plugin.c qvm_api.c $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $@ -shared $(PLUG_CFLAGS) -Iirc $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS) NATIVE_PLUGINS+=irc #for compat with ezquake -$(OUT_DIR)/fteplug_ezhud$(PLUG_NATIVE_EXT): ezhud/ezquakeisms.c ezhud/hud.c ezhud/hud_common.c ezhud/hud_editor.c plugin.c qvm_api.c +$(PLUG_PREFIX)ezhud$(PLUG_NATIVE_EXT): ezhud/ezquakeisms.c ezhud/hud.c ezhud/hud_common.c ezhud/hud_editor.c plugin.c qvm_api.c $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $@ -shared $(PLUG_CFLAGS) -Iezhud $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS) NATIVE_PLUGINS+=ezhud -$(OUT_DIR)/fteplug_models$(PLUG_NATIVE_EXT): models/gltf.c models/models.c plugin.c qvm_api.c +$(PLUG_PREFIX)models$(PLUG_NATIVE_EXT): models/gltf.c models/models.c plugin.c qvm_api.c $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $@ -shared $(PLUG_CFLAGS) -Imodels $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS) #NATIVE_PLUGINS+=models -native: $(foreach FOO,$(NATIVE_PLUGINS), $(OUT_DIR)/fteplug_$(FOO)$(PLUG_NATIVE_EXT)) +native: $(foreach FOO,$(NATIVE_PLUGINS), $(PLUG_PREFIX)$(FOO)$(PLUG_NATIVE_EXT)) diff --git a/plugins/jabber/jabberclient.c b/plugins/jabber/jabberclient.c index a0ab5ac0d..a66852d15 100644 --- a/plugins/jabber/jabberclient.c +++ b/plugins/jabber/jabberclient.c @@ -601,7 +601,7 @@ qboolean NET_DNSLookup_SRV(const char *host, char *out, int outlen) } return false; } -#elif defined(__unix__) || defined(ANDROID) || defined(__MACH__) || defined(__linux__) +#elif (defined(__unix__) || defined(__MACH__) || defined(__linux__)) && !defined(ANDROID) #include #include qboolean NET_DNSLookup_SRV(const char *host, char *out, int outlen)