diff --git a/tests/macplist/src/main.c b/tests/macplist/src/main.c
new file mode 100644
index 00000000..691b6bba
--- /dev/null
+++ b/tests/macplist/src/main.c
@@ -0,0 +1,3 @@
+int main(int argc, const char** argv) {
+ return 0;
+}
diff --git a/tests/macplist/wscript b/tests/macplist/wscript
new file mode 100644
index 00000000..4973f1e9
--- /dev/null
+++ b/tests/macplist/wscript
@@ -0,0 +1,124 @@
+#! /usr/bin/env python3
+
+import platform, sys
+
+top = '.'
+out = 'bin'
+
+plist_string = '''
+
+
+
+
+ CFBundleDevelopmentRegion
+ English
+ CFBundleExecutable
+ {app_name}
+
+ CFBundleIdentifier
+ {bundle_domain}
+
+ CFBundleVersion
+ {bundle_version}
+
+ MiscKey
+ {env[PLATFORM_NAME]}
+
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ {bundle_name}
+
+ CFBundlePackageType
+ APPL
+
+ CFBundleSignature
+ ????
+
+
+'''
+
+plist_context = {
+ 'bundle_domain': 'com.foo.bar.baz',
+ 'app_name': 'macplist_test',
+ 'bundle_version': '1.6.7'
+}
+expected_dict = {
+ 'env': {
+ 'PLATFORM_NAME': 'darwin'
+ }
+}
+
+def options(opt):
+ opt.load('compiler_c')
+
+def configure(conf):
+ conf.load('compiler_c')
+
+def build(bld):
+ # Only testing feature on Darwin
+ if (platform.system() != 'Darwin'):
+ return
+ bld.env.PLATFORM_NAME = 'darwin'
+ plist = {'bundle_name': 'InterpolatedPlistFileTest'}
+ plist.update(plist_context)
+ bld.path.make_node('Info.plist').write(plist_string)
+ bld.program(
+ features="c cprogram",
+ target="InterpolatedPlistFileTest",
+ source="src/main.c",
+ mac_app=True,
+ mac_plist="Info.plist",
+ plist_context=plist)
+ bld.add_post_fun(test1)
+
+ plist = {'bundle_name': 'InterpolatedPlistStringTest'}
+ plist.update(plist_context)
+ bld.program(
+ features="c cprogram",
+ target="InterpolatedPlistStringTest",
+ source="src/main.c",
+ mac_app=True,
+ mac_plist=plist_string,
+ plist_context=plist)
+ bld.add_post_fun(test2)
+
+ bld.program(
+ features="c cprogram",
+ target="DefaultPlistTest",
+ source="src/main.c",
+ mac_app=True)
+ bld.add_post_fun(test3)
+
+def assert_eq(expected, actual):
+ exception_string = '''
+Expected `{expected}`
+but instead got `{actual}`
+'''
+ if (expected != actual):
+ raise Exception(exception_string.format(expected=expected,actual=actual))
+
+def test1(ctx):
+ expected_plist = {'bundle_name': 'InterpolatedPlistFileTest'}
+ expected_plist.update(plist_context)
+ expected_plist.update(expected_dict)
+ expected_plist = plist_string.format(**expected_plist)
+ plist = ctx.path.make_node('bin/InterpolatedPlistFileTest.app/Contents/Info.plist').read()
+ assert_eq(expected_plist, plist)
+
+
+def test2(ctx):
+ expected_plist = {'bundle_name': 'InterpolatedPlistStringTest'}
+ expected_plist.update(plist_context)
+ expected_plist.update(expected_dict)
+ expected_plist = plist_string.format(**expected_plist)
+ plist = ctx.path.make_node('bin/InterpolatedPlistStringTest.app/Contents/Info.plist').read()
+ assert_eq(expected_plist, plist)
+
+def test3(ctx):
+ from waflib.Tools import c_osx
+ expected_plist = {'app_name': 'DefaultPlistTest'}
+ expected_plist = c_osx.app_info.format(**expected_plist)
+ plist = ctx.path.make_node('bin/DefaultPlistTest.app/Contents/Info.plist').read()
+ assert_eq(expected_plist, plist)
diff --git a/waflib/Tools/c_osx.py b/waflib/Tools/c_osx.py
index a2f62412..8eac6c97 100644
--- a/waflib/Tools/c_osx.py
+++ b/waflib/Tools/c_osx.py
@@ -24,7 +24,7 @@ app_info = '''
NOTE
THIS IS A GENERATED FILE, DO NOT MODIFY
CFBundleExecutable
- %s
+ {app_name}
'''
@@ -127,6 +127,14 @@ def create_task_macplist(self):
dir = self.create_bundle_dirs(name, out)
n1 = dir.find_or_declare(['Contents', 'Info.plist'])
self.plisttask = plisttask = self.create_task('macplist', [], n1)
+ plisttask.context = {
+ 'app_name': self.link_task.outputs[0].name,
+ 'env': self.env
+ }
+
+ plist_ctx = getattr(self, 'plist_context', None)
+ if (plist_ctx):
+ plisttask.context.update(plist_ctx)
if getattr(self, 'mac_plist', False):
node = self.path.find_resource(self.mac_plist)
@@ -135,7 +143,7 @@ def create_task_macplist(self):
else:
plisttask.code = self.mac_plist
else:
- plisttask.code = app_info % self.link_task.outputs[0].name
+ plisttask.code = app_info
inst_to = getattr(self, 'install_path', '/Applications') + '/%s/Contents/' % name
self.bld.install_files(inst_to, n1)
@@ -184,5 +192,6 @@ class macplist(Task.Task):
txt = self.code
else:
txt = self.inputs[0].read()
+ context = getattr(self, 'context', {})
+ txt = txt.format(**context)
self.outputs[0].write(txt)
-