Skip to content

Commit

Permalink
refine build flow for linux/android/jni/pi/ios
Browse files Browse the repository at this point in the history
  • Loading branch information
gozfree committed Aug 22, 2015
1 parent 44a124c commit 33c051a
Show file tree
Hide file tree
Showing 67 changed files with 828 additions and 1,921 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ This is a collection of basic libraries.
* Depend on none of open source third party libraries.
* ...

## About Build
* by default, build x86 on linux, and libxxx folder can be built independently
* if only "libxxx folder" is checkout without "build folder", you can only build x86 and no color set
* with "build folder", you can build x86, pi, android, ios and color is also set
* "sudo make install" is needed when build libxxx alone.

## How To Build
$ `./build clean`

Expand All @@ -20,3 +26,7 @@ This is a collection of basic libraries.
$ `./build install` (may need sudo)

libxxx.h, libxxx.so or libxxx.a of libraries are in ./output/$(ARCH)

## How To ndk-build
$ `cd android_jni_libs`
$ `ndk-build`
1 change: 1 addition & 0 deletions android_jni_libs/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(call all-subdir-makefiles)
1 change: 1 addition & 0 deletions android_jni_libs/jni/libdict
1 change: 1 addition & 0 deletions android_jni_libs/jni/libgevent
1 change: 1 addition & 0 deletions android_jni_libs/jni/libglog
1 change: 1 addition & 0 deletions android_jni_libs/jni/libgzf
1 change: 1 addition & 0 deletions android_jni_libs/jni/libp2p
1 change: 1 addition & 0 deletions android_jni_libs/jni/libptcp
1 change: 1 addition & 0 deletions android_jni_libs/jni/librbtree
1 change: 1 addition & 0 deletions android_jni_libs/jni/librpc
1 change: 1 addition & 0 deletions android_jni_libs/jni/libskt
1 change: 1 addition & 0 deletions android_jni_libs/jni/libsort
1 change: 1 addition & 0 deletions android_jni_libs/jni/libstun
1 change: 1 addition & 0 deletions android_jni_libs/jni/libworkq
14 changes: 14 additions & 0 deletions android_jni_libs/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-18
40 changes: 20 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ CMD=$0
MODULE=$1
ARCH=$2

#default is x86
#default is linux
case $# in
0)
MODULE=all;
ARCH=x86;;
ARCH=linux;;
1)
ARCH=x86;;
ARCH=linux;;
esac

#add supported platform to here
PLATFORM="[x86|pi|android|ios]"
PLATFORM="[linux|pi|android|ios]"

#basic libraries
BASIC_LIBS="libgzf liblog libgevent libworkq libdict libsort librbtree"
BASIC_LIBS="libgzf libglog libgevent libworkq libdict libsort librbtree"
NETWORK_LIBS="libskt libstun libptcp librpc libp2p"

usage()
{
echo "==== usage ===="
echo "$CMD <module> [platform]"
echo "<module>: library to compile or all library, must needed"
echo "[platform]: x86, raspberrypi or android, default is x86, optional"
echo "[platform]: linux, raspberrypi or android, default is linux, optional"
echo ""
echo "./build.sh all $PLATFORM"
echo "./build.sh basic_libs $PLATFORM"
Expand All @@ -43,7 +43,7 @@ usage()
exit
}

config_x86()
config_linux()
{
CROSS_PREFIX=
}
Expand Down Expand Up @@ -78,8 +78,8 @@ config_arch()
config_pi;;
"android")
config_android;;
"x86")
config_x86;;
"linux")
config_linux;;
"ios")
config_ios;;
*)
Expand All @@ -100,7 +100,7 @@ build_module()
MODULE_DIR=${LIBS_DIR}/$1
ACTION=$2
if [ ! -d "${MODULE_DIR}" ]; then
echo "==== build ${MODULE} failed!"
echo "==== build ${ARCH} ${MODULE} failed!"
echo " dir \"${MODULE_DIR}\" is not exist"
return
fi
Expand All @@ -109,45 +109,45 @@ build_module()
case $ACTION in
"clean")
make clean > /dev/null
echo "==== clean ${MODULE} done."
echo "==== clean ${ARCH} ${MODULE} done."
return
;;
"install")
MAKE="make ARCH=${ARCH}"
${MAKE} install > /dev/null
if [ $? -ne 0 ]; then
echo "==== install ${MODULE} failed"
echo "==== install ${ARCH} ${MODULE} failed"
return;
else
echo "==== install ${MODULE} ${ARCH} done."
echo "==== install ${ARCH} ${MODULE} done."
fi
;;
"uninstall")
MAKE="make ARCH=${ARCH}"
${MAKE} uninstall > /dev/null
if [ $? -ne 0 ]; then
echo "==== uninstall ${MODULE} failed"
echo "==== uninstall ${ARCH} ${MODULE} failed"
return;
else
echo "==== uninstall ${MODULE} ${ARCH} done."
echo "==== uninstall ${ARCH} ${MODULE} done."
fi
;;
*)
MAKE="make ARCH=${ARCH} OUTPUT=${OUTPUT}"
if [[ ${ARCH} == "x86" || ${ARCH} == "pi" ]]; then
if [[ ${ARCH} == "linux" || ${ARCH} == "pi" || ${ARCH} == "android" ]]; then
${MAKE} > /dev/null
else
make -f Makefile.${ARCH} > /dev/null
echo "${ARCH} not support now" #make -f Makefile.${ARCH} > /dev/null
fi
if [ $? -ne 0 ]; then
echo "==== build ${MODULE} failed"
echo "==== build ${ARCH} ${MODULE} failed"
return;
else
echo "==== build ${MODULE} ${ARCH} done."
echo "==== build ${ARCH} ${MODULE} done."
fi
${MAKE} install > /dev/null
if [ $? -ne 0 ]; then
echo "==== install ${MODULE} failed"
echo "==== install ${ARCH} ${MODULE} failed"
return;
fi
;;
Expand Down
4 changes: 3 additions & 1 deletion liblog/android.conf → build/android.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ANDROID_INC_PATH := -I$(TOOLCHAINS_INCLUDE) \
ANDROID_MAIN_OBJ := $(PLATFORM_LIB)/crtbegin_dynamic.o \
$(PLATFORM_LIB)/crtend_android.o

