Exemple #1
0
def generate_project(project_path, project_name):
    project = Project(project_name)
    extensions = [Package('opencv')]

    configure_gcc(gcc_command='g++', ccache=False)

    compile = Phase()
    compile.executor = GccCompile()
    compile.extensions += extensions
    compile.inputs = glob(project_path + '*.cpp')
    compile.executor.hooks.append(debug_hook)

    link = Phase()
    link.executor = GccLink()
    link.inputs_from.append(compile)
    link.extensions += extensions
    link.output = 'opencv'
    link.executor.hooks.append(debug_hook)
    if ctx.build.run:
        link.run_output = 1
        argv = str(ctx.get('args.argv'))
        print("Running with " + argv)
        to_run = ["{output}", argv]
        link.run_command = to_run

    project.phases['link'] = link
    project.phases['compile'] = compile
    return project
Exemple #2
0
from ronin.extensions import OutputsExtension
from ronin.phases import Phase
from ronin.projects import Project
from ronin.utils.paths import glob, input_path

with new_context() as ctx:

    # Library
    library = Project('gcc Multi-Project Example: Library', file_name='library')
    executor = GccBuild()
    executor.create_shared_library()
    executor.pic()
    Phase(project=library,
          name='build',
          executor=executor,
          inputs=glob('src/foo/**/*.c'),
          output='foo')
    
    # Main
    main = Project('Multi-Project Example: Main', file_name='main')
    executor = GccBuild()
    executor.add_include_path(input_path('src/foo'))
    executor.linker_rpath_origin() # to load the .so file from executable's directory
    Phase(project=main,
          name='build',
          executor=executor,
          inputs=glob('src/main/**/*.c'),
          extensions=[OutputsExtension(library, 'build')],
          output='main',
          run_output=1 if ctx.build.run else 0)
    
Exemple #3
0
from ronin.cli import cli
from ronin.contexts import new_context
from ronin.files import Copy
from ronin.gcc import GccBuild
from ronin.phases import Phase
from ronin.projects import Project
from ronin.sdl import SDL
from ronin.utils.paths import glob

with new_context() as ctx:

    project = Project('gcc SDL Hello World')

    static = (ctx.get('sdl.static') == 'true')

    Phase(project=project,
          name='build',
          executor=GccBuild(),
          inputs=glob('src/**/*.c'),
          extensions=[SDL(static=static)],
          output='hello',
          run_output=1 if ctx.build.run else 0)

    Phase(project=project,
          name='resource',
          executor=Copy(),
          input_path_relative='res',
          inputs=glob('res/**'))

    cli(project)
Exemple #4
0
from ronin.cli import cli
from ronin.contexts import new_context
from ronin.java import JavaCompile, Jar, JavaClasses
from ronin.phases import Phase
from ronin.projects import Project
from ronin.utils.paths import glob, input_path, join_path
from ronin.utils.platform import which

with new_context() as ctx:

    project = Project('Java Swing Hello World')

    # Compile
    Phase(project=project,
          name='compile',
          executor=JavaCompile(),
          input_path=join_path(ctx.paths.root, 'src'),
          inputs=glob('**/*.java'))

    # Jar
    Phase(project=project,
          name='jar',
          executor=Jar(manifest=input_path('MANIFEST.MF')),
          extensions=[JavaClasses(project, 'compile')],
          output='hello',
          run_output=1 if ctx.build.run else 0,
          run_command=[which('java'), '-jar', '{output}'])

    cli(project)
Exemple #5
0
#   Ubuntu: sudo apt install gcc ccache
#
# Rōnin supports Unicode.
#
# Note the magic "coding" comment at the top of this file, which tells Python to read the file in
# that encoding. Furthermore, we need to use the "u" prefix for literal strings that contain
# Unicode characters. That's pretty much all you need to do: the Ninja file is always created in
# UTF-8 by default. (To change its encoding, set "ninja.encoding" in the context.)
#

