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 diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index 99f91619..6d40c30d 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -116,6 +116,17 @@ tokens = true, } + p.api.register { + name = "debuggerflavor", + scope = "config", + kind = "string", + allowed = { + "Local", + "Remote", + "WebBrowser", + "WebService" + } + } -- -- Decide when the full module should be loaded. diff --git a/modules/vstudio/tests/vc2010/test_compile_settings.lua b/modules/vstudio/tests/vc2010/test_compile_settings.lua index bbffd42c..c7ab4de3 100644 --- a/modules/vstudio/tests/vc2010/test_compile_settings.lua +++ b/modules/vstudio/tests/vc2010/test_compile_settings.lua @@ -1238,3 +1238,49 @@ ]] 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 + +-- +-- Check StructMemberAlignment +-- + + function suite.structMemberAlignment() + structmemberalign(1) + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + 1Byte + + ]] + end diff --git a/modules/vstudio/tests/vc2010/test_debug_settings.lua b/modules/vstudio/tests/vc2010/test_debug_settings.lua index ff384ab1..8a41f202 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 "Local" + prepare() + test.capture [[ +WindowsLocalDebugger + ]] + end + + function suite.debuggerFlavor_OnWindowsRemote() + debuggerflavor "Remote" + prepare() + test.capture [[ +WindowsRemoteDebugger + ]] + end diff --git a/modules/vstudio/vs2010_rules_targets.lua b/modules/vstudio/vs2010_rules_targets.lua index 72a3074f..6079bd5c 100644 --- a/modules/vstudio/vs2010_rules_targets.lua +++ b/modules/vstudio/vs2010_rules_targets.lua @@ -458,7 +458,7 @@ p.w('', r.name, extra, r.name) end @@ -467,7 +467,7 @@ function m.tlogWrite(r) p.w('', r.name, r.name) end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 68ddde0d..a0ea25c4 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -376,6 +376,7 @@ m.compileAs, m.callingConvention, m.languageStandard, + m.structMemberAlignment, } if cfg.kind == p.STATICLIB then @@ -1373,6 +1374,20 @@ end end + function m.structMemberAlignment(cfg) + local map = { + [1] = "1Byte", + [2] = "2Bytes", + [4] = "4Bytes", + [8] = "8Bytes", + [16] = "16Bytes" + } + + local value = map[cfg.structmemberalign] + if value then + m.element("StructMemberAlignment", nil, value) + end + end function m.additionalCompileOptions(cfg, condition) local opts = cfg.buildoptions @@ -1383,6 +1398,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) diff --git a/modules/vstudio/vs2010_vcxproj_user.lua b/modules/vstudio/vs2010_vcxproj_user.lua index abea34f1..6f5c8808 100644 --- a/modules/vstudio/vs2010_vcxproj_user.lua +++ b/modules/vstudio/vs2010_vcxproj_user.lua @@ -79,7 +79,17 @@ function m.debuggerFlavor(cfg) - if cfg.debugdir or cfg.debugcommand then + 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 end 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 diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 1fe06c91..fbee9cb0 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -1336,6 +1336,25 @@ } } + api.register { + name = "unsignedchar", + scope = "config", + kind = "boolean", + } + + p.api.register { + name = "structmemberalign", + scope = "config", + kind = "integer", + allowed = { + "1", + "2", + "4", + "8", + "16", + } + } + ----------------------------------------------------------------------------- -- -- Field name aliases for backward compatibility 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, { 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/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_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 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. --