[hackers] [scc] [driver] add support for building from intermediary files || Quentin Rameau

From: <git_AT_suckless.org>
Date: Fri, 3 Jun 2016 11:03:23 +0200 (CEST)

commit e353903fa9ba4bbd405ca46c6ac651c8c8fb3cc2
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Fri Jun 3 01:00:00 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Fri Jun 3 01:10:26 2016 +0200

    [driver] add support for building from intermediary files

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index d3edc38..7c1a57a 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -99,6 +99,7 @@ inittool(int tool)
                         strcat(t->cmd, t->bin);
                         break;
                 case AS:
+ t->nargs = 2;
                         t->args[1] = "-o";
                         break;
                 default:
_AT_@ -142,12 +143,10 @@ settool(int tool, char *input, int output)
         static int fdin;
 
         switch (tool) {
- case CC1:
- t->args[t->nargs + 1] = input;
- break;
         case AS:
                 outfiles[output] = newfileext(input, "o");
- t->args[2] = outfiles[output];
+ t->args[t->nargs] = outfiles[output];
+ t->args[3] = NULL;
                 break;
         case TEE:
                 switch (output) {
_AT_@ -171,6 +170,8 @@ settool(int tool, char *input, int output)
         if (fdin) {
                 t->in = fdin;
                 fdin = 0;
+ } else {
+ t->args[t->nargs + 1] = input;
         }
 
         if (output < NR_TOOLS) {
_AT_@ -208,6 +209,22 @@ spawn(int t)
                 break;
         }
 }
+static int
+toolfor(char *file)
+{
+ char *dot = strrchr(file, '.');
+
+ if (dot) {
+ if (!strcmp(dot, ".c"))
+ return CC1;
+ if (!strcmp(dot, ".qbe"))
+ return QBE;
+ if (!strcmp(dot, ".as"))
+ return AS;
+ }
+
+ die("scc: do not recognize filetype of %s", file);
+}
 
 static void
 build(char *file)
_AT_@ -216,7 +233,7 @@ build(char *file)
         int i, st, tool, out, keepfile;
         static int preout;
 
- for (tool = CC1; tool < NR_TOOLS; tool = out) {
+ for (tool = toolfor(file); tool < NR_TOOLS; tool = out) {
                 keepfile = 0;
 
                 switch (tool) {
Received on Fri Jun 03 2016 - 11:03:23 CEST

This archive was generated by hypermail 2.3.0 : Fri Jun 03 2016 - 11:12:14 CEST