Added support to build under MSYS2 environment
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 29 May 2016 07:14:09 +0000
changeset 23 7dad21b22558
parent 22 53b717983dfd
child 24 ae6fc15070e4
Added support to build under MSYS2 environment * Automatically setup build environment for MSYS2 if C:\MSYS64 is present and lean. * Fixed `checkout_svn` to work with MSYS2 version of SubVersion. For some reason that version of `svn.exe` does not like Windows absolute filenames starting with 'device letter'. In that case the actually directory for checkout is messed up. To workaround, always use relative paths when specifying workiing copy path * Added Borland's `make.exe` to `bin` as Smalltalk/X Windows makefiles still uses it. Triple sigh here.
bin/make.exe
rakelib/setup.rake
rakelib/support.rb
rakelib/vcs.rb
Binary file bin/make.exe has changed
--- a/rakelib/setup.rake	Sat May 28 18:36:43 2016 +0100
+++ b/rakelib/setup.rake	Sun May 29 07:14:09 2016 +0000
@@ -77,23 +77,35 @@
   OBJ_SUFFIX = 'obj'
   MAKE='bmake.bat -DUSEBC'
 elsif TOOLCHAIN == 'mingw64' then
-  if not File.exist? 'C:\mingw64\bin' then
-  	raise new Exception("MINGW64 not found in C:\\mingw64!")
+  if File.exist? 'C:\mingw64\bin' then
+    ENV['MINGW_DIR'] ='C:\MINGW64'
+    ENV['USEMINGW_ARG'] = '-DUSEMINGW64'
+  elsif File.exist? 'C:\MSYS64\MINGW64\bin\gcc.exe'
+    ENV['MINGW_DIR'] ='C:\MSYS64\MINGW64'
+    ENV['USEMINGW_ARG'] = '-DUSEMINGW64'
+  else
+  	raise Exception.new("MINGW64 nor MSYS2 found in C:\\MinGW64 nor C:\\MSYS64!")
   end
-  ENV['MINGW_DIR'] ='C:\MINGW64'
   ENV['MINGW'] = '__MINGW64__'
-  ENV['USEMINGW_ARG'] = '-DUSEMINGW64'
   OBJ_DIR = 'objmingw'
   OBJ_SUFFIX = 'obj'
   MAKE='mingwmake.bat'  
   ENV["PATH"] = "#{ENV['PATH']};#{ENV['MINGW_DIR']}\\bin"
 elsif (TOOLCHAIN == 'mingw' or TOOLCHAIN == 'mingw32') then
-  if not File.exist? 'C:\mingw\bin' then
-  	raise new Exception("MINGW not found in C:\\mingw!")
+  if File.exist? 'C:\mingw\bin' then
+    ENV['MINGW_DIR'] ='C:\MINGW'
+    ENV['USEMINGW_ARG'] = '-DUSEMINGW32'  
+  elsif File.exist? 'C:\MSYS64\MINGW32\bin\gcc.exe'
+    ENV['MINGW_DIR'] ='C:\MSYS64\MINGW32'
+    ENV['USEMINGW_ARG'] = '-DUSEMINGW32'  
+  elsif File.exist? 'C:\MSYS\MINGW32\bin\gcc.exe'
+    ENV['MINGW_DIR'] ='C:\MSYS\MINGW32'
+    ENV['USEMINGW_ARG'] = '-DUSEMINGW32'  
+  else    
+    raise Exception.new("MINGW32 nor MSYS2 found in C:\\MinGW nor C:\\MSYS64 nor C:\\MSYS!")
   end
   ENV['MINGW_DIR'] ='C:\MINGW'
   ENV['MINGW'] = '__MINGW32__'
-  ENV['USEMINGW_ARG'] = '-DUSEMINGW32'	
   OBJ_DIR = 'objmingw'
   OBJ_SUFFIX = 'obj'
   MAKE='mingwmake.bat'
--- a/rakelib/support.rb	Sat May 28 18:36:43 2016 +0100
+++ b/rakelib/support.rb	Sun May 29 07:14:09 2016 +0000
@@ -17,12 +17,14 @@
   end
 end
 
-# Update PATH for build so build scripts may access 
-# scripts in `bin` directory. This is required especially
-# on Windows as Windows do not ship with some basic tools
-# (e.g. zip) by default. As a courtesy to the user, provide
-# our own
-ENV['PATH'] = "#{ENV['PATH']}#{File::PATH_SEPARATOR}#{File.expand_path('bin')}"
+# Update PATH for build so build scripts may access  scripts and programs 
+# in `bin` directory. This is required especially on Windows as Windows do 
+# not ship with some basic tools (e.g. zip) by default. As a courtesy to the
+# user, provide our own. 
+# NOTE that this MUST be the first entry in the PATH to be able to override
+# MINGW/MSYS make.exe with Borland's ancient make.exe (sigh, St/X still deals
+# with dinosaurs)
+ENV['PATH'] = "#{File.expand_path('bin')};#{File::PATH_SEPARATOR}#{ENV['PATH']}"
 
 # Return true if running under Jenkins, false otherwise
 def jenkins?
--- a/rakelib/vcs.rb	Sat May 28 18:36:43 2016 +0100
+++ b/rakelib/vcs.rb	Sun May 29 07:14:09 2016 +0000
@@ -220,11 +220,13 @@
 
   def self._checkout_svn(repository, directory, branch, root, *params)
     url = "#{repository}/#{directory}/#{branch}"
-    cmd = %W{svn --non-interactive --trust-server-cert co #{url} #{root / directory}}
+    cmd = %W{svn --non-interactive --trust-server-cert co #{url} #{directory}}
     info "executing cmd: '#{cmd}'"
-    Rake::FileUtilsExt::when_writing(cmd) do
-      if (not system(*cmd))
-        raise CheckoutException.new("SVN: Cannot checkout from #{url}")
+    FileUtils.chdir root do
+      Rake::FileUtilsExt::when_writing(cmd) do
+        if (not system(*cmd))
+          raise CheckoutException.new("SVN: Cannot checkout from #{url}")
+        end
       end
     end
   end