Skip to content

Commit 96548ed

Browse files
committed
builder-module: Add wrap-mode=nodownload to meson if building w/o network
Supersedes #643
1 parent e2f9ffc commit 96548ed

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/builder-module.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,7 @@ builder_module_build_helper (BuilderModule *self,
17541754
const char *ldflags = NULL;
17551755

17561756
gboolean autotools = FALSE, cmake = FALSE, cmake_ninja = FALSE, meson = FALSE, simple = FALSE, qmake = FALSE;
1757+
gboolean build_has_network = FALSE;
17571758
g_autoptr(GFile) configure_file = NULL;
17581759
g_autoptr(GFile) build_dir = NULL;
17591760
g_autofree char *build_dir_relative = NULL;
@@ -1796,6 +1797,8 @@ builder_module_build_helper (BuilderModule *self,
17961797
if (build_args == NULL)
17971798
return FALSE;
17981799

1800+
build_has_network = builder_options_has_network_access (build_args);
1801+
17991802
env = builder_options_get_env (self->build_options, context);
18001803
cflags = g_environ_getenv (env, "CFLAGS");
18011804
cxxflags = g_environ_getenv (env, "CXXFLAGS");
@@ -2020,6 +2023,8 @@ builder_module_build_helper (BuilderModule *self,
20202023
{
20212024
/* Meson's setup command is now meson setup */
20222025
g_ptr_array_add (configure_args_arr, g_strdup ("setup"));
2026+
if (!build_has_network)
2027+
g_ptr_array_add (configure_args_arr, g_strdup ("--wrap-mode=nodownload"));
20232028
}
20242029

20252030
if (cmake || cmake_ninja)

src/builder-options.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,26 @@ builder_options_get_build_args (BuilderOptions *self,
12361236
return (char **) g_ptr_array_free (g_steal_pointer (&array), FALSE);
12371237
}
12381238

1239+
gboolean
1240+
builder_options_has_network_access (char **build_args)
1241+
{
1242+
1243+
if (!build_args)
1244+
return FALSE;
1245+
1246+
for (size_t i = 0; build_args[i]; i++)
1247+
{
1248+
const char *arg = build_args[i];
1249+
1250+
if (g_strcmp0 (arg, "--unshare=network") == 0)
1251+
return FALSE;
1252+
else if (g_strcmp0 (arg, "--share=network") == 0)
1253+
return TRUE;
1254+
}
1255+
1256+
return FALSE;
1257+
}
1258+
12391259
char **
12401260
builder_options_get_test_args (BuilderOptions *self,
12411261
BuilderContext *context,

src/builder-options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ gboolean builder_options_get_no_debuginfo_compression (BuilderOptions *self,
8181
BuilderContext *context);
8282
gboolean builder_options_get_strip (BuilderOptions *self,
8383
BuilderContext *context);
84+
gboolean builder_options_has_network_access (char **build_args);
8485

8586
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BuilderOptions, g_object_unref)
8687

0 commit comments

Comments
 (0)