from ronin.cli import cli
from ronin.contexts import new_context
from ronin.gcc import GccBuild
from ronin.phases import Phase
from ronin.projects import Project
from ronin.utils.paths import glob

with new_context() as ctx:

    project = Project(u'浪人 gcc Unicode Example')

    Phase(
        project=project,
        name='build',  # cannot be Unicode!
        executor=GccBuild(),
        inputs=glob(u'ソース/**/*.c'),
        output='長さ',
        run_output=1 if ctx.build.run else 0)

    cli(project)
Exemple #6
0
#
# This is the simplest possible version, using a single build phase and all the defaults.
#
# A single build phase works fine, and may be the best solution for small projects. However, it does
# not make use of Ninja's ability to parallelize builds, and to track changes to individual files
# ("incremental" builds). Larger projects would generally build faster will a two-phase
# (compile/link) build. See build2.py for an example.
#

from ronin.cli import cli
from ronin.contexts import new_context
from ronin.gcc import GccBuild
from ronin.phases import Phase
from ronin.pkg_config import Package
from ronin.projects import Project
from ronin.utils.paths import glob

with new_context(output_path_relative='build1') as ctx:

    project = Project('gcc GTK+ Hello World')

    Phase(project=project,
          name='build',
          executor=GccBuild(),
          inputs=glob('src/**/*.c'),
          extensions=[Package('gtk+-3.0')],
          output='example_1',
          run_output=1 if ctx.build.run else 0)

    cli(project)
Exemple #7
0
        else:
            executor.enable_debug()
            executor.optimize('0')


with new_context() as ctx:
    project = Project('Genetic-Algo')
    # extensions = [Package('OpenCV')]
    extensions = []

    configure_gcc(gcc_command='g++', ccache=False)

    compile = Phase()
    compile.executor = GccCompile()
    compile.extensions += extensions
    compile.inputs = glob('**/*.cpp')
    compile.executor.hooks.append(debug_hook)
    compile.executor.enable_warning(value='all')

    link = Phase()
    link.executor = GccLink()
    link.inputs_from.append(compile)
    link.extensions += extensions
    link.output = 'gen-algo'
    link.executor.hooks.append(debug_hook)
    if ctx.build.run:
        link.run_output = 1

    project.phases['link'] = link
    project.phases['compile'] = compile
Exemple #8
0
# ValaPackage to make sure you configure your packages correctly for four-phase builds.
#

from ronin.cli import cli
from ronin.contexts import new_context
from ronin.gcc import GccLink
from ronin.phases import Phase
from ronin.projects import Project
from ronin.vala import ValaApi, ValaTranspile, ValaGccCompile, ValaPackage
from ronin.utils.paths import glob

with new_context(output_path_relative='build2') as ctx:

    project = Project('Vala GTK+ Hello World')

    inputs = glob('src/**/*.vala')
    extensions = [ValaPackage('gtk+-3.0')]

    # API
    executor = ValaApi()
    executor.enable_deprecated()
    Phase(project=project, name='api', executor=ValaApi(), inputs=inputs)

    # Transpile
    Phase(project=project,
          name='transpile',
          executor=ValaTranspile(apis=['api']),
          inputs=inputs,
          extensions=extensions)

    # Compile
Exemple #9
0
def glob_src(pattern):
    return \
        glob(pattern + '/*.gs') + \
        glob(pattern + '/*.vala')
Exemple #10
0
# "rebuild_on=" with the relevant source files.
#
# This example doesn't really make much use of Ronin, but shows how you can still integrate Cargo
# into a Ronin build script.
#
# Note that the first build will take a minute or two, because Cargo will download and build the
# GTK+ library and its many dependencies. Be patient. You can see them later in
# "target/[release/debug]/deps".
#

from ronin.cli import cli
from ronin.contexts import new_context
from ronin.phases import Phase
from ronin.projects import Project
from ronin.rust import CargoBuild
from ronin.utils.paths import input_path, glob

