Skip to content

Commit f2061ea

Browse files
committed
Separate functionality for binary and bundle extensions
1 parent 903b3aa commit f2061ea

File tree

7 files changed

+75
-29
lines changed

7 files changed

+75
-29
lines changed

modules/xcode/tests/test_xcode_project.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,9 +1908,9 @@
19081908
end
19091909

19101910

1911-
function suite.XCBuildConfigurationTarget_OnWindowedAppTargetExtension()
1911+
function suite.XCBuildConfigurationTarget_OnWindowedAppTargetBundleExtension()
19121912
kind "WindowedApp"
1913-
targetextension ".xyz"
1913+
targetbundleextension ".xyz"
19141914
prepare()
19151915
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
19161916
test.capture [[
@@ -1931,9 +1931,9 @@
19311931
end
19321932

19331933

1934-
function suite.XCBuildConfigurationTarget_OnWindowedAppNoTargetExtension()
1934+
function suite.XCBuildConfigurationTarget_OnWindowedAppNoTargetBundleExtension()
19351935
kind "WindowedApp"
1936-
targetextension ""
1936+
targetbundleextension ""
19371937
prepare()
19381938
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
19391939
test.capture [[
@@ -1954,10 +1954,10 @@
19541954
end
19551955

19561956

1957-
function suite.XCBuildConfigurationTarget_OnOSXBundleTargetExtension()
1957+
function suite.XCBuildConfigurationTarget_OnOSXBundleTargetBundleExtension()
19581958
kind "SharedLib"
19591959
sharedlibtype "OSXBundle"
1960-
targetextension ".xyz"
1960+
targetbundleextension ".xyz"
19611961
prepare()
19621962
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
19631963
test.capture [[
@@ -1978,10 +1978,10 @@
19781978
end
19791979

19801980

1981-
function suite.XCBuildConfigurationTarget_OnOSXBundleNoTargetExtension()
1981+
function suite.XCBuildConfigurationTarget_OnOSXBundleNoTargetBundleExtension()
19821982
kind "SharedLib"
19831983
sharedlibtype "OSXBundle"
1984-
targetextension ""
1984+
targetbundleextension ""
19851985
prepare()
19861986
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
19871987
test.capture [[
@@ -2002,10 +2002,10 @@
20022002
end
20032003

20042004

2005-
function suite.XCBuildConfigurationTarget_OnOSXFrameworkTargetExtension()
2005+
function suite.XCBuildConfigurationTarget_OnOSXFrameworkTargetBundleExtension()
20062006
kind "SharedLib"
20072007
sharedlibtype "OSXFramework"
2008-
targetextension ".xyz"
2008+
targetbundleextension ".xyz"
20092009
prepare()
20102010
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
20112011
test.capture [[
@@ -2026,10 +2026,10 @@
20262026
end
20272027

20282028

2029-
function suite.XCBuildConfigurationTarget_OnOSXFrameworkNoTargetExtension()
2029+
function suite.XCBuildConfigurationTarget_OnOSXFrameworkNoTargetBundleExtension()
20302030
kind "SharedLib"
20312031
sharedlibtype "OSXFramework"
2032-
targetextension ""
2032+
targetbundleextension ""
20332033
prepare()
20342034
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
20352035
test.capture [[

modules/xcode/xcode_common.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@
12551255
settings['EXECUTABLE_PREFIX'] = cfg.buildtarget.prefix
12561256
end
12571257

1258-
if cfg.buildtarget.extension then
1258+
if cfg.buildtarget.bundleextension then
12591259
local exts = {
12601260
WindowedApp = "app",
12611261
SharedLib = "dylib",
@@ -1264,7 +1264,7 @@
12641264
OSXFramework = "framework",
12651265
XCTest = "xctest",
12661266
}
1267-
local ext = cfg.buildtarget.extension:sub(2)
1267+
local ext = iif(cfg.kind == "WindowedApp" or (cfg.kind == "SharedLib" and cfg.sharedlibtype), cfg.buildtarget.bundleextension:sub(2), cfg.buildtarget.extension:sub(2))
12681268
if ext ~= exts[iif(cfg.kind == "SharedLib" and cfg.sharedlibtype, cfg.sharedlibtype, cfg.kind)] then
12691269
if cfg.kind == "WindowedApp" or (cfg.kind == "SharedLib" and cfg.sharedlibtype) then
12701270
settings['WRAPPER_EXTENSION'] = ext

src/_premake_init.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,12 @@
11951195
kind = "boolean"
11961196
}
11971197

1198+
p.api.register {
1199+
name = "targetbundleextension",
1200+
scope = "config",
1201+
kind = "string"
1202+
}
1203+
11981204

11991205
-----------------------------------------------------------------------------
12001206
--
@@ -1402,22 +1408,22 @@
14021408
-- Add variations for other Posix-like systems.
14031409

14041410
filter { "system:darwin", "kind:WindowedApp" }
1405-
targetextension ".app"
1411+
targetbundleextension ".app"
14061412

14071413
filter { "system:darwin", "kind:SharedLib" }
14081414
targetextension ".dylib"
14091415

14101416
filter { "system:darwin", "kind:SharedLib", "sharedlibtype:OSXBundle" }
14111417
targetprefix ""
1412-
targetextension ".bundle"
1418+
targetbundleextension ".bundle"
14131419

14141420
filter { "system:darwin", "kind:SharedLib", "sharedlibtype:OSXFramework" }
14151421
targetprefix ""
1416-
targetextension ".framework"
1422+
targetbundleextension ".framework"
14171423

14181424
filter { "system:darwin", "kind:SharedLib", "sharedlibtype:XCTest" }
14191425
targetprefix ""
1420-
targetextension ".xctest"
1426+
targetbundleextension ".xctest"
14211427

14221428
-- Windows and friends.
14231429

src/base/config.lua

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,28 @@
4444
local prefix = cfg[field.."prefix"] or cfg.targetprefix or ""
4545
local suffix = cfg[field.."suffix"] or cfg.targetsuffix or ""
4646
local extension = cfg[field.."extension"] or cfg.targetextension or ""
47+
local bundleextension = cfg[field.."bundleextension"] or cfg.targetbundleextension or ""
4748

4849
local bundlename = ""
4950
local bundlepath = ""
5051

5152
if table.contains(os.getSystemTags(cfg.system), "darwin") and (kind == p.WINDOWEDAPP or (kind == p.SHAREDLIB and cfg.sharedlibtype)) then
52-
bundlename = basename .. extension
53+
bundlename = basename .. bundleextension
5354
bundlepath = path.join(bundlename, iif(kind == p.SHAREDLIB and cfg.sharedlibtype == "OSXFramework", "Versions/A", "Contents/MacOS"))
5455
end
5556

5657
local info = {}
57-
info.directory = directory
58-
info.basename = basename .. suffix
59-
info.name = prefix .. info.basename .. extension
60-
info.extension = extension
61-
info.abspath = path.join(directory, info.name)
62-
info.fullpath = info.abspath
63-
info.bundlename = bundlename
64-
info.bundlepath = path.join(directory, bundlepath)
65-
info.prefix = prefix
66-
info.suffix = suffix
58+
info.directory = directory
59+
info.basename = basename .. suffix
60+
info.name = prefix .. info.basename .. extension
61+
info.extension = extension
62+
info.bundleextension = bundleextension
63+
info.abspath = path.join(directory, info.name)
64+
info.fullpath = info.abspath
65+
info.bundlename = bundlename
66+
info.bundlepath = path.join(directory, bundlepath)
67+
info.prefix = prefix
68+
info.suffix = suffix
6769
return info
6870
end
6971

tests/config/test_targetinfo.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
system "MacOSX"
217217
i = prepare()
218218
test.isequal("bin/Debug/MyProject.app/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
219+
test.isequal("", i.extension)
219220
end
220221

221222

@@ -229,6 +230,7 @@
229230
system "macosx"
230231
i = prepare()
231232
test.isequal("bin/Debug/MyProject.bundle/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
233+
test.isequal(".dylib", i.extension)
232234
end
233235

234236
--
@@ -241,6 +243,7 @@
241243
system "macosx"
242244
i = prepare()
243245
test.isequal("bin/Debug/MyProject.xctest/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
246+
test.isequal(".dylib", i.extension)
244247
end
245248

246249

@@ -254,6 +257,7 @@
254257
system "macosx"
255258
i = prepare()
256259
test.isequal("bin/Debug/MyProject.framework/Versions/A", path.getrelative(os.getcwd(), i.bundlepath))
260+
test.isequal(".dylib", i.extension)
257261
end
258262

259263

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Specifies the bundle extension for the MacOSX bundle.
2+
3+
```lua
4+
targetbundleextension ("ext")
5+
```
6+
7+
By default, the project will use the MacOSX's normal naming conventions: .bundle for OSX Bundles, .framework for OSX Framework, and so on. The `targetbundleextension` function allows you to change this default.
8+
9+
### Parameters ###
10+
11+
`ext` is the new bundle extension, including the leading dot.
12+
13+
### Applies To ###
14+
15+
Project configurations.
16+
17+
### Availability ###
18+
19+
Premake 5.0 beta 7 or later.
20+
21+
### Examples ###
22+
23+
```lua
24+
targetbundleextension ".zmf"
25+
```
26+
27+
### See Also ###
28+
29+
* [targetextension](targetextension.md)
30+
* [targetname](targetname.md)
31+
* [targetdir](targetdir.md)
32+
* [targetprefix](targetprefix.md)
33+
* [targetsuffix](targetsuffix.md)

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ module.exports = {
263263
'systemversion',
264264
'tags',
265265
'tailcalls',
266+
'targetbundleextension',
266267
'targetdir',
267268
'targetextension',
268269
'targetname',

0 commit comments

Comments
 (0)