[IOT-1911] Make resource/csdk/stack W4 compliant.
[platform/upstream/iotivity.git] / build_common / windows / SConscript
1 ##
2 # This script includes windows specific config (MSVS/MSVC)
3 ##
4 Import('env')
5 import os.path
6
7 # Set common flags
8 if env['CC'] == 'cl':
9     #  - warning C4133: incompatible type conversion
10     env.AppendUnique(CCFLAGS=['/we4133'])
11
12     # Disable the following warnings:
13     #  - warning C4127: conditional expression is constant
14     #    - Disabled due to the widespread usage in IoTivity
15     #  - warning C4200: zero-sized array in struct/union.
16     #    - It is an acceptable approach for variable size structs.
17     #  - warning C4201: nameless struct/union
18     #    - Disabled due to IoTivity not being ANSI compatible
19     #  - warning C4204: nonstandard extension used: non-constant aggregate initializer
20     #    - Disabled due to IoTivity not being ANSI compatible and this is an appropriate way to intialize
21     #      structs for non-legacy compilers.
22     #  - warning C4214:  bit field types other than int
23     #    - Disabled due to IoTivity not being ANSI compatible
24     #  - warning C4232: nonstandard extension used: 'read': address of dllimport 'fread' is not static, identity not guaranteed
25     #    - fread, frwrite, etc are provided by the platform and cannot be changed.
26     #  - warning C4706: assignment within conditional expression
27     #    - Disabled due to the widespread usage in IoTivity and low impact.
28     env.AppendUnique(CCFLAGS=['/wd4127', '/wd4200', '/wd4201', '/wd4204', '/wd4214', '/wd4232', '/wd4706'])
29
30     env.AppendUnique(CCFLAGS=['/EHsc'])
31
32     # Set release/debug flags
33     if env.get('RELEASE'):
34         env.AppendUnique(CCFLAGS = ['/MD', '/O2', '/GF'])
35         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
36     else:
37         env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/RTC1'])
38         env.AppendUnique(LINKFLAGS = ['/debug'])
39     env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
40     env.AppendUnique(PATH = os.environ['PATH'])
41     env['PDB'] = '${TARGET.base}.pdb'
42     env.Append(LINKFLAGS=['/PDB:${TARGET.base}.pdb'])
43
44     # Add Windows-specific libraries
45     env.AppendUnique(LIBS = ['bcrypt', 'ws2_32', 'advapi32', 'iphlpapi', 'crypt32', 'kernel32'])
46
47     # Visual Studio compiler complains that functions like strncpy are unsafe. We
48     # are aware that it's possible to create a non-null terminated string using the
49     # strncpy function.  However, the str*_s functions are not standard and thus
50     # will not work on all systems supported by IoTivity. This will prevent Visual
51     # Studio from displaying unwanted warnings.
52     # See https://msdn.microsoft.com/en-us/library/ttcz0bys.aspx for more details.
53     env.AppendUnique(CPPDEFINES=['_CRT_SECURE_NO_WARNINGS', '_CRT_NONSTDC_NO_WARNINGS'])
54
55 elif env['CC'] == 'gcc':
56     print "\nError: gcc not supported on Windows.  Use Visual Studio!\n"
57     Exit(1);
58