Reformat extlibs SConscripts to be more Pythonic
authorMats Wichmann <mats@linux.com>
Sat, 1 Jul 2017 13:31:39 +0000 (07:31 -0600)
committerPhil Coval <philippe.coval@osg.samsung.com>
Tue, 4 Jul 2017 07:54:19 +0000 (07:54 +0000)
There are not intended to be any functional changes.

Minor additonal changes:
  starred error/notice boxes trimmed to not be so wide, drop trailing stars
  minor language cleanup in a few messages
  a little reorg of comments in mbedtls
  instead of "print MESSAGE; Exit(1)" now do "msg = MESSAGE; Exit(msg)"
    to send error messages to the error stream instead of the output stream

Bug: https://jira.iotivity.org/browse/IOT-1745
Change-Id: I9d7da2559eee30c8a3e076aeeae7b5a5f2c40843
Signed-off-by: Mats Wichmann <mats@linux.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21199
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
17 files changed:
extlibs/android/gradle/SConscript
extlibs/android/ndk/SConscript
extlibs/android/sdk/SConscript
extlibs/arduino/SConscript
extlibs/boost/SConscript
extlibs/cjson/SConscript
extlibs/gtest/SConscript
extlibs/hippomocks/SConscript
extlibs/libcoap/SConscript
extlibs/libstrophe/SConscript
extlibs/mbedtls/SConscript
extlibs/rapidjson/SConscript
extlibs/raxmpp/SConscript
extlibs/sqlite3/SConscript
extlibs/tinycbor/SConscript
extlibs/wksxmppxep/SConscript
extlibs/yaml/SConscript

index 208f223..4f4b9c1 100644 (file)
@@ -17,11 +17,12 @@ path = os.path.join(src_dir, 'extlibs', 'android', 'gradle', 'gradle-2.2.1')
 
 # check 'gradle' library, if it doesn't exits, ask user to download it
 if not os.path.exists(path):
