Exemple #1
0
 def _gen_ino_build_command(lib_dir_path, src_dir_path, build_dir_path):
     env = Environment()
     env.load()
     env.lib_dir = lib_dir_path
     env.src_dir = src_dir_path
     env.build_dir = build_dir_path
     return _Build(env)
Exemple #2
0
def main():
    e = Environment()
    e.load()

    conf = configure()

    try:
        current_command = sys.argv[1]
    except IndexError:
        current_command = None

    parser = argparse.ArgumentParser(prog='ino',
                                     formatter_class=FlexiFormatter,
                                     description=__doc__)
    subparsers = parser.add_subparsers()
    is_command = lambda x: inspect.isclass(x) and issubclass(x, Command
                                                             ) and x != Command
    commands = [
        cls(e) for _, cls in inspect.getmembers(ino.commands, is_command)
    ]
    for cmd in commands:
        p = subparsers.add_parser(cmd.name,
                                  formatter_class=FlexiFormatter,
                                  help=cmd.help_line)
        if current_command != cmd.name:
            continue
        cmd.setup_arg_parser(p)
        p.set_defaults(func=cmd.run, **conf.as_dict(cmd.name))

    args = parser.parse_args()

    try:
        run_anywhere = "init clean list-models serial"

        in_project_dir = os.path.isdir(e.src_dir)
        if not in_project_dir and current_command not in run_anywhere:
            raise Abort("No project found in this directory.")

        e.process_args(args)

        if current_command not in run_anywhere:
            # For valid projects create .build & lib
            if not os.path.isdir(e.build_dir):
                os.makedirs(e.build_dir)

            if not os.path.isdir(e.lib_dir):
                os.makedirs(e.lib_dir)
                with open('lib/.holder', 'w') as f:
                    f.write("")

        args.func(args)
    except Abort as exc:
        print colorize(str(exc), 'red')
        sys.exit(1)
    except KeyboardInterrupt:
        print 'Terminated by user'
    finally:
        e.dump()
def main(arguments=None, compiled_dir=""):
    if arguments is not None:
        sys.argv = arguments

    e = Environment()
    e.load()
    #e.output_dir = compiled_dir + ".build"

    conf = configure()

    try:
        current_command = sys.argv[1]
    except IndexError:
        current_command = None

    parser = argparse.ArgumentParser(prog='ino', formatter_class=FlexiFormatter, description=__doc__)
    subparsers = parser.add_subparsers()
    is_command = lambda x: inspect.isclass(x) and issubclass(x, Command) and x != Command
    commands = [cls(e) for _, cls in inspect.getmembers(ino.commands, is_command)]
    for cmd in commands:
        p = subparsers.add_parser(cmd.name, formatter_class=FlexiFormatter, help=cmd.help_line)
        if current_command != cmd.name:
            continue
        cmd.setup_arg_parser(p)
        p.set_defaults(func=cmd.run, **conf.as_dict(cmd.name))

    args = parser.parse_args()

    try:
        run_anywhere = "init clean list-models serial"

        in_project_dir = os.path.isdir(e.src_dir)
        if not in_project_dir and current_command not in run_anywhere:
            raise Abort("No project found in this directory.")

        e.process_args(args)

        if current_command not in run_anywhere:
            # For valid projects create .build & lib
            if not os.path.isdir(e.build_dir):                
                os.makedirs(e.build_dir)

            if not os.path.isdir(e.lib_dir):
                os.makedirs(e.lib_dir)
                with open('lib/.holder', 'w') as f:
                    f.write("")

        args.func(args)
    #except Abort as exc:
    #    print colorize(str(exc), 'red')
    #    sys.exit(1)
    except KeyboardInterrupt:
        print 'Terminated by user'
    finally:
        e.dump()
Exemple #4
0
def main():
    e = Environment()
    e.load()

    conf = configure()

    try:
        current_command = sys.argv[1]
    except IndexError:
        current_command = None

    parser = argparse.ArgumentParser(prog='ino',
                                     formatter_class=FlexiFormatter,
                                     description=__doc__)
    subparsers = parser.add_subparsers()
    is_command = lambda x: inspect.isclass(x) and issubclass(x, Command
                                                             ) and x != Command
    commands = [
        cls(e) for _, cls in inspect.getmembers(ino.commands, is_command)
    ]
    for cmd in commands:
        p = subparsers.add_parser(cmd.name,
                                  formatter_class=FlexiFormatter,
                                  help=cmd.help_line)
        if current_command != cmd.name:
            continue
        cmd.setup_arg_parser(p)
        p.set_defaults(func=cmd.run, **conf.as_dict(cmd.name))

    args = parser.parse_args()

    try:
        e.process_args(args)

        if current_command not in 'clean init' and not os.path.isdir(
                e.build_dir):
            os.makedirs(e.build_dir)

        args.func(args)
    except Abort as exc:
        print colorize(str(exc), 'red')
        sys.exit(1)
    except KeyboardInterrupt:
        print 'Terminated by user'
    finally:
        e.dump()
Exemple #5
0
def main():
    e = Environment()
    e.load()

    conf = configure()

    try:
        current_command = sys.argv[1]
    except IndexError:
        current_command = None

    parser = argparse.ArgumentParser(prog='ino-cocoduino', formatter_class=FlexiFormatter, description=__doc__)
    subparsers = parser.add_subparsers()
    is_command = lambda x: inspect.isclass(x) and issubclass(x, Command) and x != Command
    commands = [cls(e) for _, cls in inspect.getmembers(ino.commands, is_command)]
    for cmd in commands:
        p = subparsers.add_parser(cmd.name, formatter_class=FlexiFormatter, help=cmd.help_line)
        if current_command != cmd.name:
            continue
        cmd.setup_arg_parser(p)
        p.set_defaults(func=cmd.run, **conf.as_dict(cmd.name))

    args = parser.parse_args()

    try:
        e.process_args(args)

        if current_command not in 'clean' and not os.path.isdir(e.build_dir):
            os.mkdir(e.build_dir)

        args.func(args)
    except Abort as exc:
        print colorize(str(exc), 'red')
        sys.exit(1)
    except KeyboardInterrupt:
        print 'Terminated by user'
    finally:
        e.dump()
Exemple #6
0
import os.path, os
import argparse

from ino.commands import Init, Preprocess, Build as OldBuild, Clean, Upload, Serial, ListModels

from ino.utils import SpaceList, list_subdirs
from ino.conf import configure
from ino.exc import Abort
from ino.filters import colorize
from ino.environment import Environment
from ino.argparsing import FlexiFormatter


base_dir = os.path.realpath(os.getcwd())
environment = Environment()
environment.load()
# Override source directory name
environment.src_dir = 'thermocouple'
environment.extra_libs = [os.path.join(base_dir, environment.src_dir)]
environment.build_base = 'build'
environment.output_dir = os.path.join(environment.build_base, environment.src_dir)

class CleanAll(Clean):
    def __init__(self, environment):
        environment.output_dir = environment.build_base
        Clean.__init__(self, environment)


class Build(OldBuild):
    def scan_dependencies(self):
        src_dir = os.path.realpath(self.e.src_dir)