help_vars.Add(PathVariable('ANDROID_HOME', 'Android SDK path', None, PathVariable.PathAccept))
help_vars.Add(PathVariable('ANDROID_GRADLE', 'Gradle binary file', None, PathVariable.PathIsFile))
+if target_os == 'windows':
+ # For VS2013, MSVC_VERSION is '12.0'. For VS2015, MSVC_VERSION is '14.0'.
+ # Default value is None, meaning that SCons has to choose automatically a VS version.
+ help_vars.Add(EnumVariable('MSVC_VERSION', 'MSVC compiler version - Windows', None, allowed_values=('12.0', '14.0')))
+
AddOption('--prefix',
dest='prefix',
type='string',
env.AppendUnique(CCFLAGS=['/EHsc'])
- vs_version = env['MSVC_VERSION']
-
# Set release/debug flags
if env.get('RELEASE'):
env.AppendUnique(CCFLAGS = ['/MD', '/O2', '/GF'])
env.AppendUnique(CPPDEFINES = ['NDEBUG'])
- elif env.get('TARGET_ARCH') in ['x86', 'x86_64'] or "14.0" in vs_version:
- env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/ZI', '/RTC1', '/Gm'])
- env.AppendUnique(LINKFLAGS = ['/debug'])
else:
env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/Zi', '/RTC1', '/Gm'])
env.AppendUnique(LINKFLAGS = ['/debug'])
gtest_env.Configure(gtest_dir, 'mv libgtest_main.a lib/.libs')
elif target_os == 'windows':
- if os.path.exists(gtest_dir):
- if gtest_env.get('RELEASE'):
- output_dir = os.path.join(gtest_dir, 'Release') + os.sep
- else:
- output_dir = os.path.join(gtest_dir, 'Debug') + os.sep
-
- # Three parts to the gtest config string...
- # 1. "Visual Studio" toolchain name.
- # 2. VS Version + Year ("14 2015", "12 2013").
- # 3. Target Architecture ("Win64", "Win32").
- vs_version_year = ""
- vs_target_arch = ""
- vs_num = env['MSVC_VERSION']
- if "12.0" in vs_num:
- vs_version_year = "Visual Studio 12 2013"
- elif "14.0" in vs_num:
- vs_version_year = "Visual Studio 14 2015"
- else:
- print "Error: unknown Visual Studio version %s" % vs_num
-
- vs_arch = env['TARGET_ARCH']
- if "amd64" in vs_arch:
- vs_target_arch = "Win64"
- elif "x86" in vs_arch:
- vs_target_arch = ""
- else:
- print "Error: unknown Visual Studio target arch %s" % vs_arch
-
- vs_target_string = vs_version_year + " " + vs_target_arch
-
- # Exit if we didn't get a match for one of the above.
- if not vs_version_year or not vs_target_arch:
- Exit(1)
-
- if not gtest_env.WhereIs('cmake', gtest_env.get('PATH')):
- print '''*********************** Error ************************
-* *
-* Please make sure that CMake is in your System PATH *
-* *
-* You can download CMake from: *
-* https://cmake.org/download/ *
-* *
-******************************************************
-'''
- Exit(1)
-
- if not os.path.exists(gtest_lib_dir):
- # Create lib dir
- os.mkdir(gtest_lib_dir)
- os.mkdir(gtest_dotlib_dir)
-
- # Run configure on gtest
- print 'Configuring google unit test for compilation'
- gtest_env.Configure(gtest_dir, 'cmake . -G"' + vs_target_string + '" -Dgtest_force_shared_crt=ON')
-
- # Run make on gtest
- print 'Making google unit test'
- gtest_env.Configure(gtest_dir, 'msbuild gtest.vcxproj')
- gtest_env.Configure(gtest_dir, 'msbuild gtest_main.vcxproj')
-
- print 'Moving libraries to lib folder'
- gtest_env.Configure(gtest_dir, 'copy '+output_dir+'gtest.lib %s' % gtest_lib_dir)
- gtest_env.Configure(gtest_dir, 'move '+output_dir+'gtest.lib %s' % gtest_dotlib_dir )
- gtest_env.Configure(gtest_dir, 'copy '+output_dir+'gtest_main.lib %s' % gtest_lib_dir)
- gtest_env.Configure(gtest_dir, 'move '+output_dir+'gtest_main.lib %s' % gtest_dotlib_dir)
+ # Avoid building the same StaticLibrary in more than one environment, by using the
+ # IOTIVITY_GTEST_HAS_BEEN_BUILT environment variable
+ if not env.has_key('IOTIVITY_GTEST_HAS_BEEN_BUILT'):
+ gtest_env.Append(CPPPATH = [ gtest_dir ])
+ gtest = gtest_env.StaticLibrary(target = 'gtest', source = [ '%s/src/gtest-all.cc' % gtest_dir ])
+ gtest_main = gtest_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')
+
+ vars = Variables();
+ vars.AddVariables(('IOTIVITY_GTEST_HAS_BEEN_BUILT', '', '1'))
+ vars.Update(env)
# Export flags once for all
if target_os in targets_need_gtest:
set DEBUG="%ProgramFiles(x86)%\Windows Kits\10\Debuggers\x64\cdb.exe" -2 -c "g"
)
-IF "%CURRENT_ARG%" == "build" IF "%BUILD_MSYS%" == "" (
- IF NOT "%VS140COMNTOOLS%" == "" (
- CALL "%VS140COMNTOOLS%"vsvars32.bat
- ) ELSE (
- IF NOT "%VS120COMNTOOLS%" == "" (
- CALL "%VS120COMNTOOLS%"vsvars32.bat
- )
- )
-
- IF NOT "!VSINSTALLDIR!" == "" (
- CALL "!VSINSTALLDIR!VC\vcvarsall.bat" amd64
- ) ELSE (
- @ECHO WARNING: Could not find vsvarsall.bat.
- @ECHO WARNING: VISUAL STUDIO 2013/2015 DOES NOT APPEAR TO BE INSTALLED ON THIS MACHINE
- GOTO :EOF
- )
-)
-
REM We need to append the "PATH" so the octbstack.dll can be found by executables
IF "%BUILD_MSYS%" == "" (
set BUILD_DIR=out\windows\amd64\debug
set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% RELEASE=0 WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=0 BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% WITH_RD=%WITH_RD% ROUTING=%ROUTING%
+REM Use MSVC_VERSION=12.0 for VS2013, or MSVC_VERSION=14.0 for VS2015.
+REM If MSVC_VERSION has not been defined here, SCons chooses automatically a VS version.
+IF NOT "%MSVC_VERSION%" == "" (
+ set BUILD_OPTIONS=%BUILD_OPTIONS% MSVC_VERSION=%MSVC_VERSION%
+)
+
REM *** BUILD OPTIONS ***
if "!CURRENT_ARG!"=="server" (
echo LOGGING=%LOGGING%
echo WITH_RD=%WITH_RD%
echo ROUTING=%ROUTING%
- CL.exe | findstr "Compiler Verison"
echo.scons VERBOSE=1 %BUILD_OPTIONS%
scons VERBOSE=1 %BUILD_OPTIONS%
) else if "!CURRENT_ARG!"=="clean" (
scons VERBOSE=1 %BUILD_OPTIONS% -c clean
rd /s /q out
del .sconsign.dblite
+ del extlibs\gtest\gtest*.lib
+ del extlibs\gtest\gtest-1.7.0\src\gtest*.obj
) else if "!CURRENT_ARG!"=="cleangtest" (
rd /s /q extlibs\gtest\gtest-1.7.0
del extlibs\gtest\gtest-1.7.0.zip