Commit 6b584033 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Andrei Vagin

compel --help: don't hardcode arch list

Instead of hardcoding list of architectures to usage(), let's
generate it from the data.
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 98fddd50
......@@ -27,6 +27,30 @@
#define COMPEL_LDFLAGS_DEFAULT "-r -z noexecstack"
typedef struct {
const char *arch;
const char *cflags;
} compel_cflags_t;
static const compel_cflags_t compel_cflags[] = {
{
.arch = "x86",
.cflags = COMPEL_CFLAGS_PIE,
}, {
.arch = "ia32",
.cflags = COMPEL_CFLAGS_NOPIC,
}, {
.arch = "aarch64",
.cflags = COMPEL_CFLAGS_PIE,
}, {
.arch = "arm",
.cflags = COMPEL_CFLAGS_PIE,
}, {
.arch = "ppc64",
.cflags = COMPEL_CFLAGS_PIE,
},
};
piegen_opt_t opts = {
.input_filename = NULL,
.output_filename = NULL,
......@@ -92,10 +116,24 @@ static void cli_log(unsigned int lvl, const char *fmt, va_list parms)
}
static int usage(int rc) {
int i = 0;
printf(
"Usage:\n"
" compel --arch=(x86|ia32|aarch64|arm|ppc64) cflags\n"
" compel --arch=(x86|ia32|aarch64|arm|ppc64) ldflags\n"
" compel --arch=ARCH cflags\n"
" compel --arch=ARCH ldflags\n"
" ARCH := { "
);
/* Print list of known arches */
while (1) {
printf("%s", compel_cflags[i++].arch);
if (i == ARRAY_SIZE(compel_cflags))
break;
printf(" | ");
}
printf(
" }\n"
" compel -f filename hgen\n"
);
......@@ -109,30 +147,6 @@ int main(int argc, char *argv[])
int opt, idx, i;
char *action;
typedef struct {
const char *arch;
const char *cflags;
} compel_cflags_t;
static const compel_cflags_t compel_cflags[] = {
{
.arch = "x86",
.cflags = COMPEL_CFLAGS_PIE,
}, {
.arch = "ia32",
.cflags = COMPEL_CFLAGS_NOPIC,
}, {
.arch = "aarch64",
.cflags = COMPEL_CFLAGS_PIE,
}, {
.arch = "arm",
.cflags = COMPEL_CFLAGS_PIE,
}, {
.arch = "ppc64",
.cflags = COMPEL_CFLAGS_PIE,
},
};
static const char short_opts[] = "a:f:o:s:p:v:r:u:hVl:";
static struct option long_opts[] = {
{ "arch", required_argument, 0, 'a' },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment