From c1b305244aba9c8ea3265cadba9ecaca0dbb9461 Mon Sep 17 00:00:00 2001 From: Erik Chen Date: Fri, 10 Feb 2017 09:43:39 -0800 Subject: [PATCH] Update mig.py to take an explicit sdk argument. BUG=chromium:690734 > Review-Url: https://codereview.chromium.org/2685233002 > Cr-Commit-Position: refs/heads/master@{#449550} > Message-Id: Merged from chromium 53f2146935506b4f382705b605dffec41b5519eb Change-Id: I1b3176a4a62078f1e27184ad589c9c3f4b548674 Reviewed-on: https://chromium-review.googlesource.com/440847 Reviewed-by: Mark Mentovai --- util/mach/mig.py | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/util/mach/mig.py b/util/mach/mig.py index eca2348..a41c4f8 100755 --- a/util/mach/mig.py +++ b/util/mach/mig.py @@ -15,6 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import argparse import os import re import subprocess @@ -107,23 +108,32 @@ extern "C" { file.close() def main(args): - if len(args) == 5: - (defs_file, user_c, server_c, user_h, server_h) = args - elif len(args) == 6: - (defs_file, user_c, server_c, user_h, server_h, dev_dir) = args - os.environ['DEVELOPER_DIR'] = dev_dir - else: - assert False, "Wrong number of arguments" - subprocess.check_call(['mig', - '-user', user_c, - '-server', server_c, - '-header', user_h, - '-sheader', server_h, - defs_file]) - FixUserImplementation(user_c) - server_declarations = FixServerImplementation(server_c) - FixHeader(user_h) - FixHeader(server_h, server_declarations) + parser = argparse.ArgumentParser() + parser.add_argument('--developer-dir', help='Path to Xcode') + parser.add_argument('--sdk', help='Path to SDK') + parser.add_argument('defs') + parser.add_argument('user_c') + parser.add_argument('server_c') + parser.add_argument('user_h') + parser.add_argument('server_h') + parsed = parser.parse_args(args) + + command = ['mig', + '-user', parsed.user_c, + '-server', parsed.server_c, + '-header', parsed.user_h, + '-sheader', parsed.server_h, + ] + if parsed.sdk is not None: + command.extend(['-isysroot', parsed.sdk]) + if parsed.developer_dir is not None: + os.environ['DEVELOPER_DIR'] = parsed.developer_dir + command.append(parsed.defs) + subprocess.check_call(command) + FixUserImplementation(parsed.user_c) + server_declarations = FixServerImplementation(parsed.server_c) + FixHeader(parsed.user_h) + FixHeader(parsed.server_h, server_declarations) if __name__ == '__main__': sys.exit(main(sys.argv[1:]))