waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

wscript (3133B)


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