digitalmars.D - script for configuring dmd to work with phobos and tango on linux
- Andrei Alexandrescu (See Website for Email) (36/36) Mar 29 2007 I previously sent a little script that configured the environment
- ideage (3/3) Mar 29 2007 Greet Andrei Alexandrescu , Thank you! you are a adept; a highly skille...
- Andrei Alexandrescu (See Website For Email) (4/6) Mar 29 2007 Note to self: never underestimate the seductive power of a little
- ideage (2/5) Mar 29 2007
- eao197 (69/79) Mar 30 2007 On Fri, 30 Mar 2007 01:57:56 +0400, Andrei Alexandrescu (See Website for...
- Kirk McDonald (9/54) Mar 30 2007 I little while back I came up with a scheme for DMD/Windows, which I
I previously sent a little script that configured the environment variable DFLAGS, but then I figured that it's best to mess with the config file directly. This way the advantage of different consoles with different dmd configuration is lost, but then there is the advantage that the configuration is persistent, which help certain modus operandi. YMMV. Paste the code below into a file e.g. dmdc, make it executable, and then run either "dmdc phobos" or "dmdc tango". Adding more parameters after that invokes the compiler, temporarily overriding the .conf file with the requested environment; the old environment is then restored HTH, Andrei D_BIN=$(dirname $(which dmd)) WHICH=$1 if [ "$WHICH" = "phobos" ]; then DFLAGS="-I$D_BIN/../src/phobos -L-L$D_BIN/../lib -L-L$D_BIN/../../dm/lib" elif [ "$WHICH" = "tango" ]; then DFLAGS="-I$D_BIN/../../tango-0.96-bin -version=Tango -version=Posix" DFLAGS="$DFLAGS -L-L$D_BIN/../../tango-0.96-bin/lib libtango.a" else echo "Please pass either phobos or tango as the first argument" WHICH="" fi if [ ! -z "$WHICH" ]; then shift mv $D_BIN/dmd.conf $D_BIN/dmd.conf.bak if [ "$*" != "" ]; then dmd $* mv $D_BIN/dmd.conf.bak $D_BIN/dmd.conf else echo "[Environment]" >$D_BIN/dmd.conf echo "DFLAGS=$DFLAGS" >>$D_BIN/dmd.conf fi fi
Mar 29 2007
Greet Andrei Alexandrescu , Thank you! you are a adept; a highly skilled person; an expert, in my mind. Why write a book <<Modern D Design>> ,it will resolve D template program!
Mar 29 2007
ideage wrote:Greet Andrei Alexandrescu , Thank you! you are a adept; a highly skilled person; an expert, in my mind.Note to self: never underestimate the seductive power of a little trivial shell script :o). Andrei
Mar 29 2007
Thank you again. i will try it's power. Expect your book! Do you think write it?Note to self: never underestimate the seductive power of a little trivial shell script :o). Andrei
Mar 29 2007
On Fri, 30 Mar 2007 01:57:56 +0400, Andrei Alexandrescu (See Website for= = Email) <SeeWebsiteForEmail erdani.org> wrote:I previously sent a little script that configured the environment variable DFLAGS, but then I figured that it's best to mess with the config file directly. This way the advantage of different consoles wit=hdifferent dmd configuration is lost, but then there is the advantage that the configuration is persistent, which help certain modus operand=i.YMMV. Paste the code below into a file e.g. dmdc, make it executable, and th=enrun either "dmdc phobos" or "dmdc tango". Adding more parameters after=that invokes the compiler, temporarily overriding the .conf file with the requested environment; the old environment is then restoredThanks for a great idea! There is a my attempt to create such script for Windows version of dmd. = = I've used Ruby because I'm a big fun of Ruby. Paste the code below into a file dmdc.rb and place the file in the = directory with dmd.exe (it is necessary because the script assumes that = = sc.ini is in the same directory). Then change definition of constant = TANGO_PATH to your tango's directory name. When dmdc.rb started with 'tango' arguments it moves sc.ini to = sc.ini.original then makes sc.ini with original content of sc.ini.origin= al = except for lines which start from LIB=3D or DFLAGS=3D (those are being = changed). This is the first (created on the knee) version :) It have been tested on Ruby 1.8.6 on Windows with dmd.1.009 and tango.0.= 96 = (it may be necessary to add '.rb' into PATHEXT environment variable). require 'fileutils' TANGO_PATH =3D 'd:/usr/tango' DMD_PATH =3D File.dirname( $0 ) SC =3D 'sc.ini' SC_INI =3D File.join( DMD_PATH, SC ) SC_COPY =3D SC_INI + '.original' if ARGV.size < 2 || /(tango|phobos)/i !~ ARGV[0] exit 1 end if /tango/i =3D~ ARGV[0] FileUtils.mv( SC_INI, SC_COPY ) at_exit do FileUtils.mv( SC_COPY, SC_INI ) end File.open( SC_INI, 'w' ) do |dest| IO.readlines( SC_COPY ).each do |cfg_line| updated_line =3D case cfg_line when /^LIB=3D/ when /^DFLAGS=3D/ else cfg_line end dest.puts updated_line end end end . guarded_args =3D ARGV[1..-1].map { |a| a.gsub( /(")/, '\\"' ) } system( cmd_line ) exit $? ? $?.exitstatus : 1 -- = Regards, Yauheni Akhotnikau
Mar 30 2007
Andrei Alexandrescu (See Website for Email) wrote:I previously sent a little script that configured the environment variable DFLAGS, but then I figured that it's best to mess with the config file directly. This way the advantage of different consoles with different dmd configuration is lost, but then there is the advantage that the configuration is persistent, which help certain modus operandi. YMMV. Paste the code below into a file e.g. dmdc, make it executable, and then run either "dmdc phobos" or "dmdc tango". Adding more parameters after that invokes the compiler, temporarily overriding the .conf file with the requested environment; the old environment is then restored HTH, Andrei D_BIN=$(dirname $(which dmd)) WHICH=$1 if [ "$WHICH" = "phobos" ]; then DFLAGS="-I$D_BIN/../src/phobos -L-L$D_BIN/../lib -L-L$D_BIN/../../dm/lib" elif [ "$WHICH" = "tango" ]; then DFLAGS="-I$D_BIN/../../tango-0.96-bin -version=Tango -version=Posix" DFLAGS="$DFLAGS -L-L$D_BIN/../../tango-0.96-bin/lib libtango.a" else echo "Please pass either phobos or tango as the first argument" WHICH="" fi if [ ! -z "$WHICH" ]; then shift mv $D_BIN/dmd.conf $D_BIN/dmd.conf.bak if [ "$*" != "" ]; then dmd $* mv $D_BIN/dmd.conf.bak $D_BIN/dmd.conf else echo "[Environment]" >$D_BIN/dmd.conf echo "DFLAGS=$DFLAGS" >>$D_BIN/dmd.conf fi fiI little while back I came up with a scheme for DMD/Windows, which I placed on the Tango wiki: http://dsource.org/projects/tango/wiki/PhobosTangoCooperation -- Kirk McDonald http://kirkmcdonald.blogspot.com Pyd: Connecting D and Python http://pyd.dsource.org
Mar 30 2007