# The main build script
#
##
-import os
-SRC_TOP_DIR = os.path.abspath('.') + '/' #oic-resource project top directory
-
-# Common build options
+# Load common build config
SConscript('build_common/SConscript')
-Import('RELEASE_BUILD', 'BUILD_TARGET', 'TARGET_CPU_ARCH')
-# Set build directory
-if RELEASE_BUILD:
- BUILD_DIR = SRC_TOP_DIR + '/out/' + BUILD_TARGET + '/' + TARGET_CPU_ARCH + '/release/'
-else:
- BUILD_DIR = SRC_TOP_DIR + '/out/' + BUILD_TARGET + '/' + TARGET_CPU_ARCH + '/debug/'
-VariantDir(BUILD_DIR, SRC_TOP_DIR, duplicate=0)
-Export('SRC_TOP_DIR', 'BUILD_DIR')
+# Load extra options
+SConscript('extra_options.scons')
+Import('env')
-if BUILD_TARGET == 'arduino':
+target_os = env.get('TARGET_OS')
+if target_os == 'arduino':
SConscript('arduino.scons')
+# By default, src_dir is current dir, the 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:
+# 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
+# be relevant to build_dir.
+build_dir = env.get('BUILD_DIR')
-# Build libcoap
-SConscript(BUILD_DIR + 'csdk/libcoap/SConscript')
-
-# Build liboctbstack
-SConscript(BUILD_DIR + 'csdk/SConscript')
-
-if BUILD_TARGET != 'arduino':
- # Build liboc_logger
- SConscript(BUILD_DIR + 'oc_logger/SConscript')
-
- # Build liboc
- SConscript(BUILD_DIR + 'src/SConscript')
-
- # Build examples
- SConscript(BUILD_DIR + 'examples/SConscript')
+# Build 'resource' sub-project
+SConscript(build_dir + 'resource/SConscript')
-# Print targets
-Import('env')
+# Build 'service' sub-project
+SConscript(build_dir + 'service/SConscript')
-Help('''
-===============================================================================
-Targets:\n ''')
-for t in env.get('TS'):
- Help(t + ' ')
-Help('''
-\nDefault all targets will be built. You can specify the target to build:
+# Append targets information to the help information, to see help info, execute command line:
+# $ scon [options] -h
+env.PrintTargets()
- #scons [options] [target]
-===============================================================================
-''')
\ No newline at end of file
+# Print bin upload command line (arduino only)
+if target_os == 'arduino':
+ env.UploadHelp()