Merge branch 'master' into vs2022_version

This commit is contained in:
Nick Clark 2021-10-31 14:39:19 -05:00 committed by GitHub
commit 6adc9c0a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 619 additions and 215 deletions

View File

@ -1,10 +1,52 @@
--------------------
5.0 (in progress)
5.0-beta1
--------------------
See https://github.com/premake/premake-core/wiki/What's-New-in-5.0
for the complete list of changes from the Premake 4.x series.
Since 5.0-alpha16:
* PR #1555 Added API to disable fast up to date checks (@nickclark2016)
* PR #1570 Initial C++20 module support for Visual Studio (@hannes-harnisch)
* PR #1619 Xcode embed libraries (@kellygravelyn)
* PR #1625 Remove "*ng" action deprecation (@noresources)
* PR #1629 Added support for Premake on macOS universal binary (@tempura-sukiyaki)
* PR #1635 Fix typo in Using Premake documentation (@abhiss)
* PR #1638 Fix broken links in docs (@KyrietS)
* PR #1642 Fix spelling mistake (@Troplo)
* PR #1644 Fix author name and update time on pages (@KyrietS)
* PR #1645 Add missing support for prebuildmessage/postbuildmessage for Codelite. (@Jarod42)
* PR #1649 Fix curl header search path (@depinxi)
* PR #1654 xcode4: Fix missing link of sibling project with custom targetextension (@depinxi)
* PR #1655 Compiler Version support for Visual Studion 2017+ (@nickclark2016)
* PR #1657 Renormalize line endings (@nickclark2016)
* PR #1661 Add frameworkdirs support to gmake and gmake2 with gcc/clang toolsets (@depinxi)
* PR #1663 compilebuildoutputs make some comments obsolete. (@Jarod42)
* PR #1668 Fix v6 bootstrapping from v5 (@starkos)
* PR #1673 Updated sidebar to include toolsversion link (@premake)
* PR #1680 Fix some build issues with mingw (@Biswa96)
* PR #1682 Add Community Update #9 (@starkos)
* PR #1687 Update deprecated entry for `newaction` (@Jarod42)
* PR #1704 VS2022 Exporter (@nickclark2016)
* PR #1710 Add support for SSE 4.2. (@ActuallyaDeviloper)
* PR #1712 Add OpenMP support for Visual Studio (@T-rvw)
* PR #1713 Upgrade docusaurus version to beta.6 (@KyrietS)
* PR #1715 Docs maintenance (@KyrietS)
* PR #1718 Deprecate `configuration()` (@starkos)
* PR #1720 Improve `justmycode` (@T-rvw)
* PR #1723 Add condition to `.csproj` references ItemGroup (@cicanci)
* PR #1726 Updated cdialect and cppdialect docs (@LORgames)
* PR #1727 Updated architecture docs (@LORgames)
* PR #1730 Added missing compileas values to docs (@LORgames)
* PR #1734 Add VS 2022 bootstrapping support (@afxw)
* PR #1736 Update showcase to include Orx (@sausagejohnson)
* PR #1662 Handle buildcommand for Codelite (@Jarod42)
* PR #1658 Fix D module compiler output for Visual Studio (@nickclark2016)
* PR #1728 Add action to check for and generate missing documentation (@LORgames)
* PR #1721 Add custom rules for Gmake2 & Codelite (@Jarod42)
* PR #1739 Fix #1628 failing macOS os.findlib() test (@starkos)
Since 5.0-alpha15:
* PR #1430 Fixed adding LD_LIBRARY_PATH to the executable run command. (@Enhex)

View File

@ -5,7 +5,7 @@
<p align="center">
<img src="https://img.shields.io/github/release/premake/premake-core/all.svg" alt="Latest release" />
<img src="https://img.shields.io/github/release-date-pre/premake/premake-core.svg" alt="Release date" />
<img src="https://img.shields.io/github/commits-since/premake/premake-core/v5.0.0-alpha16.svg" alt="Commits" />
<img src="https://img.shields.io/github/commits-since/premake/premake-core/v5.0.0-beta1.svg" alt="Commits" />
<a href="https://opensource.org/licenses/BSD-3-Clause" target="_blank">
<img src="https://img.shields.io/github/license/premake/premake-core" alt="BSD 3-Clause" />
</a>

