summaryrefslogtreecommitdiff
path: root/include_server/parse_command.py
diff options
context:
space:
mode:
authorfergus.henderson <fergushenderson@users.noreply.github.com>2010-08-19 19:23:49 +0000
committerfergus.henderson <fergushenderson@users.noreply.github.com>2010-08-19 19:23:49 +0000
commitdc2c66bf523a70178fc486abcbdfa9c2a379dbb1 (patch)
tree48f351cb35736f61d160e46eab79e7a0fc22b83a /include_server/parse_command.py
parentf07afd5a0d0150c3cb1b8559d668bbbd31ed1f2e (diff)
downloaddistcc-git-dc2c66bf523a70178fc486abcbdfa9c2a379dbb1.tar.gz
Apply --sysroot patch from Simon Baldwin <simonb@google.com>:
2010-08-18 Simon Baldwin <simonb@google.com> * include_server/compiler_defaults.py (_SystemSearchdirsGCC): Add a 'sysroot' parameter. Add --sysroot, if needed, to the gcc invocation that identifies search directories and default paths. Add debugging output. (SetSystemDirsDefaults): Add 'sysroot' parameter. Add another dictionary level to system_dirs_default for sysroot values. Add debugging output. * include_server/parse_command.py (ParseCommandArgs): Identify and handle arguments of the form '--opt=value'. Pass any --sysroot value to compiler_defaults.SetSystemDirsDefaults, use it in compiler_defaults.system_dirs_default lookups. (CPP_OPTIONS_APPEARING_AS_ASSIGNMENTS): New. * include_server/parse_command_test.py (Mock_SetSystemDirsDefaults): Add sysroot parameter, verify it on function calls. (ParseCommandUnitTest): Add --sysroot to mock gcc invocations.
Diffstat (limited to 'include_server/parse_command.py')
-rwxr-xr-xinclude_server/parse_command.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/include_server/parse_command.py b/include_server/parse_command.py
index e58f973..5b420ac 100755
--- a/include_server/parse_command.py
+++ b/include_server/parse_command.py
@@ -52,7 +52,7 @@ class ParseState:
self.language = 'none' # equivalent to commandline of '-x none'
self.isysroot = None
- self.sysroot = None
+ self.sysroot = ""
self.output_file = None
self.iprefix = ""
self.Dopts = []
@@ -109,8 +109,6 @@ CPP_OPTIONS_MAYBE_TWO_WORDS = {
'-imultilib': lambda ps, arg: _RaiseNotImplemented('-imultilib'),
'-isystem': lambda ps, arg: ps.before_system_dirs.append(arg),
'-iquote': lambda ps, arg: ps.quote_dirs.append(arg),
-# '--sysroot=': lambda ps, arg: ps.set_sysroot(arg),
- '--sysroot=': lambda ps, arg: None,
}
CPP_OPTIONS_MAYBE_TWO_WORDS_FIRST_LETTERS = ('M', 'i', '-')
# A "compile-time" check to make sure the first-letter list is up-to-date
@@ -139,6 +137,13 @@ CPP_OPTIONS_TWO_WORDS = {}
CPP_OPTIONS_TWO_WORDS.update(CPP_OPTIONS_MAYBE_TWO_WORDS)
CPP_OPTIONS_TWO_WORDS.update(CPP_OPTIONS_ALWAYS_TWO_WORDS)
+# These are the cpp options that a) are more than one letter long,
+# b) always take an argument, and c) have that argument separated from
+# the option by '='.
+CPP_OPTIONS_APPEARING_AS_ASSIGNMENTS = {
+ '--sysroot': lambda ps, arg: ps.set_sysroot(arg)
+}
+
# These are the cpp options that do not take an argument.
# (Note, most cpp options do not take an argument, but do not pertain to
# preprocessing, so we can ignore them. Those are dealt in the default
@@ -375,6 +380,16 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map,
raise NotCoveredError("No argument found for option '%s'" % args[i])
continue
+ # Deal with the have-arg options that appear as if assignments
+ # ("--sysroot=/mumble").
+ if '=' in args[i]:
+ arg, value = args[i].split('=', 1)
+ action = CPP_OPTIONS_APPEARING_AS_ASSIGNMENTS.get(arg)
+ if action:
+ action(parse_state, value)
+ i += 1
+ continue
+
# Deal with the options that take no arguments ("-nostdinc").
action = CPP_OPTIONS_ONE_WORD.get(args[i])
if action:
@@ -432,7 +447,8 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map,
parse_state.language = basics.TRANSLATION_UNIT_MAP[suffix]
assert parse_state.language in basics.LANGUAGES
- compiler_defaults.SetSystemDirsDefaults(compiler, parse_state.language, timer)
+ compiler_defaults.SetSystemDirsDefaults(compiler, parse_state.sysroot,
+ parse_state.language, timer)
def IndexDirs(dir_list):
"""Normalize directory names and index.
@@ -450,7 +466,7 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map,
if not parse_state.nostdinc:
angle_dirs.extend(
IndexDirs(compiler_defaults.system_dirs_default
- [compiler][parse_state.language]))
+ [compiler][parse_state.sysroot][parse_state.language]))
angle_dirs.extend(IndexDirs(parse_state.after_system_dirs))
quote_dirs = IndexDirs(parse_state.quote_dirs)