Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKir Kolyshkin <kir@openvz.org>2016-12-17 14:22:02 +0300
committerAndrei Vagin <avagin@virtuozzo.com>2017-03-15 00:09:55 +0300
commit51c4569cd901f1af4278a81547d0a53d3330541c (patch)
tree799f54055ba1543af61c818f88e9722469a5dc75 /compel/src
parentf53189c520bf61dd40c91a0c09a145e5f53474ca (diff)
compel cli: show includes
1. Add "compel includes" command, to be used for parasite *loading* code compilation. 2. Add includes to output of "compel cflags", which is used for parasite code compilation. Now, this patch looks big and complex, this is mostly because we want compel cli to work for both uninstalled (right from the source tree) and installed cases. The paths to be printed are quite different for these two cases, so I had to introduce a wrapper for a non-installed case. The wrapper sets an environment variable, which compel binary uses as a path to non-installed file. If this env var is not set, it means compel is installed so no tricks are needed. Note the wrapper is only provided for the compel-host binary, as compel (which differs from compel-host in case of cross-compiling) is not executed from within the source tree. Because of the wrapper, the original binary had to be renamed, thus the changes to Makefiles and .gitignore. travis-ci: success for More polishing for compel cli Signed-off-by: Kir Kolyshkin <kir@openvz.org> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Diffstat (limited to 'compel/src')
-rw-r--r--compel/src/main.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/compel/src/main.c b/compel/src/main.c
index c943febd1..f91fe2729 100644
--- a/compel/src/main.c
+++ b/compel/src/main.c
@@ -48,6 +48,7 @@ static const flags_t flags = {
};
piegen_opt_t opts = {};
+const char *uninst_root;
static int piegen(void)
{
@@ -114,7 +115,7 @@ static int usage(int rc) {
fprintf(out,
"Usage:\n"
-" compel [--compat] cflags | ldflags\n"
+" compel [--compat] includes | cflags | ldflags\n"
" compel -f FILE -o FILE -p NAME [-l N] hgen\n"
" -f, --file FILE input (parasite object) file name\n"
" -o, --output FILE output (header) file name\n"
@@ -128,9 +129,35 @@ static int usage(int rc) {
return rc;
}
+static void print_includes(void)
+{
+ int i;
+ /* list of standard include dirs (built into C preprocessor) */
+ const char *standard_includes[] = {
+ "/usr/include",
+ "/usr/local/include",
+ };
+
+ /* I am not installed, called via a wrapper */
+ if (uninst_root) {
+ printf("-I %s/include/uapi\n", uninst_root);
+ return;
+ }
+
+ /* I am installed
+ * Make sure to not print banalities */
+ for (i = 0; i < ARRAY_SIZE(standard_includes); i++)
+ if (strcmp(INCLUDEDIR, standard_includes[i]) == 0)
+ return;
+
+ /* Finally, print our non-standard include path */
+ printf("%s\n", "-I " INCLUDEDIR);
+}
+
static void print_cflags(bool compat)
{
printf("%s\n", compat ? flags.cflags_compat : flags.cflags);
+ print_includes();
}
int main(int argc, char *argv[])
@@ -152,6 +179,8 @@ int main(int argc, char *argv[])
{ },
};
+ uninst_root = getenv("COMPEL_UNINSTALLED_ROOTDIR");
+
while (1) {
idx = -1;
opt = getopt_long(argc, argv, short_opts, long_opts, &idx);
@@ -195,6 +224,10 @@ int main(int argc, char *argv[])
}
action = argv[optind++];
+ if (!strcmp(action, "includes")) {
+ print_includes();
+ return 0;
+ }
if (!strcmp(action, "cflags")) {
print_cflags(compat);
return 0;