Merge branch 'master' into recognize-swift-files-as-source-code

This commit is contained in:
sp-rafael-lecina 2020-07-30 22:42:44 +02:00 committed by GitHub
commit 68f8e9547e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 248 additions and 97 deletions

View File

@ -146,100 +146,70 @@
return types[path.getextension(node.path)] or "text" return types[path.getextension(node.path)] or "text"
end end
-- xcode.escapeSpecialChars = {
-- Print user configuration references contained in xcodeconfigreferences
-- @param offset
-- offset used by function _p
-- @param cfg
-- configuration
--
local function xcodePrintUserConfigReferences(offset, cfg, tr, kind)
local referenceName
if kind == "project" then
referenceName = cfg.xcodeconfigreferenceproject
elseif kind == "target" then
referenceName = cfg.xcodeconfigreferencetarget
end
tree.traverse(tr, {
onleaf = function(node)
filename = node.name
if node.id and path.getextension(filename) == ".xcconfig" then
if filename == referenceName then
_p(offset, 'baseConfigurationReference = %s /* %s */;', node.id, filename)
return
end
end
end
}, false)
end
local escapeSpecialChars = {
['\n'] = '\\n', ['\n'] = '\\n',
['\r'] = '\\r', ['\r'] = '\\r',
['\t'] = '\\t', ['\t'] = '\\t',
} }
local function escapeChar(c) function xcode.escapeChar(c)
return escapeSpecialChars[c] or '\\'..c return xcode.escapeSpecialChars[c] or '\\'..c
end end
local function escapeArg(value) function xcode.escapeArg(value)
value = value:gsub('[\'"\\\n\r\t ]', escapeChar) value = value:gsub('[\'"\\\n\r\t ]', xcode.escapeChar)
return value return value
end end
local function escapeSetting(value) function xcode.escapeSetting(value)
value = value:gsub('["\\\n\r\t]', escapeChar) value = value:gsub('["\\\n\r\t]', xcode.escapeChar)
return value return value
end end
local function stringifySetting(value) function xcode.stringifySetting(value)
value = value..'' value = value..''
if not value:match('^[%a%d_./]+$') then if not value:match('^[%a%d_./]+$') then
value = '"'..escapeSetting(value)..'"' value = '"'..xcode.escapeSetting(value)..'"'
end end
return value return value
end end
local function customStringifySetting(value) function xcode.customStringifySetting(value)
value = value..'' value = value..''
local test = value:match('^[%a%d_./%+]+$') local test = value:match('^[%a%d_./%+]+$')
if test then if test then
value = '"'..escapeSetting(value)..'"' value = '"'..xcode.escapeSetting(value)..'"'
end end
return value return value
end end
local function printSetting(level, name, value) function xcode.printSetting(level, name, value)
if type(value) == 'function' then if type(value) == 'function' then
value(level, name) value(level, name)
elseif type(value) ~= 'table' then elseif type(value) ~= 'table' then
_p(level, '%s = %s;', stringifySetting(name), stringifySetting(value)) _p(level, '%s = %s;', xcode.stringifySetting(name), xcode.stringifySetting(value))
--elseif #value == 1 then --elseif #value == 1 then
--_p(level, '%s = %s;', stringifySetting(name), stringifySetting(value[1])) --_p(level, '%s = %s;', xcode.stringifySetting(name), xcode.stringifySetting(value[1]))
elseif #value >= 1 then elseif #value >= 1 then
_p(level, '%s = (', stringifySetting(name)) _p(level, '%s = (', xcode.stringifySetting(name))
for _, item in ipairs(value) do for _, item in ipairs(value) do
_p(level + 1, '%s,', stringifySetting(item)) _p(level + 1, '%s,', xcode.stringifySetting(item))
end end
_p(level, ');') _p(level, ');')
end end
end end
local function printSettingsTable(level, settings) function xcode.printSettingsTable(level, settings)
-- Maintain alphabetic order to be consistent -- Maintain alphabetic order to be consistent
local keys = table.keys(settings) local keys = table.keys(settings)
table.sort(keys) table.sort(keys)
for _, k in ipairs(keys) do for _, k in ipairs(keys) do
printSetting(level, k, settings[k]) xcode.printSetting(level, k, settings[k])
end end
end end
local function overrideSettings(settings, overrides) function xcode.overrideSettings(settings, overrides)
if type(overrides) == 'table' then if type(overrides) == 'table' then
for name, value in pairs(overrides) do for name, value in pairs(overrides) do
-- Allow an override to remove a value by using false -- Allow an override to remove a value by using false
@ -421,7 +391,7 @@
if not table.isempty(settings) then if not table.isempty(settings) then
_p('/* Begin PBXBuildFile section */') _p('/* Begin PBXBuildFile section */')
printSettingsTable(2, settings); xcode.printSettingsTable(2, settings);
_p('/* End PBXBuildFile section */') _p('/* End PBXBuildFile section */')
_p('') _p('')
end end
@ -437,7 +407,7 @@
_p(3,'containerPortal = %s /* %s */;', node.id, path.getrelative(node.parent.parent.project.location, node.path)) _p(3,'containerPortal = %s /* %s */;', node.id, path.getrelative(node.parent.parent.project.location, node.path))
_p(3,'proxyType = 2;') _p(3,'proxyType = 2;')
_p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.id) _p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.id)
_p(3,'remoteInfo = %s;', stringifySetting(node.project.xcode.projectnode.name)) _p(3,'remoteInfo = %s;', xcode.stringifySetting(node.project.xcode.projectnode.name))
_p(2,'};') _p(2,'};')
end end
settings[node.targetproxyid] = function() settings[node.targetproxyid] = function()
@ -446,14 +416,14 @@
_p(3,'containerPortal = %s /* %s */;', node.id, path.getrelative(node.parent.parent.project.location, node.path)) _p(3,'containerPortal = %s /* %s */;', node.id, path.getrelative(node.parent.parent.project.location, node.path))
_p(3,'proxyType = 1;') _p(3,'proxyType = 1;')
_p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.targetid) _p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.targetid)
_p(3,'remoteInfo = %s;', stringifySetting(node.project.xcode.projectnode.name)) _p(3,'remoteInfo = %s;', xcode.stringifySetting(node.project.xcode.projectnode.name))
_p(2,'};') _p(2,'};')
end end
end end
if not table.isempty(settings) then if not table.isempty(settings) then
_p('/* Begin PBXContainerItemProxy section */') _p('/* Begin PBXContainerItemProxy section */')
printSettingsTable(2, settings); xcode.printSettingsTable(2, settings);
_p('/* End PBXContainerItemProxy section */') _p('/* End PBXContainerItemProxy section */')
_p('') _p('')
end end
@ -475,7 +445,7 @@
if node.kind == "product" then if node.kind == "product" then
settings[node.id] = function(level) settings[node.id] = function(level)
_p(level,'%s /* %s */ = {isa = PBXFileReference; explicitFileType = %s; includeInIndex = 0; name = %s; path = %s; sourceTree = BUILT_PRODUCTS_DIR; };', _p(level,'%s /* %s */ = {isa = PBXFileReference; explicitFileType = %s; includeInIndex = 0; name = %s; path = %s; sourceTree = BUILT_PRODUCTS_DIR; };',
node.id, node.name, xcode.gettargettype(node), stringifySetting(node.name), stringifySetting(path.getname(node.cfg.buildtarget.bundlename ~= "" and node.cfg.buildtarget.bundlename or node.cfg.buildtarget.relpath))) node.id, node.name, xcode.gettargettype(node), xcode.stringifySetting(node.name), xcode.stringifySetting(path.getname(node.cfg.buildtarget.bundlename ~= "" and node.cfg.buildtarget.bundlename or node.cfg.buildtarget.relpath)))
end end
-- is this a project dependency? -- is this a project dependency?
elseif node.parent.parent == tr.projects then elseif node.parent.parent == tr.projects then
@ -485,7 +455,7 @@
-- this works if we put it like below -- this works if we put it like below
local relpath = path.getrelative(path.getabsolute(tr.project.location), path.getabsolute(node.parent.project.location)) local relpath = path.getrelative(path.getabsolute(tr.project.location), path.getabsolute(node.parent.project.location))
_p(level,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = %s; path = %s; sourceTree = SOURCE_ROOT; };', _p(level,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = %s; path = %s; sourceTree = SOURCE_ROOT; };',
node.parent.id, node.name, customStringifySetting(node.parent.name), stringifySetting(path.join(relpath, node.parent.name))) node.parent.id, node.name, xcode.customStringifySetting(node.parent.name), xcode.stringifySetting(path.join(relpath, node.parent.name)))
end end
-- something else -- something else
else else
@ -537,7 +507,7 @@
--end --end
end end
_p(level,'%s /* %s */ = {isa = PBXFileReference; %s = %s; name = %s; path = %s; sourceTree = %s; };', _p(level,'%s /* %s */ = {isa = PBXFileReference; %s = %s; name = %s; path = %s; sourceTree = %s; };',
node.id, node.name, xcode.getfiletypekey(node, cfg), xcode.getfiletype(node, cfg), stringifySetting(node.name), stringifySetting(pth), stringifySetting(src)) node.id, node.name, xcode.getfiletypekey(node, cfg), xcode.getfiletype(node, cfg), xcode.stringifySetting(node.name), xcode.stringifySetting(pth), xcode.stringifySetting(src))
end end
end end
end end
@ -545,7 +515,7 @@
if not table.isempty(settings) then if not table.isempty(settings) then
_p('/* Begin PBXFileReference section */') _p('/* Begin PBXFileReference section */')
printSettingsTable(2, settings) xcode.printSettingsTable(2, settings)
_p('/* End PBXFileReference section */') _p('/* End PBXFileReference section */')
_p('') _p('')
end end
@ -623,7 +593,7 @@
if node.parent == tr.projects then if node.parent == tr.projects then
_p(3,'name = Products;') _p(3,'name = Products;')
else else
_p(3,'name = %s;', stringifySetting(node.name)) _p(3,'name = %s;', xcode.stringifySetting(node.name))
local vpath = project.getvpath(tr.project, node.name) local vpath = project.getvpath(tr.project, node.name)
@ -632,7 +602,7 @@
if node.parent.path then if node.parent.path then
p = path.getrelative(node.parent.path, node.path) p = path.getrelative(node.parent.path, node.path)
end end
_p(3,'path = %s;', stringifySetting(p)) _p(3,'path = %s;', xcode.stringifySetting(p))
end end
end end
@ -644,13 +614,13 @@
if not table.isempty(settings) then if not table.isempty(settings) then
_p('/* Begin PBXGroup section */') _p('/* Begin PBXGroup section */')
printSettingsTable(2, settings) xcode.printSettingsTable(2, settings)
_p('/* End PBXGroup section */') _p('/* End PBXGroup section */')
_p('') _p('')
end end
end end
local function xcode_GetBuildCommands(tr) function xcode.GetBuildCommands(tr)
local buildCommandInfos = {} local buildCommandInfos = {}
tree.traverse(tr, { tree.traverse(tr, {
onnode = function(node) onnode = function(node)
@ -716,7 +686,7 @@
return buildCommands return buildCommands
end end
local function xcode_PBXAggregateOrNativeTarget(tr, pbxTargetName) function xcode.PBXAggregateOrNativeTarget(tr, pbxTargetName)
local kinds = { local kinds = {
Aggregate = { Aggregate = {
"Utility", "Utility",
@ -741,7 +711,7 @@
_p('/* Begin PBX%sTarget section */', pbxTargetName) _p('/* Begin PBX%sTarget section */', pbxTargetName)
local buildCommands = xcode_GetBuildCommands(tr) local buildCommands = xcode.GetBuildCommands(tr)
for _, node in ipairs(tr.products.children) do for _, node in ipairs(tr.products.children) do
local name = tr.project.name local name = tr.project.name
@ -756,7 +726,7 @@
_p(2,'%s /* %s */ = {', node.targetid, name) _p(2,'%s /* %s */ = {', node.targetid, name)
_p(3,'isa = PBX%sTarget;', pbxTargetName) _p(3,'isa = PBX%sTarget;', pbxTargetName)
_p(3,'buildConfigurationList = %s /* Build configuration list for PBX%sTarget "%s" */;', node.cfgsection, pbxTargetName, escapeSetting(name)) _p(3,'buildConfigurationList = %s /* Build configuration list for PBX%sTarget "%s" */;', node.cfgsection, pbxTargetName, xcode.escapeSetting(name))
_p(3,'buildPhases = (') _p(3,'buildPhases = (')
if hasBuildCommands('prebuildcommands') then if hasBuildCommands('prebuildcommands') then
_p(4,'9607AE1010C857E500CD1376 /* Prebuild */,') _p(4,'9607AE1010C857E500CD1376 /* Prebuild */,')
@ -787,7 +757,7 @@
end end
_p(3,');') _p(3,');')
_p(3,'name = %s;', stringifySetting(name)) _p(3,'name = %s;', xcode.stringifySetting(name))
if pbxTargetName == "Native" then if pbxTargetName == "Native" then
local p local p
@ -797,14 +767,14 @@
p = "$(HOME)/Applications" p = "$(HOME)/Applications"
end end
if p then if p then
_p(3,'productInstallPath = %s;', stringifySetting(p)) _p(3,'productInstallPath = %s;', xcode.stringifySetting(p))
end end
end end
_p(3,'productName = %s;', stringifySetting(name)) _p(3,'productName = %s;', xcode.stringifySetting(name))
if pbxTargetName == "Native" then if pbxTargetName == "Native" then
_p(3,'productReference = %s /* %s */;', node.id, node.name) _p(3,'productReference = %s /* %s */;', node.id, node.name)
_p(3,'productType = %s;', stringifySetting(xcode.getproducttype(node))) _p(3,'productType = %s;', xcode.stringifySetting(xcode.getproducttype(node)))
end end
_p(2,'};') _p(2,'};')
end end
@ -814,12 +784,12 @@
function xcode.PBXAggregateTarget(tr) function xcode.PBXAggregateTarget(tr)
xcode_PBXAggregateOrNativeTarget(tr, "Aggregate") xcode.PBXAggregateOrNativeTarget(tr, "Aggregate")
end end
function xcode.PBXNativeTarget(tr) function xcode.PBXNativeTarget(tr)
xcode_PBXAggregateOrNativeTarget(tr, "Native") xcode.PBXAggregateOrNativeTarget(tr, "Native")
end end
@ -884,7 +854,7 @@
_p(2,'%s /* %s */ = {', node.id, node.name) _p(2,'%s /* %s */ = {', node.id, node.name)
_p(3,'isa = PBXReferenceProxy;') _p(3,'isa = PBXReferenceProxy;')
_p(3,'fileType = %s;', xcode.gettargettype(node)) _p(3,'fileType = %s;', xcode.gettargettype(node))
_p(3,'path = %s;', stringifySetting(node.name)) _p(3,'path = %s;', xcode.stringifySetting(node.name))
_p(3,'remoteRef = %s /* PBXContainerItemProxy */;', node.parent.productproxyid) _p(3,'remoteRef = %s /* PBXContainerItemProxy */;', node.parent.productproxyid)
_p(3,'sourceTree = BUILT_PRODUCTS_DIR;') _p(3,'sourceTree = BUILT_PRODUCTS_DIR;')
_p(2,'};') _p(2,'};')
@ -894,7 +864,7 @@
if not table.isempty(settings) then if not table.isempty(settings) then
_p('/* Begin PBXReferenceProxy section */') _p('/* Begin PBXReferenceProxy section */')
printSettingsTable(2, settings) xcode.printSettingsTable(2, settings)
_p('/* End PBXReferenceProxy section */') _p('/* End PBXReferenceProxy section */')
_p('') _p('')
end end
@ -959,7 +929,7 @@
_p(3,');'); _p(3,');');
_p(3,'runOnlyForDeploymentPostprocessing = 0;'); _p(3,'runOnlyForDeploymentPostprocessing = 0;');
_p(3,'shellPath = /bin/sh;'); _p(3,'shellPath = /bin/sh;');
_p(3,'shellScript = %s;', stringifySetting(table.concat(commands, '\n'))) _p(3,'shellScript = %s;', xcode.stringifySetting(table.concat(commands, '\n')))
_p(2,'};') _p(2,'};')
end end
end end
@ -1005,20 +975,20 @@
_p(level+1,'files = (') _p(level+1,'files = (')
_p(level+1,');') _p(level+1,');')
_p(level+1,'inputPaths = ('); _p(level+1,'inputPaths = (');
_p(level+2,'"%s",', escapeSetting(node.relpath)) _p(level+2,'"%s",', xcode.escapeSetting(node.relpath))
for v, _ in pairs(inputs) do for v, _ in pairs(inputs) do
_p(level+2,'"%s",', escapeSetting(project.getrelative(tr.project, v))) _p(level+2,'"%s",', xcode.escapeSetting(project.getrelative(tr.project, v)))
end end
_p(level+1,');') _p(level+1,');')
_p(level+1,'name = %s;', stringifySetting('Build "' .. node.name .. '"')) _p(level+1,'name = %s;', xcode.stringifySetting('Build "' .. node.name .. '"'))
_p(level+1,'outputPaths = (') _p(level+1,'outputPaths = (')
for v, _ in pairs(outputs) do for v, _ in pairs(outputs) do
_p(level+2,'"%s",', escapeSetting(project.getrelative (tr.project, v))) _p(level+2,'"%s",', xcode.escapeSetting(project.getrelative (tr.project, v)))
end end
_p(level+1,');') _p(level+1,');')
_p(level+1,'runOnlyForDeploymentPostprocessing = 0;'); _p(level+1,'runOnlyForDeploymentPostprocessing = 0;');
_p(level+1,'shellPath = /bin/sh;'); _p(level+1,'shellPath = /bin/sh;');
_p(level+1,'shellScript = %s;', stringifySetting(table.concat(commands, '\n'))) _p(level+1,'shellScript = %s;', xcode.stringifySetting(table.concat(commands, '\n')))
_p(level,'};') _p(level,'};')
end end
end end
@ -1030,7 +1000,7 @@
_p('/* Begin PBXShellScriptBuildPhase section */') _p('/* Begin PBXShellScriptBuildPhase section */')
wrapperWritten = true wrapperWritten = true
end end
printSettingsTable(2, settings) xcode.printSettingsTable(2, settings)
end end
doblock("9607AE3510C85E7E00CD1376", "Prelink", "prelinkcommands") doblock("9607AE3510C85E7E00CD1376", "Prelink", "prelinkcommands")
@ -1089,7 +1059,7 @@
if not table.isempty(settings) then if not table.isempty(settings) then
_p('/* Begin PBXVariantGroup section */') _p('/* Begin PBXVariantGroup section */')
printSettingsTable(2, settings) xcode.printSettingsTable(2, settings)
_p('/* End PBXVariantGroup section */') _p('/* End PBXVariantGroup section */')
_p('') _p('')
end end
@ -1103,7 +1073,7 @@
settings[node.parent.targetdependid] = function() settings[node.parent.targetdependid] = function()
_p(2,'%s /* PBXTargetDependency */ = {', node.parent.targetdependid) _p(2,'%s /* PBXTargetDependency */ = {', node.parent.targetdependid)
_p(3,'isa = PBXTargetDependency;') _p(3,'isa = PBXTargetDependency;')
_p(3,'name = %s;', stringifySetting(node.name)) _p(3,'name = %s;', xcode.stringifySetting(node.name))
_p(3,'targetProxy = %s /* PBXContainerItemProxy */;', node.parent.targetproxyid) _p(3,'targetProxy = %s /* PBXContainerItemProxy */;', node.parent.targetproxyid)
_p(2,'};') _p(2,'};')
end end
@ -1112,7 +1082,7 @@
if not table.isempty(settings) then if not table.isempty(settings) then
_p('/* Begin PBXTargetDependency section */') _p('/* Begin PBXTargetDependency section */')
printSettingsTable(2, settings) xcode.printSettingsTable(2, settings)
_p('/* End PBXTargetDependency section */') _p('/* End PBXTargetDependency section */')
_p('') _p('')
end end
@ -1182,13 +1152,13 @@
local filecfg = fileconfig.getconfig(node, cfg) local filecfg = fileconfig.getconfig(node, cfg)
if filecfg and filecfg.flags.ExcludeFromBuild then if filecfg and filecfg.flags.ExcludeFromBuild then
--fileNameList = fileNameList .. " " ..filecfg.name --fileNameList = fileNameList .. " " ..filecfg.name
table.insert(fileNameList, escapeArg(node.name)) table.insert(fileNameList, xcode.escapeArg(node.name))
end end
--ms new way --ms new way
-- if the file is not in this config file list excluded it from build !!! -- if the file is not in this config file list excluded it from build !!!
--if not cfg.files[node.abspath] then --if not cfg.files[node.abspath] then
-- table.insert(fileNameList, escapeArg(node.name)) -- table.insert(fileNameList, xcode.escapeArg(node.name))
--end --end
end end
end end
@ -1228,14 +1198,14 @@
--ms not by default ...add it manually if you need it --ms not by default ...add it manually if you need it
--settings['COMBINE_HIDPI_IMAGES'] = 'YES' --settings['COMBINE_HIDPI_IMAGES'] = 'YES'
overrideSettings(settings, cfg.xcodebuildsettings) xcode.overrideSettings(settings, cfg.xcodebuildsettings)
_p(2,'%s /* %s */ = {', cfg.xcode.targetid, cfg.buildcfg) _p(2,'%s /* %s */ = {', cfg.xcode.targetid, cfg.buildcfg)
_p(3,'isa = XCBuildConfiguration;') _p(3,'isa = XCBuildConfiguration;')
_p(3,'buildSettings = {') _p(3,'buildSettings = {')
printSettingsTable(4, settings) xcode.printSettingsTable(4, settings)
_p(3,'};') _p(3,'};')
printSetting(3, 'name', cfg.buildcfg); xcode.printSetting(3, 'name', cfg.buildcfg);
_p(2,'};') _p(2,'};')
end end
@ -1360,7 +1330,7 @@
local escapedDefines = { } local escapedDefines = { }
for i,v in ipairs(cfg.defines) do for i,v in ipairs(cfg.defines) do
escapedDefines[i] = escapeArg(v) escapedDefines[i] = xcode.escapeArg(v)
end end
settings['GCC_PREPROCESSOR_DEFINITIONS'] = escapedDefines settings['GCC_PREPROCESSOR_DEFINITIONS'] = escapedDefines
@ -1445,7 +1415,7 @@
for _, lib in ipairs(config.getlinks(cfg, "dependencies", "object")) do for _, lib in ipairs(config.getlinks(cfg, "dependencies", "object")) do
if (lib.external) then if (lib.external) then
if not xcode.isframework(lib.linktarget.basename) then if not xcode.isframework(lib.linktarget.basename) then
table.insert(flags, "-l" .. escapeArg(lib.linktarget.basename)) table.insert(flags, "-l" .. xcode.escapeArg(lib.linktarget.basename))
end end
end end
end end
@ -1472,14 +1442,14 @@
xcode.XCBuildConfiguration_SwiftLanguageVersion(settings, cfg) xcode.XCBuildConfiguration_SwiftLanguageVersion(settings, cfg)
overrideSettings(settings, cfg.xcodebuildsettings) xcode.overrideSettings(settings, cfg.xcodebuildsettings)
_p(2,'%s /* %s */ = {', cfg.xcode.projectid, cfg.buildcfg) _p(2,'%s /* %s */ = {', cfg.xcode.projectid, cfg.buildcfg)
_p(3,'isa = XCBuildConfiguration;') _p(3,'isa = XCBuildConfiguration;')
_p(3,'buildSettings = {') _p(3,'buildSettings = {')
printSettingsTable(4, settings) xcode.printSettingsTable(4, settings)
_p(3,'};') _p(3,'};')
printSetting(3, 'name', cfg.buildcfg); xcode.printSetting(3, 'name', cfg.buildcfg);
_p(2,'};') _p(2,'};')
end end
@ -1502,7 +1472,7 @@
if not table.isempty(settings) then if not table.isempty(settings) then
_p('/* Begin XCBuildConfiguration section */') _p('/* Begin XCBuildConfiguration section */')
printSettingsTable(0, settings) xcode.printSettingsTable(0, settings)
_p('/* End XCBuildConfiguration section */') _p('/* End XCBuildConfiguration section */')
_p('') _p('')
end end
@ -1511,7 +1481,7 @@
function xcode.XCBuildConfigurationList(tr) function xcode.XCBuildConfigurationList(tr)
local wks = tr.project.workspace local wks = tr.project.workspace
local defaultCfgName = stringifySetting(tr.configs[1].buildcfg) local defaultCfgName = xcode.stringifySetting(tr.configs[1].buildcfg)
local settings = {} local settings = {}
for _, target in ipairs(tr.products.children) do for _, target in ipairs(tr.products.children) do
@ -1542,6 +1512,6 @@
end end
_p('/* Begin XCConfigurationList section */') _p('/* Begin XCConfigurationList section */')
printSettingsTable(2, settings) xcode.printSettingsTable(2, settings)
_p('/* End XCConfigurationList section */') _p('/* End XCConfigurationList section */')
end end

View File

@ -173,6 +173,7 @@
filter "system:windows" filter "system:windows"
links { "ole32", "ws2_32", "advapi32", "version" } links { "ole32", "ws2_32", "advapi32", "version" }
files { "src/**.rc" }
filter "toolset:mingw" filter "toolset:mingw"
links { "crypt32" } links { "crypt32" }

View File

@ -161,9 +161,10 @@ int os_matchisfile(lua_State* L)
{ {
MatchInfo* m = (MatchInfo*)lua_touserdata(L, 1); MatchInfo* m = (MatchInfo*)lua_touserdata(L, 1);
#if defined(_DIRENT_HAVE_D_TYPE) #if defined(_DIRENT_HAVE_D_TYPE)
if (m->entry->d_type != DT_UNKNOWN) // Dirent marks symlinks as DT_LNK, not (DT_LNK|DT_DIR). The fallback handles symlinks using stat.
if (m->entry->d_type == DT_DIR)
{ {
lua_pushboolean(L, (m->entry->d_type == DT_DIR) == 0); lua_pushboolean(L, 0);
} }
else else
#endif #endif

View File

@ -68,6 +68,44 @@ int os_touchfile(lua_State* L)
// if destination exist, mark the file as modified // if destination exist, mark the file as modified
if (do_isfile(L, dst)) if (do_isfile(L, dst))
{ {
#if PLATFORM_WINDOWS
SYSTEMTIME systemTime;
FILETIME fileTime;
HANDLE fileHandle;
wchar_t wide_path[PATH_MAX];
if (MultiByteToWideChar(CP_UTF8, 0, dst, -1, wide_path, PATH_MAX) == 0)
{
lua_pushinteger(L, -1);
lua_pushstring(L, "unable to encode path");
return 2;
}
fileHandle = CreateFileW(wide_path, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (fileHandle == NULL)
{
lua_pushinteger(L, -1);
lua_pushfstring(L, "unable to touch file '%s'", dst);
return 2;
}
GetSystemTime(&systemTime);
if (SystemTimeToFileTime(&systemTime, &fileTime) == 0)
{
lua_pushinteger(L, -1);
lua_pushfstring(L, "unable to touch file '%s'", dst);
return 2;
}
if (SetFileTime(fileHandle, NULL, NULL, &fileTime) == 0)
{
lua_pushinteger(L, -1);
lua_pushfstring(L, "unable to touch file '%s'", dst);
return 2;
}
lua_pushinteger(L, 0);
return 1;
#else
if (truncate_file(dst)) if (truncate_file(dst))
{ {
lua_pushinteger(L, 0); lua_pushinteger(L, 0);
@ -77,6 +115,7 @@ int os_touchfile(lua_State* L)
lua_pushfstring(L, "unable to touch file '%s'", dst); lua_pushfstring(L, "unable to touch file '%s'", dst);
return 2; return 2;
} }
#endif
} }
#if PLATFORM_WINDOWS #if PLATFORM_WINDOWS

16
src/host/resource.h Normal file
View File

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by resource.rc
//
#define IDI_ICON1 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

107
src/host/resource.rc Normal file
View File

@ -0,0 +1,107 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "premake.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 5,0,0
PRODUCTVERSION 5,0,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Jason Perkins and the Premake Project"
VALUE "FileDescription", "Premake5"
VALUE "FileVersion", PREMAKE_VERSION
VALUE "LegalCopyright", PREMAKE_COPYRIGHT
VALUE "OriginalFilename", "premake5.exe"
VALUE "ProductName", "Premake5"
VALUE "ProductVersion", PREMAKE_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
//IDI_ICON1 ICON ""
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -55,6 +55,8 @@
test.isequal(responseCode, 418) test.isequal(responseCode, 418)
end end
-- Disable as httpbin.org returns 404 on this endpoint
--[[
function suite.http_redirect() function suite.http_redirect()
local result, err, responseCode = http.get("http://httpbin.org/redirect/3") local result, err, responseCode = http.get("http://httpbin.org/redirect/3")
if result then if result then
@ -63,6 +65,7 @@
test.fail(err); test.fail(err);
end end
end end
]]
function suite.http_headers() function suite.http_headers()
local result, err, responseCode = http.get("http://httpbin.org/headers", { local result, err, responseCode = http.get("http://httpbin.org/headers", {

View File

@ -124,6 +124,20 @@
test.istrue(table.contains(result, "folder/subfolder/hello.txt")) test.istrue(table.contains(result, "folder/subfolder/hello.txt"))
end end
function suite.matchfiles_onSymbolicLink()
if os.istarget("macosx")
or os.istarget("linux")
or os.istarget("solaris")
or os.istarget("bsd")
then
os.execute("cd folder && ln -s subfolder symlinkfolder && cd ..")
local result = os.matchfiles("folder/**/*.txt")
os.execute("rm folder/symlinkfolder")
premake.modules.self_test.print(table.tostring(result))
test.istrue(table.contains(result, "folder/symlinkfolder/hello.txt"))
end
end
-- --
-- os.pathsearch() tests -- os.pathsearch() tests