* Enable use of MSYS2 as the build host and build target.
* Add MSYS2 specific SCons files.
* Modify existing SCons files to support building /resource
directory from within MSYS2.
Change-Id: I95f4d205f106782c0dc487209fbb5c137aa3d7ac
Signed-off-by: Daniel Ferguson <daniel.j.ferguson@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5505
Reviewed-by: David Antler <david.a.antler@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
# Build 'resource' sub-project
SConscript(build_dir + 'resource/SConscript')
-if target_os not in ['arduino','darwin','ios', 'android']:
+if target_os not in ['arduino','darwin','ios', 'android', 'msys_nt']:
SConscript(build_dir + 'examples/OICMiddle/SConscript')
# Build 'service' sub-project
'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
'windows': ['windows', 'winrt', 'android', 'arduino'],
'darwin': ['darwin', 'ios', 'android', 'arduino'],
+ 'msys_nt' :['msys_nt'],
}
# Map of os and allowed archs (os: allowed archs)
'tizen': ['x86', 'x86_64', 'arm', 'arm64', 'armeabi-v7a'],
'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
'windows': ['x86', 'amd64', 'arm'],
+ 'msys_nt':['x86', 'x86_64'],
'winrt': ['arm'],
'darwin': ['i386', 'x86_64'],
'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
host = platform.system().lower()
+# the host string contains version of windows. 6.3, 6.4, 10.0 which is 8.0, 8.1, and 10 respectively.
+# Let's canonicalize the msys_nt-XX.X system name by stripping version off.
+if 'msys_nt' in host:
+ host = 'msys_nt'
+
if not host_target_map.has_key(host):
print "\nError: Current system (%s) isn't supported\n" % host
Exit(1)
--- /dev/null
+##
+# This script sets compiler flags for
+# MinGW in the MSYS environment.
+##
+Import('env')
+
+# Set common flags
+# Overwrite suffixes and prefixes
+if env['TARGET_OS'] == 'msys_nt':
+ env['SHLIBPREFIX'] = 'lib'
+
+env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+
+target_arch = env.get('TARGET_ARCH')
+
+if env['CC'] == 'gcc':
+ if env.get('RELEASE'):
+ env.AppendUnique(CCFLAGS = ['-Os'])
+ env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+ else:
+ env.AppendUnique(CCFLAGS = ['-g'])
+ env.AppendUnique(CFLAGS = ['-std=c99'])
+ env.AppendUnique(CXXFLAGS = ['-std=c++11'])
+ env.AppendUnique(CCFLAGS = ['-Wall', '-Wextra', '-Wa,-mbig-obj'])
+ env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '_GNU_SOURCE', '__msys_nt__'])
+
+ # Set arch flags
+ if target_arch in ['x86']:
+ env.AppendUnique(CCFLAGS = ['-m32'])
+ env.AppendUnique(LINKFLAGS = ['-m32'])
+ elif target_arch in ['x86_64']:
+ env.AppendUnique(CCFLAGS = ['-m64'])
+ env.AppendUnique(LINKFLAGS = ['-m64'])
# read the tools on *nix systems and sets the default parameters
- elif env["PLATFORM"] in ["darwin", "linux", "posix"] :
+ elif env["PLATFORM"] in ["darwin", "linux", "posix", "msys"] :
if env.WhereIs("unzip") :
toolset["EXTRACTOR"]["ZIP"]["RUN"] = "unzip"
+++ /dev/null
-##
-# This script includes windows specific config (MSVS/MSVC)
-##
-Import('env')
-
-# Set common flags
-env.AppendUnique(CXXFLAGS=['/wd4244', '/wd4267','/wd4345', '/wd4355', '/wd4800', '/wd4996'])
-env.AppendUnique(CCFLAGS=['/EHsc'])
-
-# Set release/debug flags
-if env.get('RELEASE'):
- env.AppendUnique(CCFLAGS = ['/MD', '/O2', '/GF'])
- env.AppendUnique(CPPDEFINES = ['NDEBUG'])
-else:
- env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/ZI', '/GZ', '/Gm'])
- env.AppendUnique(CPPDEFINES = ['_DEBUG'])
- env.AppendUnique(LINKFLAGS = ['/debug'])
build_sample = env.get('BUILD_SAMPLE')
src_dir = env.get('SRC_DIR')
-if target_os not in ['android', 'arduino', 'darwin', 'ios', 'tizen']:
+if target_os not in ['android', 'arduino', 'darwin', 'ios', 'tizen', 'msys_nt']:
SConscript(os.path.join('zigbee_wrapper', 'SConscript'))
#
##
-import os
-
Import('env')
target_os = env.get('TARGET_OS')
# Build liblogger
SConscript('csdk/logger/SConscript')
-if target_os not in ['arduino', 'darwin', 'ios', 'android']:
+if target_os not in ['arduino', 'darwin', 'ios', 'android', 'msys_nt']:
env.AppendUnique(LIBS=['rt'])
# Build libcoap
liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-if target_os in ['android', 'linux', 'tizen']:
+if target_os in ['android', 'linux', 'tizen', 'msys_nt']:
liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
if with_ra_ibb:
if target_os == 'arduino':
liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
-elif target_os not in ['darwin','ios']:
+elif target_os not in ['darwin','ios', 'msys_nt']:
liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
if target_os in ['darwin', 'ios']:
env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
liboctbstack_env.Append(LIBS = ['c_common'])
+if target_os in ['msys_nt']:
+ liboctbstack_env.Append(LIBS = ['ws2_32', 'iphlpapi'])
+
if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
liboctbstack_env.Prepend(LIBS = ['routingmanager'])
env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','EDR_ADAPTER','LE_ADAPTER', 'NFC_ADAPTER'])
elif target_os in['darwin','ios']:
env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','NO_EDR_ADAPTER','NO_LE_ADAPTER'])
+ elif target_os in ['msys_nt']:
+ env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','NO_EDR_ADAPTER','NO_LE_ADAPTER'])
else:
env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
print "CA Transport is ALL"
env.get('ARDUINO_HOME')+'/libraries/Ethernet/src/utility',
])
-if target_os not in ['arduino', 'windows', 'winrt']:
+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(CFLAGS = ['-Wall', '-ffunction-sections',
'-fdata-sections', '-fno-exceptions'])
+if target_os == 'msys_nt':
+ libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '_DEFAULT_SOURCE'])
+ libcoap_env.AppendUnique(CFLAGS = ['-std=c99'])
+
if target_os in ['linux', 'tizen', 'android', 'ios', 'arduino']:
if with_tcp == True:
libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
env.PrependUnique(CPPPATH = [ os.path.join(root_dir, 'api') ])
env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'inc'),
- os.path.join(root_dir, 'lib/libcoap-4.1.1'),
- os.path.join(src_dir, '/resource/csdk/logger/include/'),
- os.path.join(root_dir, 'common/inc'),
- os.path.join(root_dir, 'util/inc') ])
+ os.path.join(root_dir, 'lib', 'libcoap-4.1.1'),
+ os.path.join(src_dir, 'resource', 'csdk', 'logger', 'include'),
+ os.path.join(root_dir, 'common', 'inc'),
+ os.path.join(root_dir, 'util', 'inc') ])
if ca_os not in ['arduino', 'windows', 'winrt']:
env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
# Getting common source files
-env.SConscript('./../common/SConscript')
+env.SConscript(os.path.join(root_dir, 'common', 'SConscript'))
# Getting util source files
-env.SConscript(root_dir + '/util/SConscript')
+env.SConscript(os.path.join(root_dir, 'util', 'SConscript'))
# The tinydtls library is found in '#extlibs/tinydtls', where the '#'
# is interpreted by SCons as the top-level iotivity directory where
lib_env.AppendUnique(LIBS = ['timer'])
if ca_os != 'android':
lib_env.AppendUnique(LIBS = ['rt'])
- calib = lib_env.SharedLibrary('connectivity_abstraction', lib_env.get('CA_SRC'))
+ calib = lib_env.SharedLibrary('connectivity_abstraction', env.get('CA_SRC'))
+elif ca_os in ['msys_nt']:
+ lib_env.AppendUnique(LIBS = ['coap', 'mswsock', 'ws2_32', 'iphlpapi', 'logger'])
+ calib = lib_env.StaticLibrary('connectivity_abstraction', env.get('CA_SRC'))
else:
calib = lib_env.StaticLibrary('connectivity_abstraction', lib_env.get('CA_SRC'))
lib_env.InstallTarget(calib, 'libconnectivity_abstraction')
Import('env')
import os
-env.AppendUnique(CPPPATH = [os.path.join(Dir('.').abspath, './include')])
+env.AppendUnique(CPPPATH = [os.path.join(Dir('.').abspath, 'include')])
if env.get('TARGET_OS') == 'tizen':
env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
else:
- env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/csdk/logger/')])
+ env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'csdk', 'logger')])
env.PrependUnique(LIBS = ['logger'])
static oc_log_ctx_t *logCtx = 0;
#endif
#ifdef __ANDROID__
-#elif defined __linux__ || defined __APPLE__
+#elif defined __linux__ || defined __APPLE__ || defined __msys_nt__
static oc_log_level LEVEL_XTABLE[] = {OC_LOG_DEBUG, OC_LOG_INFO,
OC_LOG_WARNING, OC_LOG_ERROR, OC_LOG_FATAL};
#endif
__android_log_write(LEVEL[level], tag, logStr);
#endif
- #elif defined __linux__ || defined __APPLE__
+ #else
if (logCtx && logCtx->write_level)
{
logCtx->write_level(logCtx, LEVEL_XTABLE[level], logStr);
examples_env.AppendUnique(LIBS = ['octbstack'])
examples_env.AppendUnique(LIBS = ['oc'])
+if target_os in ['msys_nt', 'windows']:
+ examples_env.PrependUnique(LIBS = ['mswsock', 'ws2_32', 'iphlpapi', 'ole32'])
+
if env.get('SECURED') == '1':
examples_env.AppendUnique(LIBS = ['tinydtls'])
if target_os in ['darwin', 'ios']:
examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
+if env.get('LOGGING'):
+ examples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
######################################################################
# Source files and Targets
######################################################################
liboc_logger_env.AppendUnique(CFLAGS = ['-Wall', '-std=c99', '-fPIC'])
liboc_logger_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x', '-fPIC'])
-if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+if target_os not in ['darwin', 'ios', 'windows', 'winrt', 'msys_nt']:
liboc_logger_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
######################################################################
oclib_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-oclib_env.AppendUnique(LIBS = ['octbstack', 'oc_logger'])
-oclib_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+oclib_env.AppendUnique(LIBS = ['oc_logger'])
+oclib_env.PrependUnique(LIBS = ['octbstack', 'connectivity_abstraction', 'ocsrm'])
target_os = env.get('TARGET_OS')
if target_os == 'linux':
if target_os in ['linux'] and env.get('SIMULATOR', False):
oclib_env.Append( RPATH = env.Literal('\\$$ORIGIN'))
+if target_os in ['msys_nt']:
+ oclib_env.AppendUnique(LIBS = ['ws2_32', 'iphlpapi'])
######################################################################
# Source files and Targets
# read the tools on *nix systems and sets the default parameters
- elif env["PLATFORM"] in ["darwin", "linux", "posix"] :
+ elif env["PLATFORM"] in ["darwin", "linux", "posix", "msys"] :
if env.WhereIs("unzip") :
toolset["EXTRACTOR"]["ZIP"]["RUN"] = "unzip"