Example #1
0
from pymake3 import *

#---------------------------------------
# GLOBALS
#---------------------------------------

var = 0

#---------------------------------------
# FUNCTIONS
#---------------------------------------


@target
def my_target(conf):
    global var
    var += 1


#---------------------------------------
# SCRIPT
#---------------------------------------

pymake3({}, ['my_target'])
pymake3({}, ['my_target'])
pymake3({}, ['my_target'])

test.equal(var, 3, "my_target was not made three times")
test.success()
Example #2
0
# 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
#---------------------------------------

pymake3({"foo": "123", "bar": "abc"}, ['my_target1', 'my_target2'])

test.equal(counter, 2, "both targets were not made properly")
test.success()
Example #3
0
    create_dir(conf.bindir)
    create_dir(conf.objdir)

    options = (['/nologo'] + conf.cflags +
               ['/Fe' + os.path.join(conf.bindir, conf.name)] +
               ['/Fo' + conf.objdir + '\\'] +
               ['/I' + s for s in conf.includepaths] +
               find_files(conf.srcdir, '*.c') + conf.libs + ['/link'] +
               conf.lflags + ['/LIBPATH:' + s for s in conf.libpaths])

    run_program(CL, options)


@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__':
    pymake3()
#---------------------------------------

import test

from pymake3 import *

#---------------------------------------
# FUNCTIONS
#---------------------------------------


@target(name='my_target')
def my_target1(conf):
    pass


@target(name='my_target')
def my_target2(conf):
    pass


#---------------------------------------
# SCRIPT
#---------------------------------------

test.should_fail()

pymake3({}, [])

test.success()
Example #5
0
         '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(conf=csc.conf)
@depends_on('compile', 'content', 'libs')
def all(conf):
    # The 'all' target doesn't need to do anything - it just depends on other
    # relevant targets to make.
    pass

@target(conf=csc.conf)
def content(conf):
    # Copy 'res' folder to 'Content' folder in the bin directory.
    copy('res', os.path.join(conf.bindir, 'Content'))

@target(conf=csc.conf)
def libs(conf):
    # Copy the SharpDX dll-files to the bin directory.
    copy(r'lib\SharpDX', conf.bindir, '*.dll')

pymake3(conf)
Example #6
0
#---------------------------------------

import test

from pymake3 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
#---------------------------------------

pymake3({}, ['my_target_1'])
pymake3({'foo': 'xyz'}, ['my_target_2'])

test.success()
Example #7
0
import test

from pymake3 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
#---------------------------------------

pymake3({'value': '123abc'}, ['my_target_2'])

test.success()
Example #8
0
#!/usr/bin/python3

#---------------------------------------
# IMPORTS
#---------------------------------------

import test

from pymake3 import *

#---------------------------------------
# FUNCTIONS
#---------------------------------------


@default_target
def my_target(conf):
    test.equal(conf.abc, '123', "conf.abc should equal 123")
    test.success()


#---------------------------------------
# SCRIPT
#---------------------------------------

pymake3({}, ["--conf={ 'abc' : '123' }"])
#---------------------------------------


@target
@depends_on('my_target_3')
def my_target_1(conf):
    pass


@target
@depends_on('my_target_1')
def my_target_2(conf):
    pass


@target
@depends_on('my_target_2')
def my_target_3(conf):
    pass


#---------------------------------------
# SCRIPT
#---------------------------------------

test.should_fail()

pymake3({}, ['my_target_3'])

test.success()
Example #10
0
#---------------------------------------
# SCRIPT
#---------------------------------------

# The configuration below depends on the backend used for the make process.  In
# this case, we're using csc, which uses the options set below, among others.
pymake3({ 'name': 'HelloWorld.exe',

         # Flags to pass to the compiler.
         'flags': ['/nologo',
                   '/optimize',
                   '/target:exe',
                   '/platform:anycpu'],

         'libdirs': [ r'C:\Windows\Microsoft.NET\Framework64\v4.0.30319' ],

         # These are the libraries referenced by the program.  We can also add
         # the libdirs setting to add directories to look in for libraries
         # during compilation.
         'libs': [ 'System.dll' ],

         # Output the executable into the current directory. If we changed this
         # to 'bin', a directory named bin would be created, and the compiled
         # executable would be stored in it.
         'bindir': '.',

         # We have our source files in the current directory in this example.
         # More source could be added in the source directory, and they would
         # all beautomatically compiled by pymake3.
         'srcdir': '.' })