Reformat SConstruct to Python code style
authorMats Wichmann <mats@linux.com>
Fri, 7 Jul 2017 17:06:53 +0000 (11:06 -0600)
committerPhil Coval <philippe.coval@osg.samsung.com>
Tue, 11 Jul 2017 07:50:08 +0000 (07:50 +0000)
This is the last important build script that did not get reformatted:
  clarify some things in comments
  4-space indents
  python style: should use "is" and "is not" comparisons to None
  use clearer test for service/java depend (java_build was just calculated)
  use list-of-dirs form to call list of projects

Bug: https://jira.iotivity.org/browse/IOT-1745
Change-Id: Id260c2e55d62cb824d1e23e62df4ca8df5ce2b80
Signed-off-by: Mats Wichmann <mats@linux.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21157
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: George Nash <george.nash@intel.com>
Reviewed-by: Pawel Winogrodzki <pawelwi@microsoft.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
SConstruct

index 38bf323..0da7e31 100644 (file)
@@ -27,23 +27,33 @@ import os
 # Load common build config
 SConscript('build_common/SConscript')
 
+# The construction environment named 'env' is set up in build_common
+# and should be imported by all other scripts which need access to it.
+# Scripts which do not need to modify the global construction environment
+# should Clone() this environment and modify the clone.
+# Scripts which need to modify the global environment should not
+# work on a clone, since those changes will not propagate.
+# Normally global changes should be limited to build_common and
+# the extlibs scripts.
 Import('env')
 
-if os.environ.get('TERM') != None:
-       env['ENV']['TERM'] = os.environ['TERM']
+if os.environ.get('TERM') is not None:
+    env['ENV']['TERM'] = os.environ['TERM']
 
 # Load extra options
 SConscript('extra_options.scons')
 
 target_os = env.get('TARGET_OS')
 if target_os == 'arduino':
-       SConscript('arduino.scons')
+    SConscript('arduino.scons')
 
-# By default, src_dir is current dir, the build_dir is:
+# By default, src_dir is the current dir, build_dir is:
 #     ./out/<target_os>/<target_arch>/<release or debug>/
 #
-# The build_dir is a variant directory of the source directory(You can
-# consider build_dir as a soft link to src_dir, for detail please refer to:
+# The build_dir is a Variant directory of the source directory.
+# iotivity variant directories are set up with argument "duplicate=0",
+# which means build_dir files will behave like soft links to src_dir files.
+# For more reading on this:
 #     http://www.scons.org/doc/production/HTML/scons-user.html#f-VariantDir
 #
 # Any way, to make the output is in build_dir, when load scripts, the path should
@@ -54,35 +64,38 @@ build_dir = env.get('BUILD_DIR')
 SConscript(build_dir + 'resource/SConscript')
 
 if target_os not in ['arduino','darwin','ios', 'android', 'msys_nt', 'windows']:
-       SConscript(build_dir + 'examples/OICMiddle/SConscript')
+    SConscript(build_dir + 'examples/OICMiddle/SConscript')
 
 java_build = None
-if (env.get('BUILD_JAVA') == True  and env.get('JAVA_HOME') != None) or target_os == 'android':
-        java_build = SConscript(build_dir + 'java/SConscript')
+if (env.get('BUILD_JAVA') and env.get('JAVA_HOME')) or target_os == 'android':
+    java_build = SConscript(build_dir + 'java/SConscript')
 
 # Build 'service' sub-project
 service_build = SConscript(build_dir + 'service/SConscript')
 
-if (env.get('BUILD_JAVA') == True and env.get('JAVA_HOME') != None) or target_os == 'android':
-        Depends(service_build, java_build)
-
-# Build "cloud" sub-project
-SConscript(build_dir + 'cloud/SConscript')
-
-# Build "plugin interface" sub-project
-SConscript(build_dir + 'plugins/SConscript')
-
-# Build "bridging" sub-project
-SConscript(build_dir + 'bridging/SConscript')
-
-# Append targets information to the help information, to see help info, execute command line:
-#     $ scon [options] -h
+if java_build:
+    Depends(service_build, java_build)
+
+# Build other sub-projects
+SConscript(dirs=[
+    build_dir + 'cloud',
+    build_dir + 'plugins',
+    build_dir + 'bridging',
+])
+
+# Append target information to the help information (if needed)
+# To see help info, execute:
+#     $ scons [options] -h
+# Note some help is option-dependent, e.g. java-related options are
+# not added to the help unless BUILD_JAVA is seen
+#
+# This is not really needed unless requesting help, consider adding check:
+#if env.GetOption('help'):
 env.PrintTargets()
 
 # Print bin upload command line (arduino only)
 if target_os == 'arduino':
-       env.UploadHelp()
+    env.UploadHelp()
 
 # to install the generated pc file into custom prefix location
 env.UserInstallTargetPCFile('iotivity.pc', 'iotivity.pc')
-