Пример #1
0
 def __init__(self, source=None, destination=None, restored=False):
     if source is not None:
         self.source = file(source)
     else:
         self.source = file(curdir.join('test-dir').join('test.txt'))
     if destination is not None:
         self.destination = file(destination)
     else:
         self.destination = self.source.append_extension('backup')
     self.restored = restored
Пример #2
0
 def _run(self):
     base_dir = self.arguments.value('base_dir')
     include_dir = self.arguments.value('include_dir')
     lib_dir = self.arguments.value('lib_dir')
     assert include_dir is not None and lib_dir is not None
     includes = []
     libraries = []
     lib_dir = directory(lib_dir)
     for key in self._keys:
         fname = Modules.filename(lib_dir, key)
         if not lib_dir.join(fname).exists:
             self.log.fatal('qt.FindModules: Could not find shared object at `{0}`'
                            .format(lib_dir.join(fname)))
             self.success = False
             return
         libraries.append(fname)
         include_paths = Modules.includedir(include_dir, key)
         for path in include_paths:
             if not file(path).exists:
                 self.log.fatal('qt.FindModules: Could not find include directories at `{0}`'
                                .format(', '.join(x.path for x in include_paths)))
                 self.success = False
                 return
         includes.extend(include_paths)
     self.result['includes'] = includes
     self.result['libraries'] = libraries
     self.success = True
Пример #3
0
 def __init__(self, source, target=None):
     f = file(source)
     if target is None:
         target = node(':cpp/{0}'.format(str(f)))
     super().__init__(sources=f, targets=target)
     self._target_node = target
     self._f = f
     self.arguments.add(includes=[])
Пример #4
0
def moc(fs):
    fs = nodes(fs)
    ret = []
    for f in fs:
        tgt = file(f).to_builddir().append_extension('moc.cpp')
        t = shell(cmd='{moc} -o {tgt} {src}', sources=f.to_file(), targets=tgt)
        t.require('moc', spawn=find_moc)
        ret.append(t)
    return group(ret)
Пример #5
0
 def _run(self):
     if self._mocpath is None:
         super()._run()
         return
     if not file(self._mocpath).exists:
         self.log.fatal('qt.FindMoc: {0} does not exist'.format(self._mocpath))
         self.success = False
         return
     self.result.update(**{self._argprefix: self._mocpath})
     self.success = True
Пример #6
0
def link(obj_files, target='main', use_default=True):
    t = _cpp.Link(sources=nodes(obj_files), targets=file(target).to_builddir())
    if use_default:
        ldnode = ':cpp/cxx'
        spawner = _cpp .find_cxx
        if osinfo.linux:
            libraries = ['stdc++', 'c']
        else:
            libraries = []
        t.use(ldnode, libraries=libraries).require('ld', spawn=spawner)
    return t
Пример #7
0
def compile_schema():
    directory(ctx.builddir.join('schema')).ensure_exists()
    schema_sources = []
    tasks = []
    for src in directory('src/schema').glob('.*\.capnp'):
        cmd = 'capnp compile --src-prefix=src/schema -oc++:{outp} {src}'
        tgt = file(ctx.builddir.join('schema').join(src.basename)).append_extension('.c++')
        schema_sources.append(tgt)
        capnp = shell(cmd, sources=src, targets=tgt)
        capnp.use(outp=ctx.builddir.join('schema'))
        tasks.append(capnp)
    return tasks, schema_sources
Пример #8
0
def prepare():
    curdir = directory(__file__)
    testdir = directory(curdir.join('test-dir'))
    testdir.remove(recursive=True)
    assert not testdir.exists
    testdir.ensure_exists()
    for f in ['a.txt', 'dira/dirb/b.txt', 'c.txt']:
        f = file(testdir.join(f))
        directory(f).ensure_exists()
        assert directory(f).exists
        with open(f.path, 'w') as fwrite:
            fwrite.write('asdf')
        assert f.exists
Пример #9
0
def link(obj_files, target='main', use_default=True, cpp=True, shared=False):
    t = Link(sources=nodes(obj_files), targets=file(target).to_builddir())
    if use_default:
        ldnode = ':cpp/cxx' if cpp else ':cpp/cc'
        spawner = find_cxx if cpp else find_cc
        if osinfo.linux:
            t.use(libraries=['stdc++', 'c', 'pthread'])
        t.use(ldnode).require('ld', spawn=spawner)
    if shared:
        if osinfo.windows:
            t.use(ldflags='/dll')
        else:
            t.use(ldflags='-shared')
    return t
Пример #10
0
def compile_db(tasks):
    compile_db = file('compile_commands.json')
    if not compile_db.exists:
        with open(compile_db.path, 'w') as f:
            f.write('[]')
    tasks = _flatten(*tasks)
    compile_tasks = []
    for task in tasks:
        if not isinstance(task, cpp.CompileTask):
            continue
        task.run.append(add_compile_db)
        compile_tasks.append(task)
    collector = CollectCompileDb(always=True, targets=compile_db)
    collector.use(compile_tasks)
    return collector.produce(':clang/compiledb')
Пример #11
0
def compile_schema():
    tasks = []
    directory(ctx.builddir.join('schema')).ensure_exists()
    schema_sources = []
    for src in directory('src/schema').glob('.*\.capnp'):
        cmd = 'capnp compile --src-prefix=src/schema -oc++:{outp} {src_nobs}'
        tgt = file(ctx.builddir.join('schema').join(src.basename)).append_extension('.c++')
        capnp = shell(cmd, sources=src, targets=tgt)
        capnp.use(outp=ctx.builddir.join('schema'))
        # on windows, capnp compiler does not like backslashes, however
        # wasp formats with backslashes by default
        capnp.use(src_nobs=str(src).replace('\\', '/'))
        tasks.append(capnp)
        moved = tgt.replace_extension('cpp')
        mv = copy(tgt, moved).use(capnp)
        schema_sources.append(moved)
        tasks.append(mv)
    return tasks, schema_sources