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
2 changes: 1 addition & 1 deletion modules/gmake/gmake_cpp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@
local fcfg = fileconfig.getconfig(file, cfg)
local flags = {}

if cfg.pchheader and not cfg.flags.NoPCH and (not fcfg or not fcfg.flags.NoPCH) then
if cfg.pchheader and cfg.enablepch ~= p.OFF and (not fcfg or fcfg.enablepch ~= p.OFF) then
table.insert(flags, "-include $(PCH_PLACEHOLDER)")
end

Expand Down
2 changes: 1 addition & 1 deletion modules/gmakelegacy/gmakelegacy_cpp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ end

function make.forceInclude(cfg, toolset)
local includes = toolset.getforceincludes(cfg)
if not cfg.flags.NoPCH and cfg.pchheader then
if cfg.enablepch ~= p.OFF and cfg.pchheader then
table.insert(includes, 1, "-include $(OBJDIR)/$(notdir $(PCH))")
end
_x(' FORCE_INCLUDE +=%s', make.list(includes))
Expand Down
6 changes: 3 additions & 3 deletions modules/ninja/ninja_cpp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ function m.getLdFlags(cfg, toolset)
end

function m.getPchPath(cfg)
if not cfg.pchheader or cfg.flags.NoPCH then
if not cfg.pchheader or cfg.enablepch == p.OFF then
return nil
end

Expand All @@ -552,7 +552,7 @@ function m.getPchPath(cfg)
end

function m.buildPch(cfg)
if not cfg.pchheader or cfg.flags.NoPCH then
if not cfg.pchheader or cfg.enablepch == p.OFF then
return nil
end

Expand Down Expand Up @@ -806,7 +806,7 @@ function m.buildFile(cfg, node, filecfg, objFile, pchFile, prebuildTarget)
local relPath = path.getrelative(cfg.workspace.location, node.abspath)
local implicitDeps = ""

local usePch = cfg.pchheader and not cfg.flags.NoPCH and (not filecfg or not filecfg.flags.NoPCH)
local usePch = cfg.pchheader and cfg.enablepch ~= p.OFF and (not filecfg or filecfg.enablepch ~= p.OFF)
if pchFile and usePch then
implicitDeps = implicitDeps .. " | " .. pchFile
end
Expand Down
6 changes: 3 additions & 3 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4416,8 +4416,8 @@
end

function m.androidShortEnums(cfg)
if cfg.flags.UseShortEnums ~= nil then
m.element(UseShortEnums, nil, "true")
if cfg.useshortenums then
m.element("UseShortEnums", nil, iif(cfg.useshortenums == "On", "true", "false"))
end
end

Expand Down Expand Up @@ -4450,7 +4450,7 @@
end

function m.androidGenerateMapFile(cfg)
if cfg.flags.Maps then
if cfg.mapfile == p.ON then
-- Android specifies a name. Other platforms use the project name
-- so we do the same thing here
m.element("GenerateMapFile", nil, cfg.project.name..".map")
Expand Down
2 changes: 1 addition & 1 deletion modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@
local optimizeMap = { On = 3, Size = 's', Speed = 3, Full = 'fast', Debug = 'g' }
settings['GCC_OPTIMIZATION_LEVEL'] = optimizeMap[cfg.optimize] or 0

if cfg.pchheader and not cfg.flags.NoPCH then
if cfg.pchheader and cfg.enablepch ~= p.OFF then
settings['GCC_PRECOMPILE_PREFIX_HEADER'] = 'YES'
settings['GCC_PREFIX_HEADER'] = cfg.pchheader
end
Expand Down
8 changes: 4 additions & 4 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,16 @@
symbols "On"

filter "configurations:Release"
defines "NDEBUG"
optimize "Full"
flags { "NoRuntimeChecks" }
defines "NDEBUG"
optimize "Full"
runtimechecks "Off"
buffersecuritycheck "Off"

filter "action:vs*"
defines { "_CRT_SECURE_NO_DEPRECATE", "_CRT_SECURE_NO_WARNINGS", "_CRT_NONSTDC_NO_WARNINGS" }

filter { "system:windows", "configurations:Release" }
flags { "NoIncrementalLink" }
incrementallink "Off"

