Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Download, build and deploy vim (personal use on Windows)

by sg (Pilgrim)
on Oct 21, 2007 at 20:17 UTC ( #646300=CUFP: print w/replies, xml ) Need Help??

This script, which I have been using on Windows:

  • downloads vim sources from the svn repository (update: these will have the latest patches)
  • backs up existing vim
  • uses MinGW to compile gvim and vim
  • deploys gvim and vim to the release directory
  • uses rsync to update the vim runtime files

Other aspects of the script:

  • The single command of running the script does all of the above.
  • The script is configurable both in terms of parameters for the above steps and in terms of which of the above steps are done.
  • It is meant for personal use (rather than for use by, say, an IT department).

#!c:/opt/bin/perl use warnings; use strict; use Cwd qw(getcwd chdir realpath); use File::Find; use File::Copy; use File::stat; #--------------------------------------------------------- # Configuration my $svn_top_dir = 'e:/where/projects/vim/vim7'; my $vim_src_dir = "$svn_top_dir/src"; my $release_dir = 'c:\opt\vim\vim71'; my $user_name = 'the_user'; my $user_domain = 'the_domain'; my $mingw_path = 'c:\opt\MinGW\bin'; my $svn = 'c:\opt\svn\svn-win32-1.4.4\bin\svn'; my $rsync = 'c:\opt\cwRsync\bin\rsync'; my $rsync_arg = '-avzcP --delete --exclude="/dos/" ftp.nluug.nl: +:Vim/runtime/ ./runtime/'; my $make_cmd = $mingw_path . '\mingw32-make.exe -f Make_ming.m +ak'; my $cc = 'CC="c:/opt/MinGW/bin/gcc -Ic:/opt/MinGW/includ +e -Lc:/opt/MinGW/lib"'; my $general_options = 'FEATURES=HUGE DEBUG=no OLE=yes'; my $perl_current = 'c:/opt/perl'; my $perl_use = $perl_current; my $perl_options = "PERL=$perl_use PERL_VER=58"; # GUI=yes my $backup_existing = 1; my $update_svn = 1; my $stop_if_no_new_source = 1; my $build_gui = 1; my $release_gui = 1; my $build_console = 1; my $release_console = 1; my $update_runtime = 1; #--------------------------------------------------------- my $rc = ''; my $log = scalar localtime(time) . "\n"; my $start_dir = getcwd(); my $back_dir = ''; if($backup_existing) { my $back; for (1 .. 3) { # tested, but perhaps not all situations my $dir = $release_dir.".$_"; -e $dir or mkdir $dir and ($back_dir = $dir) and last; my $st = stat($dir) or die "can't stat $dir: $!\n"; $back or $back = $st->mtime; ($back < $st->mtime) or $back_dir = $dir and $back = $st->mtime; } chdir $release_dir or die "Can't cd to $release_dir: $!\n";; print "Backing up existing release at $release_dir to $back_dir ... +"; find({wanted => \&back_existing}, '.'); print "done\n"; } $ENV{USERNAME} = $user_name; $ENV{USERDOMAIN} = $user_domain; $ENV{PATH} .= ';' . $mingw_path; # Get the sources (other than runtime) # First time: svn co https://vim.svn.sourceforge.net/svnroot/vim/vim7 # chdir $svn_top_dir or die "Can't cd to $svn_top_dir: $!\n";; if($update_svn) { print "Updating sources ... "; $rc = `$svn update`; if($rc =~ /^At revision \d+\./) { print "nothing to do\n"; $stop_if_no_new_source and exit; } print "done\n"; } chdir $vim_src_dir or die "Can't cd to $vim_src_dir: $!\n";; if($build_gui) { print "Buildig GUI version ... "; $rc = `$make_cmd clean $cc $general_options $perl_options GUI=yes`; + $rc = `$make_cmd clean $cc $general_options $perl_options GUI=no`; $rc = `$make_cmd $cc $general_options $perl_options GUI=yes`; $log .= $rc; print "done\n"; if($release_gui) { print "Releasing GUI to $release_dir ... "; find({wanted => \&release}, '.'); print "done\n"; } } if($build_console) { print "Buildig console version ... "; $rc = `$make_cmd clean $cc $general_options $perl_options GUI=yes`; + $rc = `$make_cmd clean $cc $general_options $perl_options GUI=no`; $rc = `$make_cmd $cc $general_options $perl_options GUI=no`; $log .= $rc; print "done\n"; if($release_console) { print "Releasing console to $release_dir ... "; find({wanted => \&release}, '.'); print "done\n"; } } if($update_runtime) { chdir $release_dir or die "Can't cd to $release_dir: $!\n";; print "Rsync'ing runtime ... "; $rc = `$rsync $rsync_arg`; print "done\n"; print "rsync output:\n$rc,\n"; chdir $start_dir or die "Can't cd to $start_dir: $!\n";; } sub release { my $file = $_; $file =~ /\.(exe|dll)$/ and move($file, "$release_dir/$file"); } sub back_existing { my $file = $_; $file =~ /\.(exe|dll)$/ and copy($file, "$back_dir/$file"); } # nothing is actually done with $log # print "\n\n$log\n\n"; __END__

Replies are listed 'Best First'.
Re: Download, build and deploy vim (personal use on Windows)
by xdg (Monsignor) on Oct 21, 2007 at 21:32 UTC

    ++ for perl, but can you explain the benefits of compiling your own vim instead of just using the self-installing executable for Windows? It's worked quite well for me for years.

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      The svn source code has the latest patches (currently about 145). As an example of a bug that has been fixed, here's a bug in the released vim that is fixed in a recent patch:
      gvim -u NONE -U NONE --noplugin open a file with lots of lines ggyG :set more :perl VIM::Msg(VIM::Eval('@"')) Bug: At the more prompt q, <esc>, ^C do not work. NOTE: more from echo @" works as before

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://646300]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2022-12-05 20:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?