rake-compiler 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 196b8e433ab869ede009a6b0691c86e228e929143102558f7bc7ba30d7c33a32
4
- data.tar.gz: 23d6a72c3bfbd1cded05b7b58d5ccac030209da10b7f214392584520743f4c39
3
+ metadata.gz: 26eded4dd15fc9f4d4bb17d06c023c2263b0197aa81527345ba3aa55cbef83a2
4
+ data.tar.gz: d9d079304e17d2fa94bddc1973caae02c1de15d32792dd196606521f7fa135d3
5
5
  SHA512:
6
- metadata.gz: 704df0198fbeb45b4d1f033e43e49a440088ca7b34107d93e1d11f818f4d2307a63614d480f707ca39ba44b74e153a913bc6bb568ea8debfd6882529ba567868
7
- data.tar.gz: a90fd28b0b81f88ede892c914676acb1f2ac6791df8ba443800b5e9ad281b62104d8e000d6eae0863c44ea9cb313bb4d7b27cf146007c4f6f22e3b003773efbf
6
+ metadata.gz: aa0c6e30767e3b0abb567a49589773f9ff025f2bdf67114917b1e495e2bc65c9a748da22718a2e4ddd9455e16599cfc48048f4b850dfb050c123371130db1161
7
+ data.tar.gz: 9e0364625d0a68574b2fa87f7ada67454f5775640912bd8614e94d870db0ecdfdbd868a46273c9c539b72b2d55dd7807ce9a95e8356a6c54b31073149145b5cd
@@ -1,3 +1,15 @@
1
+ === 1.0.9 / 2012-12-23
2
+
3
+ * Changes:
4
+ * Use "-Xlint" option for JRuby native extension by default.
5
+ #158 [Patch by Stephen George]
6
+
7
+ * Enhancements:
8
+ * Make customizable compiler Xlint option for JRuby native extension.
9
+ #118 [Patch by Hiroshi Hatake]
10
+ * Add support for Ruby 2.7.
11
+ #161 [Reported by Masaki Hara]
12
+
1
13
  === 1.0.8 / 2019-09-21
2
14
 
3
15
  * Enhancements:
@@ -1,10 +1,10 @@
1
- = What is rake-compiler?
1
+ # What is rake-compiler?
2
2
 
3
3
  rake-compiler is first and foremost a productivity tool for Ruby developers.
4
4
  Its goal is to make the busy developer's life easier by simplifying the building
5
5
  and packaging of Ruby extensions by simplifying code and reducing duplication.
6
6
 
7
- It follows *convention over configuration* by advocating a standardized build and
7
+ It follows **convention over configuration** by advocating a standardized build and
8
8
  package structure for both C and Java based RubyGems.
9
9
 
10
10
  rake-compiler is the result of many hard-won experiences dealing with several
@@ -16,7 +16,7 @@ structure often made it very difficult for newcomers to those RubyGems.
16
16
  From these challenges, rake-compiler was born with the single-minded goal of
17
17
  making the busy RubyGem developer's life much less difficult.
18
18
 
19
- == Feature Overview
19
+ ## Feature Overview
20
20
 
21
21
  Some of the benefits rake-compiler provides include:
22
22
 
@@ -35,18 +35,18 @@ Some of the benefits rake-compiler provides include:
35
35
 
36
36
  * Simplifies cross platform extension compilation (targeting Windows from Linux).
37
37
 
38
- == OK, I'm sold! Show me how to install it!
38
+ ## OK, I'm sold! Show me how to install it!
39
39
 
40
40
  Simple:
41
41
 
42
- $ gem install rake-compiler
42
+ $ gem install rake-compiler
43
43
 
44
- == That's easy. How do I use it?
44
+ ## That's easy. How do I use it?
45
45
 
46
46
  Now that you have installed rake-compiler, it's time to give your project a
47
47
  standardized structure.
48
48
 
49
- === Using a standardized project structure
49
+ ### Using a standardized project structure
50
50
 
51
51
  Let's say you want to compile an extension called 'hello_world'. Organizing
52
52
  your project's code tree in the following way will help rake-compiler do
@@ -64,7 +64,7 @@ TIP: Having a consistent project directory structure will help developers and
64
64
  newcomers find and understand your code, making it easier for them to
65
65
  contribute back to your project.
66
66
 
67
- === Adding the code to enable rake-compiler
67
+ ### Adding the code to enable rake-compiler
68
68
 
69
69
  Now the fun part. It's time to introduce the code to your projects Rakefile
70
70
  to tell it to use rake-compiler to build your extension:
@@ -75,7 +75,6 @@ to tell it to use rake-compiler to build your extension:
75
75
  require 'mkmf'
76
76
  create_makefile('hello_world')
77
77
 
78
-
79
78
  # File: Rakefile
80
79
 
81
80
  require 'rake/extensiontask'
@@ -85,8 +84,8 @@ to tell it to use rake-compiler to build your extension:
85
84
  That's it? Yes, that's it! No other lines of code are needed for
86
85
  rake-compiler to work its magic.