with new_context(output_path_relative='build2') as ctx:

    project = Project('Rust GTK+ Hello World')

    Phase(project=project,
          name='build',
          executor=CargoBuild(),
          inputs=[input_path('Cargo.toml')],
          rebuild_on=glob('src/hello2.rs'),
          output='hello2',
          run_output=1 if ctx.build.run else 0)

    cli(project)
Exemple #11
0
        Phase(project=project,
              name='build',
              executor=executor,
              inputs=inputs,
              extensions=extensions,
              output=name)

    return project


with new_context() as ctx:
    dependencies = Dependencies()

    khovsgold_inputs = \
        glob_src('src/server/**') + \
        glob('src/version.gs') + \
        glob('src/models.gs') + \
        glob('src/iterators.gs') + \
        glob('src/utilities.gs') + \
        glob_src('src/lib/logging/**') + \
        glob_src('src/lib/console/**') + \
        glob_src('src/lib/nap/**') + \
        glob_src('src/lib/json/**') + \
        glob_src('src/lib/avahi/**') + \
        glob_src('src/lib/sqlite/**') + \
        glob_src('src/lib/gstreamer/**') + \
        glob_src('src/lib/daemonize/**') + \
        glob_src('src/lib/system/**')

    khovsgold_extensions = [
        dependencies.libsoup, dependencies.gee, dependencies.json,
Exemple #12
0
def glob_src(pattern):
    return \
        glob(pattern + '/*.gs') + \
        glob(pattern + '/*.vala')
Exemple #13
0
        executor.target_glib('2.32')
        Phase(project=project,
              name='build',
              executor=executor,
              inputs=inputs,
              extensions=extensions,
              output=name)
    
    return project

with new_context() as ctx:
    dependencies = Dependencies()

    khovsgold_inputs = \
        glob_src('src/server/**') + \
        glob('src/version.gs') + \
        glob('src/models.gs') + \
        glob('src/iterators.gs') + \
        glob('src/utilities.gs') + \
        glob_src('src/lib/logging/**') + \
        glob_src('src/lib/console/**') + \
        glob_src('src/lib/nap/**') + \
        glob_src('src/lib/json/**') + \
        glob_src('src/lib/avahi/**') + \
        glob_src('src/lib/sqlite/**') + \
        glob_src('src/lib/gstreamer/**') + \
        glob_src('src/lib/daemonize/**') + \
        glob_src('src/lib/system/**')

    khovsgold_extensions = [
        dependencies.libsoup,
Exemple #14
0
                    columns=100,
                    strict=False)

    configure_gcc(gcc_command='gcc',
                  ccache=True,
                  ccache_path='/usr/lib/ccache')

    configure_pkg_config(pkg_config_command='pkg-config', pkg_config_path=None)

    project = Project('gcc GTK+ Hello World')
    extensions = [Package('gtk+-3.0')]

    # Compile
    comp = Phase()
    comp.executor = GccCompile()
    comp.inputs = glob('src/**/*.c')
    comp.extensions += extensions
    project.phases['compile'] = comp

    # Link
    link = Phase()
    link.executor = GccLink()
    link.inputs_from.append(comp)
    link.extensions += extensions
    link.output = 'example_1'
    if ctx.build.run:
        link.run_output = 1
    project.phases['link'] = link

    cli(project)
Exemple #15
0
# Rust comes with its own build system, Cargo, which is tightly integrated with the language.
# However, Ronin still provides basic Rust support, which can be useful in projects that combine
# Rust code with other languages.
#
# Note that if you want to easily use dependencies from crates.io, you will need to use Cargo.
# Unfortunately, Cargo cannot be used just to manage dependencies, so you will have to work
# entirely with Cargo.
#
# See build2.py for an example of integration with Cargo.
#

from ronin.cli import cli
from ronin.contexts import new_context
from ronin.phases import Phase
from ronin.projects import Project
from ronin.rust import RustBuild
from ronin.utils.paths import glob

with new_context(output_path_relative='build1') as ctx:

    project = Project('Rust Hello World')

    Phase(project=project,
          name='build',
          executor=RustBuild(),
          inputs=glob('src/hello1.rs'),
          output='hello1',
          run_output=1 if ctx.build.run else 0)

    cli(project)
Exemple #16
0
from ronin.contexts import new_context
from ronin.gcc import GccCompile, GccLink, GccBuild
from ronin.phases import Phase
from ronin.pkg_config import Package
from ronin.projects import Project
from ronin.utils.paths import glob, join_path

with new_context() as ctx:

    project = Project('Testing with Check')

    # Compile
    Phase(project=project,
          name='compile',
          executor=GccCompile(),
          inputs=glob('src/**/*.c'))
    project.phases['compile'].executor.pic()

    # Link program
    Phase(project=project,
          name='link_program',
          executor=GccLink(),
          inputs_from=['compile'],
          output='money',
          run_output=2 if ctx.build.run else 0)

    if ctx.build.test:
        tests_path = join_path(project.get_output_path('binary'), 'tests')

        # Link library
        Phase(project=project,
Exemple #17
0
                    columns=100,
                    strict=False)

    utproject = Project(name='Off-target unit tests', variant='ut')

    unittestextensions = [Package('gmock_main')]
    unittestextensions += [ExplicitExtension(libraries=['pthread'])]
    unittestcompile = GccCompile(command='/usr/bin/g++')
    unittestcompile.add_argument("-std=c++11")
    unittestcompile.add_argument("-ggdb")
    unittestcompile.add_include_path('src/unittests/')
    unittestcompile.add_include_path('src/robobo/')
    unittestcompile.add_include_path('src/FreeRTOS/')
    unittestcompile.define("ROBOBO_VERSION_STRING", "\'\"Robobo 0.1\"\'")
    unittestlink = GccLink(command='/usr/bin/g++')
    unittestsources = glob('src/unittests/*.cpp')
    unittestsources += glob('src/robobo/*.cpp')

    Phase(project=utproject,
          name='utcompile',
          executor=unittestcompile,
          extensions=unittestextensions,
          inputs=unittestsources)

    Phase(project=utproject,
          name='utlink',
          executor=unittestlink,
          inputs_from=['utcompile'],
          extensions=unittestextensions,
          output='unittests',
          run_output=1 if ctx.build.run else 0)
Exemple #18
0
from ronin.go import GoCompile, GoLink, GoPackage
from ronin.phases import Phase
from ronin.projects import Project
from ronin.utils.paths import glob

with new_context() as ctx:

    project = Project('Go Example')

    extensions = [GoPackage(project, 'compile_functions')]

    # Compile main package
    Phase(project=project,
          name='compile_main',
          executor=GoCompile(),
          inputs=glob('src/main.go'),
          extensions=extensions,
          output='main')

    # Compile functions package
    Phase(project=project,
          name='compile_functions',
          executor=GoCompile(),
          inputs=glob('src/functions.go'),
          output='ronin/functions')

    # Link
    Phase(project=project,
          name='link',
          executor=GoLink(),
          inputs_from=['compile_main'],
Exemple #19
0
#

from ronin.cli import cli
from ronin.contexts import new_context
from ronin.gcc import GccBuild
from ronin.phases import Phase
from ronin.pkg_config import Package
from ronin.projects import Project
from ronin.qt import QtMetaObjectCompile
from ronin.utils.paths import glob

with new_context() as ctx:

    project = Project('g++ Qt Hello World')

    Phase(project=project,
          name='meta',
          executor=QtMetaObjectCompile(),
          inputs=glob('src/**/*.h'))

    Phase(project=project,
          name='build',
          executor=GccBuild('g++'),
          inputs=glob('src/**/*.cpp'),
          inputs_from=['meta'],
          extensions=[Package('QtGui')],
          output='hello',
          run_output=1 if ctx.build.run else 0)

    cli(project)