linguistics 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/rake/win32.rb DELETED
@@ -1,190 +0,0 @@
1
- #
2
- # Win32-specific tasks (cross-compiling, etc.)
3
- #
4
- # Thanks to some people that understand this stuff better than me for
5
- # posting helpful blog posts. This stuff is an amalgam of stuff they did:
6
- #
7
- # * Mauricio Fernandez
8
- # http://eigenclass.org/hiki/cross+compiling+rcovrt
9
- #
10
- # * Jeremy Hinegardner
11
- # http://www.copiousfreetime.org/articles/2008/10/12/building-gems-for-windows.html
12
- #
13
- # * Aaron Patterson
14
- # http://tenderlovemaking.com/2008/11/21/cross-compiling-ruby-gems-for-win32/
15
-
16
- require 'rubygems'
17
- require 'rake'
18
- require 'pathname'
19
- require 'rubygems/platform'
20
- require 'rbconfig'
21
- require 'uri'
22
- require 'net/ftp'
23
-
24
- HOMEDIR = Pathname( '~' ).expand_path
25
- RUBYVERSION = '1.8.6-p287'
26
- RUBYVERSION_MAJORMINOR = RUBYVERSION[/^\d+\.\d+/]
27
-
28
- RUBY_DL_BASE = "ftp://ftp.ruby-lang.org/pub/ruby/#{RUBYVERSION_MAJORMINOR}/"
29
- RUBY_DL_URI = URI( RUBY_DL_BASE + "ruby-#{RUBYVERSION}.tar.gz" )
30
-
31
- XCOMPILER_DIR = HOMEDIR + '.ruby_mingw32'
32
-
33
- XCOMPILER_DL = XCOMPILER_DIR + "ruby-#{RUBYVERSION}.tar.gz"
34
- XCOMPILER_SRC = XCOMPILER_DIR + "ruby-#{RUBYVERSION}"
35
-
36
- XCOMPILER_BIN = XCOMPILER_DIR + 'bin'
37
- XCOMPILER_LIB = XCOMPILER_DIR + 'lib'
38
- XCOMPILER_RUBY = XCOMPILER_BIN + 'ruby.exe'
39
-
40
- XCOMPILER_LOAD_PATH = XCOMPILER_LIB + "ruby/#{RUBYVERSION_MAJORMINOR}/i386-mingw32"
41
-
42
- TAR_OPTS = { :compression => :gzip }
43
-
44
- WIN32_GEMSPEC = GEMSPEC.dup
45
- WIN32_GEMSPEC.files += FileList[ EXTDIR + '**.{dll,so}' ]
46
- WIN32_GEMSPEC.platform = Gem::Platform.new( 'i386-mingw32' )
47
- WIN32_GEMSPEC.extensions = []
48
-
49
-
50
- CONFIGURE_CMD = %W[
51
- env
52
- ac_cv_func_getpgrp_void=no
53
- ac_cv_func_setpgrp_void=yes
54
- rb_cv_negative_time_t=no
55
- ac_cv_func_memcmp_working=yes
56
- rb_cv_binary_elf=no
57
- ./configure
58
- --host=i386-mingw32
59
- --target=i386-mingw32
60
- --build=#{Config::CONFIG['build']}
61
- --prefix=#{XCOMPILER_DIR}
62
- ]
63
-
64
- ### Archive::Tar::Reader#extract (as of 0.9.0) is broken w.r.t.
65
- ### permissions, so we have to do this ourselves.
66
- def untar( tarfile, targetdir )
67
- targetdir = Pathname( targetdir )
68
- raise "No such directory: #{targetdir}" unless targetdir.directory?
69
-
70
- reader = Archive::Tar::Reader.new( tarfile.to_s, TAR_OPTS )
71
-
72
- mkdir_p( targetdir )
73
- reader.each( true ) do |header, body|
74
- path = targetdir + header[:path]
75
- # trace "Header is: %p" % [ header ]
76
-
77
- case header[:type]
78
- when :file
79
- trace " #{path}"
80
- path.open( File::WRONLY|File::EXCL|File::CREAT|File::TRUNC, header[:mode] ) do |fio|
81
- bytesize = header[:size]
82
- fio.write( body[0,bytesize] )
83
- end
84
-
85
- when :directory
86
- trace " #{path}"
87
- path.mkpath
88
-
89
- when :link
90
- linktarget = targetdir + header[:dest]
91
- trace " #{path} => #{linktarget}"
92
- path.make_link( linktarget.to_s )
93
-
94
- when :symlink
95
- linktarget = targetdir + header[:dest]
96
- trace " #{path} -> #{linktarget}"
97
- path.make_symlink( linktarget )
98
- end
99
- end
100
-
101
- end
102
-
103
-
104
- begin
105
- require 'archive/tar'
106
-
107
- namespace :win32 do
108
- directory XCOMPILER_DIR.to_s
109
-
110
- file XCOMPILER_DL => XCOMPILER_DIR do
111
- # openuri can't handle this -- passive ftp required?
112
- # run 'wget', '-O', XCOMPILER_DL, RUBY_DL_URI
113
- log "Downloading ruby distro from %s" % [ RUBY_DL_URI ]
114
- ftp = Net::FTP.new( RUBY_DL_URI.host )
115
- ftp.login
116
- ftp.getbinaryfile( RUBY_DL_URI.path, XCOMPILER_DL, 4096 )
117
- ftp.close
118
- end
119
-
120
- directory XCOMPILER_SRC.to_s
121
- task XCOMPILER_SRC => [ XCOMPILER_DIR, XCOMPILER_DL ] do
122
- if XCOMPILER_SRC.exist?
123
- trace "Rake fails. #{XCOMPILER_SRC} already exists."
124
- else
125
- untar( XCOMPILER_DL, XCOMPILER_DIR )
126
- end
127
- end
128
-
129
- file XCOMPILER_RUBY => XCOMPILER_SRC do
130
- Dir.chdir( XCOMPILER_SRC ) do
131
- unless File.exist?( 'Makefile.in.orig' )
132
- File.open( 'Makefile.in.new', IO::CREAT|IO::WRONLY|IO::EXCL ) do |ofh|
133
- IO.readlines( 'Makefile.in' ).each do |line|
134
- next if line.include?( 0.chr )
135
- trace " copying line: %p" % [ line ]
136
- line.sub!( /ALT_SEPARATOR = ".*?"/, "ALT_SEPARATOR = 92.chr" )
137
- ofh.write( line )
138
- end
139
- end
140
-
141
- mv 'Makefile.in', 'Makefile.in.orig'
142
- mv 'Makefile.in.new', 'Makefile.in'
143
- end
144
-
145
- run *CONFIGURE_CMD
146
- run 'make', 'ruby'
147
- run 'make', 'rubyw.exe'
148
- run 'make', 'install'
149
- end
150
- end
151
-
152
- file XCOMPILER_LOAD_PATH => XCOMPILER_RUBY
153
-
154
- desc "Cross-compile the library for Win32 systems, installing a cross-" +
155
- "compiled Ruby if necessary"
156
- task :build => [ EXTDIR, XCOMPILER_LOAD_PATH.to_s ] do
157
- in_subdirectory( EXTDIR ) do
158
- ruby "-I#{XCOMPILER_LOAD_PATH}", 'extconf.rb'
159
- sh 'make'
160
- end
161
- end
162
-
163
- desc "Build a binary gem for win32 systems"
164
- task :gem => ['win32:build', PKGDIR.to_s] + WIN32_GEMSPEC.files do
165
- when_writing( "Creating win32 GEM" ) do
166
- pkgname = WIN32_GEMSPEC.file_name
167
- builder = Gem::Builder.new( WIN32_GEMSPEC )
168
- builder.build
169
- mv pkgname, PKGDIR + pkgname, :verbose => $trace
170
- end
171
- end
172
- end
173
-
174
- rescue LoadError => err
175
- trace "Couldn't load the win32 tasks: %s: %s" % [ err.class.name, err.message ]
176
-
177
- task :no_win32_build do
178
- abort "No win32 build: %s: %s" % [ err.class.name, err.message ]
179
- end
180
-
181
- namespace :win32 do
182
- desc "Build a binary Gem for Win32 systems, installing a cross " +
183
- "compiled Ruby if necessary"
184
- task :gem => :no_win32_build
185
- task :build => :no_win32_build
186
- end
187
-
188
- end
189
-
190
-