[PATCH] Basic experimental support for windows
Matthias Goldhoorn
matthias.goldhoorn at dfki.de
Fri Oct 12 08:18:59 CEST 2012
---
lib/autoproj/cmdline.rb | 22 ++++++++++++++++++----
lib/autoproj/manifest.rb | 16 +++++++++++++---
lib/autoproj/osdeps.rb | 22 +++++++++++++++++++---
lib/autoproj/system.rb | 17 +++++++++++------
4 files changed, 61 insertions(+), 16 deletions(-)
diff --git a/lib/autoproj/cmdline.rb b/lib/autoproj/cmdline.rb
index 698f2a8..04fef97 100644
--- a/lib/autoproj/cmdline.rb
+++ b/lib/autoproj/cmdline.rb
@@ -4,11 +4,14 @@ module Autoproj
class << self
attr_accessor :verbose
attr_reader :console
+ attr_reader :env
attr_predicate :silent?, true
end
@silent = false
@verbose = false
@console = HighLine.new
+ @env = RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)! ? "env.bat" : "env.sh"
+
def self.message(*args)
if !silent?
@@ -62,6 +65,7 @@ module Autoproj
# If we are under rubygems, check that the GEM_HOME is right ...
if $LOADED_FEATURES.any? { |l| l =~ /rubygems/ }
+
if ENV['GEM_HOME'] != Autoproj.gem_home
raise ConfigError.new, "RubyGems is already loaded with a different GEM_HOME, make sure you are loading the right env.sh script !"
end
@@ -1369,7 +1373,7 @@ where 'mode' is one of:
end
require 'set'
- curdir_entries = Dir.entries('.').to_set - [".", "..", "autoproj_bootstrap", ".gems", 'env.sh'].to_set
+ curdir_entries = Dir.entries('.').to_set - [".", "..", "autoproj_bootstrap", ".gems", @env].to_set
if !curdir_entries.empty? && ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] != '1'
while true
print "The current directory is not empty, continue bootstrapping anyway ? [yes] "
@@ -1444,12 +1448,22 @@ where 'mode' is one of:
Autoproj.save_config
# Finally, generate an env.sh script
- File.open('env.sh', 'w') do |io|
- io.write <<-EOSHELL
+ if(@env == "env.sh")
+ File.open(@env, 'w') do |io|
+ io.write <<-EOSHELL
export RUBYOPT=-rubygems
export GEM_HOME=#{Autoproj.gem_home}
export PATH=$GEM_HOME/bin:$PATH
- EOSHELL
+ EOSHELL
+ end
+ else
+ File.open(@env, 'w') do |io|
+ io.write <<-EOSHELL
+set RUBYOPT=-rubygems
+set GEM_HOME=#{Autoproj.gem_home}
+set PATH=%GEM_HOME%/bin;%PATH%
+ EOSHELL
+ end
end
end
diff --git a/lib/autoproj/manifest.rb b/lib/autoproj/manifest.rb
index b69dd56..b6913cb 100644
--- a/lib/autoproj/manifest.rb
+++ b/lib/autoproj/manifest.rb
@@ -3,6 +3,8 @@ require 'utilrb/kernel/options'
require 'set'
require 'rexml/document'
+require 'win32/dir' if RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
+
module Autoproj
@build_system_dependencies = Set.new
@@ -1443,11 +1445,19 @@ module Autoproj
dest = File.readlink(symlink_dest)
if dest != pkg_set.raw_local_dir
FileUtils.rm_f symlink_dest
- FileUtils.ln_sf pkg_set.raw_local_dir, symlink_dest
+ if !RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
+ FileUtils.ln_sf pkg_set.raw_local_dir, symlink_dest
+ else
+ Dir.create_junction(symlink_dest, pkg_set.raw_local_dir)
+ end
end
else
- FileUtils.rm_f symlink_dest
- FileUtils.ln_sf pkg_set.raw_local_dir, symlink_dest
+ FileUtils.rm_f symlink_dest
+ if !RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
+ FileUtils.ln_sf pkg_set.raw_local_dir, symlink_dest
+ else
+ Dir.create_junction(symlink_dest, pkg_set.raw_local_dir)
+ end
end
symlink_dest
diff --git a/lib/autoproj/osdeps.rb b/lib/autoproj/osdeps.rb
index a0288bc..bf4797e 100644
--- a/lib/autoproj/osdeps.rb
+++ b/lib/autoproj/osdeps.rb
@@ -692,6 +692,8 @@ fi
[['gentoo'], [version]]
elsif File.exists?('/etc/arch-release')
[['arch'], []]
+ elsif RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
+ [['windows'], []]
end
end
@@ -713,8 +715,14 @@ fi
end
def self.os_from_lsb
- has_lsb_release = `which lsb_release`
- return unless $?.success?
+ has_lsb_release = nil
+ begin
+ has_lsb_release = `which lsb_release`
+ return unless $?.success?
+ rescue Exception => e
+ #seems which is not installes (e.g. on windows)
+ return
+ end
distributor = `lsb_release -i -s`
distributor = distributor.strip.downcase
@@ -932,6 +940,8 @@ fi
# Raises ConfigError if some packages can't be found or if the
# nonexistent keyword was found for some of them
def resolve_os_dependencies(dependencies)
+
+
all_packages = []
dependencies.each do |name|
result = resolve_package(name)
@@ -940,7 +950,7 @@ fi
elsif result.empty?
os_names, os_versions = OSDependencies.operating_system
raise ConfigError.new, "there is an osdeps definition for #{name}, but not for this operating system and version (resp. #{os_names.join(", ")} and #{os_versions.join(", ")})"
- else
+ else
result.each do |handler, status, packages|
if status == FOUND_NONEXISTENT
raise ConfigError.new, "there is an osdep definition for #{name}, and it explicitely states that this package does not exist on your OS"
@@ -1206,6 +1216,12 @@ So, what do you want ? (all, ruby, os or none)
# Requests the installation of the given set of packages
def install(packages, package_osdeps = Hash.new)
+ #not sure here, simply show that it is installed even we dont install anything,
+ #because this functions seems to called sometimes even --no-osdeps is given or the installs_os_packages? return false
+ #it seems its not checked everywhere, so add this sainty check here
+ return true if not installs_os_packages?
+
+
os_package_handler.enabled = installs_os_packages?
package_handlers['gem'].enabled = installs_ruby_packages?
package_handlers.each_value do |v|
diff --git a/lib/autoproj/system.rb b/lib/autoproj/system.rb
index cdc6d84..d415631 100644
--- a/lib/autoproj/system.rb
+++ b/lib/autoproj/system.rb
@@ -14,12 +14,17 @@ module Autoproj
# If the current directory is not in an autoproj installation,
# raises UserError.
def self.root_dir(dir = Dir.pwd)
- while dir != "/" && !File.directory?(File.join(dir, "autoproj"))
+ while (dir != "/" && !(dir.match("(.):\/\$") && dir.size == 3 )) && !File.directory?(File.join(dir, "autoproj"))
dir = File.dirname(dir)
end
- if dir == "/"
+ if dir == "/" || ((dir.match("(.):\/\$")) && dir.size == 3 )
raise UserError, "not in a Autoproj installation"
end
+
+ #Preventing backslashed in path, that might be confusing on some path compares
+ if Autoproj::OSDependencies.operating_system[0].include?("windows")
+ dir = dir.gsub(/\\/,'/')
+ end
dir
end
@@ -121,10 +126,10 @@ module Autoproj
# Create the env.sh script in +subdir+. In general, +subdir+ should be nil.
def self.export_env_sh(subdir = nil)
filename = if subdir
- File.join(Autoproj.root_dir, subdir, "env.sh")
- else
- File.join(Autoproj.root_dir, "env.sh")
- end
+ File.join(Autoproj.root_dir, subdir, Autoproj.env)
+ else
+ File.join(Autoproj.root_dir, Autoproj.env)
+ end
shell_dir = File.expand_path(File.join("..", "..", "shell"), File.dirname(__FILE__))
if Autoproj.shell_helpers? && shell = ENV['SHELL']
--
1.7.10.4
--------------020000030508070909090903
Content-Type: text/x-patch;
name="0001-Extended-for-Darwin-OS-includeing-osdep-support-via-.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="0001-Extended-for-Darwin-OS-includeing-osdep-support-via-.pa";
filename*1="tch"
More information about the Rock-dev
mailing list