Exemplo n.º 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
Exemplo n.º 2
0
def create_project(name, inputs, extensions):
    project = Project(name, output_path_relative=name)

    with current_context() as ctx:
        single = ctx.get('vala.single') == 'true'

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

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

        # Compile
        executor = ValaGccCompile()
        executor.disable_warning('deprecated-declarations')
        Phase(project=project,
              name='compile',
              executor=executor,
              inputs_from=['transpile'],
              extensions=extensions)

        # Link
        Phase(project=project,
              name='link',
              executor=GccLink(),
              inputs_from=['compile'],
              extensions=extensions,
              output=name)
    else:
        # Build
        executor = ValaBuild()
        executor.enable_threads()
        executor.enable_experimental()
        executor.enable_deprecated()
        executor.target_glib('2.32')
        Phase(project=project,
              name='build',
              executor=executor,
              inputs=inputs,
              extensions=extensions,
              output=name)

    return project
Exemplo n.º 3
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)
Exemplo n.º 4
0
# Building Vala (or Genie) programs seems simple, and it indeed *is* simple if you just do a
# one-phase build. Behind the scenes, valac transpiles your Vala (or Genie) code to C and invokes
# gcc as a single-phase build, adding all the correct compile and link arguments assigned to the
# Vala packages (implemented in Ronin as "ValaPackage").
#
# Unfortunately, this single-phase build style is very slow for large projects, and does not support
# incremental builds. See build2.py for a much more efficient way of using Ronin to build Vala
# programs.
#

from ronin.cli import cli
from ronin.contexts import new_context
from ronin.phases import Phase
from ronin.projects import Project
from ronin.vala import ValaBuild, ValaPackage
from ronin.utils.paths import glob

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

    project = Project('Vala GTK+ Hello World')
    
    Phase(project=project,
          name='build',
          executor=ValaBuild(),
          inputs=glob('src/**/*.vala'),
          extensions=[ValaPackage('gtk+-3.0')],
          output='gtk-hello',
          run_output=1 if ctx.build.run else 0)
    
    cli(project)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 7
0
            executor.optimize(
                '2'
            )  # make sure we use '2' instead of the default 'g', as Apple's clang doesn't support this.
        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
Exemplo n.º 8
0
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
    Phase(project=project,
          name='compile',
          executor=ValaGccCompile(),
          inputs_from=['transpile'],
          extensions=extensions)
Exemplo n.º 9
0
                    encoding='utf8',
                    file_name='build',
                    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
Exemplo n.º 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)
Exemplo n.º 11
0
# 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, in Python 2 we need to import "unicode_literals" so that our literal
# strings be of type "unicode" rather than "str" (unnecessary in Python 3).
#
# That's pretty much all you need to do: Ronin creates the Ninja file in UTF-8 by default. (To
# change the encoding, set "ninja.encoding" in the context.)
#

from __future__ import unicode_literals
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('浪人 gcc Unicode Example')

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

    cli(project)
Exemplo n.º 12
0
from ronin.cli import cli
from ronin.contexts import new_context
from ronin.gcc import GccCompile, GccLink
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='build2') as ctx:

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

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

    # Link
    Phase(project=project,
          name='link',
          executor=GccLink(),
          inputs_from=['compile'],
          extensions=extensions,
          output='example_2',
          run_output=1 if ctx.build.run else 0)

    cli(project)
Exemplo n.º 13
0
#
# The gcc executors all support cross-compilation via "platform=", which could be the name of the
# platform variant ("linux64", etc.). But you can also use a project, as in this case.
#
# To test various builds, try "--variant linux64", "--variant linux32", "--variant win64",
# "--variant win32" in the command line. The project will configure itself according to the selected
# variant.
#
# Note that on Linux and MacOS you can run the Windows builds using WINE.
#

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('gcc Cross-compilation Example')

    Phase(project=project,
          name='build',
          executor=GccBuild(platform=project),
          inputs=glob('src/**/*.c'),
          output='size',
          run_output=1 if ctx.build.run else 0)

    cli(project)
Exemplo n.º 14
0
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.utils.paths import glob, join_path

with new_context() as ctx:

    project = Project('Installing Example')

    install_path = ctx.get('paths.install', join_path(ctx.paths.root,
                                                      'install'))

    Phase(project=project,
          name='build',
          executor=GccBuild(),
          inputs=glob('src/**/*.c'),
          output='size',
          run_output=1 if ctx.build.run else 0)

    if ctx.build.install:
        Phase(project=project,
              name='install',
              executor=Copy(),
              inputs_from=['build'],
              output_strip_prefix_from='build',
              output_path=install_path)

    cli(project)
Exemplo n.º 15
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)
Exemplo n.º 16
0
from ronin.gcc import GccBuild
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)
Exemplo n.º 17
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)
Exemplo n.º 18
0
from ronin.cli import cli
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
Exemplo n.º 19
0
    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)

    ard = Project(name='target build', variant="arm")

    ardCCompile = GccCompile(command='arm-none-eabi-gcc')
    ardCXXCompile = GccCompile(command='arm-none-eabi-g++')
Exemplo n.º 20
0
from ronin.contexts import new_context
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'],
Exemplo n.º 21
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)