From 2e08b0caf7ed1277f5dcc09218da54c03f36ae77 Mon Sep 17 00:00:00 2001 From: KIM JungYong Date: Wed, 5 Oct 2016 21:06:52 +0900 Subject: [PATCH] Update build scons for notificaiton android sample. When building notification service on android, was built just aar file but sample apk. In this patch building android will be built aar file and sample apk. Conflicts: service/notification/examples/android/NotiConsumerExample/app/build.gradle Change-Id: I32b9e06600e9063bc8115cd7302c73c938d14e8f Signed-off-by: KIM JungYong Reviewed-on: https://gerrit.iotivity.org/gerrit/12975 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- service/notification/SConscript | 6 +- service/notification/cpp-wrapper/SConscript | 3 +- .../android/NotiConsumerExample/SConscript | 83 +++++++++++++++++++++ .../android/NotiConsumerExample/app/build.gradle | 51 +++++++------ .../com/sec/noticonsumerexample/MainActivity.java | 4 +- .../app/src/main/res/values/styles.xml | 23 ++++-- .../android/NotiConsumerExample/build.gradle | 51 +++++++------ .../android/NotiProviderExample/SConscript | 84 ++++++++++++++++++++++ .../android/NotiProviderExample/app/build.gradle | 49 ++++++++----- .../com/sec/notiproviderexample/MainActivity.java | 4 +- .../app/src/main/res/values/styles.xml | 23 ++++-- .../android/NotiProviderExample/build.gradle | 51 +++++++------ service/notification/examples/android/SConscript | 22 ++++++ 13 files changed, 346 insertions(+), 108 deletions(-) create mode 100644 service/notification/examples/android/NotiConsumerExample/SConscript create mode 100644 service/notification/examples/android/NotiProviderExample/SConscript mode change 100644 => 100755 service/notification/examples/android/NotiProviderExample/app/build.gradle create mode 100644 service/notification/examples/android/SConscript diff --git a/service/notification/SConscript b/service/notification/SConscript index 24cc8b7..c4390a0 100755 --- a/service/notification/SConscript +++ b/service/notification/SConscript @@ -121,11 +121,11 @@ notification_env.UserInstallTargetHeader('include/NSConsumerInterface.h',\ if target_os == 'linux': SConscript('unittest/SConscript') -# Go to build sample apps -SConscript('examples/SConscript') - # Go to build c++ wrapper SConscript('cpp-wrapper/SConscript') if target_os == 'android': SConscript('android/SConscript') + +# Go to build sample apps +SConscript('examples/SConscript') \ No newline at end of file diff --git a/service/notification/cpp-wrapper/SConscript b/service/notification/cpp-wrapper/SConscript index b9005a0..fa553bd 100755 --- a/service/notification/cpp-wrapper/SConscript +++ b/service/notification/cpp-wrapper/SConscript @@ -28,5 +28,6 @@ SConscript('provider/SConscript') SConscript('consumer/SConscript') # Go to build sample apps using wrapper -SConscript('examples/linux/SConscript') +if target_os == 'linux': + SConscript('examples/linux/SConscript') diff --git a/service/notification/examples/android/NotiConsumerExample/SConscript b/service/notification/examples/android/NotiConsumerExample/SConscript new file mode 100644 index 0000000..e78f569 --- /dev/null +++ b/service/notification/examples/android/NotiConsumerExample/SConscript @@ -0,0 +1,83 @@ +#//****************************************************************** +#// +#// Copyright 2016 Samsung Electronics 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. +#// +#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +import os +import platform +Import('env') + +android_home = env.get('ANDROID_HOME') + +ANDROID_TARGET_ARCH = env.get('TARGET_ARCH') +if env.get('RELEASE'): + ANDROID_RELEASE="release" +else: + ANDROID_RELEASE="debug" + +os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME') +os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK') + +if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'): + print ''' +***************************************** Info ******************************** +* Either 'Android API 21' is not installed or 'Android SDK Build Tools * +* 20.0.0' is not installed. The Android SDK Manager will now open. Please * +* be sure to deselect all options, then select the following 2 packages: * +* 1. Under "Tools" select "Android SDK Build-tools" Revision 20. * +* 2. Under "Android 5.0.1 (API 21)" select "SDK Platform" * +* 3. Continue by selecting "Install 2 Packages" * +* * +* NOTE: If you have an http proxy, please press ctrl+c now and edit/create * +* the following file in your $HOME directory as follows: * +* * +* Edit/Create file: "$HOME/.android/androidtool.cfg" * +* * +* http.proxyPort= * +* sdkman.monitor.density=108 * +* http.proxyHost= * +* sdkman.show.update.only=true * +* sdkman.ask.adb.restart=false * +* sdkman.force.http=true * +* sdkman.show.updateonly=true * +* * +******************************************************************************* + +...Opening Android SDK Manager now. Once you are finished, the build will continue. +''' + os.system(android_home + '/tools/android') + +def ensure_libs(target, source, env): + return target, [source, + env.get('BUILD_DIR') + 'libnotification_provider_jni.so', + env.get('BUILD_DIR') + 'libnotification_provider_wrapper.so', + env.get('BUILD_DIR') + 'libnotification_provider.so', + env.get('BUILD_DIR') + 'libnotification_consumer_jni.so', + env.get('BUILD_DIR') + 'libnotification_consumer_wrapper.so', + env.get('BUILD_DIR') + 'libnotification_consumer.so'] + +jdk_env = Environment(ENV=os.environ) +jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + + ' build -bservice/notification/examples/android/NotiConsumerExample/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE), + emitter = ensure_libs) +jdk_env['BUILD_DIR'] = env.get('BUILD_DIR') +cmdBuildNotificationConsumerApp=jdk_env.Gradle(target="app/apk", + source=["app/src/main/java/com/sec/noticonsumerexample/MainActivity.java", + "app/src/main/java/com/sec/noticonsumerexample/ConsumerSample.java"]) + +Depends(cmdBuildNotificationConsumerApp, env.get('notificationAAR')) diff --git a/service/notification/examples/android/NotiConsumerExample/app/build.gradle b/service/notification/examples/android/NotiConsumerExample/app/build.gradle index 9023618..8d11640 100755 --- a/service/notification/examples/android/NotiConsumerExample/app/build.gradle +++ b/service/notification/examples/android/NotiConsumerExample/app/build.gradle @@ -1,21 +1,30 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" - - defaultConfig { - applicationId "sample.notification.service.iotivity.org.notificationconsumersample" - minSdkVersion 21 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } -} - -dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.android.support:appcompat-v7:23.0.1' - compile project(':iotivity-base-armeabi-release') - compile project(':iotivity-armeabi-notification-service-release') -} +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + packagingOptions { + pickFirst 'lib/armeabi/libocstack-jni.so' + pickFirst 'lib/armeabi-v7a/libocstack-jni.so' + pickFirst 'lib/x86/libocstack-jni.so' + } + + defaultConfig { + applicationId "sample.notification.service.iotivity.org.notificationconsumersample" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + + lintOptions { + abortOnError false + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + compile ":iotivity-${TARGET_ARCH}-notification-service-${RELEASE}@aar" +} diff --git a/service/notification/examples/android/NotiConsumerExample/app/src/main/java/com/sec/noticonsumerexample/MainActivity.java b/service/notification/examples/android/NotiConsumerExample/app/src/main/java/com/sec/noticonsumerexample/MainActivity.java index d79c440..f332ac2 100755 --- a/service/notification/examples/android/NotiConsumerExample/app/src/main/java/com/sec/noticonsumerexample/MainActivity.java +++ b/service/notification/examples/android/NotiConsumerExample/app/src/main/java/com/sec/noticonsumerexample/MainActivity.java @@ -21,7 +21,7 @@ package com.sec.noticonsumerexample; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.support.v7.app.AppCompatActivity; +import android.app.Activity; import android.util.Log; import android.view.View; import android.widget.Button; @@ -31,7 +31,7 @@ import android.widget.Toast; import org.iotivity.service.ns.common.TopicsList; import org.iotivity.service.ns.common.Topic; -public class MainActivity extends AppCompatActivity +public class MainActivity extends Activity { private final String TAG = "NS_MAIN_ACTIVITY"; diff --git a/service/notification/examples/android/NotiConsumerExample/app/src/main/res/values/styles.xml b/service/notification/examples/android/NotiConsumerExample/app/src/main/res/values/styles.xml index 6f19b47..afe1d34 100755 --- a/service/notification/examples/android/NotiConsumerExample/app/src/main/res/values/styles.xml +++ b/service/notification/examples/android/NotiConsumerExample/app/src/main/res/values/styles.xml @@ -1,11 +1,20 @@ - - - + + + + \ No newline at end of file diff --git a/service/notification/examples/android/NotiConsumerExample/build.gradle b/service/notification/examples/android/NotiConsumerExample/build.gradle index a1f101c..b009176 100755 --- a/service/notification/examples/android/NotiConsumerExample/build.gradle +++ b/service/notification/examples/android/NotiConsumerExample/build.gradle @@ -1,23 +1,28 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.5.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.5.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + + flatDir { + dirs '../../../../android/notification-service/build/outputs/aar' + dirs '../../../../../../android/android_api/base/build/outputs/aar' + } + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/service/notification/examples/android/NotiProviderExample/SConscript b/service/notification/examples/android/NotiProviderExample/SConscript new file mode 100644 index 0000000..4d4c8af --- /dev/null +++ b/service/notification/examples/android/NotiProviderExample/SConscript @@ -0,0 +1,84 @@ +#//****************************************************************** +#// +#// Copyright 2016 Samsung Electronics 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. +#// +#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +import os +import platform +Import('env') + +android_home = env.get('ANDROID_HOME') + +ANDROID_TARGET_ARCH = env.get('TARGET_ARCH') +if env.get('RELEASE'): + ANDROID_RELEASE="release" +else: + ANDROID_RELEASE="debug" + +os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME') +os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK') + +if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'): + print ''' +***************************************** Info ******************************** +* Either 'Android API 21' is not installed or 'Android SDK Build Tools * +* 20.0.0' is not installed. The Android SDK Manager will now open. Please * +* be sure to deselect all options, then select the following 2 packages: * +* 1. Under "Tools" select "Android SDK Build-tools" Revision 20. * +* 2. Under "Android 5.0.1 (API 21)" select "SDK Platform" * +* 3. Continue by selecting "Install 2 Packages" * +* * +* NOTE: If you have an http proxy, please press ctrl+c now and edit/create * +* the following file in your $HOME directory as follows: * +* * +* Edit/Create file: "$HOME/.android/androidtool.cfg" * +* * +* http.proxyPort= * +* sdkman.monitor.density=108 * +* http.proxyHost= * +* sdkman.show.update.only=true * +* sdkman.ask.adb.restart=false * +* sdkman.force.http=true * +* sdkman.show.updateonly=true * +* * +******************************************************************************* + +...Opening Android SDK Manager now. Once you are finished, the build will continue. +''' + os.system(android_home + '/tools/android') + +def ensure_libs(target, source, env): + return target, [source, + env.get('BUILD_DIR') + 'libnotification_provider_jni.so', + env.get('BUILD_DIR') + 'libnotification_provider_wrapper.so', + env.get('BUILD_DIR') + 'libnotification_provider.so', + env.get('BUILD_DIR') + 'libnotification_consumer_jni.so', + env.get('BUILD_DIR') + 'libnotification_consumer_wrapper.so', + env.get('BUILD_DIR') + 'libnotification_consumer.so'] + +jdk_env = Environment(ENV=os.environ) +jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + + ' build -bservice/notification/examples/android/NotiProviderExample/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE), + emitter = ensure_libs) +jdk_env['BUILD_DIR'] = env.get('BUILD_DIR') +cmdBuildNotificationProviderApp=jdk_env.Gradle(target="app/apk", + source=["app/src/main/java/com/sec/notiproviderexample/MainActivity.java", + "app/src/main/java/com/sec/notiproviderexample/NotiListener.java", + "app/src/main/java/com/sec/notiproviderexample/ProviderSample.java"]) + +Depends(cmdBuildNotificationProviderApp, env.get('notificationAAR')) diff --git a/service/notification/examples/android/NotiProviderExample/app/build.gradle b/service/notification/examples/android/NotiProviderExample/app/build.gradle old mode 100644 new mode 100755 index 38ea4c4..c320c1c --- a/service/notification/examples/android/NotiProviderExample/app/build.gradle +++ b/service/notification/examples/android/NotiProviderExample/app/build.gradle @@ -1,19 +1,30 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" - - defaultConfig { - applicationId "sample.notification.service.iotivity.org.notificationsample" - minSdkVersion 21 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } -} - -dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.android.support:appcompat-v7:23.0.1' -} +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + packagingOptions { + pickFirst 'lib/armeabi/libocstack-jni.so' + pickFirst 'lib/armeabi-v7a/libocstack-jni.so' + pickFirst 'lib/x86/libocstack-jni.so' + } + + defaultConfig { + applicationId "sample.notification.service.iotivity.org.notificationsample" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + + lintOptions { + abortOnError false + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + compile ":iotivity-${TARGET_ARCH}-notification-service-${RELEASE}@aar" +} diff --git a/service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/MainActivity.java b/service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/MainActivity.java index c9d821c..481f74e 100755 --- a/service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/MainActivity.java +++ b/service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/MainActivity.java @@ -28,7 +28,6 @@ import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; @@ -36,13 +35,14 @@ import android.widget.EditText; import android.widget.RadioButton; import android.widget.TextView; import android.widget.Toast; +import android.app.Activity; import org.iotivity.service.ns.common.MediaContents; import java.text.DateFormat; import java.util.Date; -public class MainActivity extends AppCompatActivity { +public class MainActivity extends Activity { private final String TAG = "NS_MAIN_ACTIVITY"; private static final int CONSUMER_SUBSCRIBED = 1; diff --git a/service/notification/examples/android/NotiProviderExample/app/src/main/res/values/styles.xml b/service/notification/examples/android/NotiProviderExample/app/src/main/res/values/styles.xml index 6f19b47..afe1d34 100644 --- a/service/notification/examples/android/NotiProviderExample/app/src/main/res/values/styles.xml +++ b/service/notification/examples/android/NotiProviderExample/app/src/main/res/values/styles.xml @@ -1,11 +1,20 @@ - - - + + + + \ No newline at end of file diff --git a/service/notification/examples/android/NotiProviderExample/build.gradle b/service/notification/examples/android/NotiProviderExample/build.gradle index a1f101c..b009176 100644 --- a/service/notification/examples/android/NotiProviderExample/build.gradle +++ b/service/notification/examples/android/NotiProviderExample/build.gradle @@ -1,23 +1,28 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.5.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.5.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + + flatDir { + dirs '../../../../android/notification-service/build/outputs/aar' + dirs '../../../../../../android/android_api/base/build/outputs/aar' + } + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/service/notification/examples/android/SConscript b/service/notification/examples/android/SConscript new file mode 100644 index 0000000..db1a1dc --- /dev/null +++ b/service/notification/examples/android/SConscript @@ -0,0 +1,22 @@ +#//****************************************************************** +#// +#// Copyright 2016 Samsung Electronics 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. +#// +#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +SConscript('NotiProviderExample/SConscript') +SConscript('NotiConsumerExample/SConscript') -- 2.7.4