87
86
 
88
- Though, you need to make sure the parameter to <tt>create_makefile</tt>
89
- and <tt>ExtensionTask.new</tt> are the same or rake-compiler will not mimic
87
+ Though, you need to make sure the parameter to `create_makefile`
88
+ and `ExtensionTask.new` are the same or rake-compiler will not mimic
90
89
  the RubyGems standard install process. You can override this standard
91
90
  behaviour if needed, see the instructions for "non-standard project structure"
92
91
  below for details.
@@ -100,45 +99,46 @@ as easy:
100
99
 
101
100
  Rake::JavaExtensionTask.new('hello_world')
102
101
 
103
- === The simple process
102
+ ### The simple process
104
103
 
105
- Those *two* simple lines of code automatically added the Rake tasks needed to
104
+ Those **two** simple lines of code automatically added the Rake tasks needed to
106
105
  build your 'hello_world' extension. For example, checking the Rake tasks on
107
106
  MRI Ruby 1.8.x/1.9 returns something similar to:
108
107
 
109
- $ rake -T
110
- (in /home/user/my_extension)
111
- rake compile # Compile the extension(s)
112
- rake compile:hello_world # Compile just the hello_world extension
108
+ $ rake -T
109
+ (in /home/user/my_extension)
110
+ rake compile # Compile the extension(s)
111
+ rake compile:hello_world # Compile just the hello_world extension
113
112
 
114
- Simply calling <tt>compile</tt> like
113
+ Simply calling `compile` like
115
114
 
116
- $ rake compile
115
+ $ rake compile
117
116
 
118
117
  performs the entire compile and build process for you and places the resulting
119
- extension inside the <tt>lib</tt> directory of your project.
118
+ extension inside the `lib` directory of your project.
120
119
 
121
- To pass <tt>dir_config</tt> options to the compilation, add to the command line:
120
+ To pass `dir_config` options to the compilation, add to the command line:
122
121
 
123
- $ rake compile -- --with-foo-[dir|lib|bin|...]=/path/to/foo
122
+ $ rake compile -- --with-foo-[dir|lib|bin|...]=/path/to/foo
124
123
 
125
124
  NOTE: Please be aware that building C extensions requires the proper
126
125
  development environment for your Platform, including libraries, headers
127
126
  and build tools. Check your distro / vendor documentation on how to install
128
127
  these development resources.
129
128
 
130
- NOTE: Building Java extensions requires the <tt>javac</tt>, part of the Java
129
+ NOTE: Building Java extensions requires the `javac`, part of the Java
131
130
  Development Kit (JDK). This should be included by default on Mac OS X, and
132
131
  downloadable from http://java.sun.com for other operating systems.
133
132
 
134
- === Generating native RubyGems
133
+ ### Generating native RubyGems
135
134
 
136
135
  A common usage scenario for rake-compiler is generating native gems that
137
136
  bundle your extensions. As mentioned above, if you have your development
138
137
  environment configured correctly, the following examples work even when
139
138
  building native gems on Windows systems.
140
139
 
141
- Creating native gems is really easy with rake-compiler's <tt>Rake::ExtensionTask</tt>:
140
+ Creating native gems is really easy with rake-compiler's
141
+ `Rake::ExtensionTask`:
142
142
 
143
143
  # somewhere in your Rakefile, define your gem spec
144
144
  spec = Gem::Specification.new do |s|
@@ -157,57 +157,57 @@ Creating native gems is really easy with rake-compiler's <tt>Rake::ExtensionTask
157
157
  As expected, you can still build your pure-ruby gem in the usual way
158
158
  (standard output) by running:
159
159
 
160
- $ rake gem
161
- (in /projects/oss/my_gem.git)
162
- mkdir -p pkg
163
- Successfully built RubyGem
164
- Name: my_gem
165
- Version: 0.1.0
166
- File: my_gem-0.1.0.gem
167
- mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
160
+ $ rake gem
161
+ (in /projects/oss/my_gem.git)
162
+ mkdir -p pkg
163
+ Successfully built RubyGem
164
+ Name: my_gem
165
+ Version: 0.1.0
166
+ File: my_gem-0.1.0.gem
167
+ mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
168
168
 
169
169
  Plus, rake-compiler tasks give you the extra functionality needed to build
170
170
  native gems by running:
171
171
 
172
- # rake native gem
173
- (... compilation output ...)
174
- mkdir -p pkg
175
- Successfully built RubyGem
176
- Name: my_gem
177
- Version: 0.1.0
178
- File: my_gem-0.1.0.gem
179
- mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
180
- Successfully built RubyGem
181
- Name: my_gem
182
- Version: 0.1.0
183
- File: my_gem-0.1.0-x86-mingw32.gem
184
- mv my_gem-0.1.0-x86-mingw32.gem pkg/my_gem-0.1.0-x86-mingw32.gem
172
+ # rake native gem
173
+ (... compilation output ...)
174
+ mkdir -p pkg
175
+ Successfully built RubyGem
176
+ Name: my_gem
177
+ Version: 0.1.0
178
+ File: my_gem-0.1.0.gem
179
+ mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
180
+ Successfully built RubyGem
181
+ Name: my_gem
182
+ Version: 0.1.0
183
+ File: my_gem-0.1.0-x86-mingw32.gem
184
+ mv my_gem-0.1.0-x86-mingw32.gem pkg/my_gem-0.1.0-x86-mingw32.gem
185
185
 
186
186
  Did you notice that you get two gems for the price of one? How's that for a
187
187
  time saver?
188
188
 
189
189
  Similarly, it's just as easy to do the same thing for JRuby extensions:
190
190
 
191
- # rake java gem
192
- (... compilation output ...)
193
- mkdir -p pkg
194
- Successfully built RubyGem
195
- Name: my_gem
196
- Version: 0.1.0
197
- File: my_gem-0.1.0.gem
198
- mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
199
- Successfully built RubyGem
200
- Name: my_gem
201
- Version: 0.1.0
202
- File: my_gem-0.1.0-java.gem
203
- mv my_gem-0.1.0-java.gem pkg/my_gem-0.1.0-java.gem
191
+ # rake java gem
192
+ (... compilation output ...)
193
+ mkdir -p pkg
194
+ Successfully built RubyGem
195
+ Name: my_gem
196
+ Version: 0.1.0
197
+ File: my_gem-0.1.0.gem
198
+ mv my_gem-0.1.0.gem pkg/my_gem-0.1.0.gem
199
+ Successfully built RubyGem
200
+ Name: my_gem
201
+ Version: 0.1.0
202
+ File: my_gem-0.1.0-java.gem
203
+ mv my_gem-0.1.0-java.gem pkg/my_gem-0.1.0-java.gem
204
204
 
205
205
 
206
- === Great, but can I use a non-standard project structure?
206
+ ### Great, but can I use a non-standard project structure?
207
207
 
208
208
  Yes you can! While the conventional project structure is recommended, you may
209
209
  want, or need, to tweak those conventions. Rake-compiler allows you to customize
210
- several settings for <tt>Rake::ExtensionTask</tt>:
210
+ several settings for `Rake::ExtensionTask`:
211
211
 
212
212
  Rake::ExtensionTask.new do |ext|
213
213
  ext.name = 'hello_world' # indicate the name of the extension.
@@ -221,7 +221,34 @@ several settings for <tt>Rake::ExtensionTask</tt>:
221
221
  # will be used.
222
222
  end
223
223
 
224
- == Cross compilation - the future is now.
224
+
225
+ ### Show me all of the supported configuration options
226
+
227
+ | Option | Supported By | Description |
228
+ | -------------------- | --------------------- | ---------------------------------------- |
229
+ | name | Both | Required. Give the target binary a name. |
230
+ | gem_spec | Both | [Optional] Indicate which gem specification will be used. |
231
+ | tmp_dir | Both | [Optional] Temporary folder used during compilation. |
232
+ | ext_dir | Both | [Optional] Where to search for `name`. Default: `ext/#{@name}`. |
233
+ | lib_dir | Both | [Optional] Put binaries into this folder. Default: `lib`. |
234
+ | config_options | Both | [Optional] Supply additional options to configure script. |
235
+ | source_pattern | Both | [Optional] Monitor file changes to allow simple rebuild. Default for CRuby: `*.{c,cc,cpp}`. Default for Java: `**/*.java`. |
236
+ | _extra_options_ | ExtensionTask (CRuby) | [Optional] _Any options you add to ARGV on the command line are passed on as complilation flags if they begin with a dash (-)._ |
237
+ | config_script | ExtensionTask (CRuby) | [Optional] Specify alternate configuration file name when [Adding the code to enable rake-compiler](#adding-the-code-to-enable-rake-compiler). Default: `extconf.rb`. |
238
+ | cross_compile | ExtensionTask (CRuby) | [Optional] See [Cross compilation - the future is now.](#cross-compilation---the-future-is-now) Default: `false`. |
239
+ | cross_platform | ExtensionTask (CRuby) | [Optional] See [Cross compilation - the future is now.](#cross-compilation---the-future-is-now) Default: `i386-mingw32`. |
240
+ | cross_config_options | ExtensionTask (CRuby) | [Optional] See [Cross compilation - the future is now.](#cross-compilation---the-future-is-now) Default: `[]`. |
241
+ | no_native | ExtensionTask (CRuby) | [Optional] Set to true to prevent non-CRuby platforms from defining native tasks. Default: `false`. |
242
+ | config_includes | ExtensionTask (CRuby) | [Optional] Specify an Array of paths to include as `-I...:...` includes during compilation. Default: `['.']`. |
243
+ | classpath | JavaExtensionTask | [Optional] Specify additional classpath paths as an Array. Default: _Uses the current CLASSPATH._ |
244
+ | debug | JavaExtensionTask | [Optional] Whether to set the debug flag during complication. Default: `false`. |
245
+ | source_version | JavaExtensionTask | [Optional] The JRE version that your source code requires to compile. Default: `1.6`. |
246
+ | target_version | JavaExtensionTask | [Optional] The oldest JRE version you want to support. Default: `1.6`. |
247
+ | encoding | JavaExtensionTask | [Optional] Specify an -encoding option to provide to the compiler. Default: `nil`. |
248
+ | lint_option | JavaExtensionTask | [Optional] Specify a `-Xlint:___` linting option such as `deprecation`, `all`, `none`, etc. (Run `javac -help -X` to see all available options.) <br> Default: _Simply `-Xlint` is run, which enables recommended warnings._ |
249
+
250
+
251
+ ## Cross compilation - the future is now.
225
252
 
226
253
  Rake-compiler also provides a standardized way to generate, from either Linux
227
254
  or OSX, extensions and gem binaries for your Windows users!
@@ -230,9 +257,9 @@ How can this be you say? Simple, rake-compiler's cross compilation features
230
257
  take advantage of GCC's host/target capabilities to build 'target' binaries on
231
258
  different 'host' OS's.
232
259
 
233
- === How do I do this from Linux or OSX?
260
+ ### How do I do this from Linux or OSX?
234
261
 
235
- ==== The Easy Way
262
+ #### The Easy Way
236
263
 
237
264
  Use rake-compiler-dock, a gem that makes use of a virtual machine provisioned with
238
265
  all the necessary build tools. You can add a task to your Rakefile, that
@@ -240,17 +267,17 @@ cross-compiles and packages your gem into Windows fat binaries (with 1.8 to 2.2
240
267
  and x86/x64 support). See https://github.com/rake-compiler/rake-compiler-dock for more
241
268
  information.
242
269
 
243
- ==== The Manual Way
270
+ #### The Manual Way
244
271
 
245
272
  In addition to having the development tool chain installed (GCC), you also need to
246
- install your platform's <tt>mingw32</tt> cross compilation package.
273
+ install your platform's `mingw32` cross compilation package.
247
274
 
248
275
  Installation depends upon your operating system/distribution. On Ubuntu and Debian
249
- host machines, a simple <tt>apt-get install mingw32</tt> will be enough.
276
+ host machines, a simple `apt-get install mingw32` will be enough.
250
277
 
251
- On Arch, <tt>mingw32</tt> is installed by running <tt>pacman -S mingw32-gcc</tt>
278
+ On Arch, `mingw32` is installed by running `pacman -S mingw32-gcc`
252
279
 
253
- On OSX, we no longer recommend the usage of MacPorts <tt>mingw32</tt> package because
280
+ On OSX, we no longer recommend the usage of MacPorts `mingw32` package because
254
281
  it stagnated in GCC version 3.4.5.
255
282
 
256
283
  Instead we recommend you download mingw-w64 automated build packages available at
@@ -258,56 +285,56 @@ SourceForge:
258
285
 
259
286
  http://sourceforge.net/downloads/mingw-w64/
260
287
 
261
- Browse into <em>Toolchains targetting Win32</em> and then <em>Automated Builds</em>.
288
+ Browse into *Toolchains targetting Win32* and then *Automated Builds*.
262
289
 
263
290
  Files will be ordered by recency, find the latest one with version 1.0 in it,
264
291
  like this one:
265
292
 
266
- mingw-w32-1.0-bin_i686-darwin_20110422.tar.bz2
293
+ mingw-w32-1.0-bin_i686-darwin_20110422.tar.bz2
267
294
 
268
295
  Download and extract. After that, make sure the bin directory is added to the PATH, eg:
269
296
 
270
- export PATH=~/mingw-w64/w32/bin:$PATH
297
+ export PATH=~/mingw-w64/w32/bin:$PATH
271
298
 
272
- You can add this to your <tt>.profile</tt> to avoid the repitition.
299
+ You can add this to your `.profile` to avoid the repitition.
273
300
 
274
- ==== I've got my tool-chain installed, now what?
301
+ #### I've got my tool-chain installed, now what?
275
302
 
276
303
  First, you need to build Ruby for Windows on your Linux or OSX system.
277
304
 
278
305
  Relax, no need to freak out! Let rake-compiler do all the heavy lifting for you:
279
306
 
280
- rake-compiler cross-ruby
307
+ rake-compiler cross-ruby
281
308
 
282
309
  And you're done. It will automatically download, configure and compile the latest
283
- stable version of Ruby for Windows, and place it into your <tt>~/.rake-compiler</tt>
310
+ stable version of Ruby for Windows, and place it into your `~/.rake-compiler`
284
311
  directory.
285
312
 
286
- This will create <tt>~/.rake-compiler/config.yml</tt> file so that rake-compiler
287
- knows where to find the <tt>rbconfig.rb</tt> file that matches the Ruby version
313
+ This will create `~/.rake-compiler/config.yml` file so that rake-compiler
314
+ knows where to find the `rbconfig.rb` file that matches the Ruby version
288
315
  on the Windows host system you're cross-compiling for. An example:
289
316
 
290
- # File: ~/.rake-compiler/config.yml
317
+ # File: ~/.rake-compiler/config.yml
291
318
 
292
- rbconfig-x86-mingw32-1.8.6: /path/to/ruby-1.8.6/rbconfig.rb
293
- rbconfig-x86-mingw32-1.8.7: /path/to/ruby-1.8.7/rbconfig.rb
294
- rbconfig-x86-mingw32-1.9.2: /path/to/ruby-1.9.2/rbconfig.rb
319
+ rbconfig-x86-mingw32-1.8.6: /path/to/ruby-1.8.6/rbconfig.rb
320
+ rbconfig-x86-mingw32-1.8.7: /path/to/ruby-1.8.7/rbconfig.rb
321
+ rbconfig-x86-mingw32-1.9.2: /path/to/ruby-1.9.2/rbconfig.rb
295
322
 
296
323
  If, instead, you want to build a different Ruby version than the default one, please
297
- supply a <tt>VERSION</tt>:
324
+ supply a `VERSION`:
298
325
 
299
- rake-compiler cross-ruby VERSION=1.8.6-p114
326
+ rake-compiler cross-ruby VERSION=1.8.6-p114
300
327
 
301
328
  If you, like me, have multiple versions of MinGW packages installed, you can
302
329
  specify the HOST that will be used to cross compile Ruby:
303
330
 
304
- rake-compiler cross-ruby HOST=x86-mingw32 # (OSX mingw32 port)
331
+ rake-compiler cross-ruby HOST=x86-mingw32 # (OSX mingw32 port)
305
332
 
306
333
  The host will vary depending on provider (mingw32 versus mingw-w64 projects).
307
334
  Please consult the documentation and website of the MinGW package provider before
308
335
  reporting any issues.
309
336
 
310
- ==== OK, let's cross compile some gems!
337
+ #### OK, let's cross compile some gems!
311
338
 
312
339
  Now, you only need specify a few additional options in your extension definition:
313
340
 
@@ -338,53 +365,53 @@ Now, you only need specify a few additional options in your extension definition
338
365
 
339
366
  By default, cross compilation targets 'i386-mingw32' which is the default
340
367
  GCC platform for Ruby. MRI Ruby's current official distribution uses
341
- <tt>i386-mswin32-60</tt>. The RubyInstaller distribution uses
342
- <tt>x86-mingw32</tt> and <tt>x64-mingw32</tt> for 32-bit and 64-bit
343
- Windows targets, respectively. Note that <tt>i386</tt> and <tt>x86</tt>
344
- are synonymous here; <tt>x86</tt> is preferred going forward.
368
+ `i386-mswin32-60`. The RubyInstaller distribution uses
369
+ `x86-mingw32` and `x64-mingw32` for 32-bit and 64-bit
370
+ Windows targets, respectively. Note that `i386` and `x86`
371
+ are synonymous here; `x86` is preferred going forward.
345
372
 
346
- The format for <tt>cross_config_options</tt> is an array of strings and
347
- hashes. Hashes will be fetched for each value of <tt>cross_platform</tt>
373
+ The format for `cross_config_options` is an array of strings and
374
+ hashes. Hashes will be fetched for each value of `cross_platform`
348
375
  as the build iterates, or ignored if there is no value for that platform.
349
376
  You can mix-and-match strings and hashes to get desired option ordering.
350
377
 
351
- ==== Warning, magician about to do some tricks, don't blink!
378
+ #### Warning, magician about to do some tricks, don't blink!
352
379
 
353
380
  Cross compiling is still very simple:
354
381
 
355
- rake cross compile
382
+ rake cross compile
356
383
 
357
384
  And now, building gems for your Windows users is just 6 more letters:
358
385
 
359
- rake cross native gem
386
+ rake cross native gem
360
387
 
361
388
  And you're done, yeah.
362
389
 
363
- ==== But wait, there's more
390
+ #### But wait, there's more
364
391
 
365
392
  You can specify which version of Ruby to build the extension against:
366
393
 
367
- rake cross compile RUBY_CC_VERSION=1.8.6
394
+ rake cross compile RUBY_CC_VERSION=1.8.6
368
395
 
369
- For example, if you installed <tt>1.9.2</tt>, you can do:
396
+ For example, if you installed `1.9.2`, you can do:
370
397
 
371
- rake cross compile RUBY_CC_VERSION=1.9.2
398
+ rake cross compile RUBY_CC_VERSION=1.9.2
372
399
 
373
400
  Even better, you can target multiple versions (ie. 1.8.6 and 1.9.2) in
374
401
  the same gem via:
375
402
 
376
- rake cross compile RUBY_CC_VERSION=1.8.6:1.9.2
403
+ rake cross compile RUBY_CC_VERSION=1.8.6:1.9.2
377
404
 
378
405
  And better yet, you can bundle both binary extensions into one so-called "fat"
379
406
  gem via:
380
407
 
381
- rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.2
408
+ rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.2
382
409
 
383
410
  That will place binaries for both the 1.8 and 1.9 versions of your Ruby
384
- extensions inside your project's <tt>lib_dir</tt> directory:
411
+ extensions inside your project's `lib_dir` directory:
385
412
 
386
- lib/1.8/my_extension.so
387
- lib/1.9/my_extension.so
413
+ lib/1.8/my_extension.so
414
+ lib/1.9/my_extension.so
388
415
 
389
416
  NOTE: building "fat" gems is currently only supported by rake-compiler when
390
417
  cross compiling from a Linux or OSX host. Patches are welcome if building
@@ -392,12 +419,12 @@ cross compiling from a Linux or OSX host. Patches are welcome if building
392
419
 
393
420
  Now it's up to you to make your gem load the proper binary at runtime:
394
421
 
395
- begin
396
- RUBY_VERSION =~ /(\d+\.\d+)/
397
- require "#{$1}/my_extension"
398
- rescue LoadError
399
- require "my_extension"
400
- end
422
+ begin
423
+ RUBY_VERSION =~ /(\d+\.\d+)/
424
+ require "#{$1}/my_extension"
425
+ rescue LoadError
426
+ require "my_extension"
427
+ end
401
428
 
402
429
  The above technique will lookup first for 1.8 or 1.9 version of the extension
403
430
  and when not found, will look for the plain extension.
@@ -406,7 +433,7 @@ This approach catch the cases of provided fat binaries or gems compiled by the
406
433
  end user installing the gem. It has also been implemented successfully in
407
434
  several projects.
408
435
 
409
- == What are you talking about? (Give me examples)
436
+ ## What are you talking about? (Give me examples)
410
437
 
411
438
  I know all the above sounds like a complete foreign language (it does even for me!).
412
439
  So, what if I show you some examples?
@@ -416,19 +443,19 @@ projects and how they use rake-compiler.
416
443
 
417
444
  http://github.com/rake-compiler/rake-compiler/wiki/projects-using-rake-compiler
418
445
 
419
- == Future
446
+ ## Future
420
447
 
421
448
  rake-compiler is a work in progress and we appreciate any and all feedback
422
449
  during the development of it! (and contributions too!)
423
450
 
424
451
  You can find more information about rake-compiler:
425
452
 
426
- * GitHub: https://github.com/rake-compiler/rake-compiler
427
- * Issues: https://github.com/rake-compiler/rake-compiler/issues
428
- * Docs: http://rubydoc.info/gems/rake-compiler
429
- * Wiki: https://github.com/rake-compiler/rake-compiler/wiki
453
+ * GitHub: https://github.com/rake-compiler/rake-compiler
454
+ * Issues: https://github.com/rake-compiler/rake-compiler/issues
455
+ * Docs: http://rubydoc.info/gems/rake-compiler
456
+ * Wiki: https://github.com/rake-compiler/rake-compiler/wiki
430
457
 
431
- == Disclaimer
458
+ ## Disclaimer
432
459
 
433
460
  If you have any trouble, don't hesitate to contact the author. As always,
434
461
  I'm not going to say "Use at your own risk" because I don't want this library
@@ -19,6 +19,9 @@ module Rake
19
19
 
20
20
  attr_accessor :encoding
21
21
 
22
+ # Specify lint option
23
+ attr_accessor :lint_option
24
+
22
25
  def platform
23
26
  @platform ||= 'java'
24
27
  end
@@ -36,6 +39,7 @@ module Rake
36
39
  @target_version = '1.6'
37
40
  @encoding = nil
38
41
  @java_compiling = nil
42
+ @lint_option = nil
39
43
  end
40
44
 
41
45
  def define
@@ -95,10 +99,19 @@ execute the Rake compilation task using the JRuby interpreter.
95
99
  EOF
96
100
  warn_once(not_jruby_compile_msg) unless defined?(JRUBY_VERSION)
97
101
 
98
- classpath_arg = java_classpath_arg(@classpath)
99
- debug_arg = @debug ? '-g' : ''
100
-
101
- sh "javac #{java_encoding_arg} #{java_extdirs_arg} -target #{@target_version} -source #{@source_version} -Xlint:unchecked #{debug_arg} #{classpath_arg} -d #{tmp_path} #{source_files.join(' ')}"
102
+ javac_command_line = [
103
+ "javac",
104
+ "-target", @target_version,
105
+ "-source", @source_version,
106
+ java_lint_arg,
107
+ "-d", tmp_path,
108
+ ]
109
+ javac_command_line.concat(java_encoding_arg)
110
+ javac_command_line.concat(java_extdirs_arg)
111
+ javac_command_line.concat(java_classpath_args)
112
+ javac_command_line << "-g" if @debug
113
+ javac_command_line.concat(source_files)
114
+ sh(*javac_command_line)
102
115
 
103
116
  # Checkpoint file
104
117
  touch "#{tmp_path}/.build"
@@ -188,31 +201,36 @@ execute the Rake compilation task using the JRuby interpreter.
188
201
  end
189
202
 
190
203
  #
191
- # Discover Java Extension Directories and build an extdirs argument
204
+ # Discover Java Extension Directories and build an extdirs arguments
192
205
  #
193
- def java_extdirs_arg
206
+ def java_extdirs_args
194
207
  extdirs = Java::java.lang.System.getProperty('java.ext.dirs') rescue nil
195
- extdirs = ENV['JAVA_EXT_DIR'] unless extdirs
196
- java_extdir = extdirs.nil? ? "" : "-extdirs \"#{extdirs}\""
208
+ extdirs ||= ENV['JAVA_EXT_DIR']
209
+ if extdirs.nil?
210
+ []
211
+ else
212
+ ["-extdirs", extdirs]
213
+ end
197
214
  end
198
215
 
199
216
  #
200
- # Build an encoding argument
217
+ # Build an encoding arguments
201
218
  #
202
- def java_encoding_arg
203
- @encoding.nil? ? "" : "-encoding \"#{@encoding}\""
219
+ def java_encoding_args
220
+ if @encoding.nil?
221
+ []
222
+ else
223
+ ["-encoding", @encoding]
224
+ end
204
225
  end
205
226
 
206
227
  #
207
- # Discover the Java/JRuby classpath and build a classpath argument
208
- #
209
- # @params
210
- # *args:: Additional classpath arguments to append
228
+ # Discover the Java/JRuby classpath and build a classpath arguments
211
229
  #
212
230
  # Copied verbatim from the ActiveRecord-JDBC project. There are a small myriad
213
231
  # of ways to discover the Java classpath correctly.
214
232
  #
215
- def java_classpath_arg(*args)
233
+ def java_classpath_args
216
234
  jruby_cpath = nil
217
235
  if RUBY_PLATFORM =~ /java/
218
236
  begin
@@ -250,9 +268,21 @@ execute the Rake compilation task using the JRuby interpreter.
250
268
  raise "Could not find jruby.jar. Please set JRUBY_HOME or use jruby in rvm"
251
269
  end
252
270
 
253
- jruby_cpath += File::PATH_SEPARATOR + args.join(File::PATH_SEPARATOR) unless args.empty?
254
- jruby_cpath ? "-cp \"#{jruby_cpath}\"" : ""
271
+ if @classpath and @classpath.size > 0
272
+ jruby_cpath = [jruby_cpath, *@classpath].join(File::PATH_SEPARATOR)
273
+ end
274
+ ["-cp", jruby_cpath]
255
275
  end
256
276
 
277
+ #
278
+ # Convert a `-Xlint:___` linting option such as `deprecation` into a full javac argument, such as `-Xlint:deprecation`.
279
+ #
280
+ # @return [String] Default: _Simply `-Xlint` is run, which enables recommended warnings.
281
+ #
282
+ def java_lint_arg
283
+ return '-Xlint' unless @lint_option
284
+
285
+ "-Xlint:#{@lint_option}"
286
+ end
257
287
  end
258
288
  end
@@ -76,9 +76,14 @@ describe Rake::JavaExtensionTask do
76
76
  @ext.config_options.should be_empty
77
77
  end
78
78
 
79
+ it 'should have no lint option preset to delegate' do
80
+ @ext.lint_option.should be_falsey
81
+ end
82
+
79
83
  it 'should default to Java platform' do
80
84
  @ext.platform.should == 'java'
81
85
  end
86
+ end
82
87
 
83
88
  context '(tasks)' do
84
89
  before :each do
@@ -165,6 +170,31 @@ describe Rake::JavaExtensionTask do
165
170
  end
166
171
  end
167
172
  end
173
+
174
+ context 'A custom extension' do
175
+ let(:extension) do
176
+ Rake::JavaExtensionTask.new('extension_two') do |ext|
177
+ ext.lint_option = lint_option if lint_option
178
+ end
179
+ end
180
+
181
+ context 'without a specified lint option' do
182
+ let(:lint_option) { nil }
183
+
184
+ it 'should honor the lint option' do
185
+ (extension.lint_option).should be_falsey
186
+ (extension.send :java_lint_arg).should eq '-Xlint'
187
+ end
188
+ end
189
+
190
+ context "with a specified lint option of 'deprecated'" do
191
+ let(:lint_option) { 'deprecated'.freeze }
192
+
193
+ it 'should honor the lint option' do
194
+ (extension.lint_option).should eq lint_option
195
+ (extension.send :java_lint_arg).should eq '-Xlint:deprecated'
196
+ end
197
+ end
168
198
  end
169
199
  end
170
200
  private
@@ -58,13 +58,16 @@ MINGW_TARGET = MINGW_HOST.gsub('msvc', '')
58
58
  ENV.delete(var)
59
59
  end
60
60
 
61
+ source_dir = "#{USER_HOME}/sources/#{RUBY_CC_VERSION}"
62
+ build_dir = "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}"
63
+
61
64
  # define a location where sources will be stored
62
- directory "#{USER_HOME}/sources/#{RUBY_CC_VERSION}"
63
- directory "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}"
65
+ directory source_dir
66
+ directory build_dir
64
67
 
65
68
  # clean intermediate files and folders
66
- CLEAN.include("#{USER_HOME}/sources/#{RUBY_CC_VERSION}")
67
- CLEAN.include("#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}")
69
+ CLEAN.include(source_dir)
70
+ CLEAN.include(build_dir)
68
71
 
69
72
  # remove the final products and sources
70
73
  CLOBBER.include("#{USER_HOME}/sources")
@@ -87,20 +90,26 @@ end
87
90
 
88
91
  # Extract the sources
89
92
  source_file = RUBY_SOURCE ? RUBY_SOURCE.split('/').last : "#{RUBY_CC_VERSION}.tar.bz2"
90
- file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}" => ["#{USER_HOME}/sources/#{source_file}"] do |t|
93
+ file source_dir => ["#{USER_HOME}/sources/#{source_file}"] do |t|
91
94
  chdir File.dirname(t.name) do
92
95
  t.prerequisites.each { |f| sh "tar xf #{File.basename(f)}" }
93
96
  end
94
97
  end
95
98
 
96
99
  # backup makefile.in
97
- file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in.bak" => ["#{USER_HOME}/sources/#{RUBY_CC_VERSION}"] do |t|
98
- cp "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in", t.name
100
+ if RUBY_CC_VERSION >= "ruby-2.7.0"
101
+ makefile_in = "#{source_dir}/template/Makefile.in"
102
+ else
103
+ makefile_in = "#{source_dir}/Makefile.in"
104
+ end
105
+ makefile_in_bak = "#{makefile_in}.bak"
106
+ file makefile_in_bak => [source_dir] do |t|
107
+ cp makefile_in, makefile_in_bak
99
108
  end
100
109
 
101
110
  # correct the makefiles
102
- file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in" => ["#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in.bak"] do |t|
103
- content = File.open(t.name, 'rb') { |f| f.read }
111
+ file makefile_in => [makefile_in_bak] do |t|
112
+ content = File.open(makefile_in_bak, 'rb') { |f| f.read }
104
113
 
105
114
  out = ""
106
115
 
@@ -113,7 +122,7 @@ file "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in" => ["#{USER_HOME}/sou
113
122
  end
114
123
 
115
124
  when_writing("Patching Makefile.in") {
116
- File.open(t.name, 'wb') { |f| f.write(out) }
125
+ File.open(makefile_in, 'wb') { |f| f.write(out) }
117
126
  }
118
127
  end
119
128
 
@@ -126,8 +135,7 @@ task :mingw32 do
126
135
  end
127
136
 
128
137
  # generate the makefile in a clean build location
129
- file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}",
130
- "#{USER_HOME}/sources/#{RUBY_CC_VERSION}/Makefile.in"] do |t|
138
+ file "#{build_dir}/Makefile" => [build_dir, makefile_in] do |t|
131
139
 
132
140
  options = [
133
141
  "--host=#{MINGW_HOST}",
@@ -149,14 +157,14 @@ file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile" => ["#{USER
149
157
  end
150
158
 
151
159
  # make
152
- file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile"] do |t|
160
+ file "#{build_dir}/ruby.exe" => ["#{build_dir}/Makefile"] do |t|
153
161
  chdir File.dirname(t.prerequisites.first) do
154
162
  sh MAKE
155
163
  end
156
164
  end
157
165
 
158
166
  # make install
159
- file "#{USER_HOME}/ruby/#{MINGW_HOST}/#{RUBY_CC_VERSION}/bin/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe"] do |t|
167
+ file "#{USER_HOME}/ruby/#{MINGW_HOST}/#{RUBY_CC_VERSION}/bin/ruby.exe" => ["#{build_dir}/ruby.exe"] do |t|
160
168
  chdir File.dirname(t.prerequisites.first) do
161
169
  sh "#{MAKE} install"
162
170
  end
@@ -210,4 +218,3 @@ end
210
218
 
211
219
  desc "Build #{RUBY_CC_VERSION} suitable for cross-platform development."
212
220
  task 'cross-ruby' => [:mingw32, :install, 'update-config']
213
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-09-20 00:00:00.000000000 Z
12
+ date: 2019-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -77,14 +77,14 @@ executables:
77
77
  - rake-compiler
78
78
  extensions: []
79
79
  extra_rdoc_files:
80
- - README.rdoc
80
+ - README.md
81
81
  - LICENSE.txt
82
82
  - History.txt
83
83
  files:
84
84
  - Gemfile
85
85
  - History.txt
86
86
  - LICENSE.txt
87
- - README.rdoc
87
+ - README.md
88
88
  - Rakefile
89
89
  - appveyor.yml
90
90
  - bin/rake-compiler
@@ -129,7 +129,7 @@ metadata: {}
129
129
  post_install_message:
130
130
  rdoc_options:
131
131
  - "--main"
132
- - README.rdoc
132
+ - README.md
133
133
  - "--title"
134
134
  - rake-compiler -- Documentation
135
135
  require_paths: