toolchain: add a way to auto copy include files or directory (need cleaning)
This commit is contained in:
parent
309a003036
commit
8c34d15a3b
1 changed files with 38 additions and 14 deletions
50
toolchain.py
50
toolchain.py
|
@ -42,6 +42,15 @@ class Arch(object):
|
||||||
super(Arch, self).__init__()
|
super(Arch, self).__init__()
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
|
|
||||||
|
@property
|
||||||
|
def include_dirs(self):
|
||||||
|
return [
|
||||||
|
"{}/{}".format(
|
||||||
|
self.ctx.include_dir,
|
||||||
|
d.format(arch=self))
|
||||||
|
for d in self.ctx.include_dirs]
|
||||||
|
|
||||||
|
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
include_dirs = [
|
include_dirs = [
|
||||||
"-I{}/{}".format(
|
"-I{}/{}".format(
|
||||||
|
@ -502,23 +511,38 @@ class Recipe(object):
|
||||||
if not self.include_dir:
|
if not self.include_dir:
|
||||||
return
|
return
|
||||||
if self.include_per_arch:
|
if self.include_per_arch:
|
||||||
for arch in self.ctx.arch:
|
archs = self.ctx.archs
|
||||||
build_dir = self.get_build_dir(arch.arch)
|
else:
|
||||||
include_dir = self.include_dir.format(arch=arch, ctx=self.ctx)
|
archs = [list(self.filtered_archs)[0]]
|
||||||
src_dir = join(build_dir, include_dir)
|
|
||||||
dest_dir = join(self.ctx.include_dir, arch.arch, self.name)
|
include_dirs = self.include_dir
|
||||||
|
if not isinstance(include_dirs, (list, tuple)):
|
||||||
|
include_dirs = list([include_dirs])
|
||||||
|
|
||||||
|
for arch in archs:
|
||||||
|
arch_dir = "common"
|
||||||
|
if self.include_per_arch:
|
||||||
|
arch_dir = arch.arch
|
||||||
|
dest_dir = join(self.ctx.include_dir, arch_dir, self.name)
|
||||||
if exists(dest_dir):
|
if exists(dest_dir):
|
||||||
shutil.rmtree(dest_dir)
|
shutil.rmtree(dest_dir)
|
||||||
|
build_dir = self.get_build_dir(arch.arch)
|
||||||
|
|
||||||
|
for include_dir in include_dirs:
|
||||||
|
dest_name = None
|
||||||
|
if isinstance(include_dir, (list, tuple)):
|
||||||
|
include_dir, dest_name = include_dir
|
||||||
|
include_dir = include_dir.format(arch=arch, ctx=self.ctx)
|
||||||
|
src_dir = join(build_dir, include_dir)
|
||||||
|
if dest_name is None:
|
||||||
|
dest_name = basename(src_dir)
|
||||||
|
if isdir(src_dir):
|
||||||
shutil.copytree(src_dir, dest_dir)
|
shutil.copytree(src_dir, dest_dir)
|
||||||
else:
|
else:
|
||||||
arch = list(self.filtered_archs)[0]
|
dest = join(dest_dir, dest_name)
|
||||||
build_dir = self.get_build_dir(arch.arch)
|
print("Copy {} to {}".format(src_dir, dest))
|
||||||
include_dir = self.include_dir.format(arch=arch, ctx=self.ctx)
|
ensure_dir(dirname(dest))
|
||||||
src_dir = join(build_dir, include_dir)
|
shutil.copy(src_dir, dest)
|
||||||
dest_dir = join(self.ctx.include_dir, "common", self.name)
|
|
||||||
if exists(dest_dir):
|
|
||||||
shutil.rmtree(dest_dir)
|
|
||||||
shutil.copytree(src_dir, dest_dir)
|
|
||||||
|
|
||||||
def install(self):
|
def install(self):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue