Improve build script functions 09/203109/1 accepted/tizen/unified/20190411.040514 submit/tizen/20190410.042901
authorwansuyoo <wansu.yoo@samsung.com>
Wed, 10 Apr 2019 03:58:39 +0000 (12:58 +0900)
committerwansuyoo <wansu.yoo@samsung.com>
Wed, 10 Apr 2019 03:58:39 +0000 (12:58 +0900)
./build.sh          : build Go executable binary for amd64
./build.sh all      : build C executable binary for amd64
./build.sh arm      : build Go object for arm
./build.sh tizen    : build arm packages for Tizen

Change-Id: Iad1fc675b4766f0b3bcdf781bdbbe82182b708c6
Signed-off-by: wansuyoo <wansu.yoo@samsung.com>
.gitignore
.tizen.gbs.conf [new file with mode: 0644]
build.sh
packaging/edge-orchestration.spec
src/CMain/Makefile
src/CMain/inc/orchestration.h [new file with mode: 0644]
src/CMain/lib/liborchestration.a [new file with mode: 0644]
src/libedge-orchestration/Makefile

index 2b7f713735aadf371d1ef6bbb348244a9aa41497..348c1b6de23bbedfeb4457ab01b13431264b527a 100644 (file)
@@ -9,7 +9,8 @@ vendor/src
 doc/generate-api/*
 3rdparty/
 src/CMain/bin/*
-src/CMain/lib/*
+### upload liborchestration.a for gbs binary packaging
+#src/CMain/lib/*
 src/GoMain/bin/*
 src/libedge-orchestration/lib/*
 src/libedge-orchestration/sample/orchestration_sample
diff --git a/.tizen.gbs.conf b/.tizen.gbs.conf
new file mode 100644 (file)
index 0000000..ec9e349
--- /dev/null
@@ -0,0 +1,210 @@
+[general]
+profile = profile.55std
+#profile = profile.55emul
+#profile = profile.50std
+#profile = profile.50emul
+#profile = profile.40arm
+#profile = profile.40arm64
+#profile = profile.40emul
+#profile = profile.40emul64
+#profile = profile.McSolisArm
+#profile = profile.McSolisEmul
+#profile = profile.McZ4Arm
+#profile = profile.McZ4Emul
+#profile = profile.VdKantM
+#profile = profile.VdKantM_LITE
+#profile = profile.VdKantM2
+#profile = profile.VdKantM2_LITE
+#profile = profile.VdKantSU
+#profile = profile.Vdemulator32
+#profile = profile.DaFhubKantM
+#profile = profile.DaFhubEmul
+user =
+passwdx =
+
+############## Tizen 5.5 ##############
+[profile.55std]
+repos = repo.55base, repo.55std
+buildroot = ~/GBS-ROOT/55std
+
+[profile.55emul]
+repos = repo.55base, repo.55emul
+buildroot = ~/GBS-ROOT/55emul
+
+[repo.55base]
+#url=http://10.113.136.32/download/public_mirror/tizen/base/latest/repos/standard/packages/
+url=http://download.tizen.org/snapshots/tizen/base/latest/repos/standard/packages/
+
+[repo.55std]
+#url=http://10.113.136.32/download/public_mirror/tizen/unified/latest/repos/standard/packages/
+url=http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/
+
+[repo.55emul]
+#url=http://10.113.136.32/download/public_mirror/tizen/unified/latest/repos/emulator/packages/
+url=http://download.tizen.org/snapshots/tizen/unified/latest/repos/emulator/packages/
+
+
+############## Tizen 5.0 ##############
+[profile.50std]
+repos = repo.50base, repo.50std
+buildroot = ~/GBS-ROOT/50std
+
+[profile.50emul]
+repos = repo.50base, repo.50emul
+buildroot = ~/GBS-ROOT/50emul
+
+[repo.50base]
+#url=http://10.113.136.32/download/public_mirror/tizen/5.0-base/latest/repos/standard/packages/
+url=http://download.tizen.org/snapshots/tizen/5.0-base/latest/repos/standard/packages/
+
+[repo.50std]
+#url=http://10.113.136.32/download/public_mirror/tizen/5.0-unified/latest/repos/standard/packages/
+url=http://download.tizen.org/snapshots/tizen/5.0-unified/latest/repos/standard/packages/
+
+[repo.50std.local]
+url=file:/home/wansu/GBS-ROOT/50std/local/repos/tizen50std/armv7l/
+
+[repo.50emul]
+#url=http://10.113.136.32/download/public_mirror/tizen/5.0-unified/latest/repos/emulator/packages/
+url=http://download.tizen.org/snapshots/tizen/5.0-unified/latest/repos/emulator/packages/
+
+
+############## Tizen 4.0 ##############
+[profile.40arm]
+repos = repo.40base_arm, repo.40std
+buildroot = ~/GBS-ROOT/40arm
+
+[profile.40arm64]
+repos = repo.40base_arm64, repo.40std
+buildroot = ~/GBS-ROOT/40arm64
+
+[profile.40emul]
+repos = repo.40base_emul, repo.40emul
+buildroot = ~/GBS-ROOT/40emul
+
+[profile.40emul64]
+repos = repo.40base_emul64, repo.40emul
+buildroot = ~/GBS-ROOT/40emul64
+
+[repo.40base_arm]
+#url=http://10.113.136.32/download/public_mirror/tizen/4.0-base/latest/repos/arm/packages/
+url=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/arm/packages/
+
+[repo.40base_arm64]
+#url=http://10.113.136.32/download/public_mirror/tizen/4.0-base/latest/repos/arm64/packages/
+url=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/arm64/packages/
+
+[repo.40base_emul]
+#url=http://10.113.136.32/download/public_mirror/tizen/4.0-base/latest/repos/emulator32/packages/
+url=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/emulator32/packages/
+
+[repo.40base_emul64]
+#url=http://10.113.136.32/download/public_mirror/tizen/4.0-base/latest/repos/emulator64/packages/
+url=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/emulator64/packages/
+
+[repo.40std]
+#url=http://10.113.136.32/download/public_mirror/tizen/4.0-unified/latest/repos/standard/packages/
+url=http://download.tizen.org/snapshots/tizen/4.0-unified/latest/repos/standard/packages/
+
+[repo.40emul]
+#url=http://10.113.136.32/download/public_mirror/tizen/4.0-unified/latest/repos/emulator/packages/
+url=http://download.tizen.org/snapshots/tizen/4.0-unified/latest/repos/emulator/packages/
+
+
+############## Tizen 4.0 MCD ##############
+#McSolisArm
+[profile.McSolisArm]
+repos = repo.mc_solis_base_arm, repo.mc_solis_std
+buildroot = ~/GBS-ROOT/McSolisArm
+[repo.mc_solis_base_arm]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-base-mcd-solis/latest/repos/arm/packages/
+[repo.mc_solis_std]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-mcd-solis/latest/repos/standard/packages/
+
+#McSolisEmul
+[profile.McSolisEmul]
+repos = repo.mc_solis_base_emul, repo.mc_solis_emul
+buildroot = ~/GBS-ROOT/McSolisEmul
+[repo.mc_solis_base_emul]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-base-mcd-solis/latest/repos/ia32/packages/
+[repo.mc_solis_emul]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-mcd-solis/latest/repos/emulator/packages/
+
+[profile.McZ4Arm]
+repos = repo.mc_z4_base_arm, repo.mc_z4_std
+buildroot = ~/GBS-ROOT/McZ4
+[repo.mc_z4_base_arm]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-base-mcd-z4/latest/repos/arm/packages/
+[repo.mc_z4_std]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-mcd-z4/latest/repos/standard/packages/
+
+[profile.McZ4Emul]
+repos = repo.mc_z4_base_emul, repo.mc_z4_emul
+buildroot = ~/GBS-ROOT/McZ4
+[repo.mc_z4_base_emul]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-base-mcd-z4/latest/repos/ia32/packages/
+[repo.mc_z4_emul]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-mcd-z4/latest/repos/emulator/packages/
+
+############## Tizen 4.0 VD ##############
+# VdKantM
+[profile.VdKantM]
+repos = repo.product_KantM, repo.vd_base_standard
+buildroot = ~/GBS-ROOT/VdKantM
+[repo.product_KantM]
+url=http://168.219.244.109/products/tv/archive/2018/MAIN2018/KantM/latest/repos/product/armv7l/packages/
+
+# VdKantM_LITE
+[profile.VdKantM_LITE]
+repos = repo.product_KantM_LITE, repo.vd_base_standard
+buildroot = ~/GBS-ROOT/VdKantM_LITE
+[repo.product_KantM_LITE]
+url=http://168.219.244.109/products/tv/archive/2018/MAIN2018/KantM_LITE/latest/repos/product/armv7l/packages/
+
+# VdKantM2
+[profile.VdKantM2]
+repos = repo.product_KantM2, repo.vd_base_standard
+buildroot = ~/GBS-ROOT/VdKantM2
+[repo.product_KantM2]
+url=http://168.219.244.109/products/tv/archive/2018/MAIN2018/KantM2/latest/repos/product/armv7l/packages/
+
+# VdKantM2_LITE
+[profile.VdKantM2_LITE]
+repos = repo.product_KantM2_LITE, repo.vd_base_standard
+buildroot = ~/GBS-ROOT/VdKantM2_LITE
+[repo.product_KantM2_LITE]
+url=http://168.219.244.109/products/tv/archive/2018/MAIN2018/KantM2_LITE/latest/repos/product/armv7l/packages/
+
+# VdKantSU
+[profile.VdKantSU]
+repos = repo.product_KantSU, repo.vd_base_standard
+buildroot = ~/GBS-ROOT/VdKantSU
+[repo.product_KantSU]
+url=http://168.219.244.109/products/tv/archive/2018/MAIN2018/KantSU/latest/repos/product/armv7l/packages/
+
+# Vdemulator32
+[profile.Vdemulator32]
+repos = repo.product_emulator32, repo.vd_base_emulator32
+buildroot = ~/GBS-ROOT/Vdemulator32
+[repo.product_emulator32]
+url=http://168.219.244.109/products/tv/archive/2018/MAIN2018/emulator32/latest/repos/product/ia32/packages/
+
+[repo.vd_base_standard]
+url=http://168.219.244.109/tizen-rsa/tizen-4.0-base-main2018/standard/latest/repos/base/armv7l/packages/
+
+[repo.vd_base_emulator32]
+url=http://168.219.244.109/tizen-rsa/tizen-4.0-base-main2018/emulator32/latest/repos/base/ia32/packages/
+
+
+############## Tizen 4.0 DA ##############
+[profile.DaFhubKantM]
+repos = repo.40base_arm, repo.da_fhub_kant
+buildroot = ~/GBS-ROOT/DaFhubKantM
+[repo.da_fhub_kant]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-da-fhub4/latest/repos/KANTM/packages/
+
+[profile.DaFhubEmul]
+repos = repo.40base_emul, repo.da_fhub_emul
+buildroot = ~/GBS-ROOT/DaFhubEmul
+[repo.da_fhub_emul]
+url=http://165.213.149.200/download/snapshots/tizen/4.0-da-fhub4/latest/repos/emulator/packages/
index daa0fc03582fbcd469d5b7bab83b176f5c551ac2..6eec702bb61cebf9b89d128de4d46f9ceaff9860 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -13,11 +13,44 @@ DBUS_CONF_DIR="/etc/dbus-1/system.d"
 DBUS_SERVICE_DIR="/usr/share/dbus-1/system-services"
 
 BUILD_ALL=false
+BUILD_ARM=false
+BUILD_PKG=false
+
+case "$1" in
+    "all"|"")
+        if [ "$1" = "all" ]; then
+            BUILD_ALL=true
+        fi
+        echo "*****************************"
+        echo " Target Binary arch is amd64 "
+        echo "*****************************"
+        export GOARCH=amd64
+        export CC="gcc"
+        ;;
+    "arm"|"tizen")
+        BUILD_ARM=true
+        if [ "$1" = "tizen" ]; then
+            BUILD_PKG=true
+        fi
+        echo "*****************************"
+        echo " Target Binary arch is armv7 "
+        echo "*****************************"
+        export GOARCH=arm GOARM=7
+        export CC="arm-linux-gnueabi-gcc"
+        ;;
+    *)
+        echo "build script"
+        echo "Usage:"
+        echo "---------------------------------------------------------"
+        echo "  $0          : build Go executable binary for amd64 "
+        echo "  $0 all      : build C executable binary for amd64  "
+        echo "  $0 arm      : build Go object for arm"
+        echo "  $0 tizen    : build arm packages for Tizen"
+        echo "---------------------------------------------------------"
+        exit 0
+        ;;
+esac
 
-echo "*****************************"
-echo " Target Binary arch is amd64 "
-echo "*****************************"
-export GOARCH=amd64
 export GOPATH=$GOPATH:$BASE_DIR:$BASE_DIR/vendor
 
 ORG_VENDOR_DIR='vendor'
@@ -26,11 +59,6 @@ if [ ! -d $BASE_DIR/$CUR_VENDOR_DIR ]; then
     ln -s $BASE_DIR/$ORG_VENDOR_DIR $BASE_DIR/$CUR_VENDOR_DIR
 fi
 
-if [ "$1" = "all" ]; then
-    BUILD_ALL=true
-fi
-
-
 function install_prerequisite() {
     echo ""
     echo "-----------------------------------"
@@ -96,6 +124,18 @@ function lint_src_code() {
     make lint
 }
 
+function build_package() {
+    echo ""
+    echo "------------------------------------------"
+    echo " Create Packages for Tizen from gbs build"
+    echo "------------------------------------------"
+
+    gbs -c ./.tizen.gbs.conf build -A armv7l --include-all
+
+    ### build through go toolchain
+    #gbs -c ./.tizen.gbs.conf build -A armv7l --include-all --define 'go_build ON'
+}
+
 function register_service() {
     echo ""
     echo "-----------------------------------"
@@ -119,19 +159,26 @@ function register_service() {
     sudo systemctl status $SERVICE_FILE
 }
 
-
-if [ "$BUILD_ALL" = true ]
-then
+if [ "$BUILD_ARM" = true ]; then
     build_clean
-    install_prerequisite
-    build_test
     build_object
-    build_dbus
-    build_binary
-    lint_src_code
-    register_service
+    if [ "$BUILD_PKG" = true ]; then
+        build_package
+    fi
 else
-    build_clean
-    build_binary
+    if [ "$BUILD_ALL" = true ]
+    then
+        build_clean
+        install_prerequisite
+        build_test
+        build_object
+        build_dbus
+        build_binary
+        lint_src_code
+        register_service
+    else
+        build_clean
+        build_binary
+    fi
 fi
 
index 02655cb1fe003c45fbce13f016b85d36bd0d4adc..05b5e16699dee07972e6c16f46aa28d24a364fc2 100755 (executable)
@@ -55,25 +55,32 @@ cp %{SOURCE2} ./%{name}.service
 cp %{SOURCE3} ./lib%{name}.manifest
 cp %{SOURCE4} ./
 cp %{SOURCE5} ./
-%ifarch armv7l
-cp %{SOURCE11} ./
-tar -zxf %{SOURCE11}
-rm -f %{_builddir}/%{name}-%{version}/go1.12.linux-armv7.tar.gz
+
+%if "%{go_build}" == "ON"
+    %ifarch armv7l
+    cp %{SOURCE11} ./
+    tar -zxf %{SOURCE11}
+    rm -f %{_builddir}/%{name}-%{version}/go1.12.linux-armv7.tar.gz
+    %endif
 %endif
 
 %build
-ORG_VENDOR_DIR='vendor'
-CUR_VENDOR_DIR='vendor/src'
-ln -s %{_builddir}/%{name}-%{version}/${ORG_VENDOR_DIR} %{_builddir}/%{name}-%{version}/${CUR_VENDOR_DIR}
-
-export GOARCH=arm GOARM=7
-export GOROOT=%{_builddir}/%{name}-%{version}/go
-export PATH=$PATH:%{_builddir}/%{name}-%{version}/go/bin/linux_arm
-export GOPATH=%{_builddir}/%{name}-%{version}:%{_builddir}/%{name}-%{version}/vendor
 export BASE_DIR=.
 
-make clean
-make build-object %{?_smp_mflags}
+%if "%{go_build}" == "ON"
+    ORG_VENDOR_DIR='vendor'
+    CUR_VENDOR_DIR='vendor/src'
+    ln -s %{_builddir}/%{name}-%{version}/${ORG_VENDOR_DIR} %{_builddir}/%{name}-%{version}/${CUR_VENDOR_DIR}
+
+    export GOARCH=arm GOARM=7
+    export GOROOT=%{_builddir}/%{name}-%{version}/go
+    export PATH=$PATH:%{_builddir}/%{name}-%{version}/go/bin/linux_arm
+    export GOPATH=%{_builddir}/%{name}-%{version}:%{_builddir}/%{name}-%{version}/vendor
+
+    make clean
+    make build-object %{?_smp_mflags}
+%endif
+
 make build-dbus-server %{?_smp_mflags}
 make build-dbus-client %{?_smp_mflags}
 
@@ -81,6 +88,10 @@ make build-dbus-client %{?_smp_mflags}
 export BASE_DIR=.
 %make_install
 
+%post
+systemctl daemon-reload
+systemctl restart %{name}
+
 %files
 %manifest %{name}.manifest
 %license LICENSE.Apache-2.0
index 3637c9464c2a0745531763fd0a6904b4c83efd94..3676751582fa0045b13efa74fba3feb68dca78de 100755 (executable)
@@ -3,16 +3,16 @@
 #
 
 # Target parameters
-BIN_DIR        := $(BASE_DIR)/bin
-LIB_DIR                := $(BASE_DIR)/lib
-INC_DIR                := $(BASE_DIR)/inc
-SRC_DIR                := $(BASE_DIR)/src
+BIN_DIR                        := bin
+LIB_DIR                        := lib
+INC_DIR                        := inc
+SRC_DIR                        := src
 LIBRARY_FILE   := orchestration
 BINARY_FILE            := edge-orchestration
 SRC_FILES              := \
                        $(SRC_DIR)/main.c \
                        $(SRC_DIR)/orchestration_server.c
-OBJ_FILES      := $(BASE_DIR)/*.o
+OBJ_FILES              := *.o
 
 # Build parameter
 CC             := gcc
diff --git a/src/CMain/inc/orchestration.h b/src/CMain/inc/orchestration.h
new file mode 100644 (file)
index 0000000..e8369f0
--- /dev/null
@@ -0,0 +1,76 @@
+/* Code generated by cmd/cgo; DO NOT EDIT. */
+
+/* package interface */
+
+
+#line 1 "cgo-builtin-prolog"
+
+#include <stddef.h> /* for ptrdiff_t below */
+
+#ifndef GO_CGO_EXPORT_PROLOGUE_H
+#define GO_CGO_EXPORT_PROLOGUE_H
+
+typedef struct { const char *p; ptrdiff_t n; } _GoString_;
+
+#endif
+
+/* Start of preamble from import "C" comments.  */
+
+
+
+
+/* End of preamble from import "C" comments.  */
+
+
+/* Start of boilerplate cgo prologue.  */
+#line 1 "cgo-gcc-export-header-prolog"
+
+#ifndef GO_CGO_PROLOGUE_H
+#define GO_CGO_PROLOGUE_H
+
+typedef signed char GoInt8;
+typedef unsigned char GoUint8;
+typedef short GoInt16;
+typedef unsigned short GoUint16;
+typedef int GoInt32;
+typedef unsigned int GoUint32;
+typedef long long GoInt64;
+typedef unsigned long long GoUint64;
+typedef GoInt32 GoInt;
+typedef GoUint32 GoUint;
+typedef __SIZE_TYPE__ GoUintptr;
+typedef float GoFloat32;
+typedef double GoFloat64;
+typedef float _Complex GoComplex64;
+typedef double _Complex GoComplex128;
+
+/*
+  static assertion to make sure the file is being used on architecture
+  at least with matching size of GoInt.
+*/
+typedef char _check_for_32_bit_pointer_matching_GoInt[sizeof(void*)==32/8 ? 1:-1];
+
+typedef _GoString_ GoString;
+typedef void *GoMap;
+typedef void *GoChan;
+typedef struct { void *t; void *v; } GoInterface;
+typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
+
+#endif
+
+/* End of boilerplate cgo prologue.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern int OrchestrationInit();
+
+extern int OrchestrationRequestService(char* p0, char* p1);
+
+extern int PrintLog(char* p0);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/CMain/lib/liborchestration.a b/src/CMain/lib/liborchestration.a
new file mode 100644 (file)
index 0000000..34c7e6e
Binary files /dev/null and b/src/CMain/lib/liborchestration.a differ
index 8d0386e00b2d3255b8179ac0b1c0a6ffeb4fc3f3..347cba3eea0b53a9f597d1d31a347bea2a9770d8 100755 (executable)
@@ -3,15 +3,15 @@
 #
 
 # Target parameters
-INC_DIR                        := $(BASE_DIR)/inc
-LIB_DIR                        := $(BASE_DIR)/lib
-SRC_DIR                        := $(BASE_DIR)/src
-SAMPLE_DIR             := $(BASE_DIR)/sample
+INC_DIR                        := inc
+LIB_DIR                        := lib
+SRC_DIR                        := src
+SAMPLE_DIR             := sample
 LIBRARY_FILE   := liborchestration-client.so
 SRC_FILES              := \
                        $(SRC_DIR)/orchestration_client.c \
                        $(SRC_DIR)/dbus_consumer.c
-OBJ_FILES              := $(BASE_DIR)/*.o
+OBJ_FILES              := *.o
 
 # Build parameters
 CC             := gcc