ios_build package

Submodules

ios_build.build module

ios_build.build.checkPath(path, **kwargs)

Determines whether the given path exists and is a valid CMake project, i.e. contains a CMakeLists.txt file. If the path is not found a NotADirectoryError is thown. Else if the path does not contain a CMakeLists.txt file, then a FileNotFoundError is raised. Whether the CMakeLists.txt file is valid is not checked here.

Parameters:

path (str | Path) – Local path for the CMake project.

Raises:

IOSBuildError – Raised if path is not a valid CMake project directory.

ios_build.build.setupDirectory(dir_prefix, clean=False, prefix=None, name='Directory', **kwargs)

Setup a directory at path prefix/dir_prefix and returns the full path. If the directory already exists, nothing is done unless the clean option is specified. If clean is specified, the existing directory is removed and a clean version created. If prefix is not specified, then dir_prefix may be specified relative to the current working directory. If prefix is specified, then dir_prefix is the desired path relative to prefix.

Parameters:
  • dir_prefix (str | Path) – Path to directory

  • clean (bool, optional) – Clean any existing directory at desired location. Defaults to False.

  • prefix (str, optional) – Optional path prefix. Defaults to None.

  • name (str)

Returns:

_description_

Return type:

str

ios_build.build.createFrameworks(install_dir, output_dir, **kwargs)

Searches for static libraries in the install_dir and uses them to create an xcframework for each. The framework contains versions of the library for each platform.

Parameters:
  • install_dir (str) – Parent directory containing static libraries for all platforms.

  • output_dir (Path)

ios_build.build.cleanUp(build_dir, install_dir, clean_up=False, **kwargs)

Function to clean up files after the program is run.

Parameters:
  • build_dir (str) – Parent directory of all build files

  • install_dir (str) – Parent directory of installations.

  • clean_up (bool, optional) – Whether to remove the above directories. Defaults to False.

ios_build.build.build(build_dir, platforms=[], **kwargs)

Loop through each platform and run CMake for each. This includes the configure step, building and installation.

Parameters:
  • build_dir (str) – Parent directory for all build files

  • platforms (list[str], optional) – List of platforms to build. Defaults to None.

Raises:

RuntimeError – _description_

ios_build.build.iosBuild(build_prefix=PosixPath('build'), install_prefix=PosixPath('install'), **kwargs)

Run the full iOSBuild using CMake and XCodeBuild for the CMake project using the options obtained from the parser.

Parameters:
  • build_prefix (str, optional) – Build directory prefix. Defaults to “build”.

  • install_prefix (str, optional) – Install directory prefix. Defaults to “install”.

ios_build.build.runBuild(print_level=0, **kwargs)

Run the full iOSBuild using CMake and XCodeBuild for the CMake project using the options obtained from the parser.

Parameters:
  • build_prefix (str, optional) – Build directory prefix. Defaults to “build”.

  • install_prefix (str, optional) – Install directory prefix. Defaults to “install”.

  • print_level (int)

ios_build.cmake module

ios_build.cmake.checkCMake(**kwargs)

Check the existence of cmake by calling the interface with the –version option.

ios_build.cmake.checkInput(*args)

Checks args are not None

Raises:

TypeError – Raised if arg is None

ios_build.cmake.configure(path=None, platform=None, toolchain_path=None, install_dir=None, platform_dir=None, platform_options={}, cmake_options={}, generator='Xcode', **kwargs)

Run the CMake configure step. This passes the path to CMake along with all the options necessary for CMake to run the configuration. Some of the cmake options are fixed and may not be altered for compatibility with the ios toolchain. CMake cache options may be specified using the cmake_options dictionary and platform specific options using a similar embedded dictionary in platform_options keyed by platform name.

Parameters:
  • path (str, optional) – Path to a valid CMake project. Defaults to None.

  • platform (str, optional) – The target platform to build. Defaults to None.

  • toolchain_path (str, optional) – Path to toolchain file. Defaults to None.

  • install_dir (str, optional) – Install directory prefix. Defaults to None.

  • platform_dir (str, optional) – Platform specific build directory. Defaults to None.

  • platform_options (dict, optional) – Platform specific cmake cache options. Defaults to {}.

  • cmake_options (dict, optional) – CMake cache options. Defaults to {}.

  • generator (str, optional) – CMake generator. Defaults to “Xcode”.

ios_build.cmake.build(platform_dir=None, config='Release', **kwargs)

CMake build step. Assumes configuration is completed runs cmake –build {platform_dir} –config {config} where platform_dir is the CMake build directory.

Parameters:
  • platform_dir (str, optional) – Directory containing CMake configuration (CMakeCache.txt). Defaults to None.

  • config (str, optional) – CMake configuration to build. Defaults to “Release”.

ios_build.cmake.install(platform_dir=None, config='Release', **kwargs)

