Merge pull request #401 from mstorsjo/android-arm-assembly
Enable the arm assembly in android builds
This commit is contained in:
commit
01a2f582c3
4
Makefile
4
Makefile
@ -2,6 +2,7 @@ OS=$(shell uname | tr A-Z a-z | tr -d \\-[:digit:].)
|
||||
ARCH=$(shell uname -m)
|
||||
LIBPREFIX=lib
|
||||
LIBSUFFIX=a
|
||||
CCAS=$(CC)
|
||||
CXX_O=-o $@
|
||||
CXX_LINK_O=-o $@
|
||||
AR_OPTS=cr $@
|
||||
@ -44,6 +45,7 @@ LDFLAGS +=
|
||||
ifneq ($(V),Yes)
|
||||
QUIET_CXX = @printf "CXX\t$@\n";
|
||||
QUIET_CC = @printf "CC\t$@\n";
|
||||
QUIET_CCAS = @printf "CCAS\t$@\n";
|
||||
QUIET_ASM = @printf "ASM\t$@\n";
|
||||
QUIET_AR = @printf "AR\t$@\n";
|
||||
QUIET = @
|
||||
@ -110,9 +112,11 @@ include codec/encoder/targets.mk
|
||||
include codec/processing/targets.mk
|
||||
|
||||
ifneq (android, $(OS))
|
||||
ifneq (ios, $(OS))
|
||||
include codec/console/dec/targets.mk
|
||||
include codec/console/enc/targets.mk
|
||||
endif
|
||||
endif
|
||||
|
||||
libraries: $(LIBPREFIX)wels.$(LIBSUFFIX) $(LIBPREFIX)wels.$(SHAREDLIBSUFFIX)
|
||||
LIBRARIES += $(LIBPREFIX)wels.$(LIBSUFFIX) $(LIBPREFIX)wels.$(SHAREDLIBSUFFIX)
|
||||
|
@ -46,11 +46,20 @@ def write_asm_rule_pattern(f):
|
||||
f.write('\t$(QUIET_ASM)$(ASM) $(ASMFLAGS) $(ASM_INCLUDES) $(' + PREFIX + '_ASMFLAGS) $(' + PREFIX + '_ASM_INCLUDES) -o $@ $<\n')
|
||||
f.write("\n")
|
||||
|
||||
def write_asm_s_rule_pattern(f):
|
||||
src = "$(%s_SRCDIR)/%%.S"%(PREFIX)
|
||||
dst = "$(%s_SRCDIR)/%%.o"%(PREFIX)
|
||||
|
||||
f.write("%s: %s\n"%(dst, src))
|
||||
f.write('\t$(QUIET_CCAS)$(CCAS) $(CFLAGS) $(ASMFLAGS) $(INCLUDES) $(' + PREFIX + '_CFLAGS) $(' + PREFIX + '_INCLUDES) -c -o $@ $<\n')
|
||||
f.write("\n")
|
||||
|
||||
|
||||
def find_sources():
|
||||
cpp_files = []
|
||||
asm_files = []
|
||||
c_files = []
|
||||
s_files = []
|
||||
print EXCLUDE
|
||||
for dir in os.walk("."):
|
||||
for file in dir[2]:
|
||||
@ -61,7 +70,9 @@ def find_sources():
|
||||
asm_files.append(os.path.join(dir[0].strip('./'), file))
|
||||
if os.path.splitext(file)[1] == '.c':
|
||||
c_files.append(os.path.join(dir[0].strip('./'), file))
|
||||
return [cpp_files, asm_files, c_files]
|
||||
if os.path.splitext(file)[1] == '.S':
|
||||
s_files.append(os.path.join(dir[0].strip('./'), file))
|
||||
return [cpp_files, asm_files, c_files, s_files]
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
@ -91,7 +102,7 @@ try:
|
||||
except:
|
||||
sys.exit(1)
|
||||
|
||||
(cpp, asm, cfiles) = find_sources()
|
||||
(cpp, asm, cfiles, sfiles) = find_sources()
|
||||
|
||||
|
||||
|
||||
@ -120,6 +131,15 @@ if len(asm) > 0:
|
||||
f.write("%s_OBJS += $(%s_ASM_SRCS:.asm=.o)\n"%(PREFIX, PREFIX))
|
||||
f.write("endif\n\n")
|
||||
|
||||
if len(sfiles) > 0:
|
||||
f.write("ifeq ($(ASM_ARCH), arm)\n")
|
||||
f.write("%s_ASM_S_SRCS=\\\n"%(PREFIX))
|
||||
for c in sfiles:
|
||||
f.write("\t$(%s_SRCDIR)/%s\\\n"%(PREFIX, c))
|
||||
f.write("\n")
|
||||
f.write("%s_OBJS += $(%s_ASM_S_SRCS:.S=.o)\n"%(PREFIX, PREFIX))
|
||||
f.write("endif\n\n")
|
||||
|
||||
f.write("OBJS += $(%s_OBJS)\n"%PREFIX)
|
||||
|
||||
write_cpp_rule_pattern(f)
|
||||
@ -130,6 +150,9 @@ if len(cfiles) > 0:
|
||||
if len(asm) > 0:
|
||||
write_asm_rule_pattern(f)
|
||||
|
||||
if len(sfiles) > 0:
|
||||
write_asm_s_rule_pattern(f)
|
||||
|
||||
if args.library is not None:
|
||||
f.write("$(LIBPREFIX)%s.$(LIBSUFFIX): $(%s_OBJS)\n"%(args.library, PREFIX))
|
||||
f.write("\t$(QUIET)rm -f $@\n")
|
||||
|
@ -8,13 +8,14 @@ ifeq ($(ARCH), arm)
|
||||
GCCPATHPREFIX = arm-linux-androideabi
|
||||
GCCPREFIX = arm-linux-androideabi
|
||||
CFLAGS += -march=armv7-a -mfloat-abi=softfp
|
||||
ifeq (Yes, $(HAVE_NEON))
|
||||
CFLAGS += -mfpu=neon
|
||||
else
|
||||
CFLAGS += -mfpu=vfpv3-d16
|
||||
endif
|
||||
LDFLAGS += -march=armv7-a -Wl,--fix-cortex-a8
|
||||
APP_ABI = armeabi-v7a
|
||||
ifeq (Yes, $(USE_ASM))
|
||||
ASM_ARCH = arm
|
||||
CFLAGS += -DHAVE_NEON
|
||||
ASMFLAGS += -march=armv7-a -mfpu=neon
|
||||
endif
|
||||
else
|
||||
GCCPATHPREFIX = x86
|
||||
GCCPREFIX = i686-linux-android
|
||||
@ -37,7 +38,7 @@ SYSROOT = $(NDKROOT)/platforms/android-$(NDKLEVEL)/arch-$(ARCH)
|
||||
CXX = $(NDKROOT)/toolchains/$(GCCPATHPREFIX)-$(GCCVERSION)/prebuilt/$(HOSTOS)-$(HOSTARCH)/bin/$(GCCPREFIX)-g++
|
||||
CC = $(NDKROOT)/toolchains/$(GCCPATHPREFIX)-$(GCCVERSION)/prebuilt/$(HOSTOS)-$(HOSTARCH)/bin/$(GCCPREFIX)-gcc
|
||||
AR = $(NDKROOT)/toolchains/$(GCCPATHPREFIX)-$(GCCVERSION)/prebuilt/$(HOSTOS)-$(HOSTARCH)/bin/$(GCCPREFIX)-ar
|
||||
CFLAGS += -DLINUX -fpic --sysroot=$(SYSROOT)
|
||||
CFLAGS += -DLINUX -DANDROID_NDK -fpic --sysroot=$(SYSROOT)
|
||||
CXXFLAGS += -fno-rtti -fno-exceptions
|
||||
LDFLAGS += --sysroot=$(SYSROOT)
|
||||
SHLDFLAGS = -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-soname,libwels.so
|
||||
@ -58,3 +59,9 @@ decdemo: libraries
|
||||
|
||||
encdemo: libraries
|
||||
cd ./codec/build/android/enc && $(NDKROOT)/ndk-build -B APP_ABI=$(APP_ABI) && android update project -t $(TARGET) -p . && ant debug
|
||||
|
||||
COMMON_INCLUDES += -I$(NDKROOT)/sources/android/cpufeatures
|
||||
COMMON_OBJS += $(COMMON_SRCDIR)/cpu-features.o
|
||||
|
||||
codec/common/cpu-features.o: $(NDKROOT)/sources/android/cpufeatures/cpu-features.c
|
||||
$(QUIET_CC)$(CC) $(CFLAGS) $(INCLUDES) $(COMMON_CFLAGS) $(COMMON_INCLUDES) -c $(CXX_O) $<
|
||||
|
@ -1,3 +1,9 @@
|
||||
ifneq ($(filter %86 x86_64, $(ARCH)),)
|
||||
include build/platform-x86-common.mk
|
||||
endif
|
||||
ifneq ($(filter-out arm64, $(filter arm%, $(ARCH))),)
|
||||
ifeq ($(USE_ASM), Yes)
|
||||
ASM_ARCH = arm
|
||||
CFLAGS += -DHAVE_NEON
|
||||
endif
|
||||
endif
|
||||
|
@ -10,6 +10,6 @@ endif
|
||||
SDK_MIN = 5.1
|
||||
|
||||
SDKROOT = /Applications/Xcode.app/Contents/Developer/Platforms/$(SDKTYPE).platform/Developer/SDKs/$(SDKTYPE)$(SDK).sdk
|
||||
CFLAGS += -arch $(ARCH) -isysroot $(SDKROOT) -miphoneos-version-min=$(SDK_MIN)
|
||||
CFLAGS += -arch $(ARCH) -isysroot $(SDKROOT) -miphoneos-version-min=$(SDK_MIN) -DAPPLE_IOS
|
||||
LDFLAGS += -arch $(ARCH) -isysroot $(SDKROOT) -miphoneos-version-min=$(SDK_MIN)
|
||||
|
||||
|
@ -10,4 +10,7 @@ else
|
||||
ASMFLAGS += -f elf32
|
||||
endif
|
||||
endif
|
||||
ifeq ($(ASM_ARCH), arm)
|
||||
ASMFLAGS += -march=armv7-a -mfpu=neon
|
||||
endif
|
||||
|
||||
|
@ -22,6 +22,14 @@ COMMON_ASM_SRCS=\
|
||||
COMMON_OBJS += $(COMMON_ASM_SRCS:.asm=.o)
|
||||
endif
|
||||
|
||||
ifeq ($(ASM_ARCH), arm)
|
||||
COMMON_ASM_S_SRCS=\
|
||||
$(COMMON_SRCDIR)/arm_arch_common_macro.S\
|
||||
$(COMMON_SRCDIR)/deblocking_neon.S\
|
||||
|
||||
COMMON_OBJS += $(COMMON_ASM_S_SRCS:.S=.o)
|
||||
endif
|
||||
|
||||
OBJS += $(COMMON_OBJS)
|
||||
$(COMMON_SRCDIR)/%.o: $(COMMON_SRCDIR)/%.cpp
|
||||
$(QUIET_CXX)$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(COMMON_CFLAGS) $(COMMON_INCLUDES) -c $(CXX_O) $<
|
||||
@ -29,6 +37,9 @@ $(COMMON_SRCDIR)/%.o: $(COMMON_SRCDIR)/%.cpp
|
||||
$(COMMON_SRCDIR)/%.o: $(COMMON_SRCDIR)/%.asm
|
||||
$(QUIET_ASM)$(ASM) $(ASMFLAGS) $(ASM_INCLUDES) $(COMMON_ASMFLAGS) $(COMMON_ASM_INCLUDES) -o $@ $<
|
||||
|
||||
$(COMMON_SRCDIR)/%.o: $(COMMON_SRCDIR)/%.S
|
||||
$(QUIET_CCAS)$(CCAS) $(CFLAGS) $(ASMFLAGS) $(INCLUDES) $(COMMON_CFLAGS) $(COMMON_INCLUDES) -c -o $@ $<
|
||||
|
||||
$(LIBPREFIX)common.$(LIBSUFFIX): $(COMMON_OBJS)
|
||||
$(QUIET)rm -f $@
|
||||
$(QUIET_AR)$(AR) $(AR_OPTS) $+
|
||||
|
@ -34,6 +34,15 @@ DECODER_ASM_SRCS=\
|
||||
DECODER_OBJS += $(DECODER_ASM_SRCS:.asm=.o)
|
||||
endif
|
||||
|
||||
ifeq ($(ASM_ARCH), arm)
|
||||
DECODER_ASM_S_SRCS=\
|
||||
$(DECODER_SRCDIR)/core/arm/block_add_neon.S\
|
||||
$(DECODER_SRCDIR)/core/arm/intra_pred_neon.S\
|
||||
$(DECODER_SRCDIR)/core/arm/mc_neon.S\
|
||||
|
||||
DECODER_OBJS += $(DECODER_ASM_S_SRCS:.S=.o)
|
||||
endif
|
||||
|
||||
OBJS += $(DECODER_OBJS)
|
||||
$(DECODER_SRCDIR)/%.o: $(DECODER_SRCDIR)/%.cpp
|
||||
$(QUIET_CXX)$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(DECODER_CFLAGS) $(DECODER_INCLUDES) -c $(CXX_O) $<
|
||||
@ -41,6 +50,9 @@ $(DECODER_SRCDIR)/%.o: $(DECODER_SRCDIR)/%.cpp
|
||||
$(DECODER_SRCDIR)/%.o: $(DECODER_SRCDIR)/%.asm
|
||||
$(QUIET_ASM)$(ASM) $(ASMFLAGS) $(ASM_INCLUDES) $(DECODER_ASMFLAGS) $(DECODER_ASM_INCLUDES) -o $@ $<
|
||||
|
||||
$(DECODER_SRCDIR)/%.o: $(DECODER_SRCDIR)/%.S
|
||||
$(QUIET_CCAS)$(CCAS) $(CFLAGS) $(ASMFLAGS) $(INCLUDES) $(DECODER_CFLAGS) $(DECODER_INCLUDES) -c -o $@ $<
|
||||
|
||||
$(LIBPREFIX)decoder.$(LIBSUFFIX): $(DECODER_OBJS)
|
||||
$(QUIET)rm -f $@
|
||||
$(QUIET_AR)$(AR) $(AR_OPTS) $+
|
||||
|
Loading…
x
Reference in New Issue
Block a user