digitalmars.D - script for configuring dmd to work with phobos and tango on linux
- "Andrei Alexandrescu (See Website for Email)" <SeeWebsiteForEmail erdani.org> Mar 29 2007
- "ideage" <lsina 126.com> Mar 29 2007
- "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail erdani.org> Mar 29 2007
- "ideage" <lsina 126.com> Mar 29 2007
- eao197 <eao197 intervale.ru> Mar 30 2007
- Kirk McDonald <kirklin.mcdonald gmail.com> Mar 30 2007
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
#!/bin/sh
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=
different dmd configuration is lost, but then there is the advantage that the configuration is persistent, which help certain modus operand=
YMMV. Paste the code below into a file e.g. dmdc, make it executable, and th=
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
Thanks 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' # Set path to your tango directory here. 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] $stderr.puts "#{File.basename($0)} <tango|phobos> args..." exit 1 end if /tango/i =3D~ ARGV[0] # It is necessary to change 'sc.ini' file. FileUtils.mv( SC_INI, SC_COPY ) # Return 'sc.int' at the end at_exit do FileUtils.mv( SC_COPY, SC_INI ) end # Make transformation of sc.ini.original content. File.open( SC_INI, 'w' ) do |dest| IO.readlines( SC_COPY ).each do |cfg_line| updated_line =3D case cfg_line when /^LIB=3D/ %{LIB=3D"#{TANGO_PATH}/lib;% P%/../lib;% P%/../../dm/lib"} when /^DFLAGS=3D/ %{DFLAGS=3D"-I#{TANGO_PATH}" -version=3DTango tango.lib} else cfg_line end dest.puts updated_line end end end # Prepare command line and run dmd with arguments. # Change all occurences of \" into \\". # Enclose each argument in quotes to defend arguments with spaces inside= . guarded_args =3D ARGV[1..-1].map { |a| a.gsub( /(")/, '\\"' ) } cmd_line =3D %{dmd "#{guarded_args.join('" "')}"} system( cmd_line ) exit $? ? $?.exitstatus : 1 # vim:ts=3D2:sts=3D2:sw=3D2:expandtab -- = 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 #!/bin/sh 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
I 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









"ideage" <lsina 126.com> 