Older Pythons can set linux or linux2 in sys.platform.
The suffix is meaningless, deprecated, and no longer happens as of Python 3.3.
The preferred idiom (from Python docs) is:
if sys.platform.startswith('linux'):
Twiddled a few other things, "imports at the top" rule,
and a couple of related error msgs, and a few strings
In a few places, more could have been done to clean up, but skipped
to keep the patches small
Change-Id: Iccdfa9eb77ff4bc1429e3b38837a8732455a5dfd
Signed-off-by: Mats Wichmann <mats@linux.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19641
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: George Nash <george.nash@intel.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
(cherry picked from commit
39f1ec664b3abc4e9d58b48a2e281a66ef11a153)
Reviewed-on: https://gerrit.iotivity.org/gerrit/20925
Reviewed-by: Ossama Othman <ossama.othman@intel.com>
# 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 == 'linux2' :
+ 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')
##
import os, subprocess, struct
+from sys import platform as _platform
import urllib2, urlparse
import SCons.Errors
import shutil
if not arduino_home:
print 'Creating ARDUINO_HOME for Arduino lib'
print '''
- *******************************************************************************
- * Arduino root directory isn't 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):
- from sys import platform as _platform
- if _platform == "linux" or _platform == "linux2":
+ if _platform.startswith("linux"):
archType = 8 * struct.calcsize("P")
print 'On %s-bit machine.' % (archType)
if archType == 32:
boost_env = env.Clone()
-modules = ['thread','program_options', 'system', 'date_time']
+modules = ['thread', 'program_options', 'system', 'date_time']
target_os = env.get('TARGET_OS')
target_arch = env.get('TARGET_ARCH')
boost_dir = os.path.join(src_dir,'extlibs','boost','boost')
boost_bootstrap = os.path.join(boost_dir,'bootstrap.bat')
-if 'linux' == target_os :
+if 'linux' == target_os:
# Check for Boost libraries in /usr/boost
print 'TODO: Perform platform check for linux'
- raise SCons.Errors.EnvironmentError('Unsupported platform')
+ msg = "Target platform (%s) is currently not supported for boost builds" % 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)
# Sanity check, in case the above method didn't work
if not os.path.exists(boost_bootstrap):
print '''
-*********************************** Error: ****************************************
+*********************************** Error: ************************************
* Please download boost from the following website:
*
* ''' + boost_url + '''
*
* ''' + boost_dir + '''
*
-* such that this build system can find:
+* such that the build system can find:
*
* ''' + boost_bootstrap + '''
*
-***********************************************************************************
+*******************************************************************************
'''
Exit(1)
host_os = sys.platform
- if host_os == 'linux2' :
+ if host_os.startswith("linux"):
boost_bootstrap = boost_base_name+os.sep+'bootstrap.sh'
- else :
+ else:
msg="Host platform (%s) is currently not supported for boost builds" % host_os
raise SCons.Errors.EnvironmentError(msg)
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+import sys
+
Import('stacksamples_env')
arduino_simplecs_env = stacksamples_env.Clone()
arduino_simplecs_env.AppendTarget('arduino_simplecs')
if(arduino_simplecs_env['UPLOAD'] == True):
- from sys import platform as _platform
- if _platform == "linux" or _platform == "linux2":
+ if sys.platform.startswith("linux"):
arduino_simplecs_env.Upload(arduino_simplecs_env.get('BUILD_DIR') + '/resource/csdk/stack/samples/arduino/SimpleClientServer/ocserver/SimpleClientServer.hex')
else:
- print 'Please use appropriate install method for your developing machine. Linux is the only supported platform right now.'
+ print 'Please use appropriate install method for your development machine. Linux is the only supported platform right now.'
# Build script for Arduino Enrollee Sample App
######################################################################
+import sys
+
Import('env')
enrollee_env = env.Clone()
env.AppendTarget('enrollee')
if(enrollee_env['UPLOAD'] == True):
- from sys import platform as _platform
- if _platform == "linux" or _platform == "linux2":
+ if sys.platform.startswith("linux"):
enrollee_env.Upload(env.get('BUILD_DIR') + '/service/easy-setup/sampleapp/enrollee/arduino/enrollee.hex')
else:
- print 'Please use appropriate install method for your developing machine. Linux is the only supported platform right now.'
+ print 'Please use appropriate install method for your development machine. Linux is the only supported platform right now.'