From 6fbb2fb2be1c97c8403c4bbabe9fc0a6388ba012 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 23 Jan 2009 00:54:03 +0000 Subject: [PATCH] ccc: Add support for several more aliases (--ansi, --assemble, --assert, --classpath). - Requires providing some option parameters to over-ride rendering in order to match gcc. There may be a cleaner way to do this (probably by introducing a new option type for long JoinedOrSeparate forms). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62825 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/ccc/ccclib/Arguments.py | 30 ++++++++++++++++++++++++++++-- tools/ccc/test/ccc/aliases.c | 13 +++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tools/ccc/test/ccc/aliases.c diff --git a/tools/ccc/ccclib/Arguments.py b/tools/ccc/ccclib/Arguments.py index 87487e0144..8b926225d8 100644 --- a/tools/ccc/ccclib/Arguments.py +++ b/tools/ccc/ccclib/Arguments.py @@ -15,7 +15,9 @@ class Option(object): """Option - Root option class.""" def __init__(self, name, group=None, alias=None, - isLinkerInput=False, noOptAsInput=False): + isLinkerInput=False, noOptAsInput=False, + forceSeparateRender=False, + forceJoinedRender=False): assert group is None or isinstance(group, OptionGroup) # Multi-level aliases are not supported, and alias options # cannot have groups. This just simplifies option tracking, it @@ -28,6 +30,8 @@ class Option(object): self.alias = alias self.isLinkerInput = isLinkerInput self.noOptAsInput = noOptAsInput + self.forceSeparateRender = forceSeparateRender + self.forceJoinedRender = forceJoinedRender def getUnaliasedOption(self): if self.alias: @@ -233,6 +237,9 @@ class JoinedValueArg(ValueArg): return args.getInputString(self.index)[len(self.opt.name):] def render(self, args): + if self.opt.forceSeparateRender: + return [self.opt.getRenderName(), + self.getValue(args)] return [self.opt.getRenderName() + self.getValue(args)] def renderAsInput(self, args): @@ -248,6 +255,8 @@ class SeparateValueArg(ValueArg): return args.getInputString(self.index, offset=1) def render(self, args): + if self.opt.forceJoinedRender: + return [self.opt.getRenderName() + self.getValue(args)] return [self.opt.getRenderName(), self.getValue(args)] def renderAsInput(self, args): @@ -520,7 +529,10 @@ class OptionParser: # Pipeline control self.hashHashHashOption = self.addOption(FlagOption('-###')) self.EOption = self.addOption(FlagOption('-E')) + self.SOption = self.addOption(FlagOption('-S')) + self.addOption(FlagOption('--assemble', alias=self.SOption)) + self.cOption = self.addOption(FlagOption('-c')) self.combineOption = self.addOption(FlagOption('-combine')) self.noIntegratedCPPOption = self.addOption(FlagOption('-no-integrated-cpp')) @@ -568,6 +580,8 @@ class OptionParser: #### # Bring on the random garbage. + self.sOption = self.addOption(FlagOption('-s')) + self.MGroup = OptionGroup('-M') self.MOption = self.addOption(FlagOption('-M', self.MGroup)) self.MDOption = self.addOption(FlagOption('-MD', self.MGroup)) @@ -707,6 +721,10 @@ class OptionParser: # stuff to cc1, but the way the ld spec is constructed it # wants to see -A options but only as a separate arg. self.AOption = self.addOption(JoinedOrSeparateOption('-A')) + self.addOption(JoinedOption('--assert=', alias=self.AOption, + forceSeparateRender=True)) + self.addOption(SeparateOption('--assert', alias=self.AOption)) + self.DOption = self.addOption(JoinedOrSeparateOption('-D')) self.FOption = self.addOption(JoinedOrSeparateOption('-F')) self.IOption = self.addOption(JoinedOrSeparateOption('-I')) @@ -737,7 +755,7 @@ class OptionParser: # FIXME: Naming convention. self.dGroup = OptionGroup('-d') self.dAOption = self.addOption(FlagOption('-dA', self.dGroup)) - self.addOption(FlagOption('-d', self.dGroup)) + self.dOption = self.addOption(FlagOption('-d', self.dGroup)) # Use a group for this in anticipation of adding more -d # options explicitly. Note that we don't put many -d things in @@ -766,6 +784,12 @@ class OptionParser: self.fastcpOption = self.addOption(FlagOption('-fastcp', self.fGroup)) self.f_appleKextOption = self.addOption(FlagOption('-fapple-kext', self.fGroup)) + + self.f_classpathOption = self.addOption(JoinedOption('-fclasspath=', self.fGroup)) + self.addOption(JoinedOption('--classpath=', alias=self.f_classpathOption)) + self.addOption(SeparateOption('--classpath', alias=self.f_classpathOption, + forceJoinedRender=True)) + self.f_constantCfstringsOption = self.addOption(FlagOption('-fconstant-cfstrings', self.fGroup)) self.f_createProfileOption = self.addOption(FlagOption('-fcreate-profile', self.fGroup)) self.f_debugPassArgumentsOption = self.addOption(FlagOption('-fdebug-pass-arguments', self.fGroup)) @@ -835,6 +859,8 @@ class OptionParser: # FIXME: Why does Darwin send -a* to cc1? self.aGroup = OptionGroup('-a') self.ansiOption = self.addOption(FlagOption('-ansi', self.aGroup)) + self.addOption(FlagOption('--ansi', alias=self.ansiOption)) + self.aOption = self.addOption(JoinedOption('-a', self.aGroup)) self.pedanticGroup = OptionGroup('-pedantic') diff --git a/tools/ccc/test/ccc/aliases.c b/tools/ccc/test/ccc/aliases.c new file mode 100644 index 0000000000..f9b89a14d4 --- /dev/null +++ b/tools/ccc/test/ccc/aliases.c @@ -0,0 +1,13 @@ +// RUN: xcc -### -S --all-warnings %s &> %t && +// RUN: grep -- '"-Wall"' %t && + +// RUN: xcc -### -S --ansi %s &> %t && +// RUN: grep -- '"-ansi"' %t && + +// RUN: xcc -### -S --assert foo --assert=foo %s &> %t && +// RUN: grep -- '"-A" "foo" "-A" "foo"' %t && + +// RUN: xcc -### -S --classpath foo --classpath=foo %s &> %t && +// RUN: grep -- '"-fclasspath=foo" "-fclasspath=foo"' %t && + +// RUN: true -- 2.40.0