diff --git a/modules/codelite/codelite_project.lua b/modules/codelite/codelite_project.lua index d9c1700f6..df442d1f2 100755 --- a/modules/codelite/codelite_project.lua +++ b/modules/codelite/codelite_project.lua @@ -235,7 +235,7 @@ end local toolset = m.getcompiler(cfg) - local flags = table.join(toolset.getldflags(cfg), toolset.getincludedirs(cfg, {}, nil, cfg.frameworkdirs), toolset.getrunpathdirs(cfg, table.join(cfg.runpathdirs, config.getsiblingtargetdirs(cfg))), cfg.linkoptions, toolset.getlinks(cfg)) + local flags = table.join(toolset.getldflags(cfg), toolset.getincludedirs(cfg, {}, nil, cfg.frameworkdirs), toolset.getrunpathdirs(cfg, table.join(cfg.runpathdirs, config.getsiblingtargetdirs(cfg))), toolset.getSections(cfg), cfg.linkoptions, toolset.getlinks(cfg)) _x(3, '', table.concat(flags, ";")) diff --git a/modules/gmake/gmake_cpp.lua b/modules/gmake/gmake_cpp.lua index a546f28de..e38158d1e 100644 --- a/modules/gmake/gmake_cpp.lua +++ b/modules/gmake/gmake_cpp.lua @@ -456,7 +456,7 @@ function cpp.ldFlags(cfg, toolset) - local flags = table.join(toolset.getLibraryDirectories(cfg), toolset.getrunpathdirs(cfg, table.join(cfg.runpathdirs, config.getsiblingtargetdirs(cfg))), toolset.getldflags(cfg), cfg.linkoptions) + local flags = table.join(toolset.getLibraryDirectories(cfg), toolset.getrunpathdirs(cfg, table.join(cfg.runpathdirs, config.getsiblingtargetdirs(cfg))), toolset.getSections(cfg), toolset.getldflags(cfg), cfg.linkoptions) p.outln('ALL_LDFLAGS += $(LDFLAGS)' .. gmake.list(flags)) end diff --git a/modules/ninja/ninja_cpp.lua b/modules/ninja/ninja_cpp.lua index 62540da11..13c71723f 100644 --- a/modules/ninja/ninja_cpp.lua +++ b/modules/ninja/ninja_cpp.lua @@ -528,7 +528,10 @@ function m.getLdFlags(cfg, toolset) local libdirs = toolset.getLibraryDirectories(cfg) flags = table.join(flags, libdirs) - + + local sections = toolset.getSections(cfg) + flags = table.join(flags, sections) + if toolset.getrunpathdirs then local runpathdirs = table.join(cfg.runpathdirs, config.getsiblingtargetdirs(cfg)) local rpaths = toolset.getrunpathdirs(cfg, runpathdirs) diff --git a/modules/xcode/tests/test_xcode_project.lua b/modules/xcode/tests/test_xcode_project.lua index 8172ff260..5759f5e2a 100644 --- a/modules/xcode/tests/test_xcode_project.lua +++ b/modules/xcode/tests/test_xcode_project.lua @@ -2130,6 +2130,28 @@ ]] end + function suite.XCBuildConfigurationTarget_infoplist() + files { "./a/b/c/MyProject-Info.plist" } + infoplist "./a/b/c/Override.plist" + prepare() + xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1]) + test.capture [[ + 0141F3FC0D9EB3163D17DF0F /* 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; + INFOPLIST_FILE = a/b/c/Override.plist; + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = MyProject; + }; + name = Debug; + }; + ]] + end + function suite.XCBuildConfigurationTarget_OnSymbols() symbols "On" diff --git a/modules/xcode/xcode_common.lua b/modules/xcode/xcode_common.lua index 6cadd01d2..3f8361508 100644 --- a/modules/xcode/xcode_common.lua +++ b/modules/xcode/xcode_common.lua @@ -1359,6 +1359,10 @@ end end + if cfg.infoplist then + settings["INFOPLIST_FILE"] = p.tools.getrelative(cfg.project, cfg.infoplist) + end + --ms not by default ...add it manually if you need it --settings['COMBINE_HIDPI_IMAGES'] = 'YES' diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 672e440be..3c9aeff70 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -408,6 +408,13 @@ tokens = true, } + api.register { + name = "infoplist", + scope = "config", + kind = "path", + tokens = true, + } + api.register { name = "bindirs", scope = "config", diff --git a/src/tools/clang.lua b/src/tools/clang.lua index 0a5ce84d6..f353219c5 100644 --- a/src/tools/clang.lua +++ b/src/tools/clang.lua @@ -242,6 +242,7 @@ clang.getstructuredimplicitincludedirs = gcc.getstructuredimplicitincludedirs clang.getrunpathdirs = gcc.getrunpathdirs + clang.getSections = gcc.getSections -- -- get the right output flag. diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 26658ef49..354d1f4ff 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -533,6 +533,19 @@ end -- +-- get the link-time file embedding flags +-- + function gcc.getSections(cfg) + local result = {} + if table.contains(os.getSystemTags(cfg.system), "darwin") then + if cfg.infoplist then + local relative = p.tools.getrelative(cfg.project, cfg.infoplist) + table.insert(result, "-Wl,-sectcreate,__TEXT,__info_plist," .. p.quoted(relative)) + end + end + return result + end +-- -- get the right output flag. -- function gcc.getsharedlibarg(cfg) diff --git a/src/tools/msc.lua b/src/tools/msc.lua index ffb7b579f..65afc873d 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -314,6 +314,10 @@ return {} end + function msc.getSections() + return {} + end + -- -- Decorate include file search paths for the MSVC command line. -- diff --git a/src/tools/snc.lua b/src/tools/snc.lua index 886d8fe5d..a49539f19 100644 --- a/src/tools/snc.lua +++ b/src/tools/snc.lua @@ -110,6 +110,7 @@ snc.getstructuredincludedirs = gcc.getstructuredincludedirs snc.getstructuredimplicitincludedirs = gcc.getstructuredimplicitincludedirs snc.getrunpathdirs = gcc.getrunpathdirs + snc.getSections = gcc.getSections snc.getLibraryDirectories = gcc.getLibraryDirectories snc.getlinks = gcc.getlinks diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index 8551f71e0..69e527cc3 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -1550,6 +1550,35 @@ end test.contains({ "-Wl,-rpath,'/usr/local/lib/mylibs'" }, gcc.getrunpathdirs(cfg, paths)) end +-- +-- Check Info.plist embedding on Apple platforms. +-- + function suite.onMacOSXInfoPlist() + system "MacOSX" + infoplist "./MyInfo.plist" + + prepare() + + local actual = gcc.getSections(cfg) + local expected = "-Wl,-sectcreate,__TEXT,__info_plist,MyInfo.plist" + test.contains({expected}, actual) + end + + function suite.notOnMacOSXInfoPlist() + system "Linux" + infoplist "./MyInfo.plist" + + prepare() + + local actual = gcc.getSections(cfg) + local notExpected = "-Wl,-sectcreate,__TEXT,__info_plist,MyInfo.plist" + test.excludes({notExpected}, actual) + --test.contains ("", "") + --test.contains ("", "") + end + + + -- -- Make sure unicode support is handled properly. -- @@ -1594,4 +1623,4 @@ end characterset "Unicode" prepare() test.excludes({ "-municode" }, gcc.getldflags(cfg)) - end \ No newline at end of file + end diff --git a/website/docs/Project-API.md b/website/docs/Project-API.md index 3a6405575..f314cc8a2 100644 --- a/website/docs/Project-API.md +++ b/website/docs/Project-API.md @@ -96,6 +96,7 @@ | [includedirs](includedirs.md) | | | [includedirsafter](includedirsafter.md) | | | [includeexternal](globals/includeexternal.md) | | +| [infoplist](infoplist.md) | Sets the Apple ap bundle infos. | | [inlining](inlining.md) | Tells the compiler when it should inline functions | | [intrinsics](intrinsics.md) | | | [kind](kind.md) | | diff --git a/website/docs/infoplist.md b/website/docs/infoplist.md new file mode 100644 index 000000000..95176c838 --- /dev/null +++ b/website/docs/infoplist.md @@ -0,0 +1,35 @@ +Sets the application bundle information file for any Apple platform application. + +```lua +infoplist ("path") +``` + +When generating Xcode action, this command will override the auto-detected Info.plist from the project file list. + +When used in Console application projects, the Info.plist is embedded in the application binary using Apple toolchain specific linker flags. + +### Parameters ### + +`path` is the file system path to the Apple property list file to use as Info.plist. + +### Applies To ### + +Project configurations. + +### Availability ### + +Premake 5.0 or later for Apple platform applications. + +### Examples ### + +This project defines a default Info.plist and a different one for the Debug configuration. + +```lua +project "MyProject" + + infoplist "Default.plist" + + filter { "configurations:Debug" } + infoplist "DebugInfo.plist" +``` + diff --git a/website/sidebars.js b/website/sidebars.js index 200fc2296..a2b5c2186 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -176,6 +176,7 @@ module.exports = { 'includedirsafter', 'incrementallink', 'inheritdependencies', + 'infoplist', 'inlinesvisibility', 'inlining', 'intrinsics',