View File

@ -379,38 +379,51 @@
_p(4, '<CustomPostBuild/>')
local dependencies = {}
local rules = {}
local function addrule(dependencies, rules, config, filename)
local makefilerules = {}
local function addrule(dependencies, makefilerules, config, filename)
if #config.buildcommands == 0 or #config.buildOutputs == 0 then
return
return false
end
local inputs = table.implode(config.buildInputs,"",""," ")
local inputs = table.implode(project.getrelative(cfg.project, config.buildInputs), "", "", " ")
if filename ~= "" and inputs ~= "" then
filename = filename .. " "
end
local outputs = config.buildOutputs[1]
local outputs = project.getrelative(cfg.project, config.buildOutputs[1])
local buildmessage = ""
if config.buildmessage then
buildmessage = "\t@{ECHO} " .. config.buildmessage .. "\n"
end
local commands = table.implode(config.buildCommands,"\t","\n","")
table.insert(rules, os.translateCommandsAndPaths(outputs .. ": " .. filename .. inputs .. "\n" .. buildmessage .. commands, cfg.project.basedir, cfg.project.location))
table.insertflat(dependencies, config.buildOutputs[1])
table.insert(makefilerules, os.translateCommandsAndPaths(outputs .. ": " .. filename .. inputs .. "\n" .. buildmessage .. commands, cfg.project.basedir, cfg.project.location))
table.insertflat(dependencies, outputs)
return true
end
local tr = project.getsourcetree(cfg.project)
p.tree.traverse(tr, {
onleaf = function(node, depth)
local filecfg = p.fileconfig.getconfig(node, cfg)
addrule(dependencies, rules, filecfg, node.relpath)
local prj = cfg.project
local rule = p.global.getRuleForFile(node.name, prj.rules)
if not addrule(dependencies, makefilerules, filecfg, node.relpath) and rule then
local environ = table.shallowcopy(filecfg.environ)
if rule.propertydefinition then
p.rule.prepareEnvironment(rule, environ, cfg)
p.rule.prepareEnvironment(rule, environ, filecfg)
end
local rulecfg = p.context.extent(rule, environ)
addrule(dependencies, makefilerules, rulecfg, node.relpath)
end
end
})
addrule(dependencies, rules, cfg, "")
addrule(dependencies, makefilerules, cfg, "")
if #rules == 0 and #dependencies == 0 then
if #makefilerules == 0 and #dependencies == 0 then
_p(4, '<CustomPreBuild/>')
else
_p(4, '<CustomPreBuild>' .. table.implode(dependencies,"",""," "))
_p(0, table.implode(rules,"","","\n") .. '</CustomPreBuild>')
_p(0, table.implode(makefilerules,"","","\n") .. '</CustomPreBuild>')
end
_p(3, '</AdditionalRules>')
end

View File

@ -4,4 +4,5 @@ return {
"test_codelite_workspace.lua",
"test_codelite_project.lua",
"test_codelite_config.lua",
"test_codelite_additional_rules.lua",
}

View File