-- MinGW AR does not handle LTO out of the box and need a plugin to be setup
filter { "system:windows", "configurations:Release", "toolset:not gcc" }
Expand Down
15 changes: 15 additions & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,21 @@
excludefrombuild("Off")
end)

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

api.deprecateField("flags", "Use dedicated APIs instead.",
function(value)
end)

-----------------------------------------------------------------------------
--
-- Field name aliases for backward compatibility
Expand Down
16 changes: 8 additions & 8 deletions src/base/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@
end
else
local field = p.fields[name]
field.deprecated = field.deprecated or {}
field.deprecated[value] = {
field.deprecatedvalues = field.deprecatedvalues or {}
field.deprecatedvalues[value] = {
add = addHandler,
remove = removeHandler,
message = message
Expand Down Expand Up @@ -548,7 +548,7 @@
error(err, 3)
end

local hasDeprecatedValues = (type(field.deprecated) == "table")
local hasDeprecatedValues = (type(field.deprecatedvalues) == "table")

-- Build a list of values to be removed. If this field has deprecated
-- values, check to see if any of those are going to be removed by this
Expand All @@ -558,8 +558,8 @@
local removes = {}

local function check(value)
if field.deprecated[value] then
local handler = field.deprecated[value]
if field.deprecatedvalues[value] then
local handler = field.deprecatedvalues[value]
if handler.remove then handler.remove(value) end
if handler.message and api._deprecations ~= "off" then
local caller = filelineinfo(8)
Expand Down Expand Up @@ -597,7 +597,7 @@
error { msg=err }
end

if field.deprecated then
if field.deprecatedvalues then
check(value)
end

Expand Down Expand Up @@ -681,8 +681,8 @@
return nil, "invalid value '" .. value .. "' for " .. field.name
end

if field.deprecated and field.deprecated[canonical] then
local handler = field.deprecated[canonical]
if field.deprecatedvalues and field.deprecatedvalues[canonical] then
local handler = field.deprecatedvalues[canonical]
handler.add(canonical)
if handler.message and api._deprecations ~= "off" then
local caller = filelineinfo(9)
Expand Down
1 change: 1 addition & 0 deletions src/tools/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
Fast = "-flto=thin",
},
profile = gcc.shared.profile,
useshortenums = gcc.shared.useshortenums,
}

clang.cflags = table.merge(gcc.cflags, {
Expand Down
5 changes: 0 additions & 5 deletions src/tools/dotnet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@
info.SubType = fcfg.buildaction
end

-- This flag is deprecated, will remove eventually
if fcfg.flags and fcfg.flags.Component then
info.SubType = "Component"
end

end

if info.action == "Content" then
Expand Down
6 changes: 5 additions & 1 deletion src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@
},
profile = {
On = "-pg",
},
useshortenums = {
On = "-fshort-enums",
Off = "-fno-short-enums",
}
}

Expand Down Expand Up @@ -381,7 +385,7 @@
-- relative pch file path if any
function gcc.getpch(cfg)
-- If there is no header, or if PCH has been disabled, I can early out
if not cfg.pchheader or cfg.flags.NoPCH then
if not cfg.pchheader or cfg.enablepch == p.OFF then
return nil
end

Expand Down
25 changes: 25 additions & 0 deletions website/docs/useshortenums.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Specifies if short enums should be used.

```lua
useshortenums ("value")
```

If no value is set for a configuration, the toolset's default option will be used.

### Parameters ###

`value` specifies the desired wpf setting:

| Value | Description | Notes |
|------------|---------------------------------------------------|
| Default | Use the default behavior |
| On | Enums are backed by the smallest legal integral. | Binaries compiled with short enums may not be ABI compatible with those without. It is recommended to compile all projects with the same setting. |
| Off | Enums are backed by the default integral. |

### Applies To ###

Android projects in Visual Studio or any GCC/Clang project.

### Availability ###

Premake 5.0.0-beta8 or later.
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ module.exports = {
'usefullpaths',
'useimportlib',
'uses',
'useshortenums',
'usestandardpreprocessor',
'usingdirs',
'uuid',
Expand Down
Loading