[beast/win32: 39/44] Implemented relocation routine, which makes beast independant of the install dir.



commit a1faad90be7d70ec54995b84574efb27d188465f
Author: Stefan Westerfeld <stefan space twc de>
Date:   Sun Sep 27 12:23:26 2009 +0200

    Implemented relocation routine, which makes beast independant of the install
    dir.
    
    Part of 014_scmoff_docoff_relocate.diff.

 bse/bsewin32.cc  |   15 +++++++++++++++
 bse/bsewin32.h   |    1 +
 data/Makefile.am |   37 +++++++++++++++++++++----------------
 shell/bsescm.c   |    4 ++--
 4 files changed, 39 insertions(+), 18 deletions(-)
---
diff --git a/bse/bsewin32.cc b/bse/bsewin32.cc
index dc2269e..688fdb9 100644
--- a/bse/bsewin32.cc
+++ b/bse/bsewin32.cc
@@ -22,6 +22,7 @@
  */
 #include "bsewin32.h"
 #include <windows.h>
+#include "topconfig.h"
 
 struct _BseWin32Waiter
 {
@@ -72,3 +73,17 @@ bse_win32_waiter_wait (BseWin32Waiter *waiter,
     return 0;
   return 1;
 }
+
+extern "C" const char*
+bse_path_relocate (const char *path)
+{
+  const char *result = path;
+  const int prefix_len = strlen ("/c/beast");
+  if (strncmp (path, "/c/beast", prefix_len) == 0)
+    {
+      char *relocated = g_strdup_printf ("c:/beast%s", path + prefix_len);
+      result = g_intern_string (relocated);
+      g_free (relocated);
+    }
+  return result;
+}
diff --git a/bse/bsewin32.h b/bse/bsewin32.h
index 8e90aa5..cf7a51a 100644
--- a/bse/bsewin32.h
+++ b/bse/bsewin32.h
@@ -20,6 +20,7 @@
 #define __BSE_WIN32_H__
 
 #include <bse/bsedefs.h>
+#include <topconfig.h>           /* bse_path_relocate */
 
 G_BEGIN_DECLS
 
diff --git a/data/Makefile.am b/data/Makefile.am
index 07e4596..fa02189 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -94,24 +94,29 @@ config-paths.h: $(top_builddir)/config.status Makefile
 	&& echo "/* Generated data from $< (by make $@) */" > xgen-cph \
 	&& echo >> xgen-cph \
 	&& echo "#define SFIDL_PATH_STDINC        \"${sfidlstdincdir}\"" >> xgen-cph \
-	&& echo "#define BSE_PATH_BINARIES        \"${bindir}\"" >> xgen-cph \
-	&& echo "#define BSE_PATH_LADSPA          \"${bseladspapath}\"" >> xgen-cph \
-	&& echo "#define BSE_PATH_PLUGINS         \"${bseplugindir}\"" >> xgen-cph \
-	&& echo "#define BSE_PATH_DRIVERS         \"${bsedriverdir}\"" >> xgen-cph \
-	&& echo "#define BSE_PATH_DEMOS           \"${bsedemodir}\"" >> xgen-cph \
-	&& echo "#define BSE_PATH_SAMPLES         \"${bsesampledir}:${bseunversionedsampledir}\"" >> xgen-cph \
-	&& echo "#define BSE_PATH_EFFECTS         \"${bseeffectdir}\"" >> xgen-cph \
-	&& echo "#define BSE_PATH_INSTRUMENTS     \"${bseinstrumentdir}\"" >> xgen-cph \
-	&& echo "#define BSE_PATH_SCRIPTS         \"${bsescriptdir}\"" >> xgen-cph \
+	&& echo "#define BSE_PATH_BINARIES        bse_path_relocate (\"${bindir}\")" >> xgen-cph \
+	&& echo "#define BSE_PATH_LADSPA          bse_path_relocate (\"${bseladspapath}\")" >> xgen-cph \
+	&& echo "#define BSE_PATH_PLUGINS         bse_path_relocate (\"${bseplugindir}\")" >> xgen-cph \
+	&& echo "#define BSE_PATH_DRIVERS         bse_path_relocate (\"${bsedriverdir}\")" >> xgen-cph \
+	&& echo "#define BSE_PATH_DEMOS           bse_path_relocate (\"${bsedemodir}\")" >> xgen-cph \
+	&& echo "#define BSE_PATH_SAMPLES         bse_path_relocate (\"${bsesampledir}:${bseunversionedsampledir}\")" >> xgen-cph \
+	&& echo "#define BSE_PATH_EFFECTS         bse_path_relocate (\"${bseeffectdir}\")" >> xgen-cph \
+	&& echo "#define BSE_PATH_INSTRUMENTS     bse_path_relocate (\"${bseinstrumentdir}\")" >> xgen-cph \
+	&& echo "#define BSE_PATH_SCRIPTS         bse_path_relocate (\"${bsescriptdir}\")" >> xgen-cph \
 	&& echo "#define BSE_PATH_USER_DATA(dir)  \"${bseuserdatadir}\" dir" >> xgen-cph \
-	&& echo "#define BST_PATH_BINARIES        \"${bindir}\"" >> xgen-cph \
-	&& echo "#define BST_PATH_DOCS            \"${beastdocsdir}\"" >> xgen-cph \
-	&& echo "#define BST_PATH_IMAGES          \"${beastimagesdir}\"" >> xgen-cph \
-	&& echo "#define BST_PATH_LOCALE          \"${beastlocaledir}\"" >> xgen-cph \
-	&& echo "#define BST_PATH_KEYS            \"${beastkeysdir}\"" >> xgen-cph \
-	&& echo "#define BST_PATH_SKINS           \"${beastskinsdir}\"" >> xgen-cph \
-	&& echo "#define BST_PATH_PREFIX          \"${prefix}\"" >> xgen-cph \
+	&& echo "#define BST_PATH_BINARIES        bse_path_relocate (\"${bindir}\")" >> xgen-cph \
+	&& echo "#define BST_PATH_DOCS            bse_path_relocate (\"${beastdocsdir}\")" >> xgen-cph \
+	&& echo "#define BST_PATH_IMAGES          bse_path_relocate (\"${beastimagesdir}\")" >> xgen-cph \
+	&& echo "#define BST_PATH_LOCALE          bse_path_relocate (\"${beastlocaledir}\")" >> xgen-cph \
+	&& echo "#define BST_PATH_KEYS            bse_path_relocate (\"${beastkeysdir}\")" >> xgen-cph \
+	&& echo "#define BST_PATH_SKINS           bse_path_relocate (\"${beastskinsdir}\")" >> xgen-cph \
+	&& echo "#define BST_PATH_PREFIX          bse_path_relocate (\"${prefix}\")" >> xgen-cph \
 	&& echo >> xgen-cph \
+	&& echo "#ifdef __cplusplus" >> xgen-cph \
+	&& echo "extern \"C\"" >> xgen-cph \
+	&& echo "#endif" >> xgen-cph \
+	&& echo "const char *bse_path_relocate (const char *path);" >> xgen-cph \
+	&& echo >>xgen-cph \
 	&& echo "/* Generated data ends here */" >> xgen-cph \
 	&& (cp xgen-cph $@) \
 	&& rm -f xgen-cph
diff --git a/shell/bsescm.c b/shell/bsescm.c
index 10a3e68..6a31957 100644
--- a/shell/bsescm.c
+++ b/shell/bsescm.c
@@ -50,7 +50,7 @@ static gboolean        bse_scm_auto_load = TRUE;
 static gboolean        bse_scm_auto_play = TRUE;
 static SfiComPort     *bse_scm_port = NULL;
 static SfiGlueContext *bse_scm_context = NULL;
-static const gchar    *boot_script_path = BSE_PATH_SCRIPTS;
+static const gchar    *boot_script_path = NULL; /* BSE_PATH_SCRIPTS */
 
 /* --- functions --- */
 static void
@@ -67,7 +67,7 @@ main (int   argc,
       char *argv[])
 {
   const gchar *env_str;
-
+  boot_script_path = BSE_PATH_SCRIPTS;
   sfi_init (&argc, &argv, "BSESCM", NULL);
   bse_init_textdomain_only();
   setlocale (LC_ALL, "");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]