ref: bfde4c47d9b5286c325f72827c2b9956d8262ed9
parent: 612866dd4e41726fa1d66bb7f9dbfa39e1dfa9e2
author: Quentin Rameau <quinq@fifth.space>
date: Mon May 30 09:05:50 EDT 2016
[driver] introduce handling of per tool flags Add a tool variable for the actual number of parameters. Add handling of cc1 -E option.
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -26,6 +26,7 @@
static struct {
char cmd[PATH_MAX];
char *args[NARGS];
+ int nargs;
char bin[16];
char name[8];
int in, out;
@@ -38,6 +39,7 @@
char *argv0;
static char *arch;
+static int Eflag;
static void
terminate(void)
@@ -53,7 +55,6 @@
int
settool(int tool, int pipeout)
{
- char *namefmt, *cmdfmt;
int fds[2], n;
static int fdin;
@@ -131,6 +132,10 @@
arch = getenv("ARCH");
ARGBEGIN {
+ case 'E':
+ Eflag = 1;
+ tools[CC1].args[++tools[CC1].nargs] = "-E";
+ break;
case 'm':
arch = EARGF(usage());
break;
@@ -144,14 +149,19 @@
if (!argc)
die("scc: fatal error: no input files");
- tools[CC1].args[1] = *argv;
+ tools[CC1].args[++tools[CC1].nargs] = *argv;
- spawn(settool(CC1, 1));
- if (!arch || strcmp(arch, "qbe")) {
- spawn(settool(CC2, 0));
+ if (Eflag) {
+ spawn(settool(CC1, 0));
} else {
- spawn(settool(CC2, 1));
- spawn(settool(QBE, 0));
+ spawn(settool(CC1, 1));
+
+ if (!arch || strcmp(arch, "qbe")) {
+ spawn(settool(CC2, 0));
+ } else {
+ spawn(settool(CC2, 1));
+ spawn(settool(QBE, 0));
+ }
}
for (i = 0; i < NR_TOOLS; ++i) {