diff --git a/prepare.py b/prepare.py index f725375ab..ac9fdfc30 100755 --- a/prepare.py +++ b/prepare.py @@ -27,6 +27,7 @@ import os import re import shutil import sys +from subprocess import Popen sys.dont_write_bytecode = True sys.path.insert(0, 'submodules/cmake-builder') import prepare @@ -34,48 +35,48 @@ import prepare class IOSTarget(prepare.Target): - def __init__(self, arch): - prepare.Target.__init__(self, 'ios-' + arch) - current_path = os.path.dirname(os.path.realpath(__file__)) - self.config_file = 'configs/config-ios-' + arch + '.cmake' - self.toolchain_file = 'toolchains/toolchain-ios-' + arch + '.cmake' - self.output = 'liblinphone-sdk/' + arch + '-apple-darwin.ios' - self.additional_args = [ - '-DLINPHONE_BUILDER_EXTERNAL_SOURCE_PATH=' + - current_path + '/submodules' - ] + def __init__(self, arch): + prepare.Target.__init__(self, 'ios-' + arch) + current_path = os.path.dirname(os.path.realpath(__file__)) + self.config_file = 'configs/config-ios-' + arch + '.cmake' + self.toolchain_file = 'toolchains/toolchain-ios-' + arch + '.cmake' + self.output = 'liblinphone-sdk/' + arch + '-apple-darwin.ios' + self.additional_args = [ + '-DLINPHONE_BUILDER_EXTERNAL_SOURCE_PATH=' + + current_path + '/submodules' + ] - def clean(self): - if os.path.isdir('WORK'): - shutil.rmtree( - 'WORK', ignore_errors=False, onerror=self.handle_remove_read_only) - if os.path.isdir('liblinphone-sdk'): - shutil.rmtree( - 'liblinphone-sdk', ignore_errors=False, onerror=self.handle_remove_read_only) + def clean(self): + if os.path.isdir('WORK'): + shutil.rmtree( + 'WORK', ignore_errors=False, onerror=self.handle_remove_read_only) + if os.path.isdir('liblinphone-sdk'): + shutil.rmtree( + 'liblinphone-sdk', ignore_errors=False, onerror=self.handle_remove_read_only) class IOSi386Target(IOSTarget): - def __init__(self): - IOSTarget.__init__(self, 'i386') + def __init__(self): + IOSTarget.__init__(self, 'i386') class IOSx8664Target(IOSTarget): - def __init__(self): - IOSTarget.__init__(self, 'x86_64') + def __init__(self): + IOSTarget.__init__(self, 'x86_64') class IOSarmv7Target(IOSTarget): - def __init__(self): - IOSTarget.__init__(self, 'armv7') + def __init__(self): + IOSTarget.__init__(self, 'armv7') class IOSarm64Target(IOSTarget): - def __init__(self): - IOSTarget.__init__(self, 'arm64') + def __init__(self): + IOSTarget.__init__(self, 'arm64') targets = {} @@ -91,29 +92,29 @@ platforms = ['all', 'devices', 'simulators'] + archs_device + archs_simu class PlatformListAction(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - if values: - for value in values: - if value not in platforms: - message = ("invalid platform: {0!r} (choose from {1})".format( - value, ', '.join([repr(platform) for platform in platforms]))) - raise argparse.ArgumentError(self, message) - setattr(namespace, self.dest, values) + def __call__(self, parser, namespace, values, option_string=None): + if values: + for value in values: + if value not in platforms: + message = ("invalid platform: {0!r} (choose from {1})".format( + value, ', '.join([repr(platform) for platform in platforms]))) + raise argparse.ArgumentError(self, message) + setattr(namespace, self.dest, values) def warning(platforms): - gpl_third_parties_enabled = False - regex = re.compile("^ENABLE_GPL_THIRD_PARTIES:BOOL=ON") - f = open( - 'WORK/ios-{arch}/cmake/CMakeCache.txt'.format(arch=platforms[0]), 'r') - for line in f: - if regex.match(line): - gpl_third_parties_enabled = True - break - f.close() + gpl_third_parties_enabled = False + regex = re.compile("^ENABLE_GPL_THIRD_PARTIES:BOOL=ON") + f = open( + 'WORK/ios-{arch}/cmake/CMakeCache.txt'.format(arch=platforms[0]), 'r') + for line in f: + if regex.match(line): + gpl_third_parties_enabled = True + break + f.close() - if gpl_third_parties_enabled: - print(""" + if gpl_third_parties_enabled: + print(""" *************************************************************************** *************************************************************************** ***** CAUTION, this liblinphone SDK is built using 3rd party GPL code ***** @@ -124,8 +125,8 @@ def warning(platforms): *************************************************************************** *************************************************************************** """) - else: - print(""" + else: + print(""" ***************************************************************** ***************************************************************** ***** Linphone SDK without 3rd party GPL software ***** @@ -138,88 +139,96 @@ def warning(platforms): def extract_libs_list(): - l = [] - # name = libspeexdsp.a; path = "liblinphone-sdk/apple-darwin/lib/libspeexdsp.a"; sourceTree = ""; }; - regex = re.compile("name = (lib(\S+)\.a); path = \"liblinphone-sdk/apple-darwin/") - f = open('linphone.xcodeproj/project.pbxproj', 'r') - lines = f.readlines() - f.close() - for line in lines: - m = regex.search(line) - if m is not None: - l += [m.group(1)] - return list(set(l)) + l = [] + # name = libspeexdsp.a; path = "liblinphone-sdk/apple-darwin/lib/libspeexdsp.a"; sourceTree = ""; }; + regex = re.compile("name = (lib(\S+)\.a); path = \"liblinphone-sdk/apple-darwin/") + f = open('linphone.xcodeproj/project.pbxproj', 'r') + lines = f.readlines() + f.close() + for line in lines: + m = regex.search(line) + if m is not None: + l += [m.group(1)] + return list(set(l)) def install_git_hook(): - git_hook_path = ".git{sep}hooks{sep}pre-commit".format(sep=os.sep) - if os.path.isdir(".git{sep}hooks".format(sep=os.sep)) and not os.path.isfile(git_hook_path): - print("Installing Git pre-commit hook") - shutil.copyfile(".git-pre-commit", git_hook_path) - os.chmod(git_hook_path, 0755) + git_hook_path = ".git{sep}hooks{sep}pre-commit".format(sep=os.sep) + if os.path.isdir(".git{sep}hooks".format(sep=os.sep)) and not os.path.isfile(git_hook_path): + print("Installing Git pre-commit hook") + shutil.copyfile(".git-pre-commit", git_hook_path) + os.chmod(git_hook_path, 0755) def main(argv=None): - if argv is None: - argv = sys.argv - argparser = argparse.ArgumentParser( - description="Prepare build of Linphone and its dependencies.") - argparser.add_argument( - '-c', '-C', '--clean', help="Clean a previous build instead of preparing a build.", action='store_true') - argparser.add_argument( - '-d', '--debug', help="Prepare a debug build, eg. add debug symbols and use no optimizations.", action='store_true') - argparser.add_argument( - '-dv', '--debug-verbose', help="Activate ms_debug logs.", action='store_true') - argparser.add_argument( - '-f', '--force', help="Force preparation, even if working directory already exist.", action='store_true') - argparser.add_argument('-L', '--list-cmake-variables', - help="List non-advanced CMake cache variables.", action='store_true', - dest='list_cmake_variables') - argparser.add_argument('platform', nargs='*', action=PlatformListAction, default=[ - 'x86_64', 'devices'], - help="The platform to build for (default is 'x86_64 devices'). Space separated" - " architectures in list: {0}.".format(', '.join([repr(platform) for platform in platforms]))) - args, additional_args = argparser.parse_known_args() + if argv is None: + argv = sys.argv + argparser = argparse.ArgumentParser( + description="Prepare build of Linphone and its dependencies.") + argparser.add_argument( + '-c', '-C', '--clean', help="Clean a previous build instead of preparing a build.", action='store_true') + argparser.add_argument( + '-d', '--debug', help="Prepare a debug build, eg. add debug symbols and use no optimizations.", action='store_true') + argparser.add_argument( + '-dv', '--debug-verbose', help="Activate ms_debug logs.", action='store_true') + argparser.add_argument( + '-f', '--force', help="Force preparation, even if working directory already exist.", action='store_true') + argparser.add_argument('-L', '--list-cmake-variables', + help="List non-advanced CMake cache variables.", action='store_true', + dest='list_cmake_variables') + argparser.add_argument('platform', nargs='*', action=PlatformListAction, default=[ + 'x86_64', 'devices'], + help="The platform to build for (default is 'x86_64 devices'). Space separated" + " architectures in list: {0}.".format(', '.join([repr(platform) for platform in platforms]))) + args, additional_args = argparser.parse_known_args() - install_git_hook() + install_git_hook() - selected_platforms = [] - for platform in args.platform: - if platform == 'all': - selected_platforms += archs_device + archs_simu - elif platform == 'devices': - selected_platforms += archs_device - elif platform == 'simulators': - selected_platforms += archs_simu - else: - selected_platforms += [platform] - selected_platforms = list(set(selected_platforms)) + selected_platforms = [] + for platform in args.platform: + if platform == 'all': + selected_platforms += archs_device + archs_simu + elif platform == 'devices': + selected_platforms += archs_device + elif platform == 'simulators': + selected_platforms += archs_simu + else: + selected_platforms += [platform] + selected_platforms = list(set(selected_platforms)) - retcode = 0 - makefile_platforms = [] - for platform in selected_platforms: - target = targets[platform] + retcode = 0 + makefile_platforms = [] + for platform in selected_platforms: + target = targets[platform] - if args.clean: - target.clean() - else: - if args.debug_verbose: - additional_args += ["-DENABLE_DEBUG_LOGS=YES"] - retcode = prepare.run( - target, args.debug, False, args.list_cmake_variables, args.force, additional_args) - if retcode != 0: - return retcode - makefile_platforms += [platform] + if args.clean: + target.clean() + else: + if args.debug_verbose: + additional_args += ["-DENABLE_DEBUG_LOGS=YES"] + retcode = prepare.run( + target, args.debug, False, args.list_cmake_variables, args.force, additional_args) + if retcode != 0: + if retcode == 51: + p = Popen(["make", "help-prepare-options"]) + return retcode + makefile_platforms += [platform] - if makefile_platforms: - libs_list = extract_libs_list() - packages = os.listdir('WORK/ios-' + makefile_platforms[0] + '/Build') - packages.sort() - arch_targets = "" - for arch in makefile_platforms: - arch_targets += """ + if makefile_platforms: + libs_list = extract_libs_list() + packages = os.listdir('WORK/ios-' + makefile_platforms[0] + '/Build') + packages.sort() + arch_targets = "" + for arch in makefile_platforms: + arch_targets += """ {arch}: all-{arch} +package-in-list-%: + if ! grep -q " $* " <<< " $(packages) "; then \\ + echo "$* not in list of available packages: $(packages)"; \\ + exit 3; \\ + fi + {arch}-build: @for package in $(packages); do \\ $(MAKE) {arch}-build-$$package; \\ @@ -235,16 +244,16 @@ def main(argv=None): $(MAKE) {arch}-veryclean-$$package; \\ done -{arch}-build-%: +{arch}-build-%: package-in-list-% rm -f WORK/ios-{arch}/Stamp/EP_$*/EP_$*-update; \\ $(MAKE) -C WORK/ios-{arch}/cmake EP_$* -{arch}-clean-%: +{arch}-clean-%: package-in-list-% $(MAKE) -C WORK/ios-{arch}/Build/$* clean; \\ rm -f WORK/ios-{arch}/Stamp/EP_$*/EP_$*-build; \\ rm -f WORK/ios-{arch}/Stamp/EP_$*/EP_$*-install; -{arch}-veryclean-%: +{arch}-veryclean-%: package-in-list-% cat WORK/ios-{arch}/Build/$*/install_manifest.txt | xargs rm; \\ rm -rf WORK/ios-{arch}/Build/$*/*; \\ rm -f WORK/ios-{arch}/Stamp/EP_$*/*; \\ @@ -276,17 +285,17 @@ def main(argv=None): rm -f WORK/ios-{arch}/Stamp/EP_vpx/*; \\ echo "Run 'make {arch}-build-vpx' to rebuild vpx correctly."; """.format(arch=arch) - multiarch = "" - for arch in makefile_platforms[1:]: - multiarch += \ - """ if test -f "$${arch}_path"; then \\ + multiarch = "" + for arch in makefile_platforms[1:]: + multiarch += \ + """ if test -f "$${arch}_path"; then \\ all_paths=`echo $$all_paths $${arch}_path`; \\ all_archs="$$all_archs,{arch}" ; \\ else \\ echo "WARNING: archive `basename $$archive` exists in {first_arch} tree but does not exists in {arch} tree: $${arch}_path."; \\ fi; \\ """.format(first_arch=makefile_platforms[0], arch=arch) - makefile = """ + makefile = """ archs={archs} packages={packages} libs_list={libs_list} @@ -303,19 +312,19 @@ all-%: done $(MAKE) -C WORK/ios-$*/cmake -build-%: +build-%: package-in-list-% @for arch in $(archs); do \\ echo "==== starting build of $* for arch $$arch ===="; \\ $(MAKE) $$arch-build-$*; \\ done -clean-%: +clean-%: package-in-list-% @for arch in $(archs); do \\ echo "==== starting clean of $* for arch $$arch ===="; \\ $(MAKE) $$arch-clean-$*; \\ done -veryclean-%: +veryclean-%: package-in-list-% @for arch in $(archs); do \\ echo "==== starting veryclean of $* for arch $$arch ===="; \\ $(MAKE) $$arch-veryclean-$*; \\ @@ -380,7 +389,12 @@ push-transifex: zipres: @tar -czf ios_assets.tar.gz Resources iTunesArtwork -help: +help-prepare-options: + @echo "prepare.py was previously executed with the following options:" + @echo " {options}" + +help: help-prepare-options + @echo "" @echo "(please read the README.md file first)" @echo "" @echo "Available architectures: {archs}" @@ -401,16 +415,17 @@ help: @echo "" @echo " * sdk : re-add all generated libraries to the SDK. Use this only after a full build." @echo " * libs : after a rebuild of a subpackage, will mix the new libs in liblinphone-sdk/apple-darwin directory" -""".format(archs=' '.join(makefile_platforms), arch_opts='|'.join(makefile_platforms), first_arch=makefile_platforms[0], - arch_targets=arch_targets, packages=' '.join(packages), libs_list=' '.join(libs_list), multiarch=multiarch) - f = open('Makefile', 'w') - f.write(makefile) - f.close() - warning(makefile_platforms) - elif os.path.isfile('Makefile'): - os.remove('Makefile') +""".format(archs=' '.join(makefile_platforms), arch_opts='|'.join(makefile_platforms), + first_arch=makefile_platforms[0], options=' '.join(sys.argv), + arch_targets=arch_targets, packages=' '.join(packages), libs_list=' '.join(libs_list), multiarch=multiarch) + f = open('Makefile', 'w') + f.write(makefile) + f.close() + warning(makefile_platforms) + elif os.path.isfile('Makefile'): + os.remove('Makefile') - return retcode + return retcode if __name__ == "__main__": - sys.exit(main()) + sys.exit(main()) diff --git a/submodules/cmake-builder b/submodules/cmake-builder index cf6ad6e18..3955daa45 160000 --- a/submodules/cmake-builder +++ b/submodules/cmake-builder @@ -1 +1 @@ -Subproject commit cf6ad6e18ce9707e8236a6ab2c0fd789bdb9287d +Subproject commit 3955daa45fa1f0eeb13b041560f78cfa7450968b diff --git a/submodules/libilbc-rfc3951 b/submodules/libilbc-rfc3951 index bc20f1196..a6bb1eb6d 160000 --- a/submodules/libilbc-rfc3951 +++ b/submodules/libilbc-rfc3951 @@ -1 +1 @@ -Subproject commit bc20f11963878a1f32511de59b05490093e5c9b8 +Subproject commit a6bb1eb6dab5541cdded6a1f0326539234954c5d