diff --git a/modules/xcode/tests/test_xcode_project.lua b/modules/xcode/tests/test_xcode_project.lua index 4ab997f229..b2601dd3f5 100644 --- a/modules/xcode/tests/test_xcode_project.lua +++ b/modules/xcode/tests/test_xcode_project.lua @@ -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() @@ -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() diff --git a/modules/xcode/xcode_common.lua b/modules/xcode/xcode_common.lua index ba1b9d757e..7c7ae30fb5 100644 --- a/modules/xcode/xcode_common.lua +++ b/modules/xcode/xcode_common.lua @@ -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 @@ -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 @@ -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'