Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfea0f09

Browse files
committed
build: sync default build flags with ndn-cxx
Change-Id: I0b46e3cfbcf0182d1569e69b693012360134b6ca
1 parent60b52cf commitfea0f09

File tree

1 file changed

+68
-57
lines changed

1 file changed

+68
-57
lines changed

‎.waf-tools/default-compiler-flags.py‎

Lines changed: 68 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
importplatform
44
fromwaflibimportConfigure,Logs,Utils
55

6+
67
defoptions(opt):
78
opt.add_option('--debug','--with-debug',action='store_true',default=False,
89
help='Compile in debugging mode with minimal optimizations (-Og)')
910

11+
1012
defconfigure(conf):
1113
conf.start_msg('Checking C++ compiler version')
1214

@@ -48,14 +50,15 @@ def configure(conf):
4850
else:
4951
conf.end_msg(ccverstr)
5052

51-
conf.areCustomCxxflagsPresent=(len(conf.env.CXXFLAGS)>0)
53+
conf.areCustomCxxflagsPresent=len(conf.env.CXXFLAGS)>0
5254

5355
# General flags are always applied (e.g., selecting C++ language standard)
5456
generalFlags=conf.flags.getGeneralFlags(conf)
5557
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
5658
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
5759
conf.env.DEFINES+=generalFlags['DEFINES']
5860

61+
5962
@Configure.conf
6063
defcheck_compiler_flags(conf):
6164
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
@@ -78,10 +81,11 @@ def check_compiler_flags(conf):
7881

7982
conf.env.DEFINES+=extraFlags['DEFINES']
8083

84+
8185
@Configure.conf
8286
defadd_supported_cxxflags(self,cxxflags):
8387
"""
84-
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
88+
Check which cxxflags are supported bythe activecompiler and add them to env.CXXFLAGS variable.
8589
"""
8690
iflen(cxxflags)==0:
8791
return
@@ -97,10 +101,11 @@ def add_supported_cxxflags(self, cxxflags):
97101
self.end_msg(' '.join(supportedFlags))
98102
self.env.prepend_value('CXXFLAGS',supportedFlags)
99103

104+
100105
@Configure.conf
101106
defadd_supported_linkflags(self,linkflags):
102107
"""
103-
Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
108+
Check which linkflags are supported bythe activecompiler and add them to env.LINKFLAGS variable.
104109
"""
105110
iflen(linkflags)==0:
106111
return
@@ -117,7 +122,7 @@ def add_supported_linkflags(self, linkflags):
117122
self.env.prepend_value('LINKFLAGS',supportedFlags)
118123

119124

120-
classCompilerFlags(object):
125+
classCompilerFlags:
121126
defgetCompilerVersion(self,conf):
122127
returntuple(int(i)foriinconf.env.CC_VERSION)
123128

@@ -133,94 +138,100 @@ def getOptimizedFlags(self, conf):
133138
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
134139
return {'CXXFLAGS': [],'LINKFLAGS': [],'DEFINES': ['NDEBUG']}
135140

136-
classGccBasicFlags(CompilerFlags):
141+
142+
classGccClangCommonFlags(CompilerFlags):
137143
"""
138-
This class definesbasic flags that work for both gcc and clang compilers
144+
This class definescommon flags that work for both gcc and clang compilers.
139145
"""
146+
140147
defgetGeneralFlags(self,conf):
141-
flags=super(GccBasicFlags,self).getGeneralFlags(conf)
148+
flags=super().getGeneralFlags(conf)
142149
flags['CXXFLAGS']+= ['-std=c++17']
143150
ifUtils.unversioned_sys_platform()!='darwin':
144151
flags['LINKFLAGS']+= ['-fuse-ld=lld']
145152
returnflags
146153

154+
__cxxFlags= [
155+
'-fdiagnostics-color',
156+
'-Wall',
157+
'-Wextra',
158+
'-Wpedantic',
159+
'-Wenum-conversion',
160+
'-Wextra-semi',
161+
'-Wnon-virtual-dtor',
162+
'-Wno-unused-parameter',
163+
]
164+
__linkFlags= ['-Wl,-O1']
165+
147166
defgetDebugFlags(self,conf):
148-
flags=super(GccBasicFlags,self).getDebugFlags(conf)
149-
flags['CXXFLAGS']+= ['-Og',
150-
'-g3',
151-
'-Wall',
152-
'-Wextra',
153-
'-Wpedantic',
154-
'-Werror',
155-
'-Wcatch-value=2',
156-
'-Wextra-semi',
157-
'-Wnon-virtual-dtor',
158-
'-Wno-error=deprecated-declarations',# Bug #3795
159-
'-Wno-error=maybe-uninitialized',# Bug #1615
160-
'-Wno-unused-parameter',
161-
]
162-
flags['LINKFLAGS']+= ['-Wl,-O1']
167+
flags=super().getDebugFlags(conf)
168+
flags['CXXFLAGS']+= ['-Og','-g']+self.__cxxFlags+ [
169+
'-Werror',
170+
'-Wno-error=deprecated-declarations',# Bug #3795
171+
'-Wno-error=maybe-uninitialized',# Bug #1615
172+
]
173+
flags['LINKFLAGS']+=self.__linkFlags
163174
returnflags
164175