@ -0,0 +1,256 @@
---
-- codelite/tests/test_codelite_config.lua
-- Automated test suite for CodeLite project generation.
-- Copyright (c) 2021 Joris Dauphin and the Premake project
---
local suite = test.declare("codelite_cproj_additional_rules")
local p = premake
local codelite = p.modules.codelite
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local wks, prj, cfg
local function prepare_rule()
rule "TestRule"
display "Test Rule"
fileextension ".rule"
propertydefinition {
name = "TestProperty",
kind = "boolean",
value = false,
switch = "-p"
}
propertydefinition {
name = "TestProperty2",
kind = "boolean",
value = false,
switch = "-p2"
}
propertydefinition {
name = "TestListProperty",
kind = "list"
}
propertydefinition {
name = "TestListPropertyWithSwitch",
kind = "list",
switch = "-S"
}
propertydefinition {
name = "TestListPropertySeparator",
kind = "list",
separator = ","
}
propertydefinition {
name = "TestListPropertySeparatorWithSwitch",
kind = "list",
separator = ",",
switch = "-O"
}
propertydefinition {
name = "TestEnumProperty",
values = { [0] = "V0", [1] = "V1"},
switch = { [0] = "S0", [1] = "S1"},
value = 0
}
buildmessage 'Rule-ing %{file.name}'
buildcommands 'dorule %{TestProperty} %{TestProperty2} %{TestListProperty} %{TestListPropertyWithSwitch} %{TestListPropertySeparator} %{TestListPropertySeparatorWithSwitch} %{TestEnumProperty} "%{file.path}"'
buildoutputs { "%{file.basename}.obj" }
end
function suite.setup()
p.action.set("codelite")
p.escaper(codelite.esc)
p.indent(" ")
prepare_rule()
wks = test.createWorkspace()
end
local function prepare()
prj = test.getproject(wks, 1)
cfg = test.getconfig(prj, "Debug")
end
function suite.customRuleEmpty()
prepare()
codelite.project.additionalRules(prj)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild/>
</AdditionalRules>
]]
end
function suite.customRuleWithPropertyDefinition()
rules { "TestRule" }
files { "test.rule", "test2.rule" }
testRuleVars {
TestProperty = true
}
filter "files:test2.rule"
testRuleVars {
TestProperty2 = true
}
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>test.obj test2.obj
test.obj: test.rule
@echo Rule-ing test.rule
dorule -p "test.rule"
test2.obj: test2.rule
@echo Rule-ing test2.rule
dorule -p -p2 "test2.rule"
</CustomPreBuild>
</AdditionalRules>
]]
end
function suite.customRuleWithPropertyDefinitionSeparator()
rules { "TestRule" }
files { "test.rule", "test2.rule", "test3.rule", "test4.rule" }
filter "files:test.rule"
testRuleVars {
TestListProperty = { "testValue1", "testValue2" }
}
filter "files:test2.rule"
testRuleVars {
TestListPropertyWithSwitch = { "testValue1", "testValue2" }
}
filter "files:test3.rule"
testRuleVars {
TestListPropertySeparator = { "testValue1", "testValue2" }
}
filter "files:test4.rule"
testRuleVars {
TestListPropertySeparatorWithSwitch = { "testValue1", "testValue2" }
}
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>test.obj test2.obj test3.obj test4.obj
test.obj: test.rule
@echo Rule-ing test.rule
dorule testValue1 testValue2 "test.rule"
test2.obj: test2.rule
@echo Rule-ing test2.rule
dorule -StestValue1 -StestValue2 "test2.rule"
test3.obj: test3.rule
@echo Rule-ing test3.rule
dorule testValue1,testValue2 "test3.rule"
test4.obj: test4.rule
@echo Rule-ing test4.rule
dorule -OtestValue1,testValue2 "test4.rule"
</CustomPreBuild>
</AdditionalRules>
]]
end
function suite.customRuleWithPropertyDefinitionEnum()
rules { "TestRule" }
files { "test.rule", "test2.rule" }
testRuleVars {
TestEnumProperty = "V0"
}
filter "files:test2.rule"
testRuleVars {
TestEnumProperty = "V1"
}
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>test.obj test2.obj
test.obj: test.rule
@echo Rule-ing test.rule
dorule S0 "test.rule"
test2.obj: test2.rule
@echo Rule-ing test2.rule
dorule S1 "test2.rule"
</CustomPreBuild>
</AdditionalRules>
]]
end
function suite.buildCommand()
files {"foo.txt", "bar.txt"}
buildinputs { "toto.txt", "extra_dependency" }
buildoutputs { "toto.c" }
buildcommands { "test", "test toto.c" }
buildmessage "Some message"
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>toto.c
toto.c: toto.txt extra_dependency
@echo Some message
test
test toto.c
</CustomPreBuild>
</AdditionalRules>]]
end
function suite.buildCommandPerFile()
files {"foo.txt", "bar.txt"}
filter "files:**.txt"
buildinputs { "%{file.basename}.h", "extra_dependency" }
buildoutputs { "%{file.basename}.c" }
buildcommands { "test", "test %{file.basename}" }
buildmessage "Some message"
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>bar.c foo.c
bar.c: bar.txt bar.h extra_dependency
@echo Some message
test
test bar
foo.c: foo.txt foo.h extra_dependency
@echo Some message
test
test foo
</CustomPreBuild>
</AdditionalRules>]]
end

