示例#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
文件: qt.py 项目: raffber/capnqml
 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
文件: cpp.py 项目: raffber/capnqml
 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
文件: qt.py 项目: raffber/capnqml
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
文件: qt.py 项目: raffber/capnqml
 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
文件: qt.py 项目: raffber/capnqml
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
文件: linux.py 项目: raffber/capnqml
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
文件: test_fs.py 项目: raffber/wasp
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
文件: cpp.py 项目: raffber/capnqml
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
文件: clang.py 项目: raffber/capnqml
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