Compiles a XIB file with ibtool into a binary plist in the bundle.
(self, source, dest)
| 70 | self._ConvertToBinary(dest) |
| 71 | |
| 72 | def _CopyXIBFile(self, source, dest): |
| 73 | """Compiles a XIB file with ibtool into a binary plist in the bundle.""" |
| 74 | |
| 75 | # ibtool sometimes crashes with relative paths. See crbug.com/314728. |
| 76 | base = os.path.dirname(os.path.realpath(__file__)) |
| 77 | if os.path.relpath(source): |
| 78 | source = os.path.join(base, source) |
| 79 | if os.path.relpath(dest): |
| 80 | dest = os.path.join(base, dest) |
| 81 | |
| 82 | args = ["xcrun", "ibtool", "--errors", "--warnings", "--notices"] |
| 83 | |
| 84 | if os.environ["XCODE_VERSION_ACTUAL"] > "0700": |
| 85 | args.extend(["--auto-activate-custom-fonts"]) |
| 86 | if "IPHONEOS_DEPLOYMENT_TARGET" in os.environ: |
| 87 | args.extend( |
| 88 | [ |
| 89 | "--target-device", |
| 90 | "iphone", |
| 91 | "--target-device", |
| 92 | "ipad", |
| 93 | "--minimum-deployment-target", |
| 94 | os.environ["IPHONEOS_DEPLOYMENT_TARGET"], |
| 95 | ] |
| 96 | ) |
| 97 | else: |
| 98 | args.extend( |
| 99 | [ |
| 100 | "--target-device", |
| 101 | "mac", |
| 102 | "--minimum-deployment-target", |
| 103 | os.environ["MACOSX_DEPLOYMENT_TARGET"], |
| 104 | ] |
| 105 | ) |
| 106 | |
| 107 | args.extend( |
| 108 | ["--output-format", "human-readable-text", "--compile", dest, source] |
| 109 | ) |
| 110 | |
| 111 | ibtool_section_re = re.compile(r"/\*.*\*/") |
| 112 | ibtool_re = re.compile(r".*note:.*is clipping its content") |
| 113 | try: |
| 114 | stdout = subprocess.check_output(args) |
| 115 | except subprocess.CalledProcessError as e: |
| 116 | print(e.output) |
| 117 | raise |
| 118 | current_section_header = None |
| 119 | for line in stdout.splitlines(): |
| 120 | if ibtool_section_re.match(line): |
| 121 | current_section_header = line |
| 122 | elif not ibtool_re.match(line): |
| 123 | if current_section_header: |
| 124 | print(current_section_header) |
| 125 | current_section_header = None |
| 126 | print(line) |
| 127 | return 0 |
| 128 | |
| 129 | def _ConvertToBinary(self, dest): |
no test coverage detected