From 0731044ae7d3932317c2cd7a708943e64a1bb061 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Tue, 29 Nov 2016 11:29:32 -0500 Subject: [PATCH] Fix bugs introduced by shared compiler flags Fix a few spots where the shared compiler flag changes (PR #623) caused things to misbehave. - Fixed duplicate flags in VC 200x external compiler options - Added missing C and CXX flag maps to Clang adapter - Reworked SNC adapter to follow same shared flags approach --- src/actions/vstudio/vs200x_vcproj.lua | 2 +- src/tools/clang.lua | 27 +++++++------- src/tools/snc.lua | 53 +++++++++++++++------------ 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index 9f1f908d..e9821d60 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -822,7 +822,7 @@ function m.additionalExternalCompilerOptions(cfg, toolset) - local buildoptions = table.join(toolset.getcflags(cfg), toolset.getcxxflags(cfg), cfg.buildoptions) + local buildoptions = table.join(toolset.getcxxflags(cfg), cfg.buildoptions) if not cfg.flags.NoPCH and cfg.pchheader then table.insert(buildoptions, '--use_pch="$(IntDir)/$(TargetName).pch"') end diff --git a/src/tools/clang.lua b/src/tools/clang.lua index 25dd2b9f..282f7d28 100644 --- a/src/tools/clang.lua +++ b/src/tools/clang.lua @@ -60,22 +60,21 @@ symbols = gcc.shared.symbols } + clang.cflags = table.merge(gcc.cflags, { + }) + function clang.getcflags(cfg) - local shared_flags = config.mapFlags(cfg, clang.shared) + local shared = config.mapFlags(cfg, clang.shared) + local cflags = config.mapFlags(cfg, clang.cflags) - -- Just pass through to GCC for now - local cflags = config.mapFlags(cfg, gcc.cflags) - - local flags = table.join(shared_flags, cflags) + local flags = table.join(shared, cflags) flags = table.join(flags, clang.getwarnings(cfg)) + return flags end function clang.getwarnings(cfg) - - -- Just pass through to GCC for now return gcc.getwarnings(cfg) - end @@ -90,13 +89,13 @@ -- An array of C++ compiler flags. -- + clang.cxxflags = table.merge(gcc.cxxflags, { + }) + function clang.getcxxflags(cfg) - local shared_flags = config.mapFlags(cfg, clang.shared) - - -- Just pass through to GCC for now - local cxxflags = config.mapFlags(cfg, gcc.cxxflags) - - local flags = table.join(shared_flags, cxxflags) + local shared = config.mapFlags(cfg, clang.shared) + local cxxflags = config.mapFlags(cfg, clang.cxxflags) + local flags = table.join(shared, cxxflags) flags = table.join(flags, clang.getwarnings(cfg)) return flags end diff --git a/src/tools/snc.lua b/src/tools/snc.lua index 1cf7a010..b1c8787a 100644 --- a/src/tools/snc.lua +++ b/src/tools/snc.lua @@ -1,20 +1,21 @@ -- -- snc.lua -- Provides Sony SNC-specific configuration strings. --- Copyright (c) 2010-2012 Jason Perkins and the Premake project +-- Copyright (c) 2010-2016 Jason Perkins and the Premake project -- - premake.tools.snc = {} - local snc = premake.tools.snc - local gcc = premake.tools.gcc - local config = premake.config + local p = premake + + p.tools.snc = {} + local snc = p.tools.snc + local gcc = p.tools.gcc -- -- Retrieve the CFLAGS for a specific configuration. -- - snc.cflags = { + snc.shared = { flags = { FatalCompileWarnings = "-Xquit=2", }, @@ -31,8 +32,13 @@ } } + snc.cflags = { + } + function snc.getcflags(cfg) - local flags = config.mapFlags(cfg, snc.cflags) + local shared = p.config.mapFlags(cfg, snc.shared) + local cflags = p.config.mapFlags(cfg, snc.cflags) + local flags = table.join(shared, cflags, snc.getwarnings(cfg)) return flags end @@ -41,22 +47,23 @@ -- Retrieve the CXXFLAGS for a specific configuration. -- + snc.cxxflags = { + exceptionhandling = { + Default = "-Xc+=exceptions", + On = "-Xc+=exceptions", + SEH = "-Xc-=exceptions", + }, + rtti = { + Default = "-Xc+=rtti", + On = "-Xc+=rtti", + SEH = "-Xc-=rtti", + } + } + function snc.getcxxflags(cfg) - local flags = {} - - -- turn on exceptions and RTTI by default, to match other toolsets - if cfg.exceptionhandling == p.ON then - table.insert(flags, "-Xc+=exceptions") - elseif cfg.exceptionhandling == p.OFF then - table.insert(flags, "-Xc-=exceptions") - end - - if cfg.rtti == p.ON then - table.insert(flags, "-Xc+=rtti") - elseif cfg.rtti == p.OFF then - table.insert(flags, "-Xc-=rtti") - end - + local shared = config.mapFlags(cfg, snc.shared) + local cxxflags = config.mapFlags(cfg, snc.cxxflags) + local flags = table.join(shared, cxxflags, snc.getwarnings(cfg)) return flags end @@ -72,11 +79,9 @@ -- function snc.getforceincludes(cfg) - -- Just pass through to GCC for now local flags = gcc.getforceincludes(cfg) return flags - end