Add prototype ccc rewrite.
- Entry point is tools/ccc/xcc until we are a functional replacement
for ccc.
This is highly experimental (FIXME/LOC ratio of 3.4%), quite crufty,
and barely usable (and then only on my specific Darwin). However, many
of the right ideas are present, and it already fixes a number of
things gcc gets wrong.
The major missing component is argument translation for tools
(translating driver arguments into cc1/ld/as/etc. arguments). This is
a large part of the driver functionality and will probably double the
LOC, but my hope is that the current architecture is relatively
stable.
Documentation & motivation to follow soon...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61739 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/ccc/ccclib/Jobs.py b/tools/ccc/ccclib/Jobs.py
new file mode 100644
index 0000000..8ef8a03
--- /dev/null
+++ b/tools/ccc/ccclib/Jobs.py
@@ -0,0 +1,60 @@
+import Arguments
+import Util
+
+class Job(object):
+ """Job - A set of commands to execute as a single task."""
+
+ def iterjobs(self):
+ abstract
+
+class Command(Job):
+ """Command - Represent the information needed to execute a single
+ process."""
+
+ def __init__(self, executable, args):
+ assert Util.all_true(args, lambda x: isinstance(x, Arguments.Arg))
+ self.executable = executable
+ self.args = args
+
+ def __repr__(self):
+ return Util.prefixAndPPrint(self.__class__.__name__,
+ (self.executable, self.args))
+
+ def render(self, args):
+ argv = [self.executable]
+ for oi in self.args:
+ argv.extend(oi.render(args))
+ return argv
+
+ def iterjobs(self):
+ yield self
+
+class PipedJob(Job):
+ """PipedJob - A sequence of piped commands."""
+
+ def __init__(self, commands):
+ assert all_true(args, lambda x: isinstance(x, Arguments.Command))
+ self.commands = list(commands)
+
+ def addJob(self, job):
+ assert isinstance(job, Command)
+ self.commands.append(job)
+
+ def __repr__(self):
+ return Util.prefixAndPPrint(self.__class__.__name__, (self.commands,))
+
+class JobList(Job):
+ """JobList - A sequence of jobs to perform."""
+
+ def __init__(self, jobs=[]):
+ self.jobs = list(jobs)
+
+ def addJob(self, job):
+ self.jobs.append(job)
+
+ def __repr__(self):
+ return Util.prefixAndPPrint(self.__class__.__name__, (self.jobs,))
+
+ def iterjobs(self):
+ for j in self.jobs:
+ yield j