toolchain: support installation of custom objc sources and frameworks.
This commit is contained in:
parent
d04fd46bf2
commit
07a3ed6222
1 changed files with 58 additions and 3 deletions
57
toolchain.py
57
toolchain.py
|
@ -357,6 +357,8 @@ class Recipe(object):
|
||||||
libraries = []
|
libraries = []
|
||||||
include_dir = None
|
include_dir = None
|
||||||
include_per_arch = False
|
include_per_arch = False
|
||||||
|
frameworks = []
|
||||||
|
sources = []
|
||||||
pbx_frameworks = []
|
pbx_frameworks = []
|
||||||
pbx_libraries = []
|
pbx_libraries = []
|
||||||
|
|
||||||
|
@ -653,6 +655,10 @@ class Recipe(object):
|
||||||
self.make_lipo(static_fn, library)
|
self.make_lipo(static_fn, library)
|
||||||
print("Install include files for {}".format(self.name))
|
print("Install include files for {}".format(self.name))
|
||||||
self.install_include()
|
self.install_include()
|
||||||
|
print("Install frameworks for {}".format(self.name))
|
||||||
|
self.install_frameworks()
|
||||||
|
print("Install sources for {}".format(self.name))
|
||||||
|
self.install_sources()
|
||||||
print("Install {}".format(self.name))
|
print("Install {}".format(self.name))
|
||||||
self.install()
|
self.install()
|
||||||
|
|
||||||
|
@ -685,6 +691,36 @@ class Recipe(object):
|
||||||
join(self.get_build_dir(arch.arch), library_fn)]
|
join(self.get_build_dir(arch.arch), library_fn)]
|
||||||
shprint(sh.lipo, "-create", "-output", filename, *args)
|
shprint(sh.lipo, "-create", "-output", filename, *args)
|
||||||
|
|
||||||
|
@cache_execution
|
||||||
|
def install_frameworks(self):
|
||||||
|
if not self.frameworks:
|
||||||
|
return
|
||||||
|
arch = self.filtered_archs[0]
|
||||||
|
build_dir = self.get_build_dir(arch.arch)
|
||||||
|
for framework in self.frameworks:
|
||||||
|
print(" - Install {}".format(framework))
|
||||||
|
src = join(build_dir, framework)
|
||||||
|
dest = join(self.ctx.dist_dir, "frameworks", framework)
|
||||||
|
ensure_dir(dirname(dest))
|
||||||
|
if exists(dest):
|
||||||
|
shutil.rmtree(dest)
|
||||||
|
shutil.copytree(src, dest)
|
||||||
|
|
||||||
|
@cache_execution
|
||||||
|
def install_sources(self):
|
||||||
|
if not self.sources:
|
||||||
|
return
|
||||||
|
arch = self.filtered_archs[0]
|
||||||
|
build_dir = self.get_build_dir(arch.arch)
|
||||||
|
for source in self.sources:
|
||||||
|
print(" - Install {}".format(source))
|
||||||
|
src = join(build_dir, source)
|
||||||
|
dest = join(self.ctx.dist_dir, "sources", self.name)
|
||||||
|
ensure_dir(dirname(dest))
|
||||||
|
if exists(dest):
|
||||||
|
shutil.rmtree(dest)
|
||||||
|
shutil.copytree(src, dest)
|
||||||
|
|
||||||
@cache_execution
|
@cache_execution
|
||||||
def install_include(self):
|
def install_include(self):
|
||||||
if not self.include_dir:
|
if not self.include_dir:
|
||||||
|
@ -883,7 +919,9 @@ def update_pbxproj(filename):
|
||||||
ctx = Context()
|
ctx = Context()
|
||||||
pbx_libraries = []
|
pbx_libraries = []
|
||||||
pbx_frameworks = []
|
pbx_frameworks = []
|
||||||
|
frameworks = []
|
||||||
libraries = []
|
libraries = []
|
||||||
|
sources = []
|
||||||
for recipe in Recipe.list_recipes():
|
for recipe in Recipe.list_recipes():
|
||||||
key = "{}.build_all".format(recipe)
|
key = "{}.build_all".format(recipe)
|
||||||
if key not in ctx.state:
|
if key not in ctx.state:
|
||||||
|
@ -893,6 +931,9 @@ def update_pbxproj(filename):
|
||||||
pbx_frameworks.extend(recipe.pbx_frameworks)
|
pbx_frameworks.extend(recipe.pbx_frameworks)
|
||||||
pbx_libraries.extend(recipe.pbx_libraries)
|
pbx_libraries.extend(recipe.pbx_libraries)
|
||||||
libraries.extend(recipe.dist_libraries)
|
libraries.extend(recipe.dist_libraries)
|
||||||
|
frameworks.extend(recipe.frameworks)
|
||||||
|
if recipe.sources:
|
||||||
|
sources.append(recipe.name)
|
||||||
|
|
||||||
pbx_frameworks = list(set(pbx_frameworks))
|
pbx_frameworks = list(set(pbx_frameworks))
|
||||||
pbx_libraries = list(set(pbx_libraries))
|
pbx_libraries = list(set(pbx_libraries))
|
||||||
|
@ -902,7 +943,9 @@ def update_pbxproj(filename):
|
||||||
print("The project need to have:")
|
print("The project need to have:")
|
||||||
print("iOS Frameworks: {}".format(pbx_frameworks))
|
print("iOS Frameworks: {}".format(pbx_frameworks))
|
||||||
print("iOS Libraries: {}".format(pbx_libraries))
|
print("iOS Libraries: {}".format(pbx_libraries))
|
||||||
|
print("iOS local Frameworks: {}".format(frameworks))
|
||||||
print("Libraries: {}".format(libraries))
|
print("Libraries: {}".format(libraries))
|
||||||
|
print("Sources to link: {}".format(sources))
|
||||||
|
|
||||||
print("-" * 70)
|
print("-" * 70)
|
||||||
print("Analysis of {}".format(filename))
|
print("Analysis of {}".format(filename))
|
||||||
|
@ -912,8 +955,14 @@ def update_pbxproj(filename):
|
||||||
sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip()
|
sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip()
|
||||||
|
|
||||||
group = project.get_or_create_group("Frameworks")
|
group = project.get_or_create_group("Frameworks")
|
||||||
|
g_classes = project.get_or_create_group("Classes")
|
||||||
for framework in pbx_frameworks:
|
for framework in pbx_frameworks:
|
||||||
print("Ensure {} is in the project".format(framework))
|
framework_name = "{}.framework".format(framework)
|
||||||
|
if framework_name in frameworks:
|
||||||
|
print("Ensure {} is in the project (local)".format(framework))
|
||||||
|
f_path = join(ctx.dist_dir, "frameworks", framework_name)
|
||||||
|
else:
|
||||||
|
print("Ensure {} is in the project (system)".format(framework))
|
||||||
f_path = join(sysroot, "System", "Library", "Frameworks",
|
f_path = join(sysroot, "System", "Library", "Frameworks",
|
||||||
"{}.framework".format(framework))
|
"{}.framework".format(framework))
|
||||||
project.add_file_if_doesnt_exist(f_path, parent=group, tree="DEVELOPER_DIR")
|
project.add_file_if_doesnt_exist(f_path, parent=group, tree="DEVELOPER_DIR")
|
||||||
|
@ -925,6 +974,12 @@ def update_pbxproj(filename):
|
||||||
for library in libraries:
|
for library in libraries:
|
||||||
print("Ensure {} is in the project".format(library))
|
print("Ensure {} is in the project".format(library))
|
||||||
project.add_file_if_doesnt_exist(library, parent=group)
|
project.add_file_if_doesnt_exist(library, parent=group)
|
||||||
|
for name in sources:
|
||||||
|
print("Ensure {} sources are used".format(name))
|
||||||
|
fn = join(ctx.dist_dir, "sources", name)
|
||||||
|
project.add_folder(fn, parent=g_classes)
|
||||||
|
|
||||||
|
|
||||||
if project.modified:
|
if project.modified:
|
||||||
project.backup()
|
project.backup()
|
||||||
project.save()
|
project.save()
|
||||||
|
|
Loading…
Reference in a new issue