summaryrefslogtreecommitdiff
path: root/src/utils/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/utils.c')
-rw-r--r--src/utils/utils.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/src/utils/utils.c b/src/utils/utils.c
index df7576f..159326e 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -640,7 +640,7 @@ void scan_build_directives(ParserContext *ctx, const char *src)
int res = system(cmd);
if (res != 0)
{
- zpanic("Shell directive failed: %s", cmd);
+ zwarn("Shell directive failed: %s", cmd);
}
}
else if (strncmp(line, "get:", 4) == 0)
@@ -671,12 +671,17 @@ void scan_build_directives(ParserContext *ctx, const char *src)
{
printf("[zprep] Downloading %s...\n", filename);
char cmd[8192];
+#ifdef _WIN32
+ // On Windows, try curl which is often built-in now
+ sprintf(cmd, "curl -s -L \"%s\" -o \"%s\"", url, filename);
+#else
// Try wget, then curl.
sprintf(cmd, "wget -q \"%s\" -O \"%s\" || curl -s -L \"%s\" -o \"%s\"", url,
filename, url, filename);
+#endif
if (system(cmd) != 0)
{
- zpanic("Failed to download %s", url);
+ zwarn("Failed to download %s", url);
}
}
}
@@ -688,6 +693,12 @@ void scan_build_directives(ParserContext *ctx, const char *src)
libs++;
}
+#ifdef _WIN32
+ zwarn("pkg-config is usually not available on Windows. Build directive "
+ "'pkg-config:%s' might fail.",
+ libs);
+#endif
+
char cmd[4096];
sprintf(cmd, "pkg-config --cflags %s", libs);
FILE *fp = popen(cmd, "r");
@@ -695,18 +706,20 @@ void scan_build_directives(ParserContext *ctx, const char *src)
{
char flags[4096];
flags[0] = 0;
- fgets(flags, sizeof(flags), fp);
- pclose(fp);
- int len = strlen(flags);
- if (len > 0 && flags[len - 1] == '\n')
+ if (fgets(flags, sizeof(flags), fp))
{
- flags[len - 1] = 0;
+ int len = strlen(flags);
+ if (len > 0 && flags[len - 1] == '\n')
+ {
+ flags[len - 1] = 0;
+ }
+ if (strlen(g_cflags) > 0)
+ {
+ strcat(g_cflags, " ");
+ }
+ strcat(g_cflags, flags);
}
- if (strlen(g_cflags) > 0)
- {
- strcat(g_cflags, " ");
- }
- strcat(g_cflags, flags);
+ pclose(fp);
}
sprintf(cmd, "pkg-config --libs %s", libs);
@@ -715,18 +728,20 @@ void scan_build_directives(ParserContext *ctx, const char *src)
{
char flags[4096];
flags[0] = 0;
- fgets(flags, sizeof(flags), fp);
- pclose(fp);
- int len = strlen(flags);
- if (len > 0 && flags[len - 1] == '\n')
- {
- flags[len - 1] = 0;
- }
- if (strlen(g_link_flags) > 0)
+ if (fgets(flags, sizeof(flags), fp))
{
- strcat(g_link_flags, " ");
+ int len = strlen(flags);
+ if (len > 0 && flags[len - 1] == '\n')
+ {
+ flags[len - 1] = 0;
+ }
+ if (strlen(g_link_flags) > 0)
+ {
+ strcat(g_link_flags, " ");
+ }
+ strcat(g_link_flags, flags);
}
- strcat(g_link_flags, flags);
+ pclose(fp);
}
}