From 3465776b491f53eb1a11bd67b9fc3ef49760b3d9 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Mon, 9 Jul 2018 18:48:28 -0400
Subject: [PATCH] use a macro to set GUIDIR

This makes it easier to point the gui dir at a local copy of the repo for
easier development. You can use this to make it easier to test out changes
to the GUI in purr-data/pd/nw.

Setting GUIDIR should even work if you haven't installed Purr Data to the
system. Just make sure the nw.js binary has been downloaded and expanded to
purr-data/pd/nw/nw. (This happens automatically when you build.)
---
 pd/src/s_inter.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c
index 61bc9d940..af96bc4ee 100644
--- a/pd/src/s_inter.c
+++ b/pd/src/s_inter.c
@@ -12,6 +12,17 @@ that didn't really belong anywhere. */
 #include "m_imp.h"
 #include "g_canvas.h"   /* for GUI queueing stuff */
 
+/* Use this if you want to point the guidir at a local copy of the
+ * repo while developing. Then recompile and copy the pd-l2ork binary
+ * to the system path. After that you can make changes to the gui code
+ * in purr-data/pd/nw and test them without having to recompile the
+ * pd-l2ork binary.
+ * If you do this, make sure you have run tar_em_up.sh first to fetch and
+ * extract the nw binary to purr-data/pd/nw/nw
+ */
+
+#define GUIDIR "" /* "/home/user/purr-data/pd/nw" */
+
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #else // if isatty exists outside unistd, please add another #ifdef
@@ -1405,10 +1416,11 @@ int sys_startgui(const char *guidir)
             strcpy(guidir2, "\"");
             strcat(guidir2, guidir);
             strcat(guidir2, "\"");
-            /* Uncomment the following line if you want to
-               use the nw binary and GUI code from your local
-               copy of the Purr Data repo. (Make sure to run
-               tar_em_up.sh first to fetch the nw binary.) */
+            /* The following line checks if our GUIDIR was defined
+               to something other than empty string. If so it will
+               use that dir to find the nw binary. */
+            if (strcmp(GUIDIR, ""))
+                strcpy(guidir2, "\"" GUIDIR "\"");
             //strcpy(guidir2, "\"/home/user/purr-data/pd/nw\"");
             sprintf(cmdbuf,
                 "\"%s\" %s %s "
@@ -1446,10 +1458,11 @@ int sys_startgui(const char *guidir)
             strcpy(guidir2, "\"");
             strcat(guidir2, guidir);
             strcat(guidir2, "\"");
-            /* Uncomment the following line if you want to
-               use the nw binary and GUI code from your local
-               copy of the Purr Data repo. (Make sure to run
-               tar_em_up.sh first to fetch the nw binary.) */
+            /* The following line checks if our GUIDIR was defined
+               to something other than empty string. If so it will
+               use that dir to find the nw binary. */
+            if (strcmp(GUIDIR, ""))
+                strcpy(guidir2, "\"" GUIDIR "\"");
             //strcpy(guidir2, "\"/home/user/purr-data/pd/nw\"");
             sprintf(cmdbuf,
                 "%s/nw/nw %s %s "
-- 
GitLab