libdirs = ['/lib:' + ','.join(conf.libdirs)] libs = ['/r:' + lib for lib in conf.libs] out = ['/out:' + exe_file] sources = ['/recurse:' + os.path.join(conf.srcdir, '*.cs')] if getattr(conf, 'debug', False): flags += ['/debug', '/define:DEBUG'] if getattr(conf, 'optimize', False): flags += ['/o'] run_program(CSC, flags + libdirs + libs + out + sources) @target(conf=conf) def run(conf): """ Runs the target executable. This target has no dependencies, so the program needs to be built first. """ os.chdir(conf.bindir) run_program(conf.name) #--------------------------------------- # SCRIPT #--------------------------------------- if __name__ == '__main__': pymake2()
for s in find_files(r'src\starburst\content\sound\music', [ '*.mp3', '*.wav' ]): f.write('/processor:SongProcessor' + '\n') f.write('/build:' + s + '\n') run_program(r'build\MonoGame\MGCB.exe', [ '/@:content.mgcb' ]) # Yes, MGCB is literally retarded. copy(r'bin\Content\src\starburst\content', r'bin\Content') delete_dir(r'bin\Content\src') copy('.', 'bin', '*map*.png') delete_file('content.mgcb') @target(conf=csc.conf) def libs(conf): copy(r'lib\MonoGame', conf.bindir, '*.dll') copy(r'lib\SharpDX', conf.bindir, '*.dll') pymake2({ 'name': 'Starburst.exe', 'flags': ['/define:GAMEPAD_VIBRATION', '/nologo', '/optimize', '/target:exe', '/platform:x64', '/warn:4' ], 'libdirs': csc.conf.libdirs + [ r'lib\MonoGame', r'lib\SharpDX' ], 'libs': [ 'MonoGame.Framework.dll', 'SharpDX.dll', 'SharpDX.XInput.dll' ] })
var_5 += '3' @target @depends_on('my_target_1', 'my_target_3') def my_target_4(conf): global var_4 var_4 += 1 global var_5 var_5 += '4' @target @depends_on('my_target_1', 'my_target_4') def my_target_5(conf): test.equal(var_1, 1, "target 1 made incorrect number of times") test.equal(var_2, 1, "target 2 made incorrect number of times") test.equal(var_3, 1, "target 3 made incorrect number of times") test.equal(var_4, 1, "target 4 made incorrect number of times") test.equal(var_5, '1234', "targets made in incorrect order") #--------------------------------------- # SCRIPT #--------------------------------------- pymake2({}, ['my_target_5']) test.success()
#--------------------------------------- # IMPORTS #--------------------------------------- import test from pymake2 import * #--------------------------------------- # FUNCTIONS #--------------------------------------- @target def my_target_1(conf): test.equal(conf.value, '123abc', "conf.value is incorrect") conf.value = 'xyz456' @target @depends_on('my_target_1') def my_target_2(conf): test.equal(conf.value, '123abc', "conf.value should be immutable") #--------------------------------------- # SCRIPT #--------------------------------------- pymake2({ 'value': '123abc' }, [ 'my_target_2' ]) test.success()
#!/usr/bin/env python #--------------------------------------- # IMPORTS #--------------------------------------- import test from pymake2 import * #--------------------------------------- # FUNCTIONS #--------------------------------------- @target def my_target(conf): # This target is not set to be the default target, so it should not be made. pass #--------------------------------------- # SCRIPT #--------------------------------------- test.should_fail() pymake2({}, []) test.success()
#!/usr/bin/env python #--------------------------------------- # IMPORTS #--------------------------------------- import test from pymake2 import * #--------------------------------------- # FUNCTIONS #--------------------------------------- @default_target def my_target(conf): test.equal(conf.abc, '123', "conf.abc should equal 123") test.success() #--------------------------------------- # SCRIPT #--------------------------------------- pymake2({}, [ "--conf={ 'abc' : '123' }" ])
#!/usr/bin/env python #--------------------------------------- # IMPORTS #--------------------------------------- import test from pymake2 import * #--------------------------------------- # SCRIPT #--------------------------------------- test.should_fail() pymake2({}, ['my_target']) test.success()
# FUNCTIONS #--------------------------------------- @target def my_target1(foo=None, bar=None): test.equal(foo, "123", "foo has wrong value 1") test.equal(bar, "abc", "bar has wrong value 1") global counter counter += 1 @target def my_target2(bar='789', foo="xyz"): test.equal(foo, "123", "foo has wrong value 2") test.equal(bar, "abc", "bar has wrong value 2") global counter counter += 1 #--------------------------------------- # SCRIPT #--------------------------------------- pymake2({"foo": "123", "bar": "abc"}, ['my_target1', 'my_target2']) test.equal(counter, 2, "both targets were not made properly") test.success()
'/target:library', '/platform:x64' ], 'libdirs': csc.conf.libdirs + [r'lib\SharpDX'], 'libs': [ 'PresentationCore.dll', 'System.IO.dll', 'System.Runtime.dll', 'WindowsBase.dll', 'SharpDX.D3DCompiler.dll', 'SharpDX.DXGI.dll', 'SharpDX.Direct3D11.dll', 'SharpDX.Mathematics.dll', 'SharpDX.XAudio2.dll', 'SharpDX.dll' ] } @default_target(depends=['compile', 'content', 'libs']) def all(conf): pass @target(conf=csc.conf) def content(conf): copy(r'assets\Content', conf.bindir + r'\Content') @target(conf=csc.conf) def libs(conf): copy(r'lib\SharpDX', conf.bindir, '*.dll') pymake2(conf)
#--------------------------------------- import test from pymake2 import * #--------------------------------------- # FUNCTIONS #--------------------------------------- @target @default_conf({'foo': '123'}) def my_target_1(conf): test.equal(conf.foo, '123', "conf.foo is incorrect") @target(conf={'foo': '123'}) def my_target_2(conf): test.equal(conf.foo, 'xyz', "conf.foo is incorrect") #--------------------------------------- # SCRIPT #--------------------------------------- pymake2({}, ['my_target_1']) pymake2({'foo': 'xyz'}, ['my_target_2']) test.success()
return srcfile = os.path.join(conf.srcdir, conf.srcfile) bibsrc = os.path.join(os.path.abspath(conf.srcdir), 'biblio.bib') bibdest = os.path.join(os.path.abspath(conf.bindir), 'biblio.bib') # Have to copy this file for this to work with MacTeX. copy(bibsrc, bibdest) cwd = os.getcwd() os.chdir(conf.bindir) run_program('bibtex', [conf.name]) delete_file('biblio.bib') os.chdir(cwd) atime = os.path.getatime(srcfile) mtime = os.path.getmtime(srcfile) os.utime(srcfile, (sys.maxint, sys.maxint)) pdflatex.compile(conf) os.utime(srcfile, (sys.maxint, sys.maxint)) pdflatex.compile(conf) # Restore access and modified times to not break the 'watch' target. os.utime(srcfile, (atime, mtime)) pymake2({'name': 'thesis', 'srcfile': 'main.tex'})