1 #//******************************************************************
3 #// Copyright 2016 Samsung Electronics All Rights Reserved.
5 #//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 #// Licensed under the Apache License, Version 2.0 (the "License");
8 #// you may not use this file except in compliance with the License.
9 #// You may obtain a copy of the License at
11 #// http://www.apache.org/licenses/LICENSE-2.0
13 #// Unless required by applicable law or agreed to in writing, software
14 #// distributed under the License is distributed on an "AS IS" BASIS,
15 #// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #// See the License for the specific language governing permissions and
17 #// limitations under the License.
19 #//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
25 android_home = env.get('ANDROID_HOME')
27 ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')
28 if env.get('RELEASE'):
29 ANDROID_RELEASE="release"
31 ANDROID_RELEASE="debug"
33 os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')
34 os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')
36 if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):
38 ***************************************** Info ********************************
39 * Either 'Android API 21' is not installed or 'Android SDK Build Tools *
40 * 20.0.0' is not installed. The Android SDK Manager will now open. Please *
41 * be sure to deselect all options, then select the following 2 packages: *
42 * 1. Under "Tools" select "Android SDK Build-tools" Revision 20. *
43 * 2. Under "Android 5.0.1 (API 21)" select "SDK Platform" *
44 * 3. Continue by selecting "Install 2 Packages" *
46 * NOTE: If you have an http proxy, please press ctrl+c now and edit/create *
47 * the following file in your $HOME directory as follows: *
49 * Edit/Create file: "$HOME/.android/androidtool.cfg" *
51 * http.proxyPort=<YOUR_PORT_NUMBER> *
52 * sdkman.monitor.density=108 *
53 * http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS> *
54 * sdkman.show.update.only=true *
55 * sdkman.ask.adb.restart=false *
56 * sdkman.force.http=true *
57 * sdkman.show.updateonly=true *
59 *******************************************************************************
61 ...Opening Android SDK Manager now. Once you are finished, the build will continue.
63 os.system(android_home + '/tools/android')
65 def ensure_libs(target, source, env):
66 return target, [source,
67 env.get('BUILD_DIR') + 'libnotification_provider_jni.so',
68 env.get('BUILD_DIR') + 'libnotification_provider_wrapper.so',
69 env.get('BUILD_DIR') + 'libnotification_provider.so',
70 env.get('BUILD_DIR') + 'libnotification_consumer_jni.so',
71 env.get('BUILD_DIR') + 'libnotification_consumer_wrapper.so',
72 env.get('BUILD_DIR') + 'libnotification_consumer.so']
74 jdk_env = Environment(ENV=os.environ)
75 jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') +
76 ' build -bservice/notification/examples/android/NotiProviderExample/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE),
77 emitter = ensure_libs)
78 jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
79 cmdBuildNotificationProviderApp=jdk_env.Gradle(target="app/apk",
80 source=["app/src/main/java/org/iotivity/service/ns/sample/provider/MainActivity.java",
81 "app/src/main/java/org/iotivity/service/ns/sample/provider/NotiListener.java",
82 "app/src/main/java/org/iotivity/service/ns/sample/provider/ProviderSample.java"])
83 jdk_env.Clean(cmdBuildNotificationProviderApp, '#/service/notification/examples/android/NotiProviderExample/build')
84 Depends(cmdBuildNotificationProviderApp, env.get('notificationAAR'))