summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2018-12-07 15:48:49 +0800
committerTanu Kaskinen <tanuk@iki.fi>2018-12-11 16:15:32 +0200
commit3d9deb1e5679e15c3277e144a822be9b0a036514 (patch)
treebc1508253eade06a827f7ba2e304cc8ad9cadbed
parentbae8c16bfadb43c596b03f9c7ff7c9e9f1709b76 (diff)
build-sys: introduce a special build flag to explicitly disables running from build tree
It is helpful to improve reproducibility build [1] since PA_SRCDIR/PA_BUILDDIR contains build path, --disable-running-from-build-tree could drop these macros at precompilation. [1] https://reproducible-builds.org/ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
-rw-r--r--configure.ac10
-rw-r--r--src/daemon/daemon-conf.c6
-rw-r--r--src/daemon/main.c6
-rw-r--r--src/modules/alsa/alsa-mixer.c4
-rw-r--r--src/modules/gconf/module-gconf.c2
-rw-r--r--src/modules/gsettings/module-gsettings.c2
-rw-r--r--src/pulsecore/core-util.c4
7 files changed, 29 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 8d08c93bb..2512d3c95 100644
--- a/configure.ac
+++ b/configure.ac
@@ -989,6 +989,16 @@ AS_IF([test "x$enable_asyncns" = "xyes" && test "x$HAVE_LIBASYNCNS" = "x0"],
AM_CONDITIONAL([HAVE_LIBASYNCNS], [test "x$HAVE_LIBASYNCNS" = x1])
AS_IF([test "x$HAVE_LIBASYNCNS" = "x1"], AC_DEFINE([HAVE_LIBASYNCNS], 1, [Have libasyncns?]))
+#### Running from build tree (optional) ####
+
+AC_ARG_ENABLE([running-from-build-tree],
+ AS_HELP_STRING([--disable-running-from-build-tree],[Disable running from build tree]))
+
+AS_IF([test "x$enable_running_from_build_tree" != "xno"],
+ AC_DEFINE([HAVE_RUNNING_FROM_BUILD_TREE], 1, [Have running from build tree]))
+
+AC_SUBST(HAVE_RUNNING_FROM_BUILD_TREE)
+
#### TCP wrappers (optional) ####
AC_ARG_ENABLE([tcpwrap],
diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
index f956a55af..33cf7a711 100644
--- a/src/daemon/daemon-conf.c
+++ b/src/daemon/daemon-conf.c
@@ -155,16 +155,18 @@ pa_daemon_conf *pa_daemon_conf_new(void) {
c->dl_search_path = pa_sprintf_malloc("%s" PA_PATH_SEP "lib" PA_PATH_SEP "pulse-%d.%d" PA_PATH_SEP "modules",
pa_win32_get_toplevel(NULL), PA_MAJOR, PA_MINOR);
#else
+#ifdef HAVE_RUNNING_FROM_BUILD_TREE
if (pa_run_from_build_tree()) {
pa_log_notice("Detected that we are run from the build tree, fixing search path.");
#ifdef MESON_BUILD
c->dl_search_path = pa_xstrdup(PA_BUILDDIR PA_PATH_SEP "src" PA_PATH_SEP "modules");
#else
c->dl_search_path = pa_xstrdup(PA_BUILDDIR);
-#endif
+#endif // Endof #ifdef MESON_BUILD
} else
+#endif // Endof #ifdef HAVE_RUNNING_FROM_BUILD_TREE
c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH);
-#endif
+#endif // Endof #ifdef OS_IS_WIN32
return c;
}
diff --git a/src/daemon/main.c b/src/daemon/main.c
index da26c385b..553f12ae9 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -941,6 +941,12 @@ int main(int argc, char *argv[]) {
pa_log_debug("Running in VM: %s", pa_yes_no(pa_running_in_vm()));
+#ifdef HAVE_RUNNING_FROM_BUILD_TREE
+ pa_log_debug("Running from build tree: %s", pa_yes_no(pa_run_from_build_tree()));
+#else
+ pa_log_debug("Running from build tree: no");
+#endif
+
#ifdef __OPTIMIZE__
pa_log_debug("Optimized build: yes");
#else
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 7d50fc7b8..91dfc66ee 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -2573,9 +2573,11 @@ static int path_verify(pa_alsa_path *p) {
}
static const char *get_default_paths_dir(void) {
+#ifdef HAVE_RUNNING_FROM_BUILD_TREE
if (pa_run_from_build_tree())
return PA_SRCDIR "/modules/alsa/mixer/paths/";
else
+#endif
return PA_ALSA_PATHS_DIR;
}
@@ -4458,7 +4460,9 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
fname = "default.conf";
fn = pa_maybe_prefix_path(fname,
+#ifdef HAVE_RUNNING_FROM_BUILD_TREE
pa_run_from_build_tree() ? PA_SRCDIR "/modules/alsa/mixer/profile-sets/" :
+#endif
PA_ALSA_PROFILE_SETS_DIR);
r = pa_config_parse(fn, NULL, items, NULL, false, ps);
diff --git a/src/modules/gconf/module-gconf.c b/src/modules/gconf/module-gconf.c
index c0f4dde56..76a1f195b 100644
--- a/src/modules/gconf/module-gconf.c
+++ b/src/modules/gconf/module-gconf.c
@@ -51,7 +51,7 @@ int pa__init(pa_module*m) {
u->buf_fill = 0;
if ((u->fd = pa_start_child_for_read(
-#if defined(__linux__) && !defined(__OPTIMIZE__)
+#if defined(__linux__) && defined(HAVE_RUNNING_FROM_BUILD_TREE)
pa_run_from_build_tree() ? PA_BUILDDIR "/gconf-helper" :
#endif
PA_GCONF_HELPER, NULL, &u->pid)) < 0)
diff --git a/src/modules/gsettings/module-gsettings.c b/src/modules/gsettings/module-gsettings.c
index 330eca1d7..209c8575b 100644
--- a/src/modules/gsettings/module-gsettings.c
+++ b/src/modules/gsettings/module-gsettings.c
@@ -51,7 +51,7 @@ int pa__init(pa_module*m) {
u->buf_fill = 0;
if ((u->fd = pa_start_child_for_read(
-#if defined(__linux__) && !defined(__OPTIMIZE__)
+#if defined(__linux__) && defined(HAVE_RUNNING_FROM_BUILD_TREE)
pa_run_from_build_tree() ? PA_BUILDDIR "/gsettings-helper" :
#endif
PA_GSETTINGS_HELPER, NULL, &u->pid)) < 0)
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 367e767db..2eff24faa 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -3269,15 +3269,17 @@ void pa_reset_personality(void) {
}
bool pa_run_from_build_tree(void) {
- char *rp;
static bool b = false;
+#ifdef HAVE_RUNNING_FROM_BUILD_TREE
+ char *rp;
PA_ONCE_BEGIN {
if ((rp = pa_readlink("/proc/self/exe"))) {
b = pa_startswith(rp, PA_BUILDDIR);
pa_xfree(rp);
}
} PA_ONCE_END;
+#endif
return b;
}