build: Propagate log facilities using pkgconfig
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Tue, 26 Jul 2016 17:10:02 +0000 (19:10 +0200)
committerJon A. Cruz <jon@joncruz.org>
Fri, 2 Sep 2016 19:41:32 +0000 (19:41 +0000)
If built with LOGGING option,
 logging facilities will be available to user using pkgconfig.

Refactored SConscript to be more extensible using a defines list too.

Bug: http://lists.iotivity.org/pipermail/iotivity-dev/2016-July/005104.html
Change-Id: I93c92dd35f4060e46d31bbe80e773b548d92fcd8
Origin: https://gerrit.iotivity.org/gerrit/#/c/9783/
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9783
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
build_common/SConscript
iotivity.pc.in

index ea968c3..0264e6a 100644 (file)
@@ -6,6 +6,8 @@
 import os
 import platform
 
+project_version = '1.2.0'
+
 # Map of host os and allowed target os (host: allowed target os)
 host_target_map = {
                'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
@@ -73,7 +75,6 @@ else:
        logging_default = (release_mode == False)
 
 
-
 ######################################################################
 # Common build options (release, target os, target arch)
 ######################################################################
@@ -307,30 +308,31 @@ Export('env')
 ######################################################################
 pc_file = env.get('SRC_DIR') + '/iotivity.pc.in'
 
-if env.get('ROUTING') == 'GW':
-       routing_define = 'ROUTING_GATEWAY'
-elif env.get('ROUTING') == 'EP':
-       routing_define = 'ROUTING_EP'
-
 user_prefix = env.get('PREFIX')
 user_lib = env.get('LIB_INSTALL_DIR')
+
+if not user_prefix:
+    user_prefix = env.get('BUILD_DIR').encode('string_escape')
+
 if not user_lib:
-       user_lib = '$${prefix}/lib'
-
-if user_prefix:
-       pc_vars = {'\@PREFIX\@': user_prefix,
-                               '\@EXEC_PREFIX\@':user_prefix,
-                               '\@VERSION\@': '1.2.0',
-                               '\@LIB_INSTALL_DIR\@': user_lib,
-                               '\@ROUTING_DEFINE\@': routing_define
-                               }
-else:
-       pc_vars = {'\@PREFIX\@': env.get('BUILD_DIR').encode('string_escape'),
-                               '\@EXEC_PREFIX\@': env.get('BUILD_DIR').encode('string_escape'),
-                               '\@VERSION\@': '1.2.0',
-                               '\@LIB_INSTALL_DIR\@': user_lib,
-                               '\@ROUTING_DEFINE\@': routing_define
-                               }
+    user_lib = '$${prefix}/lib'
+
+defines = []
+if env.get('LOGGING'):
+    defines.append('-DTB_LOG=1')
+
+if env.get('ROUTING') == 'GW':
+    defines.append('-DROUTING_GATEWAY=1')
+elif env.get('ROUTING') == 'EP':
+    defines.append('-DROUTING_EP=1')
+
+pc_vars = {
+    '\@VERSION\@': project_version,
+    '\@PREFIX\@': user_prefix,
+    '\@EXEC_PREFIX\@': user_prefix,
+    '\@LIB_INSTALL_DIR\@': user_lib,
+    '\@DEFINES\@': " ".join(defines)
+}
 
 env.Substfile(pc_file, SUBST_DICT = pc_vars)
 
index 6057152..f5c06c9 100644 (file)
@@ -19,4 +19,4 @@ Cflags: -I${includedir}/resource \
                        -I${svcincludedir}/resource-hosting \
                        -I${svcincludedir}/resource-directory \
                        -I${svcincludedir}/things-manager \
-                       -D@ROUTING_DEFINE@
+                       @DEFINES@