コード例 #1
0
    def __init__(self,
                 project,
                 includepaths=[],
                 dependlibs=[],
                 libpaths=[],
                 variables=None):
        parser = argparse.ArgumentParser(description='Ninja build generator')
        parser.add_argument('-t',
                            '--target',
                            help='Target platform',
                            choices=platform.supported_platforms())
        parser.add_argument('--host',
                            help='Host platform',
                            choices=platform.supported_platforms())
        parser.add_argument('--toolchain',
                            help='Toolchain to use',
                            choices=toolchain.supported_toolchains())
        parser.add_argument('-c',
                            '--config',
                            action='append',
                            help='Build configuration',
                            choices=['debug', 'release', 'profile', 'deploy'],
                            default=[])
        parser.add_argument('-a',
                            '--arch',
                            action='append',
                            help='Add architecture',
                            choices=toolchain.supported_architectures(),
                            default=[])
        parser.add_argument('-i',
                            '--includepath',
                            action='append',
                            help='Add include path',
                            default=[])
        parser.add_argument('--monolithic',
                            action='store_true',
                            help='Build monolithic test suite',
                            default=False)
        parser.add_argument('--coverage',
                            action='store_true',
                            help='Build with code coverage',
                            default=False)
        parser.add_argument(
            '--subninja',
            action='store',
            help=
            'Build as subproject (exclude rules and pools) with the given subpath',
            default='')
        options = parser.parse_args()

        self.project = project
        self.target = platform.Platform(options.target)
        self.host = platform.Platform(options.host)
        self.subninja = options.subninja
        archs = options.arch
        configs = options.config
        if includepaths is None:
            includepaths = []
        if not options.includepath is None:
            includepaths += options.includepath

        buildfile = open('build.ninja', 'w')
        self.writer = syntax.Writer(buildfile)

        self.writer.variable('ninja_required_version', '1.3')
        self.writer.newline()

        self.writer.comment('configure.py arguments')
        self.writer.variable('configure_args', ' '.join(sys.argv[1:]))
        self.writer.newline()

        self.writer.comment('configure options')
        self.writer.variable('configure_target', self.target.platform)
        self.writer.variable('configure_host', self.host.platform)

        env_keys = set(['CC', 'AR', 'LINK', 'CFLAGS', 'ARFLAGS', 'LINKFLAGS'])
        configure_env = dict(
            (key, os.environ[key]) for key in os.environ if key in env_keys)
        if configure_env:
            config_str = ' '.join([
                key + '=' + pipes.quote(configure_env[key])
                for key in configure_env
            ])
            writer.variable('configure_env', config_str + '$ ')

        if variables is None:
            variables = {}
        if not isinstance(variables, dict):
            variables = dict(variables)

        if options.monolithic:
            variables['monolithic'] = True
        if options.coverage:
            variables['coverage'] = True
        if self.subninja != '':
            variables['internal_deps'] = True

        self.toolchain = toolchain.make_toolchain(self.host, self.target,
                                                  options.toolchain)
        self.toolchain.initialize(project, archs, configs, includepaths,
                                  dependlibs, libpaths, variables,
                                  self.subninja)

        self.writer.variable('configure_toolchain', self.toolchain.name())
        self.writer.variable('configure_archs', archs)
        self.writer.variable('configure_configs', configs)
        self.writer.newline()

        self.toolchain.write_variables(self.writer)
        if self.subninja == '':
            self.toolchain.write_rules(self.writer)
コード例 #2
0
ファイル: generator.py プロジェクト: rampantpixels/task_lib
    def __init__(self, project, includepaths=[], dependlibs=[], libpaths=[], variables=None):
        parser = argparse.ArgumentParser(description="Ninja build generator")
        parser.add_argument("-t", "--target", help="Target platform", choices=platform.supported_platforms())
        parser.add_argument("--host", help="Host platform", choices=platform.supported_platforms())
        parser.add_argument("--toolchain", help="Toolchain to use", choices=toolchain.supported_toolchains())
        parser.add_argument(
            "-c",
            "--config",
            action="append",
            help="Build configuration",
            choices=["debug", "release", "profile", "deploy"],
            default=[],
        )
        parser.add_argument(
            "-a",
            "--arch",
            action="append",
            help="Add architecture",
            choices=toolchain.supported_architectures(),
            default=[],
        )
        parser.add_argument("-i", "--includepath", action="append", help="Add include path", default=[])
        parser.add_argument("--monolithic", action="store_true", help="Build monolithic test suite", default=False)
        parser.add_argument("--coverage", action="store_true", help="Build with code coverage", default=False)
        options = parser.parse_args()

        self.project = project
        self.target = platform.Platform(options.target)
        self.host = platform.Platform(options.host)
        archs = options.arch
        configs = options.config
        if includepaths is None:
            includepaths = []
        if not options.includepath is None:
            includepaths += options.includepath

        buildfile = open("build.ninja", "w")
        self.writer = syntax.Writer(buildfile)

        self.writer.variable("ninja_required_version", "1.3")
        self.writer.newline()

        self.writer.comment("configure.py arguments")
        self.writer.variable("configure_args", " ".join(sys.argv[1:]))
        self.writer.newline()

        self.writer.comment("configure options")
        self.writer.variable("configure_target", self.target.platform)
        self.writer.variable("configure_host", self.host.platform)

        env_keys = set(["CC", "AR", "LINK", "CFLAGS", "ARFLAGS", "LINKFLAGS"])
        configure_env = dict((key, os.environ[key]) for key in os.environ if key in env_keys)
        if configure_env:
            config_str = " ".join([key + "=" + pipes.quote(configure_env[key]) for key in configure_env])
            writer.variable("configure_env", config_str + "$ ")

        if options.monolithic:
            if variables is None:
                variables = {}
            if isinstance(variables, dict):
                variables["monolithic"] = True
            else:
                variables += [("monolithic", True)]
        if options.coverage:
            if variables is None:
                variables = {}
            if isinstance(variables, dict):
                variables["coverage"] = True
            else:
                variables += [("coverage", True)]

        self.toolchain = toolchain.make_toolchain(self.host, self.target, options.toolchain)
        self.toolchain.initialize(project, archs, configs, includepaths, dependlibs, libpaths, variables)

        self.writer.variable("configure_toolchain", self.toolchain.name())
        self.writer.variable("configure_archs", archs)
        self.writer.variable("configure_configs", configs)
        self.writer.newline()

        self.toolchain.write_variables(self.writer)
        self.toolchain.write_rules(self.writer)
コード例 #3
0
ファイル: generator.py プロジェクト: rampantpixels/memory_lib
  def __init__(self, project, includepaths = [], dependlibs = [], libpaths = [], variables = None):
    parser = argparse.ArgumentParser(description = 'Ninja build generator')
    parser.add_argument('-t', '--target',
                        help = 'Target platform',
                        choices = platform.supported_platforms())
    parser.add_argument('--host',
                        help = 'Host platform',
                        choices = platform.supported_platforms())
    parser.add_argument('--toolchain',
                        help = 'Toolchain to use',
                        choices = toolchain.supported_toolchains())
    parser.add_argument('-c', '--config', action = 'append',
                        help = 'Build configuration',
                        choices = ['debug', 'release', 'profile', 'deploy'],
                        default = [])
    parser.add_argument('-a', '--arch', action = 'append',
                        help = 'Add architecture',
                        choices = toolchain.supported_architectures(),
                        default = [])
    parser.add_argument('-i', '--includepath', action = 'append',
                        help = 'Add include path',
                        default = [])
    parser.add_argument('--monolithic', action='store_true',
                        help = 'Build monolithic test suite',
                        default = False)
    parser.add_argument('--coverage', action='store_true',
                        help = 'Build with code coverage',
                        default = False)
    parser.add_argument('--subninja', action='store',
                        help = 'Build as subproject (exclude rules and pools) with the given subpath',
                        default = '')
    options = parser.parse_args()

    self.project = project
    self.target = platform.Platform(options.target)
    self.host = platform.Platform(options.host)
    self.subninja = options.subninja
    archs = options.arch
    configs = options.config
    if includepaths is None:
      includepaths = []
    if not options.includepath is None:
      includepaths += options.includepath

    buildfile = open('build.ninja', 'w')
    self.writer = syntax.Writer(buildfile)

    self.writer.variable('ninja_required_version', '1.3')
    self.writer.newline()

    self.writer.comment('configure.py arguments')
    self.writer.variable('configure_args', ' '.join(sys.argv[1:]))
    self.writer.newline()

    self.writer.comment('configure options')
    self.writer.variable('configure_target', self.target.platform)
    self.writer.variable('configure_host', self.host.platform)

    env_keys = set(['CC', 'AR', 'LINK', 'CFLAGS', 'ARFLAGS', 'LINKFLAGS'])
    configure_env = dict((key, os.environ[key]) for key in os.environ if key in env_keys)
    if configure_env:
      config_str = ' '.join([key + '=' + pipes.quote(configure_env[key]) for key in configure_env])
      writer.variable('configure_env', config_str + '$ ')

    if options.monolithic:
      if variables is None:
        variables = {}
      if isinstance(variables, dict):
        variables['monolithic'] = True
      else:
        variables += [('monolithic', True)]
    if options.coverage:
      if variables is None:
        variables = {}
      if isinstance(variables, dict):
        variables['coverage'] = True
      else:
        variables += [('coverage', True)]

    self.toolchain = toolchain.make_toolchain(self.host, self.target, options.toolchain)
    self.toolchain.initialize(project, archs, configs, includepaths, dependlibs, libpaths, variables, self.subninja)

    self.writer.variable('configure_toolchain', self.toolchain.name())
    self.writer.variable('configure_archs', archs)
    self.writer.variable('configure_configs', configs)
    self.writer.newline()

    self.toolchain.write_variables(self.writer)
    if self.subninja == '':
      self.toolchain.write_rules(self.writer)
