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

Fix targetextension in xcode4 #1143

Merged
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
162 changes: 161 additions & 1 deletion modules/xcode/tests/test_xcode_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,51 @@
end


function suite.XCBuildConfigurationTarget_OnTargetExtension()
function suite.XCBuildConfigurationTarget_OnConsoleAppTargetExtension()
kind "ConsoleApp"
targetextension ".xyz"
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[MyProject.xyz: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.xyz;
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnConsoleAppNoTargetExtension()
kind "ConsoleApp"
targetextension ""
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_OnSharedLibTargetExtension()
kind "SharedLib"
targetextension ".xyz"
prepare()
Expand All @@ -1000,6 +1044,122 @@
end


function suite.XCBuildConfigurationTarget_OnSharedLibNoTargetExtension()
kind "SharedLib"
targetextension ""
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[libMyProject:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = bin/Debug;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EXECUTABLE_EXTENSION = "";
EXECUTABLE_PREFIX = lib;
GCC_DYNAMIC_NO_PIC = NO;
INSTALL_PATH = /usr/local/lib;
PRODUCT_NAME = MyProject;
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnStaticLibTargetExtension()
kind "StaticLib"
targetextension ".xyz"
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[libMyProject.xyz:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = bin/Debug;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EXECUTABLE_EXTENSION = xyz;
GCC_DYNAMIC_NO_PIC = NO;
INSTALL_PATH = /usr/local/lib;
PRODUCT_NAME = MyProject;
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnStaticLibNoTargetExtension()
kind "StaticLib"
targetextension ""
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[libMyProject:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = bin/Debug;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EXECUTABLE_EXTENSION = "";
GCC_DYNAMIC_NO_PIC = NO;
INSTALL_PATH = /usr/local/lib;
PRODUCT_NAME = MyProject;
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnWindowedAppTargetExtension()
kind "WindowedApp"
targetextension ".xyz"
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[MyProject.xyz: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 = "\"$(HOME)/Applications\"";
PRODUCT_NAME = MyProject;
WRAPPER_EXTENSION = xyz;
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnWindowedAppNoTargetExtension()
kind "WindowedApp"
targetextension ""
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 = "\"$(HOME)/Applications\"";
PRODUCT_NAME = MyProject;
WRAPPER_EXTENSION = "";
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnInfoPlist()
files { "./a/b/c/MyProject-Info.plist" }
prepare()
Expand Down
10 changes: 4 additions & 6 deletions modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,9 @@

-- is this the product node, describing the output target?
if node.kind == "product" then
local name = iif(tr.project.kind ~= "ConsoleApp", node.name, node.cfg.buildtarget.prefix .. node.cfg.buildtarget.basename)
settings[node.id] = function(level)
_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(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), stringifySetting(node.name), stringifySetting(path.getname(node.cfg.buildtarget.bundlename ~= "" and node.cfg.buildtarget.bundlename or node.cfg.buildtarget.relpath)))
end
-- is this a project dependency?
elseif node.parent.parent == tr.projects then
Expand Down Expand Up @@ -911,9 +910,8 @@
settings['EXECUTABLE_PREFIX'] = cfg.buildtarget.prefix
end

if cfg.kind ~= "ConsoleApp" and cfg.targetextension then
local ext = cfg.targetextension
ext = iif(ext:startswith('.'), ext:sub(2), ext)
if cfg.buildtarget.extension then
local ext = cfg.buildtarget.extension:sub(2)
if cfg.kind == "WindowedApp" and ext ~= "app" then
settings['WRAPPER_EXTENSION'] = ext
elseif (cfg.kind == "StaticLib" and ext ~= "a") or (cfg.kind == "SharedLib" and ext ~= "dylib") then
Expand Down Expand Up @@ -965,7 +963,7 @@
if not table.isempty(fileNameList) then
settings['EXCLUDED_SOURCE_FILE_NAMES'] = fileNameList
end
settings['PRODUCT_NAME'] = cfg.buildtarget.basename
settings['PRODUCT_NAME'] = iif(cfg.kind == "ConsoleApp" and cfg.buildtarget.extension, cfg.buildtarget.basename .. cfg.buildtarget.extension, cfg.buildtarget.basename)

if os.istarget(p.IOS) then
settings['SDKROOT'] = 'iphoneos'
Expand Down