TizenRefApp-4904 Prepare infrastructure for build under GBS 38/49738/2
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Tue, 20 Oct 2015 06:36:14 +0000 (09:36 +0300)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Tue, 20 Oct 2015 06:36:14 +0000 (09:36 +0300)
Change-Id: Iae509035cd32185643eb153b64043a376c21479b
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
13 files changed:
CMakeLists.txt [new file with mode: 0644]
build [new file with mode: 0755]
contacts/CMakeLists.txt [new file with mode: 0644]
contacts/shared/res/contacts.png [new file with mode: 0755]
contacts/smack.efl.in [new file with mode: 0644]
contacts/smack.manifest.in [new file with mode: 0644]
contacts/src/main.cpp [new file with mode: 0644]
contacts/tizen-manifest.xml.in [new file with mode: 0644]
deploy [new file with mode: 0755]
lib-common/CMakeLists.txt [new file with mode: 0644]
lib-common/inc/Utils/Tracer.h [new file with mode: 0644]
lib-common/src/Utils/Tracer.cpp [new file with mode: 0644]
packaging/org.tizen.contacts.spec [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..378b352
--- /dev/null
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 2.6)
+project(${PACKAGE} C CXX)
+
+include(FindPkgConfig)
+pkg_check_modules(TIZEN_PACKAGES REQUIRED
+       capi-appfw-application
+       contacts-service2
+       dlog
+       efl-extension
+       elementary
+)
+
+set(INCLUDES      "${TIZEN_PACKAGES_INCLUDE_DIRS};inc")
+set(LIBRARY_DIRS  "${TIZEN_PACKAGES_LIBRARY_DIRS}")
+set(LIBRARIES     "${TIZEN_PACKAGES_LIBRARIES};dl;rt;")
+
+include_directories(${INCLUDES})
+link_directories(${LIBRARY_DIRS})
+
+set(CMAKE_INSTALL_RPATH ${LIBDIR})
+set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+
+set(COMPILER_FLAGS "-fpie -fPIC -Wall")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS} -std=gnu99")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS} -std=c++11")
+
+add_definitions("-DPACKAGE=\"${PACKAGE}\"")
+add_definitions("-DLABEL=\"${LABEL}\"")
+add_definitions("-DRESDIR=\"${RESDIR}\"")
+add_definitions("-DEDJDIR=\"${EDJDIR}\"")
+add_definitions("-DIMGDIR=\"${IMGDIR}\"")
+
+add_subdirectory(lib-common)
+add_subdirectory(contacts)
diff --git a/build b/build
new file mode 100755 (executable)
index 0000000..90986cb
--- /dev/null
+++ b/build
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+usage()
+{
+    echo "Usage: `basename $0` [-h|--help] [-e|--emulator] | [-d|--device] [-2|--tizen2] | [-3|--tizen3] [-i|--init] [-t|--test]
+    -h, --help      Show this message.
+    -e, --emulator  Build for emulator (default).
+    -d, --device    Build for device.
+    -2, --tizen2    Build for Tizen 2.x (32-bit)
+    -3, --tizen3    Build for Tizen 3.0 (64-bit, default)
+    -i, --init      Build online (without --noinit).
+    -t, --test      Build with tests."
+}
+
+TARGET="e"
+TIZEN="3"
+NOINIT="--noinit"
+OPTS=$(getopt -o "edith23" -l "emulator,device,tizen2,tizen3,init,test,help" -- "$@" 2> /dev/null)
+
+if [ $? -ne 0 ]
+then
+    usage
+    exit 1
+fi
+
+for opt in $OPTS
+do
+    case $opt in
+        -e|--emulator)
+        TARGET="e"
+        ;;
+        -d|--device)
+        TARGET="d"
+        ;;
+        -2|--tizen2)
+        TIZEN="2"
+        ;;
+        -3|--tizen3)
+        TIZEN="3"
+        ;;
+        -i|--init)
+        NOINIT=""
+        ;;
+        -t|--test)
+        TEST=1
+        ;;
+        -h|--help)
+        usage
+        exit 1
+        ;;
+    esac
+done
+
+if [ $TIZEN = "2" ]
+then
+    if [ $TARGET = "e" ]
+    then
+        ARCH="i586"
+    else
+        ARCH="armv7l"
+    fi
+else
+    if [ $TARGET = "e" ]
+    then
+        ARCH="x86_64"
+    else
+        ARCH="aarch64"
+    fi
+fi
+
+if [ -z $TEST ]
+then
+    gbs build -A $ARCH --include-all --keep-packs $NOINIT
+else
+    gbs build -A $ARCH --include-all --keep-packs $NOINIT --define 'TEST ON'
+fi
+
diff --git a/contacts/CMakeLists.txt b/contacts/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f1b2184
--- /dev/null
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 2.6)
+project(contacts C CXX)
+
+file(GLOB_RECURSE SOURCES src/*.c src/*.cpp)
+include_directories(
+       ${CMAKE_SOURCE_DIR}/lib-common/inc
+       ${CMAKE_CURRENT_SOURCE_DIR}/inc
+)
+
+add_executable(${PROJECT_NAME} ${SOURCES})
+target_link_libraries(${PROJECT_NAME} ${LIBRARIES} common -pie)
+
+install(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+
+configure_file(tizen-manifest.xml.in ${PACKAGE}.xml)
+configure_file(smack.manifest.in ${CMAKE_SOURCE_DIR}/${PACKAGE}.manifest)
+configure_file(smack.efl.in ${PACKAGE}.efl)
+
+install(DIRECTORY shared/res/ DESTINATION ${ICONDIR})
+install(FILES ${PACKAGE}.xml DESTINATION ${MANIFESTDIR})
+install(FILES ${PACKAGE}.efl DESTINATION ${SMACKDIR})
diff --git a/contacts/shared/res/contacts.png b/contacts/shared/res/contacts.png
new file mode 100755 (executable)
index 0000000..0775b27
Binary files /dev/null and b/contacts/shared/res/contacts.png differ
diff --git a/contacts/smack.efl.in b/contacts/smack.efl.in
new file mode 100644 (file)
index 0000000..74f4554
--- /dev/null
@@ -0,0 +1,2 @@
+@PACKAGE@ device::app_logging rw---- ------
+@PACKAGE@ device::sys_logging rw---- ------
diff --git a/contacts/smack.manifest.in b/contacts/smack.manifest.in
new file mode 100644 (file)
index 0000000..edd5d05
--- /dev/null
@@ -0,0 +1,8 @@
+<manifest>
+       <define>
+               <domain name="@PACKAGE@" />
+       </define>
+       <request>
+               <domain name="@PACKAGE@" />
+       </request>
+</manifest>
diff --git a/contacts/src/main.cpp b/contacts/src/main.cpp
new file mode 100644 (file)
index 0000000..3775554
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+int main(int argc, char *argv[])
+{
+       return 0;
+}
diff --git a/contacts/tizen-manifest.xml.in b/contacts/tizen-manifest.xml.in
new file mode 100644 (file)
index 0000000..45cc66f
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="2.4" package="@PACKAGE@" version="1.0.0">
+       <profile name="mobile"/>
+       <ui-application appid="@PACKAGE@" exec="@BINDIR@/contacts" hw-acceleration="use-GL" multiple="false" nodisplay="false" taskmanage="true" type="capp">
+               <label>Contacts</label>
+               <label xml:lang="ar-ae">الأسماء</label>
+               <label xml:lang="az-az">Adlar</label>
+               <label xml:lang="bg-bg">Телефонен указател</label>
+               <label xml:lang="ca-es">Contactes</label>
+               <label xml:lang="cs-cz">Kontakty</label>
+               <label xml:lang="da-dk">Kontakter</label>
+               <label xml:lang="de-de">Kontakte</label>
+               <label xml:lang="el-gr">Επαφές</label>
+               <label xml:lang="en-gb">Contacts</label>
+               <label xml:lang="en-ph">Contacts</label>
+               <label xml:lang="en-us">Contacts</label>
+               <label xml:lang="es-es">Contactos</label>
+               <label xml:lang="es-mx">Contactos</label>
+               <label xml:lang="et-ee">Kontaktid</label>
+               <label xml:lang="eu-es">Kontaktuak</label>
+               <label xml:lang="fi-fi">Yhteystiedot</label>
+               <label xml:lang="fr-ca">Contacts</label>
+               <label xml:lang="fr-fr">Contacts</label>
+               <label xml:lang="ga-ie">Teagmhálaithe</label>
+               <label xml:lang="gl-es">Contactos</label>
+               <label xml:lang="hi-in">संपर्क</label>
+               <label xml:lang="hr-hr">Imenik</label>
+               <label xml:lang="hu-hu">Névjegyek</label>
+               <label xml:lang="hy-am">Կոնտակտներ</label>
+               <label xml:lang="is-is">Tengiliðir</label>
+               <label xml:lang="it-it">Rubrica</label>
+               <label xml:lang="ja-jp">電話帳</label>
+               <label xml:lang="ka-ge">კონტაქტები</label>
+               <label xml:lang="kk-kz">Контактілер</label>
+               <label xml:lang="ko-kr">연락처</label>
+               <label xml:lang="lt-lt">Adresatai</label>
+               <label xml:lang="lv-lv">Kontakti</label>
+               <label xml:lang="mk-mk">Именик</label>
+               <label xml:lang="nb-no">Kontakter</label>
+               <label xml:lang="nl-nl">Contacten</label>
+               <label xml:lang="pl-pl">Kontakty</label>
+               <label xml:lang="pt-br">Contatos</label>
+               <label xml:lang="pt-pt">Contactos</label>
+               <label xml:lang="ro-ro">Contacte</label>
+               <label xml:lang="ru-ru">Контакты</label>
+               <label xml:lang="sk-sk">Kontakty</label>
+               <label xml:lang="sl-si">Imenik</label>
+               <label xml:lang="sr-rs">Kontakti</label>
+               <label xml:lang="sv-se">Kontakter</label>
+               <label xml:lang="tr-tr">Rehber</label>
+               <label xml:lang="uk-ua">Контакти</label>
+               <label xml:lang="uz-uz">Kontaktlar</label>
+               <label xml:lang="zh-cn">联系人</label>
+               <label xml:lang="zh-hk">聯絡人</label>
+               <label xml:lang="zh-tw">聯絡人</label>
+               <icon>contacts.png</icon>
+       </ui-application>
+</manifest>
diff --git a/deploy b/deploy
new file mode 100755 (executable)
index 0000000..22edc8d
--- /dev/null
+++ b/deploy
@@ -0,0 +1,150 @@
+#!/bin/bash
+
+usage()
+{
+    echo "Usage: `basename $0` [-h|--help] [-e|--emulator] [-d|--device]
+    -h, --help      Show this message.
+    -e, --emulator  Install on emulator (default).
+    -d, --device    Install on device.
+    -2, --tizen2    Install on Tizen 2.x (32-bit)
+    -3, --tizen3    Install on Tizen 3.0 (64-bit, default)
+    -r, --rpm       Install packages via RPM."
+}
+
+DEVS=($(sdb devices | tail -n+2))
+
+if [ -z $DEVS ]
+then
+    echo "Please connect device or launch emulator."
+    exit 1
+fi
+
+OPTS=$(getopt -o "hedr23" -l "help,emulator,tizen2,tizen3,device,rpm" -- "$@" 2> /dev/null)
+
+if [ $? -ne 0 ]
+then
+    usage
+    exit 1
+fi
+
+TARGET="e"
+TIZEN="3"
+
+for opt in $OPTS
+do
+    case $opt in
+        -e|--emulator)
+        TARGET="e"
+        ;;
+        -d|--device)
+        TARGET="d"
+        ;;
+        -2|--tizen2)
+        TIZEN="2"
+        ;;
+        -3|--tizen3)
+        TIZEN="3"
+        ;;
+        -h|--help)
+        usage
+        exit 0
+        ;;
+        -r|--rpm)
+        RPM=true
+        ;;
+    esac
+done
+
+if [ $TIZEN = "2" ]
+then
+    if [ $TARGET = "e" ]
+    then
+        ARCH="i586"
+    else
+        ARCH="armv7l"
+    fi
+else
+    if [ $TARGET = "e" ]
+    then
+        ARCH="x86_64"
+    else
+        ARCH="aarch64"
+    fi
+fi
+
+push()
+{
+    GBS=~/GBS-ROOT
+    ROOT=$GBS/local/BUILD-ROOTS/scratch.$ARCH.0
+
+    if [ ! -e $ROOT/*.conf ]
+    then
+        echo "Build root is not ready at $ROOT."
+        exit 1
+    fi
+
+    REPO=$(basename $ROOT/*.conf)
+    REPO=${REPO%.*}
+    RPMS=$GBS/local/repos/$REPO/$ARCH/RPMS
+
+    if [ ! -e "$RPMS/$1" ]
+    then
+        echo "Can't find $1 in $RPMS. Run build first."
+        exit 1
+    fi
+
+    echo "Pushing $1 into $2..."
+    sdb -$TARGET push "$RPMS/$1" "$2"  2> /dev/null
+}
+
+install()
+{
+    echo "Installing $2..."
+
+    if [ $RPM ]
+    then
+        sdb -$TARGET root on
+        sdb -$TARGET shell rpm -i --force "$1/$2"
+        sdb -$TARGET shell pkg_initdb
+        sdb -$TARGET root off
+    else
+        sdb -$TARGET shell pkgcmd -iqt rpm -p "$1/$2"
+    fi
+}
+
+deploy()
+{
+    push "$1" "$2"
+    install "$2" "$1"
+    sdb -$TARGET shell rm "$2/$1" > /dev/null
+}
+
+DEST=/tmp
+VER=$(grep Version: packaging/*.spec | awk '{print $2}')
+REL=$(grep Release: packaging/*.spec | awk '{print $2}')
+SUFFIX="$VER-$REL.$ARCH.rpm"
+
+PKG=$(grep Name: packaging/*.spec | awk '{print $2}')
+PKGS=($(grep %package packaging/*.spec | awk '{print $3}'))
+
+if [ -z $PKGS ]
+then
+    deploy "$PKG-$SUFFIX" "$DEST"
+else
+    echo "Current package contains several sub-packages:"
+    PKGS=($PKG ${PKGS[*]})
+    for i in ${!PKGS[@]}
+    do
+        echo "$((i + 1)). ${PKGS[$i]}"
+    done
+
+    echo "Specify packages and order of installation (for example: 5 1):"
+    read NUMS
+
+    for i in $NUMS
+    do
+        deploy "${PKGS[$((i - 1))]}-$SUFFIX" "$DEST"
+    done
+fi
+echo "Done."
+
diff --git a/lib-common/CMakeLists.txt b/lib-common/CMakeLists.txt
new file mode 100644 (file)
index 0000000..817c840
--- /dev/null
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 2.6)
+project(common C CXX)
+
+file(GLOB_RECURSE SOURCES src/*.c src/*.cpp)
+include_directories(
+       ${CMAKE_CURRENT_SOURCE_DIR}/inc
+)
+
+add_library(${PROJECT_NAME} SHARED ${SOURCES})
+target_link_libraries(${PROJECT_NAME} ${LIBRARIES})
+
+install(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR})
diff --git a/lib-common/inc/Utils/Tracer.h b/lib-common/inc/Utils/Tracer.h
new file mode 100644 (file)
index 0000000..db960a6
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef UTILS_TRACER_H
+#define UTILS_TRACER_H
+
+#include <time.h>
+
+namespace Utils
+{
+       /**
+        * @brief Code block logger. Writes logs when created and destroyed. Outputs elapsed time.
+        */
+       class Tracer
+       {
+       public:
+               /**
+                * @brief Create tracer and write entry log.
+                * @param[in]   tag     Log tag
+                * @param[in]   file    Current source file
+                * @param[in]   func    Current function
+                * @param[in]   line    Current source line
+                */
+               Tracer(const char *tag, const char *file, const char *func, int line);
+               ~Tracer();
+
+       private:
+               const char *m_Tag;
+               const char *m_File;
+               const char *m_Func;
+               timespec m_startTime;
+       };
+}
+
+#endif /* UTILS_TRACER_H */
diff --git a/lib-common/src/Utils/Tracer.cpp b/lib-common/src/Utils/Tracer.cpp
new file mode 100644 (file)
index 0000000..3ad64b7
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Utils/Tracer.h"
+#include <dlog.h>
+
+using namespace Utils;
+
+void subtractTime(const timespec &a, const timespec &b, timespec &res)
+{
+       static const size_t ratio(1000000000);
+
+       res.tv_sec = b.tv_sec - a.tv_sec;
+       res.tv_nsec = b.tv_nsec - a.tv_nsec;
+       if (res.tv_nsec < 0)
+       {
+               --res.tv_sec;
+               res.tv_nsec += ratio;
+       }
+}
+
+Tracer::Tracer(const char *tag, const char *file, const char *func, int line)
+       : m_Tag(tag), m_File(file), m_Func(func)
+{
+       dlog_print(DLOG_DEBUG, m_Tag, "%s: %s(%d) <<< called", m_File, m_Func, line);
+       clock_gettime(CLOCK_REALTIME, &m_startTime);
+}
+
+Tracer::~Tracer()
+{
+       timespec endTime;
+       clock_gettime(CLOCK_REALTIME, &endTime);
+
+       timespec res;
+       subtractTime(m_startTime, endTime, res);
+
+       dlog_print(DLOG_DEBUG, m_Tag, "%s: %s >>> returned in %d.%03d seconds",
+               m_File, m_Func, res.tv_sec, res.tv_nsec / 1000000);
+}
diff --git a/packaging/org.tizen.contacts.spec b/packaging/org.tizen.contacts.spec
new file mode 100644 (file)
index 0000000..a53e9fe
--- /dev/null
@@ -0,0 +1,58 @@
+Name: org.tizen.contacts
+Version: 0.1
+Release: 1
+License: Apache-2.0
+Summary: Contacts and Phone Applications
+Group: Applications/Social
+Source: %{name}-%{version}.tar.gz
+
+BuildRequires: cmake
+BuildRequires: edje-bin
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(contacts-service2)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(efl-extension)
+BuildRequires: pkgconfig(elementary)
+
+%description
+Contacts and Phone Reference Applications.
+
+%define _pkgdir /usr/apps/%{name}
+%define _bindir %{_pkgdir}/bin
+%define _libdir %{_pkgdir}/lib
+%define _resdir %{_pkgdir}/res
+%define _manifestdir /usr/share/packages
+%define _icondir /usr/share/icons/default/small
+%define _smackdir /etc/smack/accesses.d
+
+%prep
+%setup -q
+
+%build
+cmake \
+       %{!?RELEASE: -DCMAKE_BUILD_TYPE=Debug }\
+       '-DPACKAGE=%{name}'\
+       '-DCMAKE_INSTALL_PREFIX=%{_pkgdir}'\
+       '-DBINDIR=%{_bindir}'\
+       '-DLIBDIR=%{_libdir}'\
+       '-DRESDIR=%{_resdir}'\
+       '-DMANIFESTDIR=%{_manifestdir}'\
+       '-DICONDIR=%{_icondir}'\
+       '-DSMACKDIR=%{_smackdir}'
+
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%manifest %{name}.manifest
+%{_bindir}/*
+%{_libdir}/*.so
+%{_manifestdir}/%{name}.xml
+%{_icondir}/*.png
+%{_smackdir}/%{name}.efl