本文整理汇总了Python中fbuild.path.Path.addroot方法的典型用法代码示例。如果您正苦于以下问题:Python Path.addroot方法的具体用法?Python Path.addroot怎么用?Python Path.addroot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fbuild.path.Path
的用法示例。
在下文中一共展示了Path.addroot方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def __call__(self, src:fbuild.db.SRC, dst=None, *,
suffix=None,
verbose=False,
name_prefix=None,
defines=False,
flags=[],
buildroot=None) -> fbuild.db.DST:
buildroot = buildroot or self.ctx.buildroot
suffix = suffix or self.suffix
dst = Path.addroot(dst or src, buildroot).replaceext(suffix)
dst.parent.makedirs()
cmd = [self.exe]
if verbose:
cmd.append('-v')
if name_prefix is not None:
cmd.extend(('-p', name_prefix))
if defines:
cmd.append('-d')
cmd.extend(self.flags)
cmd.extend(flags)
cmd.extend(('-o', dst))
cmd.append(src)
self.ctx.execute(cmd, self.exe, '%s -> %s' % (src, dst), color='yellow')
return dst
示例2: __call__
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def __call__(self, src: fbuild.db.SRC, header, dst=None) -> fbuild.db.DSTS:
dst = Path.addroot(dst or src, self.ctx.buildroot).replaceext(self.suffix)
dst.parent.makedirs()
header = Path.addroot(header, self.ctx.buildroot)
header.parent.makedirs()
cmd = [self.exe]
cmd.extend(self.flags)
if self.debug: cmd.append('-d')
cmd.extend(('-o', dst))
cmd.append('--header='+header)
cmd.append(src)
self.ctx.execute(cmd, self.exe, '%s -> %s %s' % (src, dst, header),
color='yellow')
return [dst, header]
示例3: translate
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def translate(self, src: fbuild.db.SRC, dst) -> fbuild.db.DST:
dst = Path.addroot(dst, self.ctx.buildroot)
dst.parent.makedirs()
cmd = [self.exe, 'dynasm/dynasm.lua']
for d in self.defs:
cmd.extend(('-D', d))
cmd.extend(('-o', dst))
cmd.append(src)
self.ctx.execute(cmd, 'dynasm', '%s -> %s' % (src, dst), color='yellow')
return dst
示例4: foo
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def foo(ctx, src:fbuild.db.SRC, dst, *, buildroot=None) -> fbuild.db.DST:
dst = Path.addroot(dst, buildroot or ctx.buildroot)
ctx.logger.log(' * foo: %s %s' % (src, dst), color='cyan')
with open(src) as f:
x = f.read().strip()
with open(dst, 'w') as f:
print(src, dst, x, file=f)
return dst
示例5: __call__
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def __call__(self, src, dst, *, buildroot=None):
buildroot = buildroot or self.ctx.buildroot
dst = Path.addroot(dst, buildroot).addprefix(self.prefix) + self.suffix
self.ctx.logger.log(' * Builder.__call__: %s %s' % (src, dst),
color='cyan')
with open(src) as f:
x = f.read().strip()
with open(dst, 'w') as f:
print(src, dst, x, file=f)
return dst
示例6: check_fluid
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def check_fluid(linker):
fluidsynth = Path(linker.prefix + 'fluidsynth' + linker.suffix)
fluidsynth = fluidsynth.addroot(Path('fluidsynth') / 'fluidsynth' / 'src')
message = textwrap.dedent('''
You need to build Fluidsynth separately first!
Try runnung 'cd fluidsynth/fluidsynth; cmake'.
(See http://sourceforge.net/p/fluidsynth/wiki/BuildingWithCMake/ for info.)
'''.rstrip().lstrip('\n')).replace('\n', ' ', 1)
if not fluidsynth.exists():
raise fbuild.ConfigFailed(message)
return fluidsynth
示例7: uncached_compile
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def uncached_compile(self, src, *,
static=None,
includes=[],
flags=[],
buildroot=None,
**kwargs):
"""Compile a felix file without caching the results. This is needed
when compiling temporary files."""
print("Uncached compile " + src)
src = Path(src)
buildroot = buildroot or self.ctx.buildroot
src_buildroot = src.addroot(buildroot)
if static is None:
static = self.static
if static:
dst = src_buildroot.replaceext(self.exe_suffix)
else:
dst = src_buildroot.replaceext(self.lib_suffix)
if src != src_buildroot:
src_buildroot.parent.makedirs()
src.copy(src_buildroot)
src = src_buildroot
includes = set(includes)
includes.update(self.includes)
includes.add(src.parent)
cmd_flags = ['-c']
cmd_flags.extend(self.flags)
cmd_flags.extend(flags)
self.flx(src, self.flx, '%s -> %s' % (src, dst),
includes=includes,
static=static,
flags=cmd_flags,
color='compile',
**kwargs)
return dst
示例8: __call__
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def __call__(self, src, *args, flags=[], buildroot=None, **kwargs):
"""Run a scala script."""
src = Path(src)
buildroot = buildroot or self.ctx.buildroot
src_buildroot = src.addroot(buildroot)
dst = src.replaceext('.jar')
# We need to copy the src into the buildroot so we don't pollute our
# tree.
if src != src_buildroot:
src_buildroot.parent.makedirs()
src.copy(src_buildroot)
src = src_buildroot
# Always save the compilation results.
flags = list(flags)
flags.append('-savecompiled')
stdout, stderr = self._run([src], *args, flags=flags, **kwargs)
return dst, stdout, stderr
示例9: find_font
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def find_font(ctx) -> fbuild.db.DST:
ctx.logger.check('locating arial font')
font = None
if sys.platform == 'win32':
font = Path(os.environ['SYSTEMROOT']) / 'Fonts' / 'Arial.ttf'
if not font.exists():
font = None
elif sys.platform.startswith('linux'):
# Check /etc/fonts/fonts.conf.
font_dirs = []
fonts = Path('/etc/fonts/fonts.conf')
if not fonts.exists():
ctx.logger.failed()
raise fbuild.ConfigFailed('cannot locate fonts.conf')
tree = etree.parse(str(fonts))
for element in tree.findall('dir'):
path = Path(element.text)
if element.attrib.get('prefix') == 'xdg' and \
'XDG_DATA_HOME' in os.environ:
path = path.addroot(os.environ['XDG_DATA_HOME'])
try:
font = Path(next(path.find('Arial.ttf', include_dirs=False)))
except StopIteration:
pass
else:
break
if font is None:
ctx.logger.failed()
raise fbuild.ConfigFailed('cannot locate arial font')
else:
ctx.logger.passed('ok %s' % font)
return font
示例10: crystal
# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import addroot [as 别名]
def crystal(ctx, srcs: fbuild.db.SRCS, dst) -> fbuild.db.DST:
dst = Path.addroot(dst, ctx.buildroot)
ctx.execute(['crystal', 'build', '-o', dst, srcs[0]], 'crystal',
'%s -> %s' % (' '.join(srcs), dst), color='yellow')
return dst