Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 26 additions & 0 deletions modules/vstudio/tests/vc2010/test_link.lua
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,32 @@
]]
end

function suite.generateMapFile_onMapFileAPI()
mapfile "On"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
<GenerateMapFile>true</GenerateMapFile>
</Link>
]]
end

function suite.generateMapFile_onMapFileWithPathAPI()
mapfile "On"
mapfilepath "bin/Debug/MyProject.map"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>bin\Debug\MyProject.map</MapFileName>
</Link>
]]
end

--
-- Test ignoring default libraries with extensions specified.
--
Expand Down
7 changes: 6 additions & 1 deletion modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2620,8 +2620,13 @@


function m.generateMapFile(cfg)
if cfg.flags.Maps then
if cfg.mapfile == p.ON then
m.element("GenerateMapFile", nil, "true")
if cfg.mapfilepath then
m.element("MapFileName", nil, vstudio.path(cfg, cfg.mapfilepath))
end
elseif cfg.mapfile == p.OFF then
m.element("GenerateMapFile", nil, "false")
end
end

Expand Down
25 changes: 25 additions & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,31 @@
kind = "string"
}

api.register {
name = "mapfile",
scope = "config",
kind = "string",
allowed = {
"Default",
"On",
"Off"
}
}

api.register {
name = "mapfilepath",
scope = "config",
kind = "string",
}

api.deprecateValue("flags", "Maps", "Use `mapfile` instead.",
function(value)
mapfile("On")
end,
function(value)
mapfile("Default")
end)


-----------------------------------------------------------------------------
--
Expand Down
1 change: 1 addition & 0 deletions src/tools/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
end,
},
linker = gcc.ldflags.linker,
mapfile = gcc.ldflags.mapfile,
profile = gcc.ldflags.profile,
sanitize = table.merge(gcc.ldflags.sanitize, {
Fuzzer = "-fsanitize=fuzzer",
Expand Down
8 changes: 8 additions & 0 deletions src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,14 @@
Default = "",
LLD = "-fuse-ld=lld"
},
mapfile = {
On = function(cfg)
-- If a map file path has been explicitly provided, use that
-- otherwise, just use the default link target path with a .map extension (no lib, exe, etc)
local path = cfg.mapfilepath or path.replaceextension(cfg.linktarget.relpath, ".map")
return "-Wl,-Map=" .. p.quoted(p.tools.getrelative(cfg.project, path))
end,
},
profile = {
On = "-pg",
},
Expand Down
4 changes: 2 additions & 2 deletions tests/base/test_configset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@
function suite.remove_onMultipleValues()
local f = field.get("flags")

local r, err = configset.store(cset, f, { "Maps", "WPF", "MultiProcessorCompile", "NoPCH" })
local r, err = configset.store(cset, f, { "WPF", "MultiProcessorCompile", "NoPCH" })
test.isnil(err)

configset.remove(cset, f, { "Maps", "WPF" })
configset.remove(cset, f, { "WPF" })

local result = configset.fetch(cset, f)
test.isequal({ "MultiProcessorCompile", "NoPCH" }, result)
Expand Down
17 changes: 17 additions & 0 deletions tests/tools/test_gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,23 @@ end
end


--
-- Check the handling of map file generation.
--

function suite.ldflags_onMapFileViaAPI()
mapfile "On"
prepare()
test.contains({ "-Wl,-Map=bin/Debug/MyProject.map" }, gcc.getldflags(cfg))
end

function suite.ldflags_onMapFileViaAPI_WithPath()
mapfile "On"
mapfilepath "maps/MyProject.map"
prepare()
test.contains({ '-Wl,-Map=maps/MyProject.map' }, gcc.getldflags(cfg))
end

--
-- Check link mode preference for system libraries.
--
Expand Down
4 changes: 2 additions & 2 deletions website/docs/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ flags { "flag_list" }
| FatalLinkWarnings | Treat linker warnings as errors. Deprecated in Premake 5.0.0-beta4. Use `fatalwarnings` API instead. | Removed in Premake 5.0.0-beta8 |
| FatalWarnings | Treat all warnings as errors; equivalent to FatalCompileWarnings, FatalLinkWarnings. Deprecated in Premake 5.0.0-beta4. Use `fatalwarnings` API instead. | Removed in Premake 5.0.0-beta8 |
| LinkTimeOptimization | Enable link-time (i.e. whole program) optimizations. Deprecated in Premake 5.0.0-beta4. Use `linktimeoptimization` API instead. | Removed in Premake 5.0.0-beta8 |
| Maps | Enable Generate Map File for Visual Studio |
| Maps | Enable Generate Map File for Visual Studio. Deprecated in Premake 5.0.0-beta8. Use `mapfile` API instead. | |
| MFC | Enable support for Microsoft Foundation Classes. Deprecated in Premake 5.0.0-beta4. Use `mfc` API instead. | Removed in Premake 5.0.0-beta8 |
| MultiProcessorCompile | Enable Visual Studio to use multiple compiler processes when building. |
| No64BitChecks | Disable 64-bit portability warnings. |
Expand Down Expand Up @@ -60,4 +60,4 @@ flags { "LinkTimeOptimization" }
* [fatalwarnings](fatalwarnings.md)
* [linktimeoptimization](linktimeoptimization.md)
* [mfc](mfc.md)

* [mapfile](mapfile.md)
27 changes: 27 additions & 0 deletions website/docs/mapfile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Specifies whether or not to generate a mapfile.

```lua
mapfile "On"
```

### Parameters ###

*value* specifies the desired MAP generation mode:

| Value | Description |
|-------------|-------------------------------------------|
| Default | Perform the default mapfile generation. |
| Off | Do not generate a mapfile for the target. |
| On | Generate a mapfile for the target. |

### Applies To ###

Project configurations.

### Availability ###

Premake 5.0-beta8 or later on Visual Studio.

### See Also ###

* [mapfilepath](mapfilepath.md)
24 changes: 24 additions & 0 deletions website/docs/mapfilepath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Specifies the path to generate a mapfile at.

```lua
mapfilepath "dir/to/file.map"
```

If `mapfile` is not `"On"`, then no mapfile will be generated. If `mapfile` is `"On"` but this value is not set, this will generate a mapfile at a default location,
as determined by either the toolset or exporter.

### Parameters ###

*value* specifies the desired mapfile path

### Applies To ###

Project configurations.

### Availability ###

Premake 5.0-beta8 or later on Visual Studio.

### See Also ###

* [mapfile](mapfile.md)
2 changes: 2 additions & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ module.exports = {
'llvmdir',
'llvmversion',
'makesettings',
'mapfile',
'mapfilepath',
'mfc',
'namespace',
'nativewchar',
Expand Down
Loading