Integrated the version info of IoTivity
authorJaewook Jung <jw0213.jung@samsung.com>
Wed, 18 Jan 2017 10:09:20 +0000 (19:09 +0900)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Tue, 7 Mar 2017 12:21:20 +0000 (12:21 +0000)
The version of IoTivity is hard-coded in several files
and it is hard to manage.
So I integrated some of them except spec files for tizen.

The version info will be handled in octypes.h and
/build_common/SConscript.

And made applications can get the version info.
 - C/C++ : 'IOTIVITY_VERSION' in octype.h
 - Java  : 'OCPlatform.getIoTivityVersion()'

Change-Id: Ief7a7ba104faaa9397c314e4efa9426c81a7c0ed
Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16527
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
12 files changed:
build_common/SConscript
java/SConscript
java/iotivity-android/build.gradle
java/iotivity-android/src/main/java/org/iotivity/base/OcPlatform.java
java/iotivity-linux/src/main/java/org/iotivity/base/OcPlatform.java
java/jni/JniOcPlatform.cpp
java/jni/JniOcPlatform.h
resource/csdk/connectivity/src/caconnectivitymanager.c
resource/csdk/include/octypes.h
resource/csdk/logger/include/logger.h
resource/csdk/stack/src/ocstack.c
service/notification/src/common/NSConstants.h

index 24d1e50..ae1be46 100644 (file)
@@ -87,6 +87,9 @@ if ARGUMENTS.get('SECURED') == '1' and target_os in targets_without_dtls_support
 targets_disallow_multitransport = ['arduino']
 
 help_vars = Variables()
+
+help_vars.Add('PROJECT_VERSION', 'The version of IoTivity', project_version)
+
 help_vars.Add(BoolVariable('VERBOSE', 'Show compilation', False))
 help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
 help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
index d30fb1c..bdec6cf 100644 (file)
@@ -2,6 +2,8 @@ import os
 import platform
 Import('env')
 
+PROJECT_VERSION = env.get('PROJECT_VERSION')
+
 TARGET_ARCH = env.get('TARGET_ARCH')
 if env.get('RELEASE'):
        RELEASE="release"
@@ -94,14 +96,14 @@ def ensure_libs(target, source, env):
 SConscript('jni/SConscript')
 
 jdk_env = Environment(ENV=os.environ)
-jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b ' + env.get('SRC_DIR') + '/java/iotivity-%s/build.gradle -PWITH_TRANSPORT_EDR=%s -PWITH_TRANSPORT_BLE=%s -PWITH_TRANSPORT_NFC=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace' %(target_os, TRANSPORT_EDR, TRANSPORT_BLE, TRANSPORT_NFC, TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD, RD_MODE, MQ_PUB, MQ_SUB, MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER, env.get('BUILD_DIR')), emitter = ensure_libs)
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b ' + env.get('SRC_DIR') + '/java/iotivity-%s/build.gradle -PPROJECT_VERSION=%s -PWITH_TRANSPORT_EDR=%s -PWITH_TRANSPORT_BLE=%s -PWITH_TRANSPORT_NFC=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace' %(target_os, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE, TRANSPORT_NFC, TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD, RD_MODE, MQ_PUB, MQ_SUB, MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER, env.get('BUILD_DIR')), emitter = ensure_libs)
 jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
 cmdBuildApi=jdk_env.Gradle(target="base/objs", source="common/src/main/java/org/iotivity/base/OcResource.java")
 
 examples_target = "java"
 if target_os == 'android':
        examples_target = "android"
-jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b ' + 'java/examples-%s/build.gradle -DWITH_TRANSPORT_EDR=%s -DWITH_TRANSPORT_BLE=%s -DWITH_TRANSPORT_NFC=%s -PTARGET_OS=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace' %(examples_target, TRANSPORT_EDR, TRANSPORT_BLE, TRANSPORT_NFC, target_os, TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD, RD_MODE, MQ_PUB, MQ_SUB, MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER, env.get('BUILD_DIR')))
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b ' + 'java/examples-%s/build.gradle -PPROJECT_VERSION=%s -DWITH_TRANSPORT_EDR=%s -DWITH_TRANSPORT_BLE=%s -DWITH_TRANSPORT_NFC=%s -PTARGET_OS=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace' %(examples_target, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE, TRANSPORT_NFC, target_os, TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD, RD_MODE, MQ_PUB, MQ_SUB, MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER, env.get('BUILD_DIR')))
 #cmdBuildExamples=jdk_env.Gradle(target="../examples-%s/devicediscoveryclient/apk" % (examples_target, ), source="examples-%s/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java" % (examples_target, ))
 cmdBuildExamples=jdk_env.Gradle(target="examples-%s/simpleclient/jar" % (examples_target, ), source="examples-%s/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java" % (examples_target, ))
 