-       gradle_zip = env.Download('gradle2.2.1.zip', 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip')
-       gradle_dir = env.UnpackAll('gradle-2.2.1', gradle_zip)
-       print '''
+    gradle_zip = env.Download(
+        'gradle2.2.1.zip',
+        'https://services.gradle.org/distributions/gradle-2.2.1-all.zip')
+    gradle_dir = env.UnpackAll('gradle-2.2.1', gradle_zip)
+    print '''
 ***********************************************************************
 * Downloading gradle:                    *
 *******************************************************************************
 '''
-
index e68f909..e6524a6 100644 (file)
@@ -18,20 +18,30 @@ path = os.path.join(src_dir, 'extlibs', 'android', 'ndk', 'android-ndk-r10e')
 
 # check 'ndk' library, if it doesn't exits, ask user to download it
 if not os.path.exists(path):
-       ndk_env = Environment(ENV = os.environ)
-       if host_os.startswith("linux"):
-               archType = 8 * struct.calcsize("P")
-               if archType == 64:
-                       env.Download('android-ndk-r10e.bin', 'http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin')
-               else:
-                       env.Download('android-ndk-r10e.bin', 'http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86.bin')
-
-               os.system("chmod a+x android-ndk-r10e.bin")
-               os.system("./android-ndk-r10e.bin")
-       else:
-               if target_arch in ['x86_64']:
-                       env.Download('android-ndk-r10e', 'http://dl.google.com/android/ndk/android-ndk-r10e-windows-x86_64.exe')
-               if target_arch in ['x86']:
-                       env.Download('android-ndk-r10e', 'http://dl.google.com/android/ndk/android-ndk-r10e-windows-x86.exe')
-
-
+    ndk_env = Environment(ENV=os.environ)
+    if host_os.startswith("linux"):
+        archType = 8 * struct.calcsize("P")
+        if archType == 64:
+            env.Download(
+                'android-ndk-r10e.bin',
+                'http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin'
+            )
+        else:
+            env.Download(
+                'android-ndk-r10e.bin',
+                'http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86.bin'
+            )
+
+        os.system("chmod a+x android-ndk-r10e.bin")
+        os.system("./android-ndk-r10e.bin")
+    else:
+        if target_arch in ['x86_64']:
+            env.Download(
+                'android-ndk-r10e',
+                'http://dl.google.com/android/ndk/android-ndk-r10e-windows-x86_64.exe'
+            )
+        if target_arch in ['x86']:
+            env.Download(
+                'android-ndk-r10e',
+                'http://dl.google.com/android/ndk/android-ndk-r10e-windows-x86.exe'
+            )
index a06adf6..980d7c6 100644 (file)
@@ -16,47 +16,45 @@ SConscript(src_dir + '/build_common/tools/UnpackAll.py')
 
 # Download
 if target_os == 'android':
-       android_home = env.get('ANDROID_HOME')
-       if not android_home:
-               print 'Creating ANDROID_HOME for Android SDK'
-
-               # older IoTivity versions expected the SDK at this position, this is left for backwards compatibility
-               androidlib_dir      = src_dir + '/extlibs/android/sdk/android-sdk_r24.2'
-
-               if not os.path.exists(androidlib_dir):
-                       from sys import platform as _platform
-                       if _platform == "linux" or _platform == "linux2":
-                               androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-linux.tgz'
-                               androidlib_url      = 'http://dl.google.com/android/android-sdk_r24.2-linux.tgz'
-                               androidlib_dir      = src_dir + '/extlibs/android/sdk/android-sdk-linux'
-                       elif _platform == "darwin":
-                               androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-macosx.zip'
-                               androidlib_url      = 'http://dl.google.com/android/android-sdk_r24.2-macosx.zip'
-                               androidlib_dir      = src_dir + '/extlibs/android/sdk/android-sdk-macosx'
-                       elif _platform == "win32":
-                               androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-windows.zip'
-                               androidlib_url      = 'http://dl.google.com/android/android-sdk_r24.2-windows.zip'
-                               androidlib_dir      = src_dir + '/extlibs/android/sdk/android-sdk-windows'
-
-               if not os.path.exists(androidlib_dir):
-                       # If the zip file is not already present, download it
-                       if not os.path.exists(androidlib_zip_file):
-                               androidlib_zip = env.Download(androidlib_zip_file, androidlib_url)
-                       else:
-                               androidlib_zip = androidlib_zip_file
-
-                       # Unzip the lib
-                       print 'Unzipping android lib...'
-                       env.UnpackAll(androidlib_dir, androidlib_zip)
-                       print 'Unzipping android lib complete'
-
-                       # Remove downloaded file
-#                      os.remove(androidlib_zip_file)
-       else:
-               androidlib_dir = env.get('ANDROID_HOME')
+    android_home = env.get('ANDROID_HOME')
+    if not android_home:
+        print 'Creating ANDROID_HOME for Android SDK'
+
+        # older IoTivity versions expected the SDK at this position, this is left for backwards compatibility
+        androidlib_dir = src_dir + '/extlibs/android/sdk/android-sdk_r24.2'
+
+        if not os.path.exists(androidlib_dir):
+            from sys import platform as _platform
+            if _platform == "linux" or _platform == "linux2":
+                androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-linux.tgz'
+                androidlib_url = 'http://dl.google.com/android/android-sdk_r24.2-linux.tgz'
+                androidlib_dir = src_dir + '/extlibs/android/sdk/android-sdk-linux'
+            elif _platform == "darwin":
+                androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-macosx.zip'
+                androidlib_url = 'http://dl.google.com/android/android-sdk_r24.2-macosx.zip'
+                androidlib_dir = src_dir + '/extlibs/android/sdk/android-sdk-macosx'
+            elif _platform == "win32":
+                androidlib_zip_file = src_dir + '/extlibs/android/android-sdk_r24.2-windows.zip'
+                androidlib_url = 'http://dl.google.com/android/android-sdk_r24.2-windows.zip'
+                androidlib_dir = src_dir + '/extlibs/android/sdk/android-sdk-windows'
+
+        if not os.path.exists(androidlib_dir):
+            # If the zip file is not already present, download it
+            if not os.path.exists(androidlib_zip_file):
+                androidlib_zip = env.Download(androidlib_zip_file, androidlib_url)
+            else:
+                androidlib_zip = androidlib_zip_file
+
+            # Unzip the lib
+            print 'Unzipping android lib...'
+            env.UnpackAll(androidlib_dir, androidlib_zip)
+            print 'Unzipping android lib complete'
+
+            # Remove downloaded file
+            # os.remove(androidlib_zip_file)
+    else:
+        androidlib_dir = env.get('ANDROID_HOME')
 
 # Set the ANDROID_HOME
-env.Replace(ANDROID_HOME = androidlib_dir)
+env.Replace(ANDROID_HOME=androidlib_dir)
 print 'ANDROID_HOME = ' + env.get('ANDROID_HOME')
-
-
index 1bd0d9e..f086b31 100644 (file)
@@ -18,163 +18,163 @@ SConscript(src_dir + '/build_common/tools/UnpackAll.py')
 
 # Download
 if target_os == 'arduino':
-       arduino_home = env.get('ARDUINO_HOME')
-       if not arduino_home:
-               print 'Creating ARDUINO_HOME for Arduino lib'
-               print '''
+    arduino_home = env.get('ARDUINO_HOME')
+    if not arduino_home:
+        print 'Creating ARDUINO_HOME for Arduino lib'
+        print '''
 *******************************************************************************
-*   Arduino root directory is not set, you can set enviornment variable       *
-*   ARDUINO_HOME or add it in command line as follows (Only set if your       *
-*   version has fixes applied as depicted below. Press ctrl+c now if you      *
-*   wish to manually set ARDUINO_HOME.):                                      *
-*      # scons ARDUINO_HOME=<path to arduino root directory> ...              *
+* Arduino root directory is not set, you can set enviornment variable
+* ARDUINO_HOME or add it in command line as follows (Only set if your
+* version has fixes applied as depicted below. Press ctrl+c now if you
+* wish to manually set ARDUINO_HOME):
+*   # scons ARDUINO_HOME=<path to arduino root directory> ...
 *******************************************************************************
-        '''
-               arduinolib_dir      = src_dir + '/extlibs/arduino/arduino-1.5.8'
-
-               if not os.path.exists(arduinolib_dir):
-                       if _platform.startswith("linux"):
-                               archType = 8 * struct.calcsize("P")
-                               print 'On %s-bit machine.' % (archType)
-                               if archType == 32:
-                                       arduinolib_zip_file = src_dir + '/extlibs/arduino/arduino-1.5.8-linux32.tgz'
-                                       arduinolib_url      = 'http://arduino.cc/download.php?f=/arduino-1.5.8-linux32.tgz'
-                               else:
-                                       arduinolib_zip_file = src_dir + '/extlibs/arduino/arduino-1.5.8-linux64.tgz'
-                                       arduinolib_url      = 'http://arduino.cc/download.php?f=/arduino-1.5.8-linux64.tgz'
-                       elif _platform == "darwin":
-                               arduinolib_zip_file = src_dir + '/extlibs/arduino/arduino-1.5.8-macosx.zip'
-                               arduinolib_url      = 'http://arduino.cc/download.php?f=/arduino-1.5.8-macosx.zip'
-                       elif _platform == "win32":
-                               arduinolib_zip_file = src_dir + '/extlibs/arduino/arduino-1.5.8-windows.zip'
-                               arduinolib_url      = src_dir + 'http://arduino.cc/download.php?f=/arduino-1.5.8-windows.zip'
-
-                       # If the zip file is not already present, download it
-                       if not os.path.exists(arduinolib_zip_file):
-                               arduinolib_zip = env.Download(arduinolib_zip_file, arduinolib_url)
-                       else:
-                               arduinolib_zip = arduinolib_zip_file
-
-                       # Unzip the lib
-                       print 'Unzipping arduino lib...'
-                       env.UnpackAll(arduinolib_dir, arduinolib_zip)
-                       print 'Unzipping arduino lib complete'
-
-                       # Remove downloaded file
-                       os.remove(arduinolib_zip_file)
-       else:
-               arduinolib_dir = env.get('ARDUINO_HOME')
-
-       timelib_dir         = arduinolib_dir + '/libraries/Time'
-
-       if not os.path.exists(timelib_dir):
-               if WhereIs('dos2unix') is not None:
-                       timelib_zip_file    = src_dir + '/extlibs/arduino/Time.zip'
-                       timelib_url         = 'http://playground.arduino.cc/uploads/Code/Time.zip'
-                       # Install Arduino Time library
-                       # If the zip file is not already present, download it
-                       os.mkdir(timelib_dir)
-                       os.chdir(timelib_dir)
-                       if not os.path.exists(timelib_zip_file):
-                               timelib_zip = env.Download(timelib_zip_file, timelib_url)
-                       else:
-                               timelib_zip = timelib_zip_file
-
-                       # Unzip the lib
-                       print 'Unzipping Arduino Time lib...'
-                       env.UnpackAll(timelib_dir + '/Time', timelib_zip)
-
-                       # Apply patches to ARDUINO_HOME directory.
-                       os.chdir(arduinolib_dir)
-                       print 'Patching Arduino libraries...'
-
-                       os.system("find ./libraries/Time/Time/DateStrings.cpp -type f -exec dos2unix {} \;")
-                       os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_libraries.patch --directory=" + arduinolib_dir)
-
-                       # Remove downloaded file
-                       os.remove(timelib_zip_file)
-               else:
-                       print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
-                       print 'You may likely retrieve this package as follows:'
-                       print '      sudo apt-get install dos2unix'
-                       print '               or'
-                       print '      sudo yum install dos2unix'
-                       exit(1)
-
-       redbearlib_dir         = arduinolib_dir + '/libraries/RBL_nRF8001'
-
-       if not os.path.exists(redbearlib_dir):
-               if WhereIs('dos2unix') is not None:
-                       redbearlib_zip_file    = src_dir + '/extlibs/arduino/25643e7b1b7da3740406325a471e3faa4b948747.zip'
-                       redbearlib_url         = 'https://github.com/RedBearLab/nRF8001/archive/25643e7b1b7da3740406325a471e3faa4b948747.zip'
-                       if not os.path.exists(redbearlib_zip_file):
-                               redbearlib_zip = env.Download(redbearlib_zip_file, redbearlib_url)
-                       else:
-                               redbearlib_zip = redbearlib_zip_file
-
-                       # Unzip the lib
-                       print 'Unzipping Red Bear lib...'
-                       os.chdir(arduinolib_dir + '/libraries')
-                       env.UnpackAll(redbearlib_dir, redbearlib_zip)
-
-                       # Because the way Red Bear lib is distributed... All Red Bear source files must be moved up a few directories.
-                       shutil.move('nRF8001-25643e7b1b7da3740406325a471e3faa4b948747/Arduino/libraries/RBL_nRF8001/', '.')
-                       shutil.rmtree('nRF8001-25643e7b1b7da3740406325a471e3faa4b948747')
-
-                       # Apply Red Bear patches
-                       print 'Patching Red Bear library...'
-                       os.chdir(arduinolib_dir + '/libraries/RBL_nRF8001/')
-
-                       os.system("find . -type f -exec dos2unix {} \;")
-                       os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/RBL_nRF8001.patch")
-
-                       # Remove downloaded file
-                       os.remove(redbearlib_zip_file)
-               else:
-                       print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
-                       print 'You may likely retrieve this package as follows:'
-                       print '      sudo apt-get install dos2unix'
-                       print '               or'
-                       print '      sudo yum install dos2unix'
-                       exit(1)
-
-       nordiclib_dir           = arduinolib_dir + '/libraries/BLE'
-
-       if not os.path.exists(nordiclib_dir):
-               if WhereIs('dos2unix') is not None:
-                       nordiclib_zip_file    = src_dir + '/extlibs/arduino/ble-sdk-arduino-0.9.5.beta.zip'
-                       nordiclib_url         = 'https://github.com/NordicSemiconductor/ble-sdk-arduino/archive/0.9.5.beta.zip'
-                       if not os.path.exists(nordiclib_zip_file):
-                               nordiclib_zip = env.Download(nordiclib_zip_file, nordiclib_url)
-                       else:
-                               nordiclib_zip = nordiclib_zip_file
-
-                       # Unzip the lib
-                       print 'Unzipping Nordic lib...'
-                       os.chdir(arduinolib_dir + '/libraries')
-                       env.UnpackAll(nordiclib_dir, nordiclib_zip)
-
-                       # Because the way Nordic lib is distributed... All Nordic source files must be moved up a few directories.
-                       shutil.move('ble-sdk-arduino-0.9.5.beta/libraries/BLE/', '.')
-                       shutil.rmtree('ble-sdk-arduino-0.9.5.beta')
-
-                       # Apply Nordic lib patches
-                       print 'Patching Nordic library...'
-                       os.chdir(arduinolib_dir + '/libraries/BLE/')
-
-                       os.system("find . -type f -exec dos2unix {} \;")
-                       os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_due_ble.patch")
-
-                       # Remove downloaded file
-                       os.remove(nordiclib_zip_file)
-               else:
-                       print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
-                       print 'You may likely retrieve this package as follows:'
-                       print '      sudo apt-get install dos2unix'
-                       print '               or'
-                       print '      sudo yum install dos2unix'
-                       exit(1)
+'''
+        arduinolib_dir = src_dir + '/extlibs/arduino/arduino-1.5.8'
+
+        if not os.path.exists(arduinolib_dir):
+            if _platform.startswith("linux"):
+                archType = 8 * struct.calcsize("P")
+                print 'On %s-bit machine.' % (archType)
+                if archType == 32:
+                    arduinolib_zip_file = src_dir + '/extlibs/arduino/arduino-1.5.8-linux32.tgz'
+                    arduinolib_url = 'http://arduino.cc/download.php?f=/arduino-1.5.8-linux32.tgz'
+                else:
+                    arduinolib_zip_file = src_dir + '/extlibs/arduino/arduino-1.5.8-linux64.tgz'
+                    arduinolib_url = 'http://arduino.cc/download.php?f=/arduino-1.5.8-linux64.tgz'
+            elif _platform == "darwin":
+                arduinolib_zip_file = src_dir + '/extlibs/arduino/arduino-1.5.8-macosx.zip'
+                arduinolib_url = 'http://arduino.cc/download.php?f=/arduino-1.5.8-macosx.zip'
+            elif _platform == "win32":
+                arduinolib_zip_file = src_dir + '/extlibs/arduino/arduino-1.5.8-windows.zip'
+                arduinolib_url = src_dir + 'http://arduino.cc/download.php?f=/arduino-1.5.8-windows.zip'
+
+            # If the zip file is not already present, download it
+            if not os.path.exists(arduinolib_zip_file):
+                arduinolib_zip = env.Download(arduinolib_zip_file, arduinolib_url)
+            else:
+                arduinolib_zip = arduinolib_zip_file
+
+            # Unzip the lib
+            print 'Unzipping arduino lib...'
+            env.UnpackAll(arduinolib_dir, arduinolib_zip)
+            print 'Unzipping arduino lib complete'
+
+            # Remove downloaded file
+            os.remove(arduinolib_zip_file)
+    else:
+        arduinolib_dir = env.get('ARDUINO_HOME')
+
+    timelib_dir = arduinolib_dir + '/libraries/Time'
+
+    if not os.path.exists(timelib_dir):
+        if WhereIs('dos2unix') is not None:
+            timelib_zip_file = src_dir + '/extlibs/arduino/Time.zip'
+            timelib_url = 'http://playground.arduino.cc/uploads/Code/Time.zip'
+            # Install Arduino Time library
+            # If the zip file is not already present, download it
+            os.mkdir(timelib_dir)
+            os.chdir(timelib_dir)
+            if not os.path.exists(timelib_zip_file):
+                timelib_zip = env.Download(timelib_zip_file, timelib_url)
+            else:
+                timelib_zip = timelib_zip_file
+
+            # Unzip the lib
+            print 'Unzipping Arduino Time lib...'
+            env.UnpackAll(timelib_dir + '/Time', timelib_zip)
+
+            # Apply patches to ARDUINO_HOME directory.
+            os.chdir(arduinolib_dir)
+            print 'Patching Arduino libraries...'
+
+            os.system("find ./libraries/Time/Time/DateStrings.cpp -type f -exec dos2unix {} \;")
+            os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_libraries.patch --directory=" + arduinolib_dir)
+
+            # Remove downloaded file
+            os.remove(timelib_zip_file)
+        else:
+            print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
+            print 'You may likely retrieve this package as follows:'
+            print '      sudo apt-get install dos2unix'
+            print '               or'
+            print '      sudo yum install dos2unix'
+            exit(1)
+
+    redbearlib_dir = arduinolib_dir + '/libraries/RBL_nRF8001'
+
+    if not os.path.exists(redbearlib_dir):
+        if WhereIs('dos2unix') is not None:
+            redbearlib_zip_file = src_dir + '/extlibs/arduino/25643e7b1b7da3740406325a471e3faa4b948747.zip'
+            redbearlib_url = 'https://github.com/RedBearLab/nRF8001/archive/25643e7b1b7da3740406325a471e3faa4b948747.zip'
+            if not os.path.exists(redbearlib_zip_file):
+                redbearlib_zip = env.Download(redbearlib_zip_file, redbearlib_url)
+            else:
+                redbearlib_zip = redbearlib_zip_file
+
+            # Unzip the lib
+            print 'Unzipping Red Bear lib...'
+            os.chdir(arduinolib_dir + '/libraries')
+            env.UnpackAll(redbearlib_dir, redbearlib_zip)
+
+            # Because the way Red Bear lib is distributed... All Red Bear source files must be moved up a few directories.
+            shutil.move('nRF8001-25643e7b1b7da3740406325a471e3faa4b948747/Arduino/libraries/RBL_nRF8001/', '.')
+            shutil.rmtree('nRF8001-25643e7b1b7da3740406325a471e3faa4b948747')
+
+            # Apply Red Bear patches
+            print 'Patching Red Bear library...'
+            os.chdir(arduinolib_dir + '/libraries/RBL_nRF8001/')
+
+            os.system("find . -type f -exec dos2unix {} \;")
+            os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/RBL_nRF8001.patch")
+
+            # Remove downloaded file
+            os.remove(redbearlib_zip_file)
+        else:
+            print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
+            print 'You may likely retrieve this package as follows:'
+            print '      sudo apt-get install dos2unix'
+            print '               or'
+            print '      sudo yum install dos2unix'
+            exit(1)
+
+    nordiclib_dir = arduinolib_dir + '/libraries/BLE'
+
+    if not os.path.exists(nordiclib_dir):
+        if WhereIs('dos2unix') is not None:
+            nordiclib_zip_file = src_dir + '/extlibs/arduino/ble-sdk-arduino-0.9.5.beta.zip'
+            nordiclib_url = 'https://github.com/NordicSemiconductor/ble-sdk-arduino/archive/0.9.5.beta.zip'
+            if not os.path.exists(nordiclib_zip_file):
+                nordiclib_zip = env.Download(nordiclib_zip_file, nordiclib_url)
+            else:
+                nordiclib_zip = nordiclib_zip_file
+
+            # Unzip the lib
+            print 'Unzipping Nordic lib...'
+            os.chdir(arduinolib_dir + '/libraries')
+            env.UnpackAll(nordiclib_dir, nordiclib_zip)
+
+            # Because the way Nordic lib is distributed... All Nordic source files must be moved up a few directories.
+            shutil.move('ble-sdk-arduino-0.9.5.beta/libraries/BLE/', '.')
+            shutil.rmtree('ble-sdk-arduino-0.9.5.beta')
+
+            # Apply Nordic lib patches
+            print 'Patching Nordic library...'
+            os.chdir(arduinolib_dir + '/libraries/BLE/')
+
+            os.system("find . -type f -exec dos2unix {} \;")
+            os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_due_ble.patch")
+
+            # Remove downloaded file
+            os.remove(nordiclib_zip_file)
+        else:
+            print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
+            print 'You may likely retrieve this package as follows:'
+            print '      sudo apt-get install dos2unix'
+            print '               or'
+            print '      sudo yum install dos2unix'
+            exit(1)
 
 # Set the ARDUINO_HOME
-env.Replace(ARDUINO_HOME = arduinolib_dir)
+env.Replace(ARDUINO_HOME=arduinolib_dir)
 print 'ARDUINO_HOME = ' + env.get('ARDUINO_HOME')
index 30a24da..6a69b39 100644 (file)
@@ -1,3 +1,8 @@
+##
+# 'boost' script to check if boost libraries are installed.
+# get and install
+#
+
 import os, string, sys, subprocess
 import SCons.Errors
 
@@ -11,19 +16,19 @@ target_os = env.get('TARGET_OS')
 target_arch = env.get('TARGET_ARCH')
 src_dir = env.get('SRC_DIR')
 
-boost_version   = '1.60.0'
+boost_version = '1.60.0'
 
 # TODO: Remove coupling between build scripts and 1_58_0 version for Android
 if target_os in ['android']:
-    boost_version   = '1.58.0'
+    boost_version = '1.58.0'
 
-boost_base_name  = 'boost_'+string.replace(boost_version,'.','_')
-boost_arch_name  = boost_base_name+'.zip'
-boost_b2_name    = boost_base_name+os.sep+'b2'
-boost_url       = 'http://downloads.sourceforge.net/project/boost/boost/'+boost_version+'/'+boost_arch_name+'?r=&ts=1421801329&use_mirror=iweb'
+boost_base_name = 'boost_' + string.replace(boost_version, '.', '_')
+boost_arch_name = boost_base_name + '.zip'
+boost_b2_name = boost_base_name + os.sep + 'b2'
+boost_url = 'http://downloads.sourceforge.net/project/boost/boost/' + boost_version + '/' + boost_arch_name + '?r=&ts=1421801329&use_mirror=iweb'
 
-boost_dir = os.path.join(src_dir,'extlibs','boost','boost')
-boost_bootstrap = os.path.join(boost_dir,'bootstrap.bat')
+boost_dir = os.path.join(src_dir, 'extlibs', 'boost', 'boost')
+boost_bootstrap = os.path.join(boost_dir, 'bootstrap.bat')
 
 if 'linux' == target_os:
     # Check for Boost libraries in /usr/boost
@@ -32,7 +37,7 @@ if 'linux' == target_os:
     raise SCons.Errors.EnvironmentError(msg)
 
 elif target_os in ['windows']:
-    boost_zip_file   = os.path.join(src_dir,'extlibs','boost',boost_arch_name)
+    boost_zip_file = os.path.join(src_dir, 'extlibs', 'boost', boost_arch_name)
 
     if not os.path.exists(boost_bootstrap):
 
@@ -52,7 +57,7 @@ elif target_os in ['windows']:
 
     # Sanity check, in case the above method didn't work
     if not os.path.exists(boost_bootstrap):
-        print '''
+        msg = '''
 *********************************** Error: ************************************
 * Please download boost from the following website:
 *
@@ -68,33 +73,33 @@ elif target_os in ['windows']:
 *
 *******************************************************************************
 '''
-        Exit(1)
+        Exit(msg)
 
 elif target_os in ['android']:
-    boost_env.Tool('URLDownload',    toolpath=['../../tools/scons'])
-    boost_env.Tool('UnpackAll',      toolpath=['../../tools/scons'])
+    boost_env.Tool('URLDownload', toolpath=['../../tools/scons'])
+    boost_env.Tool('UnpackAll', toolpath=['../../tools/scons'])
     boost_env.Tool('BoostBootstrap', toolpath=['../../tools/scons'])
-    boost_env.Tool('BoostBuild',     toolpath=['../../tools/scons'])
+    boost_env.Tool('BoostBuild', toolpath=['../../tools/scons'])
 
     host_os = sys.platform
 
     if host_os.startswith("linux"):
-        boost_bootstrap = boost_base_name+os.sep+'bootstrap.sh'
+        boost_bootstrap = boost_base_name + os.sep + 'bootstrap.sh'
     else:
-        msg="Host platform (%s) is currently not supported for boost builds" % host_os
+        msg = "Host platform (%s) is currently not supported for boost builds" % host_os
         raise SCons.Errors.EnvironmentError(msg)
 
     if not os.path.exists(boost_arch_name) and not os.path.exists(boost_base_name):
         boost_arch_name = boost_env.URLDownload(boost_arch_name, boost_url)
 
     if not os.path.exists(boost_base_name):
-       boost_arch_name = boost_env.UnpackAll(boost_bootstrap, boost_arch_name)
+        boost_arch_name = boost_env.UnpackAll(boost_bootstrap, boost_arch_name)
 
-    boost_b2  = boost_env.BoostBootstrap(boost_b2_name, boost_arch_name)
+    boost_b2 = boost_env.BoostBootstrap(boost_b2_name, boost_arch_name)
 
     dep_sys_root = boost_env['DEP_SYS_ROOT']
-    dep_src_dir =  dep_sys_root + os.sep + 'include'
-    dep_lib_dir =  dep_sys_root + os.sep + 'lib'
+    dep_src_dir = dep_sys_root + os.sep + 'include'
+    dep_lib_dir = dep_sys_root + os.sep + 'lib'
 
     boost_targets = [
         os.path.join(dep_src_dir, 'boost', 'config.hpp'),
@@ -102,12 +107,11 @@ elif target_os in ['android']:
         os.path.join(dep_src_dir, 'boost', 'program_options.hpp'),
         os.path.join(dep_src_dir, 'boost', 'thread.hpp'),
         os.path.join(dep_src_dir, 'boost', 'date_time.hpp'),
-        os.path.join(dep_src_dir, 'libboost_thread.a'),        
+        os.path.join(dep_src_dir, 'libboost_thread.a'),
         os.path.join(dep_src_dir, 'libboost_date_time.a'),
         os.path.join(dep_src_dir, 'libboost_atomic.a'),
         os.path.join(dep_src_dir, 'libboost_system.a'),
         os.path.join(dep_src_dir, 'libboost_program_options.a')
-        ]
+    ]
 
     boost_build = boost_env.BoostBuild(boost_targets, boost_b2, PREFIX=dep_sys_root, MODULES=modules)
