Revision: 78043
          http://sourceforge.net/p/brlcad/code/78043
Author:   starseeker
Date:     2021-01-06 13:25:36 +0000 (Wed, 06 Jan 2021)
Log Message:
-----------
Set up similar wrapper for rtwizard to adjust working dir when invoking from 
MSI shortcut.  Archer is trickier, since all of its option parsing is in Tcl/Tk 
right now.

Modified Paths:
--------------
    brlcad/trunk/src/mged/CMakeLists.txt
    brlcad/trunk/src/rtwizard/CMakeLists.txt
    brlcad/trunk/src/rtwizard/main.c

Added Paths:
-----------
    brlcad/trunk/src/rtwizard/rtwizard.bat

Modified: brlcad/trunk/src/mged/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/mged/CMakeLists.txt        2021-01-06 09:40:14 UTC (rev 
78042)
+++ brlcad/trunk/src/mged/CMakeLists.txt        2021-01-06 13:25:36 UTC (rev 
78043)
@@ -95,6 +95,8 @@
     add_dependencies(mged ${item})
   endforeach(item ${tclindex_target_list})
 
+  # The bat file is used to set the working directory for shortcuts in MSIS
+  # installers generated with WiX.
   BRLCAD_MANAGE_FILES("mged.bat" ${BIN_DIR} EXEC)
 
   # MGED is one of the programs that gets a start menu entry

Modified: brlcad/trunk/src/rtwizard/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/rtwizard/CMakeLists.txt    2021-01-06 09:40:14 UTC (rev 
78042)
+++ brlcad/trunk/src/rtwizard/CMakeLists.txt    2021-01-06 13:25:36 UTC (rev 
78043)
@@ -26,11 +26,15 @@
     add_dependencies(rtwizard ${item})
   endforeach(item ${tclindex_target_list})
 
+  # The bat file is used to set the working directory for shortcuts in MSIS
+  # installers generated with WiX.
+  BRLCAD_MANAGE_FILES("rtwizard.bat" ${BIN_DIR} EXEC)
+
   # RtWizard is one of the programs that gets a start menu entry
-  set_property(INSTALL "${BIN_DIR}/$<TARGET_FILE_NAME:rtwizard>"
+  set_property(INSTALL "${BIN_DIR}/rtwizard.bat"
     PROPERTY CPACK_START_MENU_SHORTCUTS "RtWizard ${BRLCAD_VERSION}"
     )
-  set_property(INSTALL "${BIN_DIR}/$<TARGET_FILE_NAME:rtwizard>"
+  set_property(INSTALL "${BIN_DIR}/rtwizard.bat"
     PROPERTY CPACK_DESKTOP_SHORTCUTS "RtWizard ${BRLCAD_VERSION}"
     )
 

Modified: brlcad/trunk/src/rtwizard/main.c
===================================================================
--- brlcad/trunk/src/rtwizard/main.c    2021-01-06 09:40:14 UTC (rev 78042)
+++ brlcad/trunk/src/rtwizard/main.c    2021-01-06 13:25:36 UTC (rev 78043)
@@ -22,8 +22,12 @@
  */
 
 #include "common.h"
-#include "string.h"
+#include <string.h>
 
+#ifdef HAVE_WINDOWS_H
+#  include <direct.h> /* For chdir */
+#endif
+
 #include "tcl.h"
 
 #include "vmath.h"
@@ -945,10 +949,12 @@
     int need_help_dev = 0;
     int uac = 0;
 
+    struct bu_vls wdir = BU_VLS_INIT_ZERO;
+
     struct bu_vls optparse_msg = BU_VLS_INIT_ZERO;
     struct bu_vls info_msg = BU_VLS_INIT_ZERO;
     struct rtwizard_settings *s = rtwizard_settings_create();
-    struct bu_opt_desc d[35];
+    struct bu_opt_desc d[36];
 
     BU_OPT(d[0],  "h", "help",          "",          NULL,            
&need_help,    "Print help and exit");
     BU_OPT(d[1],  "",  "help-dev",      "",          NULL,            
&need_help_dev,    "Print options intended for developer/programmatic use and 
exit.");
@@ -984,7 +990,8 @@
     BU_OPT(d[31], "v", "verbose",       "#",         &bu_opt_int,     
&s->verbose,      "Verbosity");
     BU_OPT(d[32], "",  "log-file",      "filename",  &bu_opt_vls,     
s->log_file,      "Log debugging output to this file");
     BU_OPT(d[33], "",  "pid-file",      "filename",  &bu_opt_vls,     
s->pid_file,      "File used to communicate PID numbers (for app developers)");
-    BU_OPT_NULL(d[34]);
+    BU_OPT(d[34], "",  "working-dir",   "path",   &bu_opt_vls,     &wdir,      
"Specify a working directory");
+    BU_OPT_NULL(d[35]);
 
     /* initialize progname for run-time resource finding */
     bu_setprogname(argv[0]);
@@ -1010,6 +1017,18 @@
        bu_exit(EXIT_SUCCESS, NULL);
     }
 
+    if (bu_vls_strlen(&wdir)) {
+       /* Make sure '~' is always interpreted as the home directory */
+       if (BU_STR_EQUAL(bu_vls_cstr(&wdir), "~")) {
+           const char *homed = bu_dir(NULL, 0, BU_DIR_HOME, NULL);
+           bu_vls_sprintf(&wdir, "%s", homed);
+       }
+       if (chdir(bu_vls_cstr(&wdir))) {
+           bu_exit(EXIT_FAILURE, "Failed to change working directory to \"%s\" 
", bu_vls_cstr(&wdir));
+       }
+    }
+    bu_vls_free(&wdir);
+
     {
        int stop = 0;
        for (i = 0; i < uac; i++) {

Added: brlcad/trunk/src/rtwizard/rtwizard.bat
===================================================================
--- brlcad/trunk/src/rtwizard/rtwizard.bat                              (rev 0)
+++ brlcad/trunk/src/rtwizard/rtwizard.bat      2021-01-06 13:25:36 UTC (rev 
78043)
@@ -0,0 +1,30 @@
+REM                    R T W I Z A R D . B A T
+REM  BRL-CAD
+REM
+REM  Copyright (c) 2006-2021 United States Government as represented by
+REM  the U.S. Army Research Laboratory.
+REM
+REM  This library is free software; you can redistribute it and/or
+REM  modify it under the terms of the GNU Lesser General Public License
+REM  version 2.1 as published by the Free Software Foundation.
+REM
+REM  This library is distributed in the hope that it will be useful, but
+REM  WITHOUT ANY WARRANTY; without even the implied warranty of
+REM  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+REM  Lesser General Public License for more details.
+REM
+REM  You should have received a copy of the GNU Lesser General Public
+REM  License along with this file; see the file named COPYING for more
+REM  information.
+REM
+
+@ECHO OFF
+
+SETLOCAL
+
+SET PATH=%~dp0;%PATH%
+SET RTWIZARD=%~dp0rtwizard
+
+START /B "" "%RTWIZARD%" --working-dir ~ %*
+
+EXIT


Property changes on: brlcad/trunk/src/rtwizard/rtwizard.bat
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+CRLF
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to