summaryrefslogtreecommitdiff
path: root/package/build.macos-64
diff options
context:
space:
mode:
Diffstat (limited to 'package/build.macos-64')
-rw-r--r--package/build.macos-64215
1 files changed, 215 insertions, 0 deletions
diff --git a/package/build.macos-64 b/package/build.macos-64
new file mode 100644
index 0000000..f9bb1ae
--- /dev/null
+++ b/package/build.macos-64
@@ -0,0 +1,215 @@
+#!/bin/sh -e
+BUILD_ARCH=x86_64
+BUILD_PACKAGE="emulator-common-lib"
+BUILD_SW=cocoa
+TMP_DIR="$SRCDIR/data"
+META_MF=meta.mf
+OS_COMMON_DIR="$ROOTDIR/os-common"
+BIN_DIR="$SRCDIR/package/${BUILD_PACKAGE}.package.${TARGET_OS}/data/tools/emulator/bin/"
+# general .mf example
+#Extension: dylib
+#Usage: check-net
+#Version: 8.0 //get from "file" command
+#OS: ubuntu-32
+#Arch: x86_64
+#Package: emulator-lib
+#License:
+
+patch_loader_path()
+{
+
+ cd $BIN_DIR
+
+ # Libs[] is an array.
+ declare -a Libs
+
+ cnt=0
+ for i in $(ls *.dylib)
+ do
+ Libs[cnt]=$i
+ cnt+=1
+ done
+
+ for i in "${Libs[@]}"
+ do
+ Arr=( $(otool -L $i | awk '/\/opt\/local\/lib/ { split($1,lib,"/"); print lib[5] }') )
+ for lib in "${Arr[@]}"
+ do
+ #echo $lib
+ if [ "$i" == "$lib" ]
+ then
+ echo $i
+ install_name_tool -id $i $i
+ else
+ install_name_tool -change /opt/local/lib/$lib @loader_path/$lib $i
+ fi
+ done
+ done
+}
+
+trim_string()
+{
+ trimmed=$1
+ trimmed=${trimmed%% }
+ trimmed=${trimmed## }
+
+ echo "$trimmed"
+}
+
+contains()
+{
+ string="$1"
+ substring="$2"
+ if test "${string#*$substring}" != "$string"
+ then
+ echo $substring is in $string
+ else
+ echo $substring is not in $string
+ exit 1
+ fi
+}
+
+check_swt()
+{
+ # especially check for swt.jar
+ unzip $2
+ TEMP_SWT_WS=$(cat $2/META-INF/MANIFEST.MF | grep "SWT-WS:" | cut -d ':' -f2)
+ SWT_WS=$(trim_string $TEMP_SWT_WS)
+ if [ $SWT_WS != $BUILD_WS ];then
+ echo $SWT_WS is not supported.
+ exit 1
+ fi
+ TEMP_SWT_ARCH=$(cat $2/META-INF/MANIFEST.MF | grep "SWT-Arch:" | cut -d ':' -f2)
+ SWT_ARCH=$(trim_string $TEMP_SWT_ARCH)
+ if [ $SWT_ARCH != $BUILD_ARCH ];then
+ echo $SWT_ARCH is not supported.
+ exit 1
+ fi
+}
+
+# $1: mf file path (e.g. xxx.mf)
+# $2: original binary/library file path (e.g. xxx.dylib)
+check_file()
+{
+ # check arch from mf file
+ ARCHS=$(cat $1 | grep "Arch:" | cut -d ':' -f2)
+ contains "$ARCHS" $BUILD_ARCH
+ # do not use file command if file extension is not dylib.
+ if [ "$EXTENSION" == "dylib" ];then
+ ARCH_RESULT=$(file $2)
+ contains "$ARCH_RESULT" $BUILD_ARCH
+ fi
+ # TODO: some libraries do not have extension. need handling
+ # check OS
+ OSES=$(cat $i | grep "OS:" | cut -d ':' -f2)
+ contains "$OSES" $TARGET_OS
+
+ # copy file if validation passed.
+ echo "move $2 to $TMP_DIR"
+ mv -f "$2" $TMP_DIR
+}
+
+clean()
+{
+ rm -rf $SRCDIR/*.zip
+ rm -rf $SRCDIR/*.tar.gz
+}
+
+prepare()
+{
+ if [ ! -d $TMP_DIR ]
+ then
+ echo "make temp directory for emulator install : ( $TMP_DIR )"
+ mkdir $TMP_DIR
+ fi
+}
+
+# $1: root directory for traversing
+traverse_manifest()
+{
+
+ for i in $(find $1 -iname '*.mf')
+ do
+ # skip if filename is meta.mf it's used for packaging dev
+ if [ "$META_MF" == $(basename "$i") ];then
+ echo "skip $i"
+ continue
+ fi
+
+ TEMP_PACKAGE=$(cat "$i" | grep "Package:" | cut -d ':' -f2)
+ PACKAGES=$(trim_string "$(echo $TEMP_PACKAGE | tr "," "\n")")
+ TEMP_EXTENSION=$(cat "$i" | grep "Extension:" | cut -d ':' -f2)
+ EXTENSIONS=$(trim_string "$(echo $TEMP_EXTENSION | tr "," "\n")")
+ BUILD_OK=0
+ for PACKAGE in $PACKAGES
+ do
+ if [ ! -e "$PACKAGE" ] && [ "$PACKAGE" == $BUILD_PACKAGE ]
+ then
+ # BUILD_OK=1 means this manifest file support current build project
+ BUILD_OK=1
+
+ # find origin file(s) from manifest file
+ TRIM_EXTENSIONS=$(trim_string "$EXTENSIONS")
+ if [ "x" == "$TRIM_EXTENSIONS"x ];then
+ # used for Qt library. they do not have extension.
+ FILE=${i%%.mf}
+ check_file "$i" "$FILE"
+ else
+ for EXTENSION in $EXTENSIONS
+ do
+ echo found \"$PACKAGE\" in $i
+
+ if [ ! -e $EXTENSION ]
+ then
+ FILE=${i%%.mf}.$EXTENSION
+ else
+ FILE=${i%%.mf}
+ fi
+ if [ ! -f "$FILE" ] ;then
+ echo $FILE does not exist.
+ exit 1
+ fi
+ if [ $(basename $i) == swt ];then
+ check_swt "$i" "$FILE"
+ else
+ check_file "$i" "$FILE"
+ fi
+ done
+ fi
+ fi
+ done
+ if [ $BUILD_OK -eq 0 ]
+ then
+ echo "cannot find $BUILD_PACKAGE in $i skipped."
+ fi
+ done
+
+}
+
+build()
+{
+ prepare
+ echo "traverse_manifest $OS_COMMON_DIR"
+ traverse_manifest $OS_COMMON_DIR
+
+ echo "traverse_manifest $ROOTDIR/$TARGET_OS"
+ traverse_manifest $ROOTDIR/$TARGET_OS
+}
+
+install()
+{
+ # make directory structure
+ mkdir -p $BIN_DIR
+ mv -f $TMP_DIR/* $BIN_DIR
+
+ patch_loader_path
+
+ # after done, remove temp
+ rm -rf $TMP_DIR
+}
+
+[ "$1" = "clean" ] && clean
+[ "$1" = "build" ] && build
+[ "$1" = "install" ] && install
+
+echo "success"