#__ANDROID_APP__ is binary file
#__ANDROID_APK__ is apk file
ANDROID_CFLAGS := $(ANDROID_INC_PATH) \
-D__ANDROID_APP__ \
-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables
Expand All @@ -25,6 +27,6 @@ ANDROID_LDFLAGS := -L$(PLATFORM_LIB) \
-L$(STL_PATH)/thumb/ -lgnustl_static \
-L$(STL_PATH) -lsupc++ -nostdlib -Bdynamic -lstdc++ -lc -lgcc

MAKEDIR_OUTPUT := mkdir -p $(OUTPUT)
MAKEDIR_OUTPUT := @mkdir -p $(OUTPUT)/include -p $(OUTPUT)/lib
android_CFLAGS := $(ANDROID_CFLAGS)
android_LDFLAGS := $(ANDROID_LDFLAGS)
43 changes: 43 additions & 0 deletions build/color.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#color define

NC = "\033[0m"
BRED = "\033[1;31m"
BGREEN = "\033[1;32m"
BYELLOW = "\033[1;33m"
BBLUE = "\033[1;34m"
BMAGENTA = "\033[1;35m"
BCYAN = "\033[1;36m"
BWHITE = "\033[1;37m"

RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
BLUE = "\033[34m"
MAGENTA = "\033[35m"
CYAN = "\033[36m"
WHITE = "\033[37m"


#COLOR 0: disable color; 1: enable color
COLOR = 1

CC_V = $(CC_$(COLOR))
CXX_V = $(CXX_$(COLOR))
LD_V = $(LD_$(COLOR))
AR_V = $(AR_$(COLOR))
CP_V = $(CP_$(COLOR))
RM_V = $(RM_$(COLOR))
CC_0 = $(CC)
CC_1 = @printf '%b\t%b\t%b\n' $(CYAN)$(ARCH) CC $@$(NC); $(CC)
CXX_0 = $(CXX)
CXX_1 = @printf '%b\t%b\t%b\n' $(CYAN)$(ARCH) CXX $@$(NC); $(CXX)
LD_0 = $(LD)
LD_1 = @printf '%b\t%b\t%b\n' $(BGREEN)$(ARCH) LD $@$(NC); $(LD)
AR_0 = $(AR)
AR_1 = @printf '%b\t%b\t%b\n' $(YELLOW)$(ARCH) AR $@$(NC); $(AR)
CP_0 = cp
CP_1 = @printf '%b\t%b\n' $(BGREEN)$(ARCH) install$(NC); cp
RM_0 = rm
RM_1 = @printf '%b\t%b\n' $(BGREEN)$(ARCH) clean$(NC); rm


File renamed without changes.
7 changes: 7 additions & 0 deletions build/linux.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#### x86.conf
CROSS_PREFIX :=
#OUTPUT := `pwd`/../output/x86/

TOOLCHAINS_ROOT := `$(CROSS_PREFIX)gcc -print-sysroot`
PLATFORM_LIB := $(TOOLCHAINS_ROOT)/usr/lib
MAKEDIR_OUTPUT :=
7 changes: 7 additions & 0 deletions build/pi.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#### rasberrypi.conf
CROSS_PREFIX := arm-linux-gnueabihf-
OUTPUT := `pwd`/../output/pi/

TOOLCHAINS_ROOT := `$(CROSS_PREFIX)gcc -print-sysroot`
PLATFORM_LIB := $(TOOLCHAINS_ROOT)/usr/lib
MAKEDIR_OUTPUT := @mkdir -p $(OUTPUT)/lib -p $(OUTPUT)/include
17 changes: 17 additions & 0 deletions libdict/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := libdict

LIBRARIES_DIR := $(LOCAL_PATH)/../

LIBGZF_INC := $(LIBRARIES_DIR)/libgzf/

LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LIBGZF_INC)

# Add your application source files here...
LOCAL_SRC_FILES := libdict.c

include $(BUILD_SHARED_LIBRARY)
Loading

0 comments on commit 33c051a

Please sign in to comment.