View File

@ -203,52 +203,6 @@
]]
end
function suite.OnProjectCfg_BuildCommand()
files {"/c/foo.txt", "/c/bar.txt"}
buildinputs { "/c/toto.txt", "/c/extra_dependency" }
buildoutputs { "/c/toto.c" }
buildcommands { "test", "test /c/toto.c" }
buildmessage "Some message"
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>/c/toto.c
/c/toto.c: /c/toto.txt /c/extra_dependency
@echo Some message
test
test /c/toto.c
</CustomPreBuild>
</AdditionalRules>]]
end
function suite.OnProjectCfg_BuildCommandPerFile()
files {"/c/foo.txt", "/c/bar.txt"}
filter "files:**.txt"
buildinputs { "/c/%{file.basename}.h", "/c/extra_dependency" }
buildoutputs { "/c/%{file.basename}.c" }
buildcommands { "test", "test /c/%{file.basename}" }
buildmessage "Some message"
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>/c/bar.c /c/foo.c
/c/bar.c: /c/bar.txt /c/bar.h /c/extra_dependency
@echo Some message
test
test /c/bar
/c/foo.c: /c/foo.txt /c/foo.h /c/extra_dependency
@echo Some message
test
test /c/foo
</CustomPreBuild>
</AdditionalRules>]]
end
function suite.OnProjectCfg_General()
system "Windows"
prepare()
@ -386,20 +340,6 @@ cmd2</StartupCommands>
]]
end
-- TODO: test custom build
function suite.OnProjectCfg_AdditionalRules()
prepare()
codelite.project.additionalRules(prj)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild/>
</AdditionalRules>
]]
end
function suite.OnProjectCfg_Completion()
language "C++"
cppdialect "C++11"

View File

@ -171,20 +171,6 @@
return value
end
function gmake2.path(cfg, value)
cfg = cfg.project or cfg
local dirs = path.translate(project.getrelative(cfg, value))
if type(dirs) == 'table' then
dirs = table.filterempty(dirs)
end
return dirs
end
function gmake2.getToolSet(cfg)
local default = iif(cfg.system == p.MACOSX, "clang", "gcc")
local toolset = p.tools[_OPTIONS.cc or cfg.toolset or default]
@ -259,71 +245,6 @@
-- convert a rule property into a string
function gmake2.expandRuleString(rule, prop, value)
-- list?
if type(value) == "table" then
if #value > 0 then
if prop.switch then
return prop.switch .. table.concat(value, " " .. prop.switch)
else
prop.separator = prop.separator or " "
return table.concat(value, prop.separator)
end
else
return nil
end
end
-- bool just emits the switch
if prop.switch and type(value) == "boolean" then
if value then
return prop.switch
else
return nil
end
end
local switch = prop.switch or ""
-- enum?
if prop.values then
value = table.findKeyByValue(prop.values, value)
if value == nil then
value = ""
end
end
-- primitive
value = tostring(value)
if #value > 0 then
return switch .. value
else
return nil
end
end
function gmake2.prepareEnvironment(rule, environ, cfg)
for _, prop in ipairs(rule.propertydefinition) do
local fld = p.rule.getPropertyField(rule, prop)
local value = cfg[fld.name]
if value ~= nil then
if fld.kind == "path" then
value = gmake2.path(cfg, value)
elseif fld.kind == "list:path" then
value = gmake2.path(cfg, value)
end
value = gmake2.expandRuleString(rule, prop, value)
if value ~= nil and #value > 0 then
environ[prop.name] = p.esc(value)
end
end
end
end
---------------------------------------------------------------------------
--
-- Handlers for the individual makefile elements that can be shared

View File

@ -269,8 +269,8 @@
local environ = table.shallowcopy(filecfg.environ)
if rule.propertydefinition then
gmake2.prepareEnvironment(rule, environ, cfg)
gmake2.prepareEnvironment(rule, environ, filecfg)
p.rule.prepareEnvironment(rule, environ, cfg)
p.rule.prepareEnvironment(rule, environ, filecfg)
end
local shadowContext = p.context.extent(rule, environ)

View File

