Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / build_common / iotivityconfig / compiler / default_configuration.py
1 # ------------------------------------------------------------------------
2 # Copyright 2015 Intel Corporation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # ------------------------------------------------------------------------
16
17 from .configuration import Configuration
18
19 # Default (very simple) compiler configuration
20 class DefaultConfiguration(Configuration):
21     def __init__(self, context):
22         Configuration.__init__(self, context)
23
24     # ------------------------------------------------------------
25     # Return test program to be used when checking for basic C++11
26     # support.
27     # ------------------------------------------------------------
28     def _c99_test_program(self):
29         return """
30 // Some headers found in C99.
31 #include <stdbool.h>
32 #include <stdint.h>
33
34 int main()
35 {
36     struct foo
37     {
38         bool b;      // C99 type
39         int i;
40         uint64_t q;  // C99 type
41     };
42
43     // Designated initializer.
44     struct foo bar = { .b = false, .q = UINT64_MAX };
45
46     // Implicitly initialized field.
47     return bar.i != 0;
48 }
49 """
50
51     # --------------------------------------------------------------
52     # Get list of flags that could potentially enable C99 support.
53     #
54     # The default configuration assumes that no flag is needed to
55     # enable C99 support.
56     # --------------------------------------------------------------
57     def _c99_flags(self):
58         return []
59
60     # ------------------------------------------------------------
61     # Return test program to be used when checking for basic C++11
62     # support.
63     # ------------------------------------------------------------
64     def _cxx11_test_program(self):
65         return """
66 int main()
67 {
68     int x = 3210;
69     auto f = [x](){
70         return x;
71     };
72
73     return f() != x;
74 }
75 """
76
77     # --------------------------------------------------------------
78     # Get list of flags that could potentially enable C++11 support.
79     #
80     # The default configuration assumes that no flag is needed to
81     # enable C++11 support.
82     # --------------------------------------------------------------
83     def _cxx11_flags(self):
84         return []