index a650c31..75184ba 100755 (executable)
@@ -73,7 +73,7 @@ android {
         minSdkVersion 21\r
         targetSdkVersion 21\r
         versionCode 1\r
-        versionName "1.3.0"\r
+        versionName PROJECT_VERSION\r
         buildConfigField 'int', 'SECURED', SECURED\r
         buildConfigField 'int', 'WITH_TCP', WITH_TCP\r
         buildConfigField 'int', 'WITH_CLOUD', WITH_CLOUD\r
index 2b604a2..34b0026 100644 (file)
@@ -1234,4 +1234,9 @@ public final class OcPlatform {
      * Method to set DeviceId.
      */
     public static native void setDeviceId(byte[] deviceId) throws OcException;
+
+    /**
+     * Method to get the version of IoTivity.
+     */
+    public static native String getIoTivityVersion();
 }
index b47587f..58807e9 100644 (file)
@@ -1225,4 +1225,9 @@ public final class OcPlatform {
      * Method to set DeviceId.
      */
     public static native void setDeviceId(byte[] deviceId) throws OcException;
+
+    /**
+     * Method to get the version of IoTivity.
+     */
+    public static native String getIoTivityVersion();
 }
index 83e4c7d..5fd6685 100644 (file)
@@ -2762,3 +2762,15 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setDeviceId(
         ThrowOcException(e.code(), e.reason().c_str());
     }
 }
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    getIoTivityVersion
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcPlatform_getIoTivityVersion(
+    JNIEnv *env, jclass thiz)
+{
+    LOGI("OcPlatform_getIoTivityVersion");
+    return env->NewStringUTF(IOTIVITY_VERSION);
+}
index df5ab12..71cf66c 100644 (file)
@@ -402,8 +402,16 @@ extern "C" {
      * Method:    setDeviceId
      * Signature: (Ljava/lang/byte;)V
      */
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setDeviceId(
-            JNIEnv *, jobject, jbyteArray);
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setDeviceId
+        (JNIEnv *, jobject, jbyteArray);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    getIoTivityVersion
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcPlatform_getIoTivityVersion
+        (JNIEnv *, jclass);
 
 #ifdef __cplusplus
 }
index 6c870ed..b37f163 100644 (file)
@@ -57,7 +57,6 @@ extern void CAsetCredentialTypesCallback(CAgetCredentialTypesHandler credCallbac
 
 CAResult_t CAInitialize(CATransportAdapter_t transportType)
 {
-    OIC_LOG_V(DEBUG, TAG, "IoTivity version is v%s", IOTIVITY_VERSION);
     OIC_LOG_V(DEBUG, TAG, "CAInitialize type : %d", transportType);
 
     if (!g_isInitialized)
index 4d6b639..008d931 100755 (executable)
@@ -48,6 +48,9 @@ extern "C" {
 // Defines
 //-----------------------------------------------------------------------------
 
+/** Version of IoTivity. */
+#define IOTIVITY_VERSION                      "1.3.0"
+
 /**
  * OIC Virtual resources supported by every OIC device.
  */
index 1f83f98..a009139 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef LOGGER_H_
 #define LOGGER_H_
 
-#define IOTIVITY_VERSION "1.3.0"
-
 #include <inttypes.h>
 #include <stdint.h>
 #include <stdio.h>
index 72a2fb7..cc1abd0 100644 (file)
@@ -2483,8 +2483,8 @@ OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlag
     return OCInit2(mode, serverFlags, clientFlags, OC_DEFAULT_ADAPTER);
 }
 
-OCStackResult OCInit2(OCMode mode, OCTransportFlags serverFlags,
-    OCTransportFlags clientFlags, OCTransportAdapter transportType)
+OCStackResult OCInit2(OCMode mode, OCTransportFlags serverFlags, OCTransportFlags clientFlags,
+                      OCTransportAdapter transportType)
 {
     OIC_LOG(INFO, TAG, "Entering OCInit2");
 
@@ -2498,7 +2498,7 @@ OCStackResult OCInit2(OCMode mode, OCTransportFlags serverFlags,
         // This is the first call to initialize the stack so it gets to do the real work.
         result = OCInitializeInternal(mode, serverFlags, clientFlags, transportType);
     }
-    
+
     if (result == OC_STACK_OK)
     {
         // Increment the start count since we're about to return success.
@@ -2512,7 +2512,7 @@ OCStackResult OCInit2(OCMode mode, OCTransportFlags serverFlags,
 }
 
 OCStackResult OCInitializeInternal(OCMode mode, OCTransportFlags serverFlags,
-    OCTransportFlags clientFlags, OCTransportAdapter transportType)
+                                   OCTransportFlags clientFlags, OCTransportAdapter transportType)
 {
     if (stackState == OC_STACK_INITIALIZED)
     {
@@ -2537,6 +2537,7 @@ OCStackResult OCInitializeInternal(OCMode mode, OCTransportFlags serverFlags,
     }
 #endif
 
+    OIC_LOG_V(INFO, TAG, "IoTivity version is v%s", IOTIVITY_VERSION);
     OCStackResult result = OC_STACK_ERROR;
 
     // Validate mode
index 4570aad..01d4a29 100644 (file)
         } \
     }
 
-#define VERSION        "1.3.0"
+#define VERSION        IOTIVITY_VERSION
 
 #define NS_ATTRIBUTE_VERSION "x.org.iotivity.ns.version"
 #define NS_ATTRIBUTE_POLICY "x.org.iotivity.ns.subcontrollability"