From ba8835fb54cac3225778347324e0d270c18983c9 Mon Sep 17 00:00:00 2001 From: Thomas Desveaux Date: Mon, 9 Apr 2018 16:57:11 +0200 Subject: [PATCH 1/8] Add UnsignedChar API + implement for gcc --- src/_premake_init.lua | 6 ++++++ src/tools/gcc.lua | 4 ++++ tests/tools/test_gcc.lua | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index bcb445ed..5c395739 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -1336,6 +1336,12 @@ } } + api.register { + name = "unsignedchar", + scope = "config", + kind = "boolean", + } + ----------------------------------------------------------------------------- -- -- Field name aliases for backward compatibility diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index aa89bd4c..9fc65fd6 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -96,6 +96,10 @@ }, symbols = { On = "-g" + }, + unsignedchar = { + On = "-funsigned-char", + Off = "-fno-unsigned-char" } } diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index 4dfccfba..52c0adb1 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -788,3 +788,23 @@ test.contains({ "-std=gnu++17" }, gcc.getcxxflags(cfg)) test.contains({ }, gcc.getcflags(cfg)) end + +-- +-- Test unsigned-char flags. +-- + + function suite.sharedflags_onUnsignedChar() + unsignedchar "On" + + prepare() + test.contains({ "-funsigned-char" }, gcc.getcxxflags(cfg)) + test.contains({ "-funsigned-char" }, gcc.getcflags(cfg)) + end + + function suite.sharedflags_onNoUnsignedChar() + unsignedchar "Off" + + prepare() + test.contains({ "-fno-unsigned-char" }, gcc.getcxxflags(cfg)) + test.contains({ "-fno-unsigned-char" }, gcc.getcflags(cfg)) + end From ed2b419128fd6027793f2a797f51b2cfce16faca Mon Sep 17 00:00:00 2001 From: Thomas Desveaux Date: Mon, 9 Apr 2018 17:20:38 +0200 Subject: [PATCH 2/8] Add debuggerflavor API + implement for vstudio --- modules/vstudio/_preload.lua | 13 +++++++++++++ .../tests/vc2010/test_debug_settings.lua | 19 +++++++++++++++++++ modules/vstudio/vs2010_vcxproj_user.lua | 4 +++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index 28301f5b..58c2ab2d 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -21,6 +21,19 @@ include("vs2015.lua") include("vs2017.lua") + + p.api.register { + name = "debuggerflavor", + scope = "config", + kind = "string", + allowed = { + "WindowsLocalDebugger", + "WindowsRemoteDebugger", + "WebBrowserDebugger", + "WebServiceDebugger" + } + } + -- -- Decide when the full module should be loaded. -- diff --git a/modules/vstudio/tests/vc2010/test_debug_settings.lua b/modules/vstudio/tests/vc2010/test_debug_settings.lua index ff384ab1..c071d625 100644 --- a/modules/vstudio/tests/vc2010/test_debug_settings.lua +++ b/modules/vstudio/tests/vc2010/test_debug_settings.lua @@ -101,3 +101,22 @@ foo=bar ]] end +-- +-- Test Debugger Flavor +-- + + function suite.debuggerFlavor_OnWindowsLocal() + debuggerflavor "WindowsLocalDebugger" + prepare() + test.capture [[ +WindowsLocalDebugger + ]] + end + + function suite.debuggerFlavor_OnWindowsRemote() + debuggerflavor "WindowsRemoteDebugger" + prepare() + test.capture [[ +WindowsRemoteDebugger + ]] + end diff --git a/modules/vstudio/vs2010_vcxproj_user.lua b/modules/vstudio/vs2010_vcxproj_user.lua index abea34f1..dce6769f 100644 --- a/modules/vstudio/vs2010_vcxproj_user.lua +++ b/modules/vstudio/vs2010_vcxproj_user.lua @@ -79,7 +79,9 @@ function m.debuggerFlavor(cfg) - if cfg.debugdir or cfg.debugcommand then + if cfg.debuggerflavor then + p.w('%s', cfg.debuggerflavor) + elseif cfg.debugdir or cfg.debugcommand then p.w('WindowsLocalDebugger') end end From 92f0f086488135778c67a6d963bdd4db06acef37 Mon Sep 17 00:00:00 2001 From: Thomas Desveaux Date: Tue, 10 Apr 2018 20:00:41 +0200 Subject: [PATCH 3/8] debuggerflavor: use simpler terms in api --- modules/vstudio/_preload.lua | 8 ++++---- modules/vstudio/tests/vc2010/test_debug_settings.lua | 4 ++-- modules/vstudio/vs2010_vcxproj_user.lua | 12 ++++++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index 27d2d947..6d40c30d 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -121,10 +121,10 @@ scope = "config", kind = "string", allowed = { - "WindowsLocalDebugger", - "WindowsRemoteDebugger", - "WebBrowserDebugger", - "WebServiceDebugger" + "Local", + "Remote", + "WebBrowser", + "WebService" } } diff --git a/modules/vstudio/tests/vc2010/test_debug_settings.lua b/modules/vstudio/tests/vc2010/test_debug_settings.lua index c071d625..8a41f202 100644 --- a/modules/vstudio/tests/vc2010/test_debug_settings.lua +++ b/modules/vstudio/tests/vc2010/test_debug_settings.lua @@ -106,7 +106,7 @@ foo=bar -- function suite.debuggerFlavor_OnWindowsLocal() - debuggerflavor "WindowsLocalDebugger" + debuggerflavor "Local" prepare() test.capture [[ WindowsLocalDebugger @@ -114,7 +114,7 @@ foo=bar end function suite.debuggerFlavor_OnWindowsRemote() - debuggerflavor "WindowsRemoteDebugger" + debuggerflavor "Remote" prepare() test.capture [[ WindowsRemoteDebugger diff --git a/modules/vstudio/vs2010_vcxproj_user.lua b/modules/vstudio/vs2010_vcxproj_user.lua index dce6769f..6f5c8808 100644 --- a/modules/vstudio/vs2010_vcxproj_user.lua +++ b/modules/vstudio/vs2010_vcxproj_user.lua @@ -79,8 +79,16 @@ function m.debuggerFlavor(cfg) - if cfg.debuggerflavor then - p.w('%s', cfg.debuggerflavor) + local map = { + Local = "WindowsLocalDebugger", + Remote = "WindowsRemoteDebugger", + WebBrowser = "WebBrowserDebugger", + WebService = "WebServiceDebugger" + } + + local value = map[cfg.debuggerflavor] + if value then + p.w('%s', value) elseif cfg.debugdir or cfg.debugcommand then p.w('WindowsLocalDebugger') end From 40f258b2d1c836faabb5341f66eaed1fd84b7cb0 Mon Sep 17 00:00:00 2001 From: Thomas Desveaux Date: Tue, 10 Apr 2018 20:14:22 +0200 Subject: [PATCH 4/8] Implement unsignedchar for clang --- src/tools/clang.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/clang.lua b/src/tools/clang.lua index 4afa4349..66144b6a 100644 --- a/src/tools/clang.lua +++ b/src/tools/clang.lua @@ -61,7 +61,8 @@ vectorextensions = gcc.shared.vectorextensions, isaextensions = gcc.shared.isaextensions, warnings = gcc.shared.warnings, - symbols = gcc.shared.symbols + symbols = gcc.shared.symbols, + unsignedchar = gcc.shared.unsignedchar } clang.cflags = table.merge(gcc.cflags, { From d556b6510f791fbc5bffdecd85c91c35cde6b156 Mon Sep 17 00:00:00 2001 From: Thomas Desveaux Date: Tue, 10 Apr 2018 20:24:05 +0200 Subject: [PATCH 5/8] Implement unsignedchar for msc --- src/tools/msc.lua | 4 ++++ tests/tools/test_msc.lua | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/tools/msc.lua b/src/tools/msc.lua index 7cadab5d..8040bbde 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -99,7 +99,11 @@ }, symbols = { On = "/Z7" + }, + unsignedchar = { + On = "/J", } + } msc.cflags = { diff --git a/tests/tools/test_msc.lua b/tests/tools/test_msc.lua index 2219ce96..fecd4e03 100644 --- a/tests/tools/test_msc.lua +++ b/tests/tools/test_msc.lua @@ -160,6 +160,25 @@ end +-- +-- Check the translation of unsignedchar. +-- + + function suite.sharedflags_onUnsignedCharOn() + unsignedchar "On" + prepare() + test.contains({ "/J" }, msc.getcflags(cfg)) + test.contains({ "/J" }, msc.getcxxflags(cfg)) + end + + function suite.sharedflags_onUnsignedCharOff() + unsignedchar "Off" + prepare() + test.excludes({ "/J" }, msc.getcflags(cfg)) + test.excludes({ "/J" }, msc.getcxxflags(cfg)) + end + + -- -- Check handling of debugging support. -- From 159281ea5af663a86388b6877d5c7c05ccace9ee Mon Sep 17 00:00:00 2001 From: Thomas Desveaux Date: Tue, 10 Apr 2018 21:38:31 +0200 Subject: [PATCH 6/8] Implement unsignedchar for vstudio --- .../tests/vc2010/test_compile_settings.lua | 29 +++++++++++++++++++ modules/vstudio/vs2010_vcxproj.lua | 6 ++++ 2 files changed, 35 insertions(+) diff --git a/modules/vstudio/tests/vc2010/test_compile_settings.lua b/modules/vstudio/tests/vc2010/test_compile_settings.lua index bbffd42c..86777f25 100644 --- a/modules/vstudio/tests/vc2010/test_compile_settings.lua +++ b/modules/vstudio/tests/vc2010/test_compile_settings.lua @@ -1238,3 +1238,32 @@ ]] end + +-- +-- Check UnsignedChar. +-- + + function suite.unsignedChar_On() + unsignedchar "On" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + /J %(AdditionalOptions) + + ]] + end + + function suite.unsignedChar_Off() + unsignedchar "Off" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 6909fac8..703e292f 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -1355,6 +1355,12 @@ table.insert(opts, "/std:c++latest") end end + + if cfg.toolset and cfg.toolset:startswith("msc") then + local value = iif(cfg.unsignedchar, "On", "Off") + table.insert(opts, p.tools.msc.shared.unsignedchar[value]) + end + if #opts > 0 then opts = table.concat(opts, " ") m.element("AdditionalOptions", condition, '%s %%(AdditionalOptions)', opts) From 6ad87a76c14f0994d56a5e305e3b05c95482f1bf Mon Sep 17 00:00:00 2001 From: Thomas Desveaux Date: Tue, 10 Apr 2018 21:54:51 +0200 Subject: [PATCH 7/8] Implement unsignedchar for xcode --- modules/xcode/tests/test_xcode_project.lua | 52 ++++++++++++++++++++++ modules/xcode/xcode_common.lua | 4 ++ 2 files changed, 56 insertions(+) diff --git a/modules/xcode/tests/test_xcode_project.lua b/modules/xcode/tests/test_xcode_project.lua index 4daad4ac..51c245e5 100644 --- a/modules/xcode/tests/test_xcode_project.lua +++ b/modules/xcode/tests/test_xcode_project.lua @@ -2486,6 +2486,58 @@ ]] end + function suite.XCBuildConfigurationProject_OnUnsignedCharOn() + workspace("MyWorkspace") + unsignedchar "On" + prepare() + xcode.XCBuildConfiguration_Project(tr, tr.configs[1]) + test.capture [[ + [MyProject:Debug(2)] /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; + CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; + GCC_CHAR_IS_UNSIGNED_CHAR = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = obj/Debug; + ONLY_ACTIVE_ARCH = NO; + SYMROOT = bin/Debug; + }; + name = Debug; + }; + ]] + end + + function suite.XCBuildConfigurationProject_OnUnsignedCharOff() + workspace("MyWorkspace") + unsignedchar "Off" + prepare() + xcode.XCBuildConfiguration_Project(tr, tr.configs[1]) + test.capture [[ + [MyProject:Debug(2)] /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; + CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; + GCC_CHAR_IS_UNSIGNED_CHAR = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = obj/Debug; + ONLY_ACTIVE_ARCH = NO; + SYMROOT = bin/Debug; + }; + name = Debug; + }; + ]] + end + --------------------------------------------------------------------------- -- XCBuildConfigurationList tests --------------------------------------------------------------------------- diff --git a/modules/xcode/xcode_common.lua b/modules/xcode/xcode_common.lua index 57cb394f..1fe58ba9 100644 --- a/modules/xcode/xcode_common.lua +++ b/modules/xcode/xcode_common.lua @@ -1100,6 +1100,10 @@ settings["GCC_SYMBOLS_PRIVATE_EXTERN"] = 'NO' + if cfg.unsignedchar ~= nil then + settings['GCC_CHAR_IS_UNSIGNED_CHAR'] = iif(cfg.unsignedchar, "YES", "NO") + end + if cfg.flags.FatalWarnings then settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES' end From 228bba970246c923502e981ae1e0682a90a74605 Mon Sep 17 00:00:00 2001 From: Thomas Desveaux Date: Tue, 10 Apr 2018 22:03:12 +0200 Subject: [PATCH 8/8] Implement unsignedchar tests for CodeLite --- .../codelite/tests/test_codelite_config.lua | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/modules/codelite/tests/test_codelite_config.lua b/modules/codelite/tests/test_codelite_config.lua index b00500d7..3e0454db 100644 --- a/modules/codelite/tests/test_codelite_config.lua +++ b/modules/codelite/tests/test_codelite_config.lua @@ -234,3 +234,29 @@ cmd2 ]] end + + +--------------------------------------------------------------------------- +-- Setup/Teardown +--------------------------------------------------------------------------- + + function suite.OnProjectCfg_UnsignedCharOn() + unsignedchar "On" + prepare() + codelite.project.compiler(cfg) + test.capture [[ + + + ]] + end + + + function suite.OnProjectCfg_UnsignedCharOff() + unsignedchar "Off" + prepare() + codelite.project.compiler(cfg) + test.capture [[ + + + ]] + end