Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'Default', 'Dwarf' and 'SplitDwarf' arguments to 'debugformat' #1067

Merged
merged 2 commits into from
Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add 'Default', 'Dwarf' and 'SplitDwarf' inputs to 'debugformat'
  • Loading branch information
ratzlaff committed Nov 18, 2018
commit da90c1ffd02baf507b8db90a7a2285b6b909f260
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 @@ -1209,6 +1209,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 @@ -294,6 +294,27 @@
return types[iif(node.cfg.kind == "SharedLib" and node.cfg.sharedlibtype, node.cfg.sharedlibtype, 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 @@ -1111,7 +1132,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 @@ -255,7 +255,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 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does -gc7 mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a supported feature that we return a table from this function?
I thought this function was just meant to return the options string (the value part)...?

Assuming this works, it should also support FastLink and Full values for symbols. Docs allege that if they are undefined for a platform, they are a synonym for On.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning a table from this function is to preserve as much of the existing behavior prior to this change as possible.

The test for 'function' type and executing the function here is what triggers this logic to take place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I see what you mean about FastLink and Full. Will add those in when I get home later.

end,
unsignedchar = {
On = "-funsigned-char",
Off = "-fno-unsigned-char"
Expand Down