[hackers] [scc] [driver] add a build function to manage build sequence || Quentin Rameau
commit 1d6a2a973016cdd636ca66132a559896e5817bab
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Wed Jun 1 18:56:00 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Wed Jun 1 18:56:00 2016 +0200
[driver] add a build function to manage build sequence
This will help us set more complex sequences in the future (notably for
writing intermediary files).
diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index d558734..faf27ee 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -87,19 +87,17 @@ inittool(int tool)
}
int
-settool(int t, int pipeout)
+settool(int t, int output)
{
struct tool *tool = &tools[t];
int fds[2], n;
static int fdin;
- inittool(t);
-
if (fdin) {
tool->in = fdin;
fdin = 0;
}
- if (pipeout) {
+ if (output < NR_TOOLS) {
if (pipe(fds))
die("scc: pipe: %s", strerror(errno));
tool->out = fds[1];
_AT_@ -135,6 +133,31 @@ spawn(int t)
}
}
+void
+build(char *file)
+{
+ int tool, out;
+
+ for (tool = CC1; tool < NR_TOOLS; tool = out) {
+ switch (tool) {
+ case CC1:
+ out = CC2;
+ ADDARG(tool, file);
+ break;
+ case CC2:
+ out = (!arch || strcmp(arch, "qbe")) ? NR_TOOLS : QBE;
+ break;
+ case QBE:
+ out = NR_TOOLS;
+ break;
+ default:
+ break;
+ }
+
+ spawn(settool(inittool(tool), out));
+ }
+}
+
static void
usage(void)
{
_AT_@ -169,20 +192,7 @@ main(int argc, char *argv[])
if (!argc)
die("scc: fatal error: no input files");
- ADDARG(CC1, *argv);
-
- if (Eflag) {
- spawn(settool(CC1, 0));
- } else {
- spawn(settool(CC1, 1));
-
- if (!arch || strcmp(arch, "qbe")) {
- spawn(settool(CC2, 0));
- } else {
- spawn(settool(CC2, 1));
- spawn(settool(QBE, 0));
- }
- }
+ build(*argv);
for (i = 0; i < NR_TOOLS; ++i) {
if ((pid = wait(&st)) < 0)
Received on Wed Jun 01 2016 - 18:57:53 CEST
This archive was generated by hypermail 2.3.0
: Wed Jun 01 2016 - 19:00:21 CEST