Cmake install step. Assumes configuration and build are complete and runs cmake –install {platform_dir} –config {config} where platform_dir is the CMake build directory.

Parameters:
  • platform_dir (str, optional) – CMake build directory containing CMakeCache.txt. Defaults to None.

  • config (str, optional) – CMake configuration. Defaults to “Release”.

ios_build.cmake.runCMake(**kwargs)

Run CMake configuration, build and install, with all options specified using kwargs.

ios_build.interface module

ios_build.interface.callSubProcess(command, printer)

Call a subprocess specified using a list of commands.

Parameters:
  • command (list) – List of commands to run formatted for subprocess.

  • printer (Printer) – Printer class

Raises:

RuntimeError – Raised if the process returns a non-zero exit code.

ios_build.interface.cmake(*args, cmake_command='cmake', **kwargs)

Runs cmake using subprocess.

Parameters:
  • cmake_command (str, optional) – Custom CMake command. Defaults to “cmake”.

  • verbose (bool) – Toggle additional output

ios_build.interface.xcodebuild(*args, xcode_build_command='xcodebuild', **kwargs)

Runs xcodebuild using subprocess.

Parameters:

xcode_build_command (str, optional) – Custom xcodebuild command. Defaults to “xcodebuild”.

ios_build.parser module

ios_build.parser.tmpDir()
Return type:

Path

ios_build.parser.parseArgs(args=None)

Main parser, parses the command-line arguments using argparse. The full list of arguments is found using the help option -h. Note that any errors in argparse return a SystemExit signal which must be caught.

Parameters:

args (optional) – Optional additional arguments (for testing purposes).

ios_build.printer module

class ios_build.printer.Printer(print_level=0)

Bases: object

Class to handle all printing using a verbosity scale to determine what to print

print(value, verbosity=0, **kwargs)
printValue(text, value, verbosity=0, **kwargs)

Print a value inline with a fixed width for key. :param text: Key for printed value :type text: str :param value: value to be printed :type value: str :param verbosity: The level of verbosity at which the statement should be printed. Defaults to 0. :type verbosity: int

tick(verbosity=0, **kwargs)

Print a ✅ character

Parameters:

verbosity (int) – The level of verbosity at which the statement should be printed. Defaults to 0.

cross(verbosity=0, **kwargs)

Print a ❌ character

Parameters:

verbosity (int) – The level of verbosity at which the statement should be printed. Defaults to 0.

printStat(text, tick='tick', **kwargs)
printEmbeddedDict(input_dict, verbosity=0, header=None)

Print a dictionary using a recursive algorithm for embedded dictionaries.

Parameters:
  • input_dict (dict) – Input dictionary

  • verbosity (int) – The level of verbosity at which the statement should be printed. Defaults to 0.

  • he

  • header (str | None)

showOutput()
showError()
printError(value)
printHeader(**kwargs)
printFooter(**kwargs)
Return type:

str | None

ios_build.printer.getPrinter(**kwargs)
Return type:

Printer

ios_build.run module

ios_build.run.runner(args=None)

iOSBuild runner.

Parameters:

args (list, optional) – Optional arguments for testing. Defaults to None.

Returns:

exit code

Return type:

int

ios_build.search module

ios_build.search.findPlatformLibraries(directory)

Search for static libraries within the directory. This function uses walk() to search the directory for static libraries (files with suffix .a). Any results are added to the results dictionary.

Parameters:

directory (str) – Directory to search

Returns:

Full path to libraries keyed by library names.

Return type:

dict[str, str]

ios_build.search.invertDict(libraries)

Invert a dictionary of structure libraries[k1][k2] to a dictionary with structure result[k2][k1].

Parameters:

libraries (_type_) – Two-level input dictionary to be inverted.

Returns:

Output dictionary with key order inverted.

Return type:

dict[str, dict]

ios_build.search.findlibraries(install_dir, platforms=[], **kwargs)

Find static libraries for each platform in a directory. Assuming files for each platform are contained in a subdirectory of the same name.

Parameters:
  • install_dir (str) – Parent directory where libraries should be installed

  • platforms (list[str], optional) – List of platforms corresponding to subdirectories in the install_dir folder. Defaults to [].

Returns:

Dictionary of the paths ordered by library and platform

Return type:

dict[str, dict[str, Path]]

ios_build.xcodebuild module

ios_build.xcodebuild.checkXCodeBuild(**kwargs)

Check availability of xcodebuild command using xcodebuild -version.

ios_build.xcodebuild.createXCFramework(install_dir, lib, files, **kwargs)

Create an xcframework for library lib in install_dir containing all the libraries in files.

Parameters:
  • install_dir (str) – Parent directory for framework

  • lib (str) – Name of output library

  • files (dict[str, str]) – All library files in a dictionary