MCPcopy Create free account
hub / github.com/celer-pkg/celer / setLanguageStandard

Method setLanguageStandard

buildsystems/buildconfig_envs.go:290–328  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

288}
289
290func (b *BuildConfig) setLanguageStandard() {
291 toolchain := b.Ctx.Platform().GetToolchain()
292
293 // Set C standard.
294 cstandard := expr.If(b.CStandard != "", b.CStandard, toolchain.GetCStandard())
295 if cstandard != "" {
296 var cflag string
297 switch toolchain.GetName() {
298 case "gcc", "clang":
299 cflag = "-std=" + cstandard
300
301 case "msvc", "clang-cl":
302 cflag = "/std:" + cstandard
303
304 default:
305 panic("unsupported toolchain: " + toolchain.GetName())
306 }
307
308 b.envBackup.setenv("CFLAGS", env.JoinSpace(cflag, os.Getenv("CFLAGS")))
309 }
310
311 // Set C++ standard.
312 cxxstandard := expr.If(b.CXXStandard != "", b.CXXStandard, toolchain.GetCXXStandard())
313 if cxxstandard != "" {
314 var cxxflag string
315 switch toolchain.GetName() {
316 case "gcc", "clang":
317 cxxflag = "-std=" + cxxstandard
318
319 case "msvc", "clang-cl":
320 cxxflag = "/std:" + cxxstandard
321
322 default:
323 panic("unsupported toolchain: " + toolchain.GetName())
324 }
325
326 b.envBackup.setenv("CXXFLAGS", env.JoinSpace(cxxflag, os.Getenv("CXXFLAGS")))
327 }
328}
329
330func (b *BuildConfig) setEnvFlags() {
331 rootfs := b.Ctx.Platform().GetRootFS()

Callers 1

setupEnvsMethod · 0.95

Calls 8

IfFunction · 0.92
JoinSpaceFunction · 0.92
setenvMethod · 0.80
GetToolchainMethod · 0.65
PlatformMethod · 0.65
GetCStandardMethod · 0.65
GetNameMethod · 0.65
GetCXXStandardMethod · 0.65

Tested by

no test coverage detected