-
index 4f17642..932eb2a 100644 (file)
@@ -23,9 +23,9 @@ Import('env')
 cjson_env = env.Clone()
 
 if cjson_env.get('TARGET_OS') in ['windows', 'msys_nt']:
-    # Macro needed for Windows builds to avoid __declspec(dllexport) and __declspec(dllimport) for cJSON APIs.
-    cjson_env.AppendUnique(CPPDEFINES = ['CJSON_HIDE_SYMBOLS'])
+    # Macro needed for Windows builds to avoid __declspec(dllexport)
+    # and __declspec(dllimport) for cJSON APIs.
+    cjson_env.AppendUnique(CPPDEFINES=['CJSON_HIDE_SYMBOLS'])
 
 libcjson = cjson_env.StaticLibrary('cjson', ['cJSON.c'], OBJPREFIX='libcjson_')
-cjson_env.InstallTarget(libcjson, 'cjson');
-
+cjson_env.InstallTarget(libcjson, 'cjson')
index ca7ddd0..a677033 100644 (file)
@@ -15,7 +15,8 @@ src_dir = gtest_env.get('SRC_DIR')
 targets_need_gtest = ['darwin', 'linux', 'msys_nt', 'windows']
 
 GTEST_VERSION = '1.7.0'
-gtest_dir = os.path.join(src_dir, 'extlibs', 'gtest', 'googletest-release-' + GTEST_VERSION)
+gtest_dir = os.path.join(src_dir, 'extlibs', 'gtest',
+                         'googletest-release-' + GTEST_VERSION)
 gtest_lib_dir = os.path.join(gtest_dir, 'lib')
 gtest_configured_sentinel = os.path.join(gtest_dir, 'Makefile')
 gtest_unpacked_sentinel = os.path.join(gtest_dir, 'CMakeLists.txt')
@@ -57,9 +58,12 @@ if target_os in ['linux']:
         print 'Configuring google unit test'
         reconfigure_ran = gtest_env.Configure(gtest_dir, 'autoreconf -i')
         if env.get('CROSS_COMPILE'):
-            configure_ran = env.Configure(gtest_dir, './configure --disable-shared --host=' + env['CROSS_COMPILE'])
+            configure_ran = env.Configure(
+                gtest_dir,
+                './configure --disable-shared --host=' + env['CROSS_COMPILE'])
         else:
-            configure_ran = env.Configure(gtest_dir, './configure --disable-shared')
+            configure_ran = env.Configure(gtest_dir,
+                                          './configure --disable-shared')
         gtest_env.Depends(configure_ran, reconfigure_ran)
 
     # Run make on gtest
@@ -94,8 +98,10 @@ elif target_os in ['windows'] and 'IOTIVITY_GTEST_HAS_BEEN_BUILT' not in env:
     gtest_build_env.AppendUnique(CPPPATH=[os.path.join(gtest_dir, 'include')])
     gtest_build_env.AppendUnique(CXXFLAGS=['/EHsc'])
     gtest_build_env.AppendUnique(CCFLAGS=['/W4', '/WX'])
-    gtest = gtest_build_env.StaticLibrary(target='gtest', source=['%s/src/gtest-all.cc' % gtest_dir])
-    gtest_main = gtest_build_env.StaticLibrary(target='gtest_main', source=['%s/src/gtest_main.cc' % gtest_dir])
+    gtest = gtest_build_env.StaticLibrary(
+        target='gtest', source=['%s/src/gtest-all.cc' % gtest_dir])
+    gtest_main = gtest_build_env.StaticLibrary(
+        target='gtest_main', source=['%s/src/gtest_main.cc' % gtest_dir])
     gtest_env.InstallTarget(gtest, 'gtest')
     gtest_env.InstallTarget(gtest_main, 'gtest_main')
 
index 6359ee0..db2cd3e 100644 (file)
@@ -44,6 +44,7 @@ if target_os in ['linux', 'windows']:
             hippomocks_zip = env.Download(hippomocks_zip_file, hippomocks_url)
         else:
             hippomocks_zip = hippomocks_zip_file
-        print 'hippomocks: Unzipping %s to %s' % (hippomocks_zip_file, hippomocks_dest_dir)
+        print 'hippomocks: Unzipping %s to %s' % (hippomocks_zip_file,
+                                                  hippomocks_dest_dir)
         env.UnpackAll(hippomocks_src_dir, hippomocks_zip)
         os.rename(hippomocks_src_dir, hippomocks_dest_dir)
index 8f1335b..1a57d25 100644 (file)
@@ -40,17 +40,18 @@ with_upstream_libcoap = libcoap_env.get('WITH_UPSTREAM_LIBCOAP')
 
 # Temporary LibCoAP URL is a fork of the original.
 # Once a pull request is merged, change this back to the obgm original below.
-libcoap_repo_url    = 'https://github.com/dthaler/libcoap'
+libcoap_repo_url = 'https://github.com/dthaler/libcoap'
 #libcoap_repo_url    = 'https://github.com/obgm/libcoap'
 
 ######################################################################
 # Download libCoAP
 ######################################################################
-# Right now this script assumes the revision is a tag, and not a branch or an arbitrary
-# commit. If this changes, update the check below, or else the script will always conclude
-# the repo is not up to date because a tag with that name doesn't exist.
-libcoap_version          = 'IoTivity-1.2.1d'
-libcoap_dir              = os.path.join(src_dir, 'extlibs', 'libcoap', 'libcoap')
+# Right now this script assumes the revision is a tag, and not a branch or
+# an arbitrary commit. If this changes, update the check below, or else
+# the script will always conclude the repo is not up to date because a tag
+# with that name doesn't exist.
+libcoap_version = 'IoTivity-1.2.1d'
+libcoap_dir = os.path.join(src_dir, 'extlibs', 'libcoap', 'libcoap')
 libcoap_checkout_command = 'git clone ' + libcoap_repo_url + '.git extlibs/libcoap/libcoap -b ' + libcoap_version
 libcoap_update_command = 'git fetch --tags && git checkout -f ' + libcoap_version
 libcoap_change_dir_command = 'cd ' + libcoap_dir
@@ -58,45 +59,46 @@ libcoap_change_dir_command = 'cd ' + libcoap_dir
 if with_upstream_libcoap == '1':
     print '*** Checking for installation of libCoAP ***'
     if not os.path.exists(libcoap_dir):
-        print '''
-*********************************** Error: ****************************************
-* Please download libcoap using the following command:                            *
+        msg = '''
+*********************************** Error: ************************************
+* Please download libcoap using the following command:
 *     $ %s
-***********************************************************************************
- ''' % libcoap_checkout_command
-        Exit(1)
+*******************************************************************************
+''' % libcoap_checkout_command
+        Exit(msg)
 
     os.chdir(libcoap_dir)
-    out = subprocess.check_output('git log --format=%d -n 1', shell = True)
+    out = subprocess.check_output('git log --format=%d -n 1', shell=True)
     if libcoap_version not in out:
         print '''
-*********************************** Info: *****************************************
+******************************* Info: *****************************************
 * Your libCoAP repo is not up to date with the latest version we require (%s).
-***********************************************************************************
- ''' %(libcoap_version)
+*******************************************************************************
+''' % (libcoap_version)
         if libcoap_env.get('AUTOMATIC_UPDATE'):
             print '''
-*********************************** Info: *****************************************
+******************************* Info: *****************************************
 * Automatically updating libcoap to version %s.
-***********************************************************************************
- ''' %(libcoap_version)
-            subprocess.check_output(libcoap_update_command, shell = True)
+*******************************************************************************
+''' % (libcoap_version)
+            subprocess.check_output(libcoap_update_command, shell=True)
         else:
-            print '''
-*********************************** Info: *****************************************
+            msg = '''
+******************************* Info: *****************************************
 * Please update using the following commands:
 *   %s
 *   %s
-***********************************************************************************
- ''' %(libcoap_change_dir_command, libcoap_update_command)
-            Exit(1)
+*******************************************************************************
+''' % (libcoap_change_dir_command, libcoap_update_command)
+            Exit(msg)
 
 else:
     print '''
-*********************************** Info: *****************************************
-* Using FORKED copy of libCoap located in:                                        *
-* resource/csdk/connectivity/lib/libcoap-4.1.1                                    *
-***********************************************************************************'''
+******************************* Info: *****************************************
+* Using FORKED copy of libCoap located in:
+* resource/csdk/connectivity/lib/libcoap-4.1.1
+*******************************************************************************
+'''
 
 ######################################################################
 # Build libCoAP
@@ -104,8 +106,8 @@ else:
 # As in the source code(C) includes arduino Time library head file(C++)
 # It requires compile the .c with g++
 if target_os == 'arduino':
-    libcoap_env.Replace(CFLAGS = libcoap_env.get('CXXFLAGS'))
-    libcoap_env.PrependUnique(CPPPATH = [
+    libcoap_env.Replace(CFLAGS=libcoap_env.get('CXXFLAGS'))
+    libcoap_env.PrependUnique(CPPPATH=[
         './',
         env.get('ARDUINO_HOME') + '/',
         env.get('ARDUINO_HOME') + '/hardware/arduino/avr/cores/arduino',
@@ -115,38 +117,38 @@ if target_os == 'arduino':
         env.get('ARDUINO_HOME') + '/libraries/TimedAction',
         env.get('ARDUINO_HOME') + '/hardware/arduino/avr/libraries/SPI',
         env.get('ARDUINO_HOME') + '/libraries/Ethernet/src/utility',
-        ])
+    ])
 
 # Build flags
 if target_os not in ['arduino', 'windows', 'winrt', 'msys_nt']:
-    libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '_DEFAULT_SOURCE'])
-    libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99','-fPIC'])
+    libcoap_env.AppendUnique(CPPDEFINES=['WITH_POSIX', '_DEFAULT_SOURCE'])
+    libcoap_env.AppendUnique(CFLAGS=['-std=gnu99','-fPIC'])
 
 if target_os not in ['windows', 'winrt']:
-    libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
+    libcoap_env.AppendUnique(CFLAGS=['-Wall', '-ffunction-sections',
             '-fdata-sections', '-fno-exceptions'])
 
 if target_os == 'msys_nt':
-    libcoap_env.AppendUnique(CPPDEFINES = ['_DEFAULT_SOURCE'])
-    libcoap_env.AppendUnique(CFLAGS = ['-std=c99'])
+    libcoap_env.AppendUnique(CPPDEFINES=['_DEFAULT_SOURCE'])
+    libcoap_env.AppendUnique(CFLAGS=['-std=c99'])
 
 if target_os in ['linux', 'tizen', 'android', 'ios', 'arduino', 'windows']:
     if with_tcp == True:
-        libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
+        libcoap_env.AppendUnique(CPPDEFINES=['WITH_TCP'])
 
 if target_os in ['linux', 'tizen', 'android', 'arduino']:
-    libcoap_env.AppendUnique(LIBS = ['log'])
-    if (('BLE' in ca_transport) or ('BT' in ca_transport) or ('ALL' in ca_transport)):
-        libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
+    libcoap_env.AppendUnique(LIBS=['log'])
+    if 'BLE' in ca_transport or 'BT' in ca_transport or 'ALL' in ca_transport:
+        libcoap_env.AppendUnique(CPPDEFINES=['WITH_TCP'])
 
 if target_os == 'arduino':
-    libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
+    libcoap_env.AppendUnique(CPPDEFINES=['NDEBUG', 'WITH_ARDUINO'])
 
 if target_os in ['darwin', 'ios']:
-    libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
+    libcoap_env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])
 
 if env.get('LOGGING') == '1':
-    libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    libcoap_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 
 ######################################################################
 # Source files and Target(s)
@@ -154,26 +156,26 @@ if env.get('LOGGING') == '1':
 with_upstream_libcoap = libcoap_env.get('WITH_UPSTREAM_LIBCOAP')
 config_h_file_path = os.path.join(src_dir, 'extlibs', 'libcoap', 'libcoap', 'include', 'coap', 'coap_config.h')
 if with_upstream_libcoap == '1':
-    libcoap_env.PrependUnique(CPPPATH = ['libcoap/include/coap'])
-    libcoap_env.AppendUnique(CPPDEFINES = ['WITH_UPSTREAM_LIBCOAP'])
+    libcoap_env.PrependUnique(CPPPATH=['libcoap/include/coap'])
+    libcoap_env.AppendUnique(CPPDEFINES=['WITH_UPSTREAM_LIBCOAP'])
     libcoap_src_root = os.path.join(libcoap_dir, 'src')
 
     # We need to generate coap.h from coap.h.in
     coap_h_pc_file = os.path.join(libcoap_dir, 'include', 'coap', 'coap.h.in')
-    coap_h_output  = os.path.join(libcoap_dir, 'include', 'coap', 'coap.h')
+    coap_h_output = os.path.join(libcoap_dir, 'include', 'coap', 'coap.h')
 
     # Generate coap_config.h
     target_arch = env.get('TARGET_ARCH')
     lib_prefix = '' + str(libcoap_env.get('PREFIX'))
 
-    if (not os.path.isfile(config_h_file_path)) and (not env.GetOption('clean')):
-        conf = Configure(libcoap_env.Clone(LIBS = []))
+    if not os.path.isfile(config_h_file_path) and not env.GetOption('clean'):
+        conf = Configure(libcoap_env.Clone(LIBS=[]))
 
         config_h_header = '''
 /* ****************************************************************************
  * coap_config.h - libcoap platform-specific configuration header.
  *
- * Auto-generated code for the %s %s platform.
+ * Auto-generated code for the %s %s platform. Do not edit.
  *
  *************************************************************************** */
 
@@ -204,7 +206,7 @@ if with_upstream_libcoap == '1':
 
 #endif // _COAP_CONFIG_H_
 
-    ''' % (str(lib_prefix + 'coap'), str(lib_prefix + 'coap ' + libcoap_version))
+''' % (str(lib_prefix + 'coap'), str(lib_prefix + 'coap ' + libcoap_version))
 
         config_h_body = ''
 
@@ -239,44 +241,50 @@ if with_upstream_libcoap == '1':
 #define in_port_t uint16_t
 '''
         else:
-            cxx_headers = ['arpa/inet.h',
-                           'assert.h',
-                           'limits.h',
-                           'netinet/in.h',
-                           'stdio.h',
-                           'strings.h',
-                           'sys/select.h',
-                           'sys/socket.h',
-                           'sys/time.h',
-                           'sys/types.h',
-                           'sys/uio.h',
-                           'sys/unistd.h',
-                           'syslog.h',
-                           'time.h',
-                           'unistd.h',
-                           'winsock2.h',
-                           'ws2tcpip.h']
-
-            cxx_functions = ['malloc',
-                             'snprintf',
-                             'strnlen',
-                             'vprintf']
+            cxx_headers = [
+                'arpa/inet.h',
+                'assert.h',
+                'limits.h',
+                'netinet/in.h',
+                'stdio.h',
+                'strings.h',
+                'sys/select.h',
+                'sys/socket.h',
+                'sys/time.h',
+                'sys/types.h',
+                'sys/uio.h',
+                'sys/unistd.h',
+                'syslog.h',
+                'time.h',
+                'unistd.h',
+                'winsock2.h',
+                'ws2tcpip.h'
+            ]
+
+            cxx_functions = [
+                'malloc',
+                'snprintf',
+                'strnlen',
+                'vprintf'
+            ]
 
             if target_os == 'arduino':
                 # Detection of headers on the Arduino platform is currently broken.
                 cxx_headers = []
 
             def get_define_from_string(string):
-                string_converted = string.replace("/","_").replace(".","_").upper()
+                string_converted = string.replace("/", "_").replace(".", "_").upper()
                 return "HAVE_" + string_converted
 
             for header_file_name in cxx_headers:
                 if conf.CheckCXXHeader(header_file_name):
-                    config_h_body += "#define %s 1\n\n" % get_define_from_string(header_file_name)
+                    config_h_body += "#define %s 1\n\n" % get_define_from_string(
+                        header_file_name)
 
             for function_name in cxx_functions:
                 if conf.CheckFunc(function_name):
-                    config_h_body += "#define %s 1\n\n" % get_define_from_string(function_name)
+                    config_h_body += "#define %s 1\n\n" % get_define_from_string(
+                        function_name)
 
             if conf.CheckCXXHeader('windows.h'):
                 config_h_body += "#define ssize_t SSIZE_T\n\n"
@@ -284,7 +292,8 @@ if with_upstream_libcoap == '1':
 
             conf.Finish()
 
-            # Autoconf feature doesn't work with Jenkins' arduino toolchain, so hardcode it here.
+            # Autoconf feature doesn't work with Jenkins' arduino toolchain,
+            # so hardcode it here.
             if target_os == 'arduino':
                 config_h_body += "#define HAVE_ARDUINO_TIME_H\n\n"
 
@@ -296,18 +305,18 @@ if with_upstream_libcoap == '1':
         config_h_file.close()
 
     # Sanity check to ensure that the above block created the file.
-    if (not os.path.exists(config_h_file_path)) and (not env.GetOption('clean')):
-        print "Error: coap_config.h file not created!"
-        Exit(1)
+    if not os.path.exists(config_h_file_path) and not env.GetOption('clean'):
+        msg = "Error: coap_config.h file not created!"
+        Exit(msg)
 
     pc_vars = {
-        '\@LIBCOAP_PACKAGE_NAME\@'          : lib_prefix + 'coap',
-        '\@LIBCOAP_PACKAGE_STRING\@'        : lib_prefix + 'coap-' + libcoap_version,
-        '\@LIBCOAP_PACKAGE_URL\@'           : libcoap_repo_url,
-        '\@LIBCOAP_PACKAGE_BUGREPORT\@'     : libcoap_repo_url + '/issues',
-        '\@LIBCOAP_PACKAGE_VERSION\@'       : libcoap_version
-        }
-    libcoap_env.Substfile(coap_h_pc_file, SUBST_DICT = pc_vars)
+        '\@LIBCOAP_PACKAGE_NAME\@': lib_prefix + 'coap',
+        '\@LIBCOAP_PACKAGE_STRING\@': lib_prefix + 'coap-' + libcoap_version,
+        '\@LIBCOAP_PACKAGE_URL\@': libcoap_repo_url,
+        '\@LIBCOAP_PACKAGE_BUGREPORT\@': libcoap_repo_url + '/issues',
+        '\@LIBCOAP_PACKAGE_VERSION\@': libcoap_version
+    }
+    libcoap_env.Substfile(coap_h_pc_file, SUBST_DICT=pc_vars)
 
     libcoap_src = glob.glob(os.path.join(libcoap_src_root, '*.c'))
     libcoap_src.remove(os.path.join(libcoap_src_root, 'coap_io_lwip.c'))
index 9d20cb2..f2dfdd1 100644 (file)
@@ -2,6 +2,7 @@
 # ref. raxmpp library build script
 #
 ######################################################################
+
 import os
 import commands
 
@@ -24,61 +25,70 @@ LIB_PATH = SRC_PATH + '/' + '.libs'
 LIBSTROPHY_LIBS = ['strophe', 'ssl', 'crypto', 'resolv']
 
 if with_ra_ibb:
-       # check 'libstrophe' library, if it doesn't exits, ask user to download it
-       if not os.path.exists(SRC_NAME):
-               raxmpp_env = Environment(ENV = os.environ)
-               c = raxmpp_env.Action(['git clone https://github.com/strophe/libstrophe.git ' + SRC_NAME,
-                       'cd ' + SRC_NAME + ' && git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77'
-                       ])
+    # check 'libstrophe' library, if it doesn't exist, ask user to download it
+    if not os.path.exists(SRC_NAME):
+        raxmpp_env = Environment(ENV=os.environ)
+        c = raxmpp_env.Action([
+            'git clone https://github.com/strophe/libstrophe.git ' + SRC_NAME,
+            'cd ' + SRC_NAME +
+            ' && git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77'
+        ])
+
+        print 'Downloading xmpp library ...'
+        if raxmpp_env.Execute(c):
+            msg = '''
+*********************************** Error: ************************************
+* Please download ra_xmpp as following:
+*     $ git clone https://github.com/strophe/libstrophe.git extlibs/libstrophe/libstrophe
+*     $ cd  extlibs/libstrophe/libstrophe
+*     $ git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77
+*******************************************************************************
+'''
+            Exit(msg)
+        else:
+            print 'Download xmpp library complete'
 
-               print 'Downloading xmpp library ...'
-               if raxmpp_env.Execute(c):
-                       print '''
-       *********************************** Error: ***********************************************
-       * Please download ra_xmpp as following:
-       *     $ git clone https://github.com/strophe/libstrophe.git extlibs/libstrophe/libstrophe
-       *     $ cd  extlibs/libstrophe/libstrophe
-       *     $ git checkout 527bc0573a52f2af3ecad5b9ef39aeec7b669f77
-       ******************************************************************************************
-       '''
-                       Exit(1)
-               else:
-                       print 'Download xmpp library complete'
+    if not env.GetOption('clean'):
+        print 'Building with ' + SRC_NAME
+        #print 'base_dir', base_dir
+        #print 'target_os', target_os
+        #print 'target_arch', target_arch
 
-       if not env.GetOption('clean'):
-               print 'Building with ' + SRC_NAME
-               #print 'base_dir', base_dir
-               #print 'target_os', target_os
-               #print 'target_arch', target_arch
-       
-               foo=commands.getoutput('patch -N -p1 -d libstrophe < strophe-xmpp_conn_is_secured.patch')
-               print foo
-               os.chdir(SRC_NAME)
-               #sconsflags = ' RELEASE=true' if  env['RELEASE'] else ' RELEASE=false'
-               if not os.path.exists('configure') :
-                       foo=commands.getoutput('./bootstrap.sh')
-                       print foo
-               if not os.path.exists('config.status') :
-                       foo=commands.getoutput('./configure')
-                       print foo
-               if not os.path.exists('.libs/libstrophe.a') :
-                       foo=commands.getoutput('make libstrophe.la')
-                       print foo
-               if not os.path.exists('.libs/libstrophe.a') :
-                       print 'Building with ' + SRC_NAME + ' failed.'
-                       Exit(2)
-               else:
-                       foo = commands.getoutput('cp .libs/libstrophe.a ' + env.get('BUILD_DIR'))
-                       foo = commands.getoutput('cp .libs/libstrophe.so* ' + env.get('BUILD_DIR'))
-                       print foo
+        foo = commands.getoutput(
+            'patch -N -p1 -d libstrophe < strophe-xmpp_conn_is_secured.patch')
+        print foo
+        os.chdir(SRC_NAME)
+        #sconsflags = ' RELEASE=true' if  env['RELEASE'] else ' RELEASE=false'
+        if not os.path.exists('configure'):
+            foo = commands.getoutput('./bootstrap.sh')
+            print foo
+        if not os.path.exists('config.status'):
+            foo = commands.getoutput('./configure')
+            print foo
+        if not os.path.exists('.libs/libstrophe.a'):
+            foo = commands.getoutput('make libstrophe.la')
+            print foo
+        if not os.path.exists('.libs/libstrophe.a'):
+            msg = 'Building with ' + SRC_NAME + ' failed.'
+            Exit(msg)
+        else:
+            foo = commands.getoutput('cp .libs/libstrophe.a ' +
+                                     env.get('BUILD_DIR'))
+            foo = commands.getoutput('cp .libs/libstrophe.so* ' +
+                                     env.get('BUILD_DIR'))
+            print foo
 
-               print 'Building with ' + SRC_NAME + ' Completely.'
-       env.AppendUnique(CPPPATH = [INC_PATH], RALIBS = LIBSTROPHY_LIBS, RALIBPATH = [LIB_PATH], RARPATH = [LIB_PATH])
-       env.AppendUnique(LIBS= LIBSTROPHY_LIBS, LIBPATH = [LIB_PATH])
+        print 'Building with ' + SRC_NAME + ' Completely.'
+    env.AppendUnique(
+        CPPPATH=[INC_PATH],
+        RALIBS=LIBSTROPHY_LIBS,
+        RALIBPATH=[LIB_PATH],
+        RARPATH=[LIB_PATH])
+    env.AppendUnique(LIBS=LIBSTROPHY_LIBS, LIBPATH=[LIB_PATH])
 
 if env.GetOption('clean'):
-       act = env.Action(['cd ' + SRC_PATH, 'make clean'])
-       env.Execute(act)
-       if os.path.isfile(env.get('BUILD_DIR') + '/libstrophe.a'):
-               act2 = env.Action(['rm ' + env.get('BUILD_DIR') + '/libstrophe.*'])
-               env.Execute(act2)
+    act = env.Action(['cd ' + SRC_PATH, 'make clean'])
+    env.Execute(act)
+    if os.path.isfile(env.get('BUILD_DIR') + '/libstrophe.a'):
+        act2 = env.Action(['rm ' + env.get('BUILD_DIR') + '/libstrophe.*'])
+        env.Execute(act2)
index 420dc9a..cc50d91 100644 (file)
@@ -22,50 +22,50 @@ Import('env')
 import SCons.Errors
 import os
 import sys
+import re
 import subprocess
 from shutil import copyfile
 
 target_os = env.get('TARGET_OS')
 root_dir = env.get('SRC_DIR')
-mbedtls_dir = os.path.join(root_dir, 'extlibs','mbedtls','mbedtls')
+mbedtls_dir = os.path.join(root_dir, 'extlibs', 'mbedtls', 'mbedtls')
 start_dir = os.getcwd()
 mbedtls_config_file = 'config-iotivity.h' if target_os != 'windows' else 'config-iotivity_windows.h'
-# Right now this script assumes the revision is a tag, and not a branch or an arbitrary
-# commit. If this changes, update the check below, or else the script will always conclude
-# the repo is not up to date because a tag with that name doesn't exist.
-mbedtls_revision = 'mbedtls-2.4.2'
 
 if not os.path.exists(mbedtls_dir):
-    print '''
-*********************************** Error: ****************************************
-* Please download mbedtls using the following command:                            *
+    msg = '''
+*********************************** Error: ************************************
+* The iotivity repository does not include cryptgraphic software,
+* but requires it to be added by the developer.
+* Please download mbedtls using the following command:
 * $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls -b %s
-***********************************************************************************
- ''' % mbedtls_revision
-    Exit(1)
-#cd extlib/mbedtls/mbedtls
+*******************************************************************************
+''' % mbedtls_revision
+    Exit(msg)
+
 os.chdir(mbedtls_dir)
 
-# Tizen uses its own process to prepare the mbedTLS repo in gbsbuild.sh. Make sure
-# the mbedtls_revision tag selected is the same as in extlibs/mbedtls/prep.sh.
-# This code also assumes mbedtls_revision is a tag; if it changes to
-# a branch or an arbitrary commit, disable this check below.
+# Right now this script assumes the revision is a tag, and not a branch or
+# an arbitrary commit. If this changes, update the check below, or else
+# the script will always conclude the repo is not up to date because a tag
+# with that name doesn't exist.
+# Tizen uses its own process to prepare the mbedTLS repo in gbsbuild.sh.
+# The mbedtls_revision tag here must match the one in extlibs/mbedtls/prep.sh.
+mbedtls_revision = 'mbedtls-2.4.2'
 if os.path.exists('.git/HEAD'):
-    out = subprocess.check_output('git tag -l ' + mbedtls_revision, shell = True)
+    out = subprocess.check_output('git tag -l ' + mbedtls_revision, shell=True)
     if mbedtls_revision not in out:
         print out
-        print '''
-*********************************** Error: ****************************************
-* Your mbedTLS repo is not up to date with the latest version we require. Please  *
-* update with the following commands:                                             *
-*     $ cd extlibs/mbedtls/mbedtls                                                *
-*     $ git fetch                                                                 *
-***********************************************************************************
- '''
-        Exit(1)
+        msg = '''
+*********************************** Error: ************************************
+* Your mbedTLS repo is not up to date with the version required by iotivity.
+* Please update with the following commands:
+*     $ cd extlibs/mbedtls/mbedtls
+*     $ git fetch
+*******************************************************************************
+'''
+        Exit(msg)
 
-import re
-import sys
 found = False
 
 # Check for the desired version of mbedTLS, first.
@@ -99,7 +99,8 @@ if not found:
         cmd = 'patch -p1 -l -f < ../ocf.patch'
         res = os.system(cmd)
     if 0 != res:
-        raise SCons.Errors.StopError('mbedtls: issue on applying patch: %d' % res)
+        raise SCons.Errors.StopError(
+            'mbedtls: issue on applying patch: %d' % res)
 
 os.chdir(start_dir)
 
@@ -107,123 +108,122 @@ os.chdir(start_dir)
 # from extlibs/mbedtls/iotivity-config.h
 # to extlibs/mbedtls/mbedtls/include/mbedtls/config.h
 iotivity_config = os.path.join(root_dir, 'extlibs', 'mbedtls', mbedtls_config_file)
-mbedtls_config = os.path.join(root_dir, 'extlibs', 'mbedtls', 'mbedtls', 'include', 'mbedtls', 'config.h')
+mbedtls_config = os.path.join(root_dir, 'extlibs', 'mbedtls', 'mbedtls',
+                              'include', 'mbedtls', 'config.h')
 
 try:
     copyfile(iotivity_config, mbedtls_config)
 except:
     print 'mbedtls SConscript: cannot copy ' + iotivity_config + ' to ' + mbedtls_config
-    print 'error: ' + str(sys.exc_info()[0])
-    Exit(1)
+    msg = 'error: ' + str(sys.exc_info()[0])
+    Exit(msg)
 else:
     print 'Copied IoTivity version of config.h to ' + mbedtls_config
 
 mbedtls_env = env.Clone()
 
-mbedtls_env.AppendUnique(CPPPATH = [
+mbedtls_env.AppendUnique(CPPPATH=[
     mbedtls_dir,
     os.path.join(mbedtls_dir, 'include'),
     os.path.join(mbedtls_dir, 'include', 'mbedtls')
-    ])
+])
 if 'g++' in mbedtls_env.get('CXX'):
-    mbedtls_env.AppendUnique(CFLAGS = ['-Wall'])
+    mbedtls_env.AppendUnique(CFLAGS=['-Wall'])
 
     if mbedtls_env['CC'] != 'cl':
-        mbedtls_env.AppendUnique(CFLAGS = ['-fPIC'])
+        mbedtls_env.AppendUnique(CFLAGS=['-fPIC'])
 
 ######################################################################
 # Source files and Target(s)
 ######################################################################
 mbedtls_src = [
-                'mbedtls/library/debug.c',
-                'mbedtls/library/net_sockets.c',
-                'mbedtls/library/ssl_cache.c',
-                'mbedtls/library/ssl_ciphersuites.c',
-                'mbedtls/library/ssl_cli.c',
-                'mbedtls/library/ssl_cookie.c',
-                'mbedtls/library/ssl_srv.c',
-                'mbedtls/library/ssl_ticket.c',
-                'mbedtls/library/ssl_tls.c'
-        ]
-
+    'mbedtls/library/debug.c',
+    'mbedtls/library/net_sockets.c',
+    'mbedtls/library/ssl_cache.c',
+    'mbedtls/library/ssl_ciphersuites.c',
+    'mbedtls/library/ssl_cli.c',
+    'mbedtls/library/ssl_cookie.c',
+    'mbedtls/library/ssl_srv.c',
+    'mbedtls/library/ssl_ticket.c',
+    'mbedtls/library/ssl_tls.c'
+]
 
 mbedcrypto_src = [
-                    'mbedtls/library/aes.c',
-                    'mbedtls/library/aesni.c',
-                    'mbedtls/library/arc4.c',
-                    'mbedtls/library/asn1parse.c',
-                    'mbedtls/library/asn1write.c',
-                    'mbedtls/library/base64.c',
-                    'mbedtls/library/bignum.c',
-                    'mbedtls/library/blowfish.c',
-                    'mbedtls/library/camellia.c',
-                    'mbedtls/library/ccm.c',
-                    'mbedtls/library/cipher.c',
-                    'mbedtls/library/cipher_wrap.c',
-                    'mbedtls/library/ctr_drbg.c',
-                    'mbedtls/library/des.c',
-                    'mbedtls/library/dhm.c',
-                    'mbedtls/library/ecdh.c',
-                    'mbedtls/library/ecdsa.c',
-                    'mbedtls/library/ecjpake.c',
-                    'mbedtls/library/ecp.c',
-                    'mbedtls/library/ecp_curves.c',
-                    'mbedtls/library/entropy.c',
-                    'mbedtls/library/entropy_poll.c',
-                    'mbedtls/library/error.c',
-                    'mbedtls/library/gcm.c',
-                    'mbedtls/library/havege.c',
-                    'mbedtls/library/hmac_drbg.c',
-                    'mbedtls/library/md.c',
-                    'mbedtls/library/md2.c',
-                    'mbedtls/library/md4.c',
-                    'mbedtls/library/md5.c',
-                    'mbedtls/library/md_wrap.c',
-                    'mbedtls/library/memory_buffer_alloc.c',
-                    'mbedtls/library/oid.c',
-                    'mbedtls/library/padlock.c',
-                    'mbedtls/library/pem.c',
-                    'mbedtls/library/pk.c',
-                    'mbedtls/library/pk_wrap.c',
-                    'mbedtls/library/pkcs12.c',
-                    'mbedtls/library/pkcs5.c',
-                    'mbedtls/library/pkparse.c',
-                    'mbedtls/library/pkwrite.c',
-                    'mbedtls/library/platform.c',
-                    'mbedtls/library/ripemd160.c',
-                    'mbedtls/library/rsa.c',
-                    'mbedtls/library/sha1.c',
-                    'mbedtls/library/sha256.c',
-                    'mbedtls/library/sha512.c',
-                    'mbedtls/library/threading.c',
-                    'mbedtls/library/timing.c',
-                    'mbedtls/library/version.c',
-                    'mbedtls/library/version_features.c',
-                    'mbedtls/library/xtea.c'
-        ]
+    'mbedtls/library/aes.c',
+    'mbedtls/library/aesni.c',
+    'mbedtls/library/arc4.c',
+    'mbedtls/library/asn1parse.c',
+    'mbedtls/library/asn1write.c',
+    'mbedtls/library/base64.c',
+    'mbedtls/library/bignum.c',
+    'mbedtls/library/blowfish.c',
+    'mbedtls/library/camellia.c',
+    'mbedtls/library/ccm.c',
+    'mbedtls/library/cipher.c',
+    'mbedtls/library/cipher_wrap.c',
+    'mbedtls/library/ctr_drbg.c',
+    'mbedtls/library/des.c',
+    'mbedtls/library/dhm.c',
+    'mbedtls/library/ecdh.c',
+    'mbedtls/library/ecdsa.c',
+    'mbedtls/library/ecjpake.c',
+    'mbedtls/library/ecp.c',
+    'mbedtls/library/ecp_curves.c',
+    'mbedtls/library/entropy.c',
+    'mbedtls/library/entropy_poll.c',
+    'mbedtls/library/error.c',
+    'mbedtls/library/gcm.c',
+    'mbedtls/library/havege.c',
+    'mbedtls/library/hmac_drbg.c',
+    'mbedtls/library/md.c',
+    'mbedtls/library/md2.c',
+    'mbedtls/library/md4.c',
+    'mbedtls/library/md5.c',
+    'mbedtls/library/md_wrap.c',
+    'mbedtls/library/memory_buffer_alloc.c',
+    'mbedtls/library/oid.c',
+    'mbedtls/library/padlock.c',
+    'mbedtls/library/pem.c',
+    'mbedtls/library/pk.c',
+    'mbedtls/library/pk_wrap.c',
+    'mbedtls/library/pkcs12.c',
+    'mbedtls/library/pkcs5.c',
+    'mbedtls/library/pkparse.c',
+    'mbedtls/library/pkwrite.c',
+    'mbedtls/library/platform.c',
+    'mbedtls/library/ripemd160.c',
+    'mbedtls/library/rsa.c',
+    'mbedtls/library/sha1.c',
+    'mbedtls/library/sha256.c',
+    'mbedtls/library/sha512.c',
+    'mbedtls/library/threading.c',
+    'mbedtls/library/timing.c',
+    'mbedtls/library/version.c',
+    'mbedtls/library/version_features.c',
+    'mbedtls/library/xtea.c'
+]
 
 mbeX509_src = [
-                'mbedtls/library/certs.c',
-                'mbedtls/library/pkcs11.c',
-                'mbedtls/library/x509.c',
-                'mbedtls/library/x509_create.c',
-                'mbedtls/library/x509_crl.c',
-                'mbedtls/library/x509_crt.c',
-                'mbedtls/library/x509_csr.c',
-                'mbedtls/library/x509write_crt.c',
-                'mbedtls/library/x509write_csr.c'
-        ]
+    'mbedtls/library/certs.c',
+    'mbedtls/library/pkcs11.c',
+    'mbedtls/library/x509.c',
+    'mbedtls/library/x509_create.c',
+    'mbedtls/library/x509_crl.c',
+    'mbedtls/library/x509_crt.c',
+    'mbedtls/library/x509_csr.c',
+    'mbedtls/library/x509write_crt.c',
+    'mbedtls/library/x509write_csr.c'
+]
 
 mbedcrypto_env = mbedtls_env.Clone()
 static_libmbedcrypto = mbedcrypto_env.StaticLibrary('mbedcrypto', mbedcrypto_src)
 mbedcrypto_env.InstallTarget(static_libmbedcrypto, 'mbedcrypto')
 
 mbex509_env = mbedtls_env.Clone()
-mbex509_env.AppendUnique(LIBS = ['mbedcrypto'])
+mbex509_env.AppendUnique(LIBS=['mbedcrypto'])
 static_libmbedx509 = mbex509_env.StaticLibrary('mbedx509', mbeX509_src)
 mbex509_env.InstallTarget(static_libmbedx509, 'mbedx509')
 
-
-mbedtls_env.AppendUnique(LIBS = ['mbedx509', 'mbedcrypto'])
+mbedtls_env.AppendUnique(LIBS=['mbedx509', 'mbedcrypto'])
 static_libmbedtls = mbedtls_env.StaticLibrary('mbedtls', mbedtls_src)
 mbedtls_env.InstallTarget(static_libmbedtls, 'mbedtls')
index 7b8200a..2fa7eee 100644 (file)
@@ -1,3 +1,8 @@
+######################################################################
+# rapidjson library fetch script
+#
+######################################################################
+
 import os, string, sys
 
 Import('env')
@@ -16,9 +21,11 @@ host_os = sys.platform
 src_dir = env.get('SRC_DIR')
 path = os.path.join(src_dir, 'extlibs', 'rapidjson', 'rapidjson')
 
-# check 'rapidjson' library, if it doesn't exits, ask user to download it
+# check 'rapidjson' library, if it doesn't exist, download it
 if not os.path.exists(path):
-    rapidjson_env = Environment(ENV = os.environ)
-    rapidjson_zip = env.Download('v1.0.2.zip', 'https://github.com/miloyip/rapidjson/archive/v1.0.2.zip')
+    rapidjson_env = Environment(ENV=os.environ)
+    rapidjson_zip = env.Download(
+        'v1.0.2.zip',
+        'https://github.com/miloyip/rapidjson/archive/v1.0.2.zip')
     rapidjson_dir = env.UnpackAll('rapidjson', rapidjson_zip)
     os.rename("rapidjson-1.0.2", "rapidjson")
index 6db32f5..2fc3cac 100644 (file)
@@ -32,30 +32,33 @@ target_os = env.get('TARGET_OS')
 target_arch = env.get('TARGET_ARCH')
 with_ra = env.get('WITH_RA')
 with_ra_ibb = env.get('WITH_RA_IBB')
-if with_ra and not with_ra_ibb :
-       # check 'raxmppl' library, if it doesn't exits, ask user to download it
-       if not os.path.exists('raxmpp'):
-               print '''
-       *********************************** Error: ***********************************************
-       * Please download ra_xmpp as following :
-       *     $ git clone https://gerrit.iotivity.org/gerrit/iotivity-xmpp extlibs/raxmpp/raxmpp
-       ******************************************************************************************
-       '''
-               Exit(1)
+if with_ra and not with_ra_ibb:
+    # check 'raxmppl' library, if it doesn't exist, ask user to download it
+    if not os.path.exists('raxmpp'):
+        msg = '''
+*********************************** Error: ************************************
+* Please download ra_xmpp as following :
+*     $ git clone https://gerrit.iotivity.org/gerrit/iotivity-xmpp extlibs/raxmpp/raxmpp
+*******************************************************************************
+'''
+        Exit(msg)
 
-       print 'building with ra_xmpp'
-       if env.get('RELEASE'):
-               print src_dir
-               build_dir = os.path.join(src_dir, 'extlibs/raxmpp/raxmpp/out', target_os, target_arch, 'release/')
-       else:
-               build_dir = os.path.join(src_dir, 'extlibs/raxmpp/raxmpp/out/', target_os, target_arch, 'debug/')
-       os.chdir('raxmpp')
-       sconsflags = ' RELEASE=true' if  env['RELEASE'] else ' RELEASE=false'
-       foo=commands.getoutput('scons external' + sconsflags )
-       print foo
-       foo=commands.getoutput('scons' + sconsflags )
-       print foo
+    print 'building with ra_xmpp'
+    if env.get('RELEASE'):
+        print src_dir
+        build_dir = os.path.join(src_dir, 'extlibs/raxmpp/raxmpp/out',
+                                 target_os, target_arch, 'release/')
+    else:
+        build_dir = os.path.join(src_dir, 'extlibs/raxmpp/raxmpp/out/',
+                                 target_os, target_arch, 'debug/')
+    os.chdir('raxmpp')
+    sconsflags = ' RELEASE=true' if env['RELEASE'] else ' RELEASE=false'
+    foo = commands.getoutput('scons external' + sconsflags)
+    print foo
+    foo = commands.getoutput('scons' + sconsflags)
+    print foo
 
-       env.AppendUnique(CPPPATH = src_dir+'/extlibs/raxmpp/raxmpp/ra_xmpp/',
-                               LIBPATH=build_dir,
-                               RPATH = build_dir)
+    env.AppendUnique(
+        CPPPATH=src_dir + '/extlibs/raxmpp/raxmpp/ra_xmpp/',
+        LIBPATH=build_dir,
+        RPATH=build_dir)
index 73498cd..c5e9666 100644 (file)
@@ -16,7 +16,7 @@ sqlite_dir = src_dir + '/extlibs/sqlite3/'
 sqlite_build_dir = src_dir + '/extlibs/sqlite3/sqlite-amalgamation-3081101/'
 sqlite_zip_file = src_dir + '/extlibs/sqlite3/sqlite-amalgamation-3081101.zip'
 sqlite_url = 'https://www.sqlite.org/2015/sqlite-amalgamation-3081101.zip'
-sqlite_package= 'sqlite-amalgamation-3081101'
+sqlite_package = 'sqlite-amalgamation-3081101'
 sqlite_url = 'https://www.sqlite.org/2015/' + sqlite_package + '.zip'
 
 sqlite_dir = os.path.join(src_dir, 'extlibs', 'sqlite3')
@@ -46,4 +46,4 @@ if target_os in ['windows']:
     # In multi-threaded builds, SCons appears to proceed to using sqlite3.lib
     # before finishing InstallTarget(libsqlite3, 'sqlite3') here. So, use the
     # generated LIB directly, without installing it.
-    env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'extlibs/sqlite3')])
+    env.AppendUnique(LIBPATH=[os.path.join(env.get('BUILD_DIR'), 'extlibs/sqlite3')])
index 9b7bb84..e04bf67 100644 (file)
@@ -26,17 +26,17 @@ Import('env')
 src_dir = env.get('SRC_DIR')
 target_os = env.get('TARGET_OS')
 
-cborDir = os.path.join(src_dir, 'extlibs','tinycbor','tinycbor')
+cborDir = os.path.join(src_dir, 'extlibs', 'tinycbor', 'tinycbor')
 cborRevision = 'v0.4.1'
 
 if not os.path.exists(cborDir):
-    print '''
-*********************************** Error: ****************************************
-* Please download cbor using the following command:                               *
-*   $ git clone https://github.com/01org/tinycbor.git extlibs/tinycbor/tinycbor -b %s *
-***********************************************************************************
+    msg = '''
+*********************************** Error: ************************************
+* Please download cbor using the following command:
+*   $ git clone https://github.com/01org/tinycbor.git extlibs/tinycbor/tinycbor -b %s
+*******************************************************************************
 ''' % cborRevision
-    Exit(1)
+    Exit(msg)
 
 start_dir = os.getcwd()
 os.chdir(cborDir)
@@ -46,19 +46,18 @@ os.chdir(cborDir)
 # This code also assumes tinycbor_revision is a tag; if it changes to a branch
 # or an arbitrary commit, disable this check below.
 if target_os != 'tizen' and os.path.exists('.git/HEAD'):
-    out = subprocess.check_output('git tag -l ' + cborRevision, shell = True)
+    out = subprocess.check_output('git tag -l ' + cborRevision, shell=True)
     if cborRevision not in out:
         print out
-        print '''
-*********************************** Error: ****************************************
-* Your TinyCBOR repo is not up to date with the latest version we require. Please *
-* update with the following commands:                                             *
-*     $ cd extlibs/tinycbor/tinycbor                                              *
-*     $ git fetch                                                                 *
-***********************************************************************************
- '''
-        Exit(1)
-
+        msg = '''
+*********************************** Error: ************************************
+* Your TinyCBOR repo is not up to date with the version required by iotivity.
+* Please update with the following commands:
+*     $ cd extlibs/tinycbor/tinycbor
+*     $ git fetch
+*******************************************************************************
+'''
+        Exit(msg)
 
 # Point TinyCBOR repo to desired release tag
 if os.path.exists('.git/HEAD'):
@@ -70,13 +69,11 @@ else:
 os.chdir(start_dir)
 
 cbor_src = [
-    os.path.join(cborDir,'src/cborparser.c'),
-    os.path.join(cborDir,'src/cborparser_dup_string.c'),
-    os.path.join(cborDir,'src/cborencoder.c'),
-    os.path.join(cborDir,'src/cborerrorstrings.c'),
-    ]
+    os.path.join(cborDir, 'src/cborparser.c'),
+    os.path.join(cborDir, 'src/cborparser_dup_string.c'),
+    os.path.join(cborDir, 'src/cborencoder.c'),
+    os.path.join(cborDir, 'src/cborerrorstrings.c'),
+]
 
 env['cbor_files'] = cbor_src
-env.AppendUnique(CPPPATH  = [os.path.join(cborDir, 'src')])
-
-
+env.AppendUnique(CPPPATH=[os.path.join(cborDir, 'src')])
index f8e9b2c..1b1956a 100644 (file)
@@ -8,9 +8,9 @@ import commands
 Import('env')
 
 base_dir = env.get('SRC_DIR')
+build_dir = env.get('BUILD_DIR')
 target_os = env.get('TARGET_OS')
 target_arch = env.get('TARGET_ARCH')
-
 with_ra_ibb = env.get('WITH_RA_IBB')
 
 SRC_NAME = 'wks_xep0047'
@@ -23,52 +23,58 @@ LIB_PATH = SRC_PATH
 WJSXMPPXEP_LIBS = ['wksxmppxep', 'm', 'crypto']
 
 if with_ra_ibb:
-       env.SConscript(base_dir + '/extlibs/libstrophe/SConscript')
-       if not os.path.exists(SRC_NAME):
-               raxmpp_env = Environment(ENV = os.environ)
-               c = raxmpp_env.Action(['git clone https://github.com/WorksSystems/wks_xep0047.git ' + SRC_NAME,
-                       'cd ' + SRC_NAME + ' && git checkout 8e9f42d02a0f416001065d1cddc1ab07974cef14'
+    env.SConscript(base_dir + '/extlibs/libstrophe/SConscript')
+    if not os.path.exists(SRC_NAME):
+        raxmpp_env = Environment(ENV=os.environ)
+        c = raxmpp_env.Action([
+            'git clone https://github.com/WorksSystems/wks_xep0047.git ' + SRC_NAME,
+            'cd ' + SRC_NAME + ' && git checkout 8e9f42d02a0f416001065d1cddc1ab07974cef14'
         ])
 
-               print 'Downloading', SRC_NAME ,'library ...'
-               if raxmpp_env.Execute(c):
-                       print '''
-       *********************************** Error: ***********************************************
-       * Please download ra_xmpp as following:
-       *     $ git clone https://github.com/WorksSystems/wksxmpp_chat.git extlibs/wksxmppxep/wksxmpp_chat
-       *     $ cd extlibs/wksxmppxep/wksxmpp_chat
-       *     $ git checkout 8e9f42d02a0f416001065d1cddc1ab07974cef14
-       ******************************************************************************************
-       '''
-                       Exit(1)
-               else:
-                       print 'Download', SRC_NAME, 'library complete'
+        print 'Downloading', SRC_NAME, 'library ...'
+        if raxmpp_env.Execute(c):
+            msg = '''
+*********************************** Error: ************************************
+* Please download ra_xmpp as following:
+*     $ git clone https://github.com/WorksSystems/wksxmpp_chat.git extlibs/wksxmppxep/wksxmpp_chat
+*     $ cd extlibs/wksxmppxep/wksxmpp_chat
+*     $ git checkout 8e9f42d02a0f416001065d1cddc1ab07974cef14
+*******************************************************************************
+'''
+            Exit(msg)
+        else:
+            print 'Download', SRC_NAME, 'library complete'
+
+        if not env.GetOption('clean'):
+            print 'Building with ' + SRC_NAME
+            os.chdir(SRC_NAME)
+            if not os.path.exists('libwksxmppxep.so'):
+                LIBSTROPHE_BASE = base_dir + '/extlibs/libstrophe/libstrophe'
+                foo = commands.getoutput('make LIBSTROPHE_BASE=' +
+                                         LIBSTROPHE_BASE + ' libraries')
+                print foo
+            if not os.path.exists('libwksxmppxep.so'):
+                msg = 'Building with ' + SRC_NAME + ' failed.'
+                Exit(msg)
+            else:
+                foo = commands.getoutput('cp libwksxmppxep.so ' + build_dir)
+                print foo
+                foo = commands.getoutput('cp libwksxmppxep.a ' + build_dir)
+                print foo
 
-       if not env.GetOption('clean'):
-               print 'Building with ' + SRC_NAME
-               os.chdir(SRC_NAME)
-               if not os.path.exists('libwksxmppxep.so') :
-                       LIBSTROPHE_BASE=base_dir + '/extlibs/libstrophe/libstrophe'
-                       foo=commands.getoutput('make LIBSTROPHE_BASE=' + LIBSTROPHE_BASE + ' libraries')
-                       print foo
-               if not os.path.exists('libwksxmppxep.so') :
-                       print 'Building with ' + SRC_NAME + ' failed.'
-                       Exit(2)
-               else:
-                       foo = commands.getoutput('cp libwksxmppxep.so ' + env.get('BUILD_DIR'))
-                       print foo
-                       foo = commands.getoutput('cp libwksxmppxep.a ' + env.get('BUILD_DIR'))
-                       print foo
-       
-               print 'Building with ' + SRC_NAME + ' Completely.'
+            print 'Building with ' + SRC_NAME + ' Completely.'
 
-       env.PrependUnique(CPPPATH = [INC_PATH], RALIBS = WJSXMPPXEP_LIBS, RALIBPATH = [LIB_PATH], RARPATH = [LIB_PATH])
-       env.AppendUnique(LIBS = WJSXMPPXEP_LIBS, LIBPATH = [LIB_PATH])
-       env.AppendUnique(LIBS = ['boost_system', 'boost_thread'])
+        env.PrependUnique(
+            CPPPATH=[INC_PATH],
+            RALIBS=WJSXMPPXEP_LIBS,
+            RALIBPATH=[LIB_PATH],
+            RARPATH=[LIB_PATH])
+        env.AppendUnique(LIBS=WJSXMPPXEP_LIBS, LIBPATH=[LIB_PATH])
+        env.AppendUnique(LIBS=['boost_system', 'boost_thread'])
 
-if env.GetOption('clean') :
-       act = env.Action(['cd ' + SRC_PATH, 'make clean'])
-       env.Execute(act)
-       if os.path.isfile(env.get('BUILD_DIR') + '/libwksxmppxep.so'):
-               act2 = env.Action(['rm ' + env.get('BUILD_DIR') + '/libwksxmppxep.*'])
-               env.Execute(act2)
\ No newline at end of file
+if env.GetOption('clean'):
+    act = env.Action(['cd ' + SRC_PATH, 'make clean'])
+    env.Execute(act)
+    if os.path.isfile(build_dir + '/libwksxmppxep.so'):
+        act2 = env.Action(['rm ' + build_dir + '/libwksxmppxep.*'])
+        env.Execute(act2)
index ba569af..6ea4b60 100644 (file)
@@ -24,26 +24,27 @@ Import('env')
 yaml_env = env.Clone()
 src_dir = env.get('SRC_DIR')
 
-yamlDir = os.path.join(src_dir, 'extlibs','yaml','yaml')
+yamlDir = os.path.join(src_dir, 'extlibs', 'yaml', 'yaml')
 
 if not os.path.exists(yamlDir):
-    print '''
-*********************************** Error: ****************************************
-* Please download yaml using the following command:                               *
-*     $ git clone https://github.com/jbeder/yaml-cpp.git extlibs/yaml/yaml *
-***********************************************************************************
+    msg = '''
+*********************************** Error: ************************************
+* Please download yaml using the following command:
+*     $ git clone https://github.com/jbeder/yaml-cpp.git extlibs/yaml/yaml
+*******************************************************************************
 '''
-    Exit(1)
+    Exit(msg)
 
 ######################################################################
 # Build flags
 ######################################################################
-yaml_env.AppendUnique(CPPPATH = ['yaml/src' , 'yaml/include'])
-yaml_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
-yaml_env.AppendUnique(CPPDEFINES = ['LINUX'])
-yaml_env.AppendUnique(LIBS = ['pthread'])
+yaml_env.AppendUnique(CPPPATH=['yaml/src', 'yaml/include'])
+yaml_env.AppendUnique(CXXFLAGS=['-std=c++0x', '-Wall', '-pthread'])
+yaml_env.AppendUnique(CPPDEFINES=['LINUX'])
+yaml_env.AppendUnique(LIBS=['pthread'])
 
-yaml_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
+yaml_env.AppendUnique(
+    CXXFLAGS=['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
 
 ######################################################################
 # Source files and Targets