Skip to content

Commit

Permalink
Add 'Default', 'Dwarf' and 'SplitDwarf' inputs to 'debugformat'
Browse files Browse the repository at this point in the history
  • Loading branch information
ratzlaff committed May 7, 2018
1 parent 7c0fa10 commit 95d1c02
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 4 deletions.
71 changes: 71 additions & 0 deletions modules/gmake/tests/cpp/test_flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,74 @@
INCLUDES += -Isrc/include -I../include
]]
end


--
-- symbols "on" should produce -g
--
function suite.symbols_on()
symbols "on"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
]]
end

--
-- symbols "off" should not produce -g
--
function suite.symbols_off()
symbols "off"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS)
]]
end

--
-- symbols "on" with a proper debugformat should produce a corresponding -g
--
function suite.symbols_on_default()
symbols "on"
debugformat "Default"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
]]
end

function suite.symbols_on_dwarf()
symbols "on"
debugformat "Dwarf"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gdwarf
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gdwarf
]]
end

function suite.symbols_on_split_dwarf()
symbols "on"
debugformat "SplitDwarf"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf
]]
end

--
-- symbols "off" with a proper debugformat should not produce -g
--
function suite.symbols_off_dwarf()
symbols "off"
debugformat "Dwarf"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS)
]]
end
70 changes: 70 additions & 0 deletions modules/gmake2/tests/test_gmake2_flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,73 @@
INCLUDES += -Isrc/include -I../include
]]
end

--
-- symbols "on" should produce -g
--
function suite.symbols_on()
symbols "on"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
]]
end

--
-- symbols "off" should not produce -g
--
function suite.symbols_off()
symbols "off"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS)
]]
end

--
-- symbols "on" with a proper debugformat should produce a corresponding -g
--
function suite.symbols_on_default()
symbols "on"
debugformat "Default"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
]]
end

function suite.symbols_on_dwarf()
symbols "on"
debugformat "Dwarf"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gdwarf
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gdwarf
]]
end

function suite.symbols_on_split_dwarf()
symbols "on"
debugformat "SplitDwarf"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf
]]
end

--
-- symbols "off" with a proper debugformat should not produce -g
--
function suite.symbols_off_dwarf()
symbols "off"
debugformat "Dwarf"
prepare { "cFlags", "cxxFlags" }
test.capture [[
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS)
]]
end
63 changes: 63 additions & 0 deletions modules/xcode/tests/test_xcode_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,69 @@
end


function suite.XCBuildConfigurationTarget_OnConsoleApp_dwarf()
debugformat "Dwarf"
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[MyProject:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = bin/Debug;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_DYNAMIC_NO_PIC = NO;
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = MyProject;
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnConsoleApp_split_dwarf()
debugformat "SplitDwarf"
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[MyProject:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = bin/Debug;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_DYNAMIC_NO_PIC = NO;
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = MyProject;
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnConsoleApp_default()
debugformat "Default"
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[MyProject:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = bin/Debug;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_DYNAMIC_NO_PIC = NO;
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = MyProject;
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnWindowedApp()
kind "WindowedApp"
prepare()
Expand Down
23 changes: 22 additions & 1 deletion modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,27 @@
return types[node.cfg.kind]
end

--
-- Return the Xcode debug information format for the current configuration
--
-- @param cfg
-- The current configuration
-- @returns
-- The corresponding value of DEBUG_INFORMATION_FORMAT, or 'dwarf-with-dsym' if invalid
--

function xcode.getdebugformat(cfg)
local formats = {
["Dwarf"] = "dwarf",
["Default"] = "dwarf-with-dsym",
["SplitDwarf"] = "dwarf-with-dsym",
}
local rval = "dwarf-with-dsym"
if cfg.debugformat then
rval = formats[cfg.debugformat] or rval
end
return rval
end

--
-- Return a unique file name for a project. Since Xcode uses .xcodeproj's to
Expand Down Expand Up @@ -886,7 +907,7 @@
settings['ALWAYS_SEARCH_USER_PATHS'] = 'NO'

if cfg.symbols ~= p.OFF then
settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
settings['DEBUG_INFORMATION_FORMAT'] = xcode.getdebugformat(cfg)
end

if cfg.kind ~= "StaticLib" and cfg.buildtarget.prefix ~= '' then
Expand Down
3 changes: 3 additions & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@
scope = "config",
kind = "string",
allowed = {
"Default",
"c7",
"Dwarf",
"SplitDwarf",
},
}

Expand Down
3 changes: 3 additions & 0 deletions src/base/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@

for field in p.field.eachOrdered() do
local map = mappings[field.name]
if type(map) == "function" then
map = map(cfg, mappings)
end
if map then

-- Pass each cfg value in the list through the map and append the
Expand Down
20 changes: 17 additions & 3 deletions src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@
end


--
-- Returns string to be appended to -g
--
function gcc.getdebugformat(cfg)
local flags = {
Default = "",
Dwarf = "dwarf",
SplitDwarf = "split-dwarf",
}
return flags
end

--
-- Returns list of C compiler flags for a configuration.
--
Expand Down Expand Up @@ -93,9 +105,11 @@
High = "-Wall",
Off = "-w",
},
symbols = {
On = "-g"
},
symbols = function(cfg, mappings)
local values = gcc.getdebugformat(cfg)
local debugformat = values[cfg.debugformat] or ""
return { On = "-g" .. debugformat }
end,
unsignedchar = {
On = "-funsigned-char",
Off = "-fno-unsigned-char"
Expand Down

0 comments on commit 95d1c02

Please sign in to comment.