wscript 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #! /usr/bin/env python3
  2. import platform, sys
  3. top = '.'
  4. out = 'bin'
  5. plist_string = '''
  6. <?xml version="1.0" encoding="UTF-8"?>
  7. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  8. "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  9. <plist version="1.0">
  10. <dict>
  11. <key>CFBundleDevelopmentRegion</key>
  12. <string>English</string>
  13. <key>CFBundleExecutable</key>
  14. <string>{app_name}</string>
  15. <key>CFBundleIdentifier</key>
  16. <string>{bundle_domain}</string>
  17. <key>CFBundleVersion</key>
  18. <string>{bundle_version}</string>
  19. <key>MiscKey</key>
  20. <string>{env[PLATFORM_NAME]}</string>
  21. <key>CFBundleInfoDictionaryVersion</key>
  22. <string>6.0</string>
  23. <key>CFBundleName</key>
  24. <string>{bundle_name}</string>
  25. <key>CFBundlePackageType</key>
  26. <string>APPL</string>
  27. <key>CFBundleSignature</key>
  28. <string>????</string>
  29. </dict>
  30. </plist>
  31. '''
  32. plist_context = {
  33. 'bundle_domain': 'com.foo.bar.baz',
  34. 'app_name': 'macplist_test',
  35. 'bundle_version': '1.6.7'
  36. }
  37. expected_dict = {
  38. 'env': {
  39. 'PLATFORM_NAME': 'darwin'
  40. }
  41. }
  42. def options(opt):
  43. opt.load('compiler_c')
  44. def configure(conf):
  45. conf.load('compiler_c')
  46. def build(bld):
  47. # Only testing feature on Darwin
  48. if (platform.system() != 'Darwin'):
  49. return
  50. bld.env.PLATFORM_NAME = 'darwin'
  51. plist = {'bundle_name': 'InterpolatedPlistFileTest'}
  52. plist.update(plist_context)
  53. bld.path.make_node('Info.plist').write(plist_string)
  54. bld.program(
  55. features="c cprogram",
  56. target="InterpolatedPlistFileTest",
  57. source="src/main.c",
  58. mac_app=True,
  59. mac_plist="Info.plist",
  60. plist_context=plist)
  61. bld.add_post_fun(test1)
  62. plist = {'bundle_name': 'InterpolatedPlistStringTest'}
  63. plist.update(plist_context)
  64. bld.program(
  65. features="c cprogram",
  66. target="InterpolatedPlistStringTest",
  67. source="src/main.c",
  68. mac_app=True,
  69. mac_plist=plist_string,
  70. plist_context=plist)
  71. bld.add_post_fun(test2)
  72. bld.program(
  73. features="c cprogram",
  74. target="DefaultPlistTest",
  75. source="src/main.c",
  76. mac_app=True)
  77. bld.add_post_fun(test3)
  78. def assert_eq(expected, actual):
  79. exception_string = '''
  80. Expected `{expected}`
  81. but instead got `{actual}`
  82. '''
  83. if (expected != actual):
  84. raise Exception(exception_string.format(expected=expected,actual=actual))
  85. def test1(ctx):
  86. expected_plist = {'bundle_name': 'InterpolatedPlistFileTest'}
  87. expected_plist.update(plist_context)
  88. expected_plist.update(expected_dict)
  89. expected_plist = plist_string.format(**expected_plist)
  90. plist = ctx.path.make_node('bin/InterpolatedPlistFileTest.app/Contents/Info.plist').read()
  91. assert_eq(expected_plist, plist)
  92. def test2(ctx):
  93. expected_plist = {'bundle_name': 'InterpolatedPlistStringTest'}
  94. expected_plist.update(plist_context)
  95. expected_plist.update(expected_dict)
  96. expected_plist = plist_string.format(**expected_plist)
  97. plist = ctx.path.make_node('bin/InterpolatedPlistStringTest.app/Contents/Info.plist').read()
  98. assert_eq(expected_plist, plist)
  99. def test3(ctx):
  100. from waflib.Tools import c_osx
  101. expected_plist = {'app_name': 'DefaultPlistTest'}
  102. expected_plist = c_osx.app_info.format(**expected_plist)
  103. plist = ctx.path.make_node('bin/DefaultPlistTest.app/Contents/Info.plist').read()
  104. assert_eq(expected_plist, plist)