Commit 7ad7ee4d authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Andrei Vagin

compel cli: add plugins cmd, use it

A compel user should not be aware of compel internals, including
the paths to various files. This commit introduces a command to
get the plugin files (well, currently just one plugin, "std").

Example for uninstalled compel:
 $ cd compel/test/infect/
 $ ../../../compel/compel-host plugins
 ../../../compel/plugins/std.built-in

Example for installed compel:
 $ compel plugins
 /usr/libexec/compel/std.built-in.o

The commit also makes use of this command by compel/test/infect
and criu/pie.

travis-ci: success for More polishing for compel cli
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 616c6d17
...@@ -120,7 +120,7 @@ static int usage(int rc) { ...@@ -120,7 +120,7 @@ static int usage(int rc) {
fprintf(out, fprintf(out,
"Usage:\n" "Usage:\n"
" compel [--compat] includes | cflags | ldflags\n" " compel [--compat] includes | cflags | ldflags | plugins\n"
" compel -f FILE -o FILE -p NAME [-l N] hgen\n" " compel -f FILE -o FILE -p NAME [-l N] hgen\n"
" -f, --file FILE input (parasite object) file name\n" " -f, --file FILE input (parasite object) file name\n"
" -o, --output FILE output (header) file name\n" " -o, --output FILE output (header) file name\n"
...@@ -182,12 +182,25 @@ static void print_ldflags(bool compat) ...@@ -182,12 +182,25 @@ static void print_ldflags(bool compat)
} }
} }
static void print_plugins(const char *list[])
{
while (*list != NULL) {
if (uninst_root)
printf("%s/plugins/%s.built-in.o\n",
uninst_root, *list);
else
printf("%s/compel/%s.built-in.o\n", LIBEXECDIR, *list);
list++;
}
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int log_level = DEFAULT_LOGLEVEL; int log_level = DEFAULT_LOGLEVEL;
bool compat = false; bool compat = false;
int opt, idx; int opt, idx;
char *action; char *action;
const char *plugins_list[] = { "std", NULL };
static const char short_opts[] = "cf:o:p:hVl:"; static const char short_opts[] = "cf:o:p:hVl:";
static struct option long_opts[] = { static struct option long_opts[] = {
...@@ -260,6 +273,13 @@ int main(int argc, char *argv[]) ...@@ -260,6 +273,13 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
if (!strcmp(action, "plugins")) {
/* TODO: add option to specify additional plugins
* if/when we'll have any */
print_plugins(plugins_list);
return 0;
}
if (!strcmp(action, "hgen")) { if (!strcmp(action, "hgen")) {
if (!opts.input_filename) { if (!opts.input_filename) {
fprintf(stderr, "Error: option --file required\n"); fprintf(stderr, "Error: option --file required\n");
......
...@@ -2,7 +2,6 @@ CC := gcc ...@@ -2,7 +2,6 @@ CC := gcc
CFLAGS ?= -O2 -g -Wall -Werror CFLAGS ?= -O2 -g -Wall -Werror
COMPEL := ../../../compel/compel-host COMPEL := ../../../compel/compel-host
COMPEL_PLUGINS := ../../../compel/plugins
COMPEL_LIBRARY := ../../../compel/libcompel.a COMPEL_LIBRARY := ../../../compel/libcompel.a
all: victim spy all: victim spy
...@@ -25,8 +24,8 @@ parasite.h: parasite.po ...@@ -25,8 +24,8 @@ parasite.h: parasite.po
-p parasite \ -p parasite \
-o $@ -o $@
parasite.po: parasite.o $(COMPEL_PLUGINS)/std.built-in.o parasite.po: parasite.o
ld $(shell $(COMPEL) ldflags) -o $@ $^ ld $(shell $(COMPEL) ldflags) -o $@ $^ $(shell $(COMPEL) plugins)
parasite.o: parasite.c parasite.o: parasite.c
$(CC) $(CFLAGS) -c $(shell $(COMPEL) cflags) -o $@ $^ $(CC) $(CFLAGS) -c $(shell $(COMPEL) cflags) -o $@ $^
target += parasite restorer target += parasite restorer
compel_std := $(SRC_DIR)/compel/plugins/std.built-in.o
parasite-obj-e += ./compel/plugins/std.built-in.o parasite-obj-e += ./compel/plugins/std.built-in.o
restorer-obj-e += ./compel/plugins/std.built-in.o restorer-obj-e += ./compel/plugins/std.built-in.o
...@@ -36,6 +35,7 @@ ccflags-y += -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=0 ...@@ -36,6 +35,7 @@ ccflags-y += -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=0
ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),) ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
CFLAGS += $(shell $(COMPEL_BIN) cflags) CFLAGS += $(shell $(COMPEL_BIN) cflags)
compel_std := $(shell $(COMPEL_BIN) plugins)
endif endif
ifeq ($(SRCARCH),arm) ifeq ($(SRCARCH),arm)
......
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