[hackers] [scc] [driver] add support for custom runtime libexec path || Quentin Rameau

From: <git_AT_suckless.org>
Date: Mon, 23 Jan 2017 15:26:20 +0100 (CET)

commit e93f759a6bcd0d6e812a3f6c6f6146c637f7145c
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Mon Jan 23 14:31:04 2017 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Mon Jan 23 14:47:51 2017 +0100

    [driver] add support for custom runtime libexec path
    
    Now scc will lookup the env for SCCEXECPATH and search there for exec
    lib tools.

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index 647affb..beaed6f 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -38,9 +38,9 @@ static struct tool {
         int in, out, init;
         pid_t pid;
 } tools[] = {
- [CC1] = { .bin = "cc1", .cmd = PREFIX "/libexec/scc/", },
+ [CC1] = { .bin = "cc1" },
         [TEEIR] = { .bin = "tee", .cmd = "tee", },
- [CC2] = { .bin = "cc2", .cmd = PREFIX "/libexec/scc/", },
+ [CC2] = { .bin = "cc2" },
         [TEEQBE] = { .bin = "tee", .cmd = "tee", },
         [QBE] = { .bin = "qbe", .cmd = "qbe", },
         [TEEAS] = { .bin = "tee", .cmd = "tee", },
_AT_@ -50,7 +50,7 @@ static struct tool {
 };
 
 char *argv0;
-static char *arch, *objfile, *outfile;
+static char *arch, *execpath, *objfile, *outfile;
 static char *tmpdir;
 static size_t tmpdirln;
 static struct items objtmp, objout;
_AT_@ -114,9 +114,11 @@ inittool(int tool)
                         die("scc: target tool bin too long");
                 binln = strlen(t->bin);
 
- if (strlen(t->cmd) + binln + 1 > sizeof(t->cmd))
+ if (!execpath)
+ execpath = PREFIX "/libexec/scc";
+ n = snprintf(t->cmd, sizeof(t->cmd), "%s/%s", execpath, t->bin);
+ if (n < 0 || n >= sizeof(t->cmd))
                         die("scc: target tool path too long");
- strcat(t->cmd, t->bin);
                 break;
         case LD:
                 addarg(tool, "-no-pie");
_AT_@ -425,6 +427,7 @@ main(int argc, char *argv[])
         atexit(terminate);
 
         arch = getenv("ARCH");
+ execpath = getenv("SCCEXECPATH");
 
         ARGBEGIN {
         case 'D':
Received on Mon Jan 23 2017 - 15:26:20 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 23 2017 - 15:36:16 CET