コード例 #4
0
ファイル: generator.py プロジェクト: johanster/window_lib
  def __init__( self, project, includepaths = [], dependlibs = [] ):
    parser = argparse.ArgumentParser( description = 'Ninja build generator' )
    parser.add_argument( '-t', '--target',
                         help = 'Target platform',
                         choices = platform.supported_platforms() )
    parser.add_argument( '--host',
                         help = 'Host platform',
                         choices = platform.supported_platforms() )
    parser.add_argument( '--toolchain',
                         help = 'Toolchain to use',
                         choices = toolchain.supported_toolchains() )
    parser.add_argument( '-c', '--config', action = 'append',
                         help = 'Build configuration',
                         choices = ['debug', 'release', 'profile', 'deploy'],
                         default = [] )
    parser.add_argument( '-a', '--arch', action = 'append',
                         help = 'Add architecture',
                         choices = toolchain.supported_architectures(),
                         default = [] )
    parser.add_argument( '-i', '--includepath', action = 'append',
                         help = 'Add include path',
                         default = [] )
    options = parser.parse_args()

    self.project = project
    self.target = platform.Platform(options.target)
    self.host = platform.Platform(options.host)
    archs = options.arch
    configs = options.config
    if configs is None or configs == []:
      configs = [ 'release' ]
    if includepaths is None:
      includepaths = []
    if not options.includepath is None:
      includepaths += options.includepath

    buildfile = open( 'build.ninja', 'w' )
    self.writer = syntax.Writer( buildfile )

    self.writer.variable( 'ninja_required_version', '1.3' )
    self.writer.newline()

    self.writer.comment( 'configure.py arguments' )
    self.writer.variable( 'configure_args', ' '.join( sys.argv[1:] ) )
    self.writer.newline()

    self.writer.comment( 'configure options' )
    self.writer.variable( 'configure_target', self.target.platform )
    self.writer.variable( 'configure_host', self.host.platform )

    env_keys = set( [ 'CC', 'AR', 'LINK', 'CFLAGS', 'ARFLAGS', 'LINKFLAGS' ] )
    configure_env = dict( ( key, os.environ[key] ) for key in os.environ if key in env_keys )
    if configure_env:
      config_str = ' '.join( [ key + '=' + pipes.quote( configure_env[key] ) for key in configure_env ] )
      writer.variable('configure_env', config_str + '$ ')

    self.toolchain = toolchain.Toolchain( project, options.toolchain, self.host, self.target, archs, configs, includepaths, dependlibs,
                                          configure_env.get( 'CC' ),
                                          configure_env.get( 'AR' ),
                                          configure_env.get( 'LINK' ),
                                          configure_env.get( 'CFLAGS' ),
                                          configure_env.get( 'ARFLAGS' ),
                                          configure_env.get( 'LINKFLAGS' ) )

    self.writer.variable( 'configure_toolchain', self.toolchain.toolchain )
    self.writer.variable( 'configure_archs', self.toolchain.archs )
    self.writer.variable( 'configure_configs', self.toolchain.configs )
    self.writer.variable( 'configure_includepaths', self.toolchain.includepaths )
    self.writer.newline()

    self.toolchain.write_variables( self.writer )
    self.toolchain.write_rules( self.writer )