|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
/*******************************************************************/
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
/* slibtool: a skinny libtool implementation, written in C */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ca7ab6 |
/* Copyright (C) 2017 Z. Gilboa */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
/*******************************************************************/
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
|
|
Kylie McClain |
e20148 |
#include <unistd.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
#include <stdio.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
#include <slibtool/slibtool.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
#include "slibtool_errinfo_impl.h"
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
8ea8fc |
static const char aclr_null[] = "";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
8ea8fc |
static const char aclr_reset[] = "\x1b[0m";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
8ea8fc |
static const char aclr_bold[] = "\x1b[1m";
|
|
Kylie McClain |
e20148 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
8ea8fc |
static const char aclr_green[] = "\x1b[32m";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
8ea8fc |
static const char aclr_blue[] = "\x1b[34m";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
8ea8fc |
static const char aclr_magenta[] = "\x1b[35m";
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
static int slbt_output_exec_annotated(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
const struct slbt_driver_ctx * dctx,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
const struct slbt_exec_ctx * ectx,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
const char * step)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
{
|
|
Kylie McClain |
e20148 |
char ** parg;
|
|
Kylie McClain |
e20148 |
const char * aclr_set;
|
|
Kylie McClain |
e20148 |
const char * aclr_color;
|
|
Kylie McClain |
e20148 |
const char * aclr_unset;
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
if (fprintf(stdout,"%s%s%s: %s%s%s%s:%s",
|
|
Kylie McClain |
e20148 |
aclr_bold,aclr_magenta,
|
|
Kylie McClain |
e20148 |
dctx->program,aclr_reset,
|
|
Kylie McClain |
e20148 |
aclr_bold,aclr_green,step,aclr_reset) < 0)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
return SLBT_SYSTEM_ERROR(dctx);
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
for (parg=ectx->argv; *parg; parg++) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
df07fb |
if ((parg == ectx->lout[0]) || (parg == ectx->mout[0])) {
|
|
Kylie McClain |
e20148 |
aclr_set = aclr_bold;
|
|
Kylie McClain |
e20148 |
aclr_color = aclr_blue;
|
|
Kylie McClain |
e20148 |
aclr_unset = aclr_null;
|
|
Kylie McClain |
e20148 |
} else {
|
|
Kylie McClain |
e20148 |
aclr_set = aclr_null;
|
|
Kylie McClain |
e20148 |
aclr_color = aclr_null;
|
|
Kylie McClain |
e20148 |
aclr_unset = aclr_reset;
|
|
Kylie McClain |
e20148 |
}
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
if (fprintf(stdout," %s%s%s%s",
|
|
Kylie McClain |
e20148 |
aclr_set,aclr_color,
|
|
Kylie McClain |
e20148 |
*parg,
|
|
Kylie McClain |
e20148 |
aclr_unset) < 0)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
return SLBT_SYSTEM_ERROR(dctx);
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
}
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
if (fputc('\n',stdout) < 0)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
return SLBT_SYSTEM_ERROR(dctx);
|
|
Kylie McClain |
e20148 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
26127d |
return fflush(stdout);
|
|
Kylie McClain |
e20148 |
}
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
static int slbt_output_exec_plain(
|
|
Kylie McClain |
e20148 |
const struct slbt_driver_ctx * dctx,
|
|
Kylie McClain |
e20148 |
const struct slbt_exec_ctx * ectx,
|
|
Kylie McClain |
e20148 |
const char * step)
|
|
Kylie McClain |
e20148 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
char ** parg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
if (fprintf(stdout,"%s: %s:",dctx->program,step) < 0)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
return SLBT_SYSTEM_ERROR(dctx);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
for (parg=ectx->argv; *parg; parg++)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
if (fprintf(stdout," %s",*parg) < 0)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
return SLBT_SYSTEM_ERROR(dctx);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
if (fputc('\n',stdout) < 0)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
return SLBT_SYSTEM_ERROR(dctx);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
return fflush(stdout)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
? SLBT_SYSTEM_ERROR(dctx)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
522163 |
: 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
6f991b |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
|
|
Kylie McClain |
e20148 |
int slbt_output_exec(
|
|
Kylie McClain |
e20148 |
const struct slbt_driver_ctx * dctx,
|
|
Kylie McClain |
e20148 |
const struct slbt_exec_ctx * ectx,
|
|
Kylie McClain |
e20148 |
const char * step)
|
|
Kylie McClain |
e20148 |
{
|
|
Kylie McClain |
e20148 |
if (dctx->cctx->drvflags & SLBT_DRIVER_ANNOTATE_NEVER)
|
|
Kylie McClain |
e20148 |
return slbt_output_exec_plain(dctx,ectx,step);
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
else if (dctx->cctx->drvflags & SLBT_DRIVER_ANNOTATE_ALWAYS)
|
|
Kylie McClain |
e20148 |
return slbt_output_exec_annotated(dctx,ectx,step);
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
else if (isatty(STDOUT_FILENO))
|
|
Kylie McClain |
e20148 |
return slbt_output_exec_annotated(dctx,ectx,step);
|
|
Kylie McClain |
e20148 |
|
|
Kylie McClain |
e20148 |
else
|
|
Kylie McClain |
e20148 |
return slbt_output_exec_plain(dctx,ectx,step);
|
|
Kylie McClain |
e20148 |
}
|
|
Kylie McClain |
e20148 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
int slbt_output_compile(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
const struct slbt_driver_ctx * dctx,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
const struct slbt_exec_ctx * ectx)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
return slbt_output_exec(dctx,ectx,"compile");
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fab986 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ba3523 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
045b88 |
int slbt_output_execute(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
045b88 |
const struct slbt_driver_ctx * dctx,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
045b88 |
const struct slbt_exec_ctx * ectx)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
045b88 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
045b88 |
return slbt_output_exec(dctx,ectx,"execute");
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
045b88 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
045b88 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ca15b9 |
int slbt_output_install(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ca15b9 |
const struct slbt_driver_ctx * dctx,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ca15b9 |
const struct slbt_exec_ctx * ectx)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ca15b9 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ca15b9 |
return slbt_output_exec(dctx,ectx,"install");
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ca15b9 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ca15b9 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ba3523 |
int slbt_output_link(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ba3523 |
const struct slbt_driver_ctx * dctx,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ba3523 |
const struct slbt_exec_ctx * ectx)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ba3523 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ba3523 |
return slbt_output_exec(dctx,ectx,"link");
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ba3523 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
0fb20a |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
0fb20a |
int slbt_output_uninstall(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
0fb20a |
const struct slbt_driver_ctx * dctx,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
0fb20a |
const struct slbt_exec_ctx * ectx)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
0fb20a |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
0fb20a |
return slbt_output_exec(dctx,ectx,"uninstall");
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
0fb20a |
}
|