@ -175,8 +175,8 @@
local environ = table.shallowcopy(filecfg.environ)
if rule.propertydefinition then
gmake2.prepareEnvironment(rule, environ, cfg)
gmake2.prepareEnvironment(rule, environ, filecfg)
p.rule.prepareEnvironment(rule, environ, cfg)
p.rule.prepareEnvironment(rule, environ, filecfg)
end
local shadowContext = p.context.extent(rule, environ)

View File

@ -41,15 +41,31 @@
name = "TestListProperty",
kind = "list"
}
propertydefinition {
name = "TestListPropertyWithSwitch",
kind = "list",
switch = "-S"
}
propertydefinition {
name = "TestListPropertySeparator",
kind = "list",
separator = ","
}
propertydefinition {
name = "TestListPropertySeparatorWithSwitch",
kind = "list",
separator = ",",
switch = "-O"
}
propertydefinition {
name = "TestEnumProperty",
values = { [0] = "V0", [1] = "V1"},
switch = { [0] = "S0", [1] = "S1"},
value = 0
}
buildmessage 'Rule-ing %{file.name}'
buildcommands 'dorule %{TestProperty} %{TestProperty2} %{TestListProperty} %{TestListPropertySeparator} "%{file.path}"'
buildcommands 'dorule %{TestProperty} %{TestProperty2} %{TestListProperty} %{TestListPropertyWithSwitch} %{TestListPropertySeparator} %{TestListPropertySeparatorWithSwitch} %{TestEnumProperty} "%{file.path}"'
buildoutputs { "%{file.basename}.obj" }
wks = test.createWorkspace()
@ -292,7 +308,7 @@ test2.obj: test2.rule
rules { "TestRule" }
files { "test.rule", "test2.rule" }
files { "test.rule", "test2.rule", "test3.rule", "test4.rule" }
filter "files:test.rule"
testRuleVars {
@ -300,9 +316,18 @@ test2.obj: test2.rule
}
filter "files:test2.rule"
testRuleVars {
TestListPropertyWithSwitch = { "testValue1", "testValue2" }
}
filter "files:test3.rule"
testRuleVars {
TestListPropertySeparator = { "testValue1", "testValue2" }
}
filter "files:test4.rule"
testRuleVars {
TestListPropertySeparatorWithSwitch = { "testValue1", "testValue2" }
}
prepare()
test.capture [[
@ -314,7 +339,41 @@ test.obj: test.rule
$(SILENT) dorule testValue1\ testValue2 "test.rule"
test2.obj: test2.rule
@echo Rule-ing test2.rule
$(SILENT) dorule testValue1,testValue2 "test2.rule"
$(SILENT) dorule -StestValue1\ -StestValue2 "test2.rule"
test3.obj: test3.rule
@echo Rule-ing test3.rule
$(SILENT) dorule testValue1,testValue2 "test3.rule"
test4.obj: test4.rule
@echo Rule-ing test4.rule
$(SILENT) dorule -OtestValue1,testValue2 "test4.rule"
]]
end
function suite.customRuleWithPropertyDefinitionEnum()
rules { "TestRule" }
files { "test.rule", "test2.rule" }
testRuleVars {
TestEnumProperty = "V0"
}
filter "files:test2.rule"
testRuleVars {
TestEnumProperty = "V1"
}
prepare()
test.capture [[
# File Rules
# #############################################
test.obj: test.rule
@echo Rule-ing test.rule
$(SILENT) dorule S0 "test.rule"
test2.obj: test2.rule
@echo Rule-ing test2.rule
$(SILENT) dorule S1 "test2.rule"
]]
end

View File

@ -2,18 +2,14 @@
## PREP
* Create a new release branch; push to origin
* Notify `@premakeapp` of release branch availability; request testing
* Create a new release branch `release/v5.0-beta1`
* Update `CHANGES.txt`
* Set version at top of file
* `premake5 --file=scripts/changes.lua --since=<last_release_rev> changes`
* Review and clean up as needed
* Update `README.md`
* "Commits since last release" badge (once out of prerelease replace `v5.0.0-alphaXX` with `latest`)
* Update version in `src/host/premake.h`
@ -30,7 +26,7 @@
* On each platform, run `premake5 package <release branch name> binary`
* Submit Windows binary to [Microsoft malware analysis](https://www.microsoft.com/en-us/wdsi/filesubmission/)
* Submit Windows binary to [Microsoft malware analysis](https://www.microsoft.com/en-us/wdsi/filesubmission/) _(Can no longer do this unless it has already been flagged as malware; needs the failing signature in order to submit.)_
* Push any remaining changes; tag release branch
@ -38,7 +34,6 @@
* Post announcement to `@premakeapp`
## CYCLE
* Update version in `src/host/premake.h` (e.x `"5.0.0-dev"`)

View File

@ -103,10 +103,26 @@
return path
end
function os.findlib(libname, libdirs)
-- libname: library name with or without prefix and suffix
-- libdirs: (array or string): A set of additional search paths
---
-- Attempt to locate and return the path to a shared library.
--
-- This function does not work to locate system libraries on macOS 11 or later; it may still
-- be used to locate user libraries: _"New in macOS Big Sur 11.0.1, the system ships with
-- a built-in dynamic linker cache of all system-provided libraries. As part of this change,
-- copies of dynamic libraries are no longer present on the filesystem. Code that attempts to
-- check for dynamic library presence by looking for a file at a path or enumerating a directory
-- will fail."
-- https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes
--
-- @param libname
-- The library name with or without prefix and suffix.
-- @param libdirs
-- An array of paths to be searched.
-- @returns
-- The full path to the library if found; `nil` otherwise.
---
function os.findlib(libname, libdirs)
local path = get_library_search_path()
local formats

View File

@ -136,21 +136,14 @@
-- @param format
-- The formatting to be used, ie "[%s]".
---
function rule.prepareEnvironment(self, environ, format)
function rule.createEnvironment(self, format)
local environ = {}
for _, def in ipairs(self.propertydefinition) do
environ[def.name] = string.format(format, def.name)
end
end
function rule.createEnvironment(self, format)
local environ = {}
rule.prepareEnvironment(self, environ, format)
return environ
end
---
-- prepare an table of pathVars with the rule properties as global tokens,
-- according to the format specified.
@ -172,3 +165,78 @@
rule.preparePathVars(self, pathVars, format)
return pathVars
end
function rule.prepareEnvironment(self, environ, cfg)
local function path(cfg, value)
cfg = cfg.project or cfg
local dirs = path.translate(project.getrelative(cfg, value))
if type(dirs) == 'table' then
dirs = table.filterempty(dirs)
end
return dirs
end
local function expandRuleString(prop, value)
-- list
if type(value) == "table" then
if #value > 0 then
local switch = prop.switch or ""
if prop.separator then
return switch .. table.concat(value, prop.separator)
else
return switch .. table.concat(value, " " .. switch)
end
else
return nil
end
end
-- bool just emits the switch
if prop.switch and type(value) == "boolean" then
if value then
return prop.switch
else
return nil
end
end
-- enum
if prop.values then
local switch = prop.switch or {}
value = table.findKeyByValue(prop.values, value)
if value == nil then
return nil
end
return switch[value]
end
-- primitive
local switch = prop.switch or ""
value = tostring(value)
if #value > 0 then
return switch .. value
else
return nil
end
end
for _, prop in ipairs(self.propertydefinition) do
local fld = p.rule.getPropertyField(self, prop)
local value = cfg[fld.name]
if value ~= nil then
if fld.kind == "path" then
value = path(cfg, value)
elseif fld.kind == "list:path" then
value = path(cfg, value)
end
value = expandRuleString(prop, value)
if value ~= nil and #value > 0 then
environ[prop.name] = p.esc(value)
end
end
end
end

View File

@ -16,6 +16,7 @@ return {
"base/test_premake_command.lua",
"base/test_table.lua",
"base/test_tree.lua",
"base/test_rule.lua",
"base/test_uuid.lua",
"base/test_versions.lua",
"base/test_http.lua",

View File

@ -23,7 +23,10 @@
--
function suite.findlib_FindSystemLib()
if os.istarget("windows") then
if os.istarget("macosx") then
-- macOS no longer stores system libraries on filesystem; see
-- https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes
elseif os.istarget("windows") then
test.istrue(os.findlib("user32"))
elseif os.istarget("haiku") then
test.istrue(os.findlib("root"))

85
tests/base/test_rule.lua Normal file
View File

@ -0,0 +1,85 @@
--
-- tests/base/test_rule.lua
-- Automated test suite for custom rule.
-- Copyright (c) 2008-2021 Jason Perkins and the Premake project
--
local suite = test.declare("rule")
local p = premake
function suite.setup()
rule "TestRule"
display "Test Rule"
fileextension ".rule"
propertydefinition {
name = "TestPropertyFalse",
kind = "boolean",
value = false,
switch = "-dummy"
}
propertydefinition {
name = "TestPropertyTrue",
kind = "boolean",
value = false,
switch = "-p"
}
propertydefinition {
name = "TestListProperty",
kind = "list"
}
propertydefinition {
name = "TestListPropertyWithSwitch",
kind = "list",
switch = "-S"
}
propertydefinition {
name = "TestListPropertySeparator",
kind = "list",
separator = ","
}
propertydefinition {
name = "TestListPropertySeparatorWithSwitch",
kind = "list",
separator = ",",
switch = "-O"
}
propertydefinition {
name = "TestEnumProperty",
values = { [0] = "V0", [1] = "V1"},
switch = { [0] = "S0", [1] = "S1"},
value = 0
}
end
--
-- rule tests
--
function suite.prepareEnvironment()
local rule = premake.global.getRule("TestRule")
local environ = {}
local cfg = {
["_rule_TestRule_TestPropertyFalse"] = false,
["_rule_TestRule_TestPropertyTrue"] = true,
["_rule_TestRule_TestListProperty"] = {"a", "b"},
["_rule_TestRule_TestListPropertyWithSwitch"] = {"c", "d"},
["_rule_TestRule_TestListPropertySeparator"] = {"e", "f"},
["_rule_TestRule_TestListPropertySeparatorWithSwitch"] = {"1", "2"},
["_rule_TestRule_TestEnumProperty"] = 'V1'
}
p.rule.prepareEnvironment(rule, environ, cfg)
test.isequal(nil, environ["TestPropertyFalse"])
test.isequal("-p", environ["TestPropertyTrue"])
test.isequal("a b", environ["TestListProperty"])
test.isequal("-Sc -Sd", environ["TestListPropertyWithSwitch"])
test.isequal("e,f", environ["TestListPropertySeparator"])
test.isequal("-O1,2", environ["TestListPropertySeparatorWithSwitch"])
test.isequal("S1", environ["TestEnumProperty"])
end

View File

@ -4,16 +4,21 @@ Scan the well-known system locations looking for a library file.
p = os.findlib("libname" [, additionalpaths])
```
This function does not work to locate system libraries on macOS 11 or later; it may still be used to locate user libraries. From [the release notes](https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes):
> New in macOS Big Sur 11.0.1, the system ships with a built-in dynamic linker cache of all system-provided libraries. As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail.
### Parameters ###
`libname` is name of the library to locate. It may be specified with (libX11.so) or without (X11) system-specific decorations.
`libname` is name of the library to locate. It may be specified with (`libX11.so`) or without (`X11`) system-specific decorations.
`additionalpaths` is a string or a table of one or more additional search path.
`additionalpaths` is a string or a table of one or more additional search path
### Return Value ###
The path containing the library file, if found. Otherwise, nil.
### Availability ###
Premake 4.0 or later.
Premake 4.0 or later. Non-macOS host systems only.

View File

@ -47,9 +47,8 @@ For enum properties, a key-value table of the possible values of the property, a
The value to be placed into the command line for this property. See the examples below for more information.
#### separator ####
For list properties, this sets the value of the list item separator in the command line.\
gmake2: Default value is ' '. If a switch is set, the separator is ignored and instead the switch is duplicated.\
VS201x: If set, the list is concatenated by the separator and placed behind a single switch. If not set, the switch is duplicated.
For list properties, this sets the value of the list item separator in the command line.
If set, the list is concatenated by the separator and placed behind a single switch. If not set, the switch is duplicated.
#### category ####
Visual Studio only.

View File

@ -6,7 +6,7 @@ import { Column, Container, Row } from '../components/Grid';
import Sponsors from '../components/Sponsors';
const LATEST_VERSION = '5.0.0-alpha16';
const LATEST_VERSION = '5.0.0-beta1';
const DownloadLink = ({ arch }) => {