165176
defgetOptimizedFlags(self,conf):
166-
flags=super(GccBasicFlags,self).getOptimizedFlags(conf)
167-
flags['CXXFLAGS']+= ['-O2',
168-
'-g',
169-
'-Wall',
170-
'-Wextra',
171-
'-Wpedantic',
172-
'-Wcatch-value=2',
173-
'-Wextra-semi',
174-
'-Wnon-virtual-dtor',
175-
'-Wno-unused-parameter',
176-
]
177-
flags['LINKFLAGS']+= ['-Wl,-O1']
177+
flags=super().getOptimizedFlags(conf)
178+
flags['CXXFLAGS']+= ['-O2','-g1']+self.__cxxFlags
179+
flags['LINKFLAGS']+=self.__linkFlags
178180
returnflags
179181

180-
classGccFlags(GccBasicFlags):
182+
183+
classGccFlags(GccClangCommonFlags):
184+
__cxxFlags= [
185+
'-Wcatch-value=2',
186+
'-Wcomma-subscript',# enabled by default in C++20
187+
'-Wduplicated-branches',
188+
'-Wduplicated-cond',
189+
'-Wlogical-op',
190+
'-Wredundant-tags',
191+
'-Wvolatile',# enabled by default in C++20
192+
]
193+
181194
defgetDebugFlags(self,conf):
182-
flags=super(GccFlags,self).getDebugFlags(conf)
183-
flags['CXXFLAGS']+= ['-fdiagnostics-color',
184-
'-Wredundant-tags',
185-
]
195+
flags=super().getDebugFlags(conf)
196+
flags['CXXFLAGS']+=self.__cxxFlags
186197
ifplatform.machine()=='armv7l':
187198
flags['CXXFLAGS']+= ['-Wno-psabi']# Bug #5106
188199
returnflags
189200

190201
defgetOptimizedFlags(self,conf):
191-
flags=super(GccFlags,self).getOptimizedFlags(conf)
192-
flags['CXXFLAGS']+= ['-fdiagnostics-color',
193-
'-Wredundant-tags',
194-
]
202+
flags=super().getOptimizedFlags(conf)
203+
flags['CXXFLAGS']+=self.__cxxFlags
195204
ifplatform.machine()=='armv7l':
196205
flags['CXXFLAGS']+= ['-Wno-psabi']# Bug #5106
197206
returnflags
198207

199-
classClangFlags(GccBasicFlags):
208+
209+
classClangFlags(GccClangCommonFlags):
200210
defgetGeneralFlags(self,conf):
201-
flags=super(ClangFlags,self).getGeneralFlags(conf)
211+
flags=super().getGeneralFlags(conf)
202212
ifUtils.unversioned_sys_platform()=='darwin':
203213
# Bug #4296
204214
brewdir='/opt/homebrew'ifplatform.machine()=='arm64'else'/usr/local'
205-
flags['CXXFLAGS']+= [['-isystem',f'{brewdir}/include'],# for Homebrew
206-
['-isystem','/opt/local/include']]# for MacPorts
215+
flags['CXXFLAGS']+= [
216+
['-isystem',f'{brewdir}/include'],# for Homebrew
217+
['-isystem','/opt/local/include'],# for MacPorts
218+
]
207219
elifUtils.unversioned_sys_platform()=='freebsd':
208220
# Bug #4790
209221
flags['CXXFLAGS']+= [['-isystem','/usr/local/include']]
210222
returnflags
211223

224+
__cxxFlags= [
225+
'-Wundefined-func-template',
226+
'-Wno-unused-local-typedef',# Bugs #2657 and #3209
227+
]
228+
212229
defgetDebugFlags(self,conf):
213-
flags=super(ClangFlags,self).getDebugFlags(conf)
214-
flags['CXXFLAGS']+= ['-fcolor-diagnostics',
215-
'-Wundefined-func-template',
216-
'-Wno-unused-local-typedef',# Bugs #2657 and #3209
217-
]
230+
flags=super().getDebugFlags(conf)
231+
flags['CXXFLAGS']+=self.__cxxFlags
218232
returnflags
219233

220234
defgetOptimizedFlags(self,conf):
221-
flags=super(ClangFlags,self).getOptimizedFlags(conf)
222-
flags['CXXFLAGS']+= ['-fcolor-diagnostics',
223-
'-Wundefined-func-template',
224-
'-Wno-unused-local-typedef',# Bugs #2657 and #3209
225-
]
235+
flags=super().getOptimizedFlags(conf)
236+
flags['CXXFLAGS']+=self.__cxxFlags
226237
returnflags

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp