mirror of https://github.com/Gnucash/gnucash
This eliminates another guile dependency in the build chain Conflicts: src/backend/dbi/test/Makefile.ampull/27/head
parent
87520cdde4
commit
48b30271e0
@ -1,139 +0,0 @@
|
||||
#!/bin/sh
|
||||
exec @GUILE@ -s $0 "$@"
|
||||
!#
|
||||
|
||||
;; Spit out the environment variable settings needed based on
|
||||
;; arguments listing gnc-module-dirs, guile-load-dirs, and
|
||||
;; library-dirs
|
||||
|
||||
(use-modules (srfi srfi-13) (srfi srfi-14)) ;; for string-tokenize
|
||||
;; 'debug is deprecated and unused since guile 2
|
||||
(cond-expand
|
||||
(guile-2 )
|
||||
(else
|
||||
(debug-enable 'debug)))
|
||||
(debug-enable 'backtrace)
|
||||
(read-enable 'positions)
|
||||
|
||||
;; Are we on MS Windows here? If yes, make this a #t.
|
||||
;; (utsname:sysname (uname)) wasn't available in my guile-1.6.7 on
|
||||
;; mingw, so I don't know an automated way to do this so far.
|
||||
(define is-windows?
|
||||
(let ((ostype (getenv "OSTYPE")))
|
||||
(and ostype
|
||||
(string=? ostype "msys"))))
|
||||
|
||||
(define args (cdr (command-line)))
|
||||
(define display-exports? #t)
|
||||
|
||||
(define gnc-module-dirs '())
|
||||
(define guile-load-dirs '())
|
||||
(define library-dirs '())
|
||||
|
||||
(define (usage-death)
|
||||
(display "Usage: gnc-test-env [ --no-exports ]\n")
|
||||
(display " [ (--gnc-module-dir dir | \n")
|
||||
(display " --guile-load-dir dir | \n")
|
||||
(display " --library-dir dir) ... ]\n")
|
||||
(exit 1))
|
||||
|
||||
(define (process-args! args)
|
||||
(let loop ((rest args))
|
||||
(cond
|
||||
((null? rest) #t)
|
||||
((string=? "--gnc-module-dir" (car rest))
|
||||
(set! gnc-module-dirs (cons (cadr rest) gnc-module-dirs))
|
||||
(loop (cddr rest)))
|
||||
((string=? "--guile-load-dir" (car rest))
|
||||
(set! guile-load-dirs (cons (cadr rest) guile-load-dirs))
|
||||
(loop (cddr rest)))
|
||||
((string=? "--library-dir" (car rest))
|
||||
(set! library-dirs (cons (cadr rest) library-dirs))
|
||||
(loop (cddr rest)))
|
||||
(else (usage-death))))
|
||||
(set! gnc-module-dirs (reverse gnc-module-dirs))
|
||||
(set! guile-load-dirs (reverse guile-load-dirs)))
|
||||
|
||||
;; The character set of everything except a directory separator as
|
||||
;; necessary for string-tokenize below
|
||||
(define char-set-path
|
||||
(char-set-adjoin
|
||||
(char-set-delete char-set:graphic #\/)
|
||||
#\ ))
|
||||
|
||||
;; The directory separator string.
|
||||
(define dir-separator-string
|
||||
(if is-windows?
|
||||
"\\\\" ;; Needs to be quoted twice because of additional shell quoting
|
||||
"/"))
|
||||
|
||||
;; The path separator string; only needed for GUILE_LOAD_PATH
|
||||
(define path-sep-str
|
||||
(if is-windows?
|
||||
";"
|
||||
":"))
|
||||
|
||||
;; Adapt the directory separator character in the given PATH and
|
||||
;; return the result.
|
||||
(define (adapt-dirsep path)
|
||||
(string-join
|
||||
(string-tokenize path char-set-path)
|
||||
dir-separator-string))
|
||||
|
||||
(if (and (not (null? args))
|
||||
(string=? "--no-exports" (car args)))
|
||||
(begin
|
||||
(set! display-exports? #f)
|
||||
(set! args (cdr args))))
|
||||
|
||||
(if (null? args) (exit 0))
|
||||
|
||||
(process-args! args)
|
||||
|
||||
(define (get-dir-adder env-name dir-list item-suffix separator)
|
||||
(string-append env-name "=\""
|
||||
(apply string-append
|
||||
(map
|
||||
(lambda (dir)
|
||||
(string-append dir item-suffix separator))
|
||||
dir-list))
|
||||
"${" env-name "}\" "))
|
||||
|
||||
(display
|
||||
(adapt-dirsep
|
||||
(get-dir-adder "GNC_MODULE_PATH" gnc-module-dirs "/.libs" path-sep-str)))
|
||||
|
||||
(display
|
||||
(adapt-dirsep
|
||||
(get-dir-adder "GUILE_LOAD_PATH" guile-load-dirs "" path-sep-str)))
|
||||
|
||||
(display
|
||||
(adapt-dirsep
|
||||
(get-dir-adder "GUILE_LOAD_COMPILED_PATH" guile-load-dirs "" path-sep-str)))
|
||||
|
||||
(display
|
||||
(adapt-dirsep
|
||||
(get-dir-adder "LD_LIBRARY_PATH" library-dirs "/.libs" path-sep-str)))
|
||||
|
||||
(display
|
||||
(adapt-dirsep
|
||||
(get-dir-adder "DYLD_LIBRARY_PATH" library-dirs "/.libs" path-sep-str)))
|
||||
|
||||
(if is-windows?
|
||||
(display
|
||||
(get-dir-adder "PATH" library-dirs "/.libs" ":")))
|
||||
|
||||
(if display-exports?
|
||||
(begin
|
||||
(display "; ")
|
||||
(display " export GNC_MODULE_PATH;")
|
||||
(display " export GUILE_LOAD_PATH;")
|
||||
(display " export GUILE_LOAD_COMPILED_PATH;")
|
||||
(display " export LD_LIBRARY_PATH;")
|
||||
(display " export DYLD_LIBRARY_PATH;")
|
||||
(if is-windows?
|
||||
(display " export PATH;"))))
|
||||
|
||||
;; Local Variables:
|
||||
;; mode: scheme
|
||||
;; End:
|
||||
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# Spit out the environment variable settings needed based on
|
||||
# arguments listing @gnc_module_dirs, @guile_load_dirs, and
|
||||
# @library_dirs
|
||||
use Getopt::Long;
|
||||
|
||||
my $define_exports=1;
|
||||
my @gnc_module_dirs=();
|
||||
my @guile_load_dirs=();
|
||||
my @library_dirs=();
|
||||
GetOptions ("exports!" => \$define_exports, # flag
|
||||
"gnc-module-dir=s" => \@gnc_module_dirs, # arry of strings
|
||||
"guile-load-dir=s" => \@guile_load_dirs, # arry of strings
|
||||
"library-dir=s" => \@library_dirs, # arry of strings
|
||||
"verbose" => \$verbose) # flag
|
||||
or die(
|
||||
"Usage: gnc-test-env.pl [ --exports | --noexports ]\n" .
|
||||
" [ (--gnc-module-dir dir | --guile-load-dir dir | --library-dir dir) ... ]\n");
|
||||
|
||||
if ( $^O =~ /MSWin32/ ) {
|
||||
$path_separator=";";
|
||||
} else {
|
||||
$path_separator=":";
|
||||
}
|
||||
|
||||
sub print_env_var {
|
||||
($env_name, $dir_suffix, $separator, @dir_list) = @_;
|
||||
return if not @dir_list;
|
||||
my @suffixed_dir_list = map {
|
||||
my $dir = $_ . $dir_suffix;
|
||||
if ( $^O =~ /MSWin32/ ) {
|
||||
$dir =~ s!/!\\\\!g; } # Backslashes need to be escaped for the environment
|
||||
$dir;
|
||||
} @dir_list;
|
||||
print $env_name . '="' .
|
||||
join($separator, @suffixed_dir_list) .
|
||||
$separator . '${' . $env_name . '}" ';
|
||||
}
|
||||
|
||||
print_env_var "GNC_MODULE_PATH", "/.libs", $path_separator, @gnc_module_dirs;
|
||||
print_env_var "GUILE_LOAD_PATH", "", $path_separator, @guile_load_dirs;
|
||||
print_env_var "GUILE_LOAD_COMPILED_PATH", "", $path_separator, @guile_load_dirs;
|
||||
print_env_var "LD_LIBRARY_PATH", "/.libs", $path_separator, @library_dirs;
|
||||
print_env_var "DYLD_LIBRARY_PATH", "/.libs", $path_separator, @library_dirs;
|
||||
|
||||
if ( $^O =~ /MSWin32/ ) {
|
||||
print_env_var "PATH", "/.libs", ":", @library_dirs;
|
||||
}
|
||||
|
||||
if ($define_exports) {
|
||||
print ";\n";
|
||||
print "export GNC_MODULE_PATH;\n" if @gnc_module_dirs;
|
||||
print "export GUILE_LOAD_PATH;\n" if @guile_load_dirs;
|
||||
print "export GUILE_LOAD_COMPILED_PATH;\n" if @guile_load_dirs;
|
||||
print "export LD_LIBRARY_PATH;\n" if @library_dirs;
|
||||
print "export DYLD_LIBRARY_PATH;\n" if @library_dirs;
|
||||
if ( $^O =~ /MSWin32/ ) {
|
||||
print "export PATH;\n" if @library_dirs;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue