rubygems-compile 0.2.0 → 1.0.0beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/README.rdoc +37 -23
- data/Rakefile +16 -33
- data/lib/rubygems-compile/analysis.rb +11 -0
- data/lib/rubygems-compile/commands/autocompile_command.rb +27 -0
- data/lib/rubygems-compile/commands/compile_command.rb +50 -0
- data/lib/rubygems-compile/commands/uncompile_command.rb +39 -0
- data/lib/rubygems-compile/commands.rb +8 -0
- data/lib/rubygems-compile/common_methods.rb +32 -15
- data/lib/rubygems-compile/compiler.rb +61 -0
- data/lib/rubygems-compile/post_install_hook.rb +9 -0
- data/lib/rubygems-compile/uncompiler.rb +31 -0
- data/lib/rubygems_plugin.rb +23 -3
- data/test/helper.rb +2 -11
- data/test/test_autocompile_command.rb +22 -0
- data/test/test_compile_command.rb +36 -0
- data/test/test_uncompile_command.rb +16 -0
- metadata +33 -41
- data/lib/rubygems-compile/compile.rb +0 -70
- data/lib/rubygems-compile/decompile.rb +0 -52
- data/lib/rubygems-compile/monkey_patches.rb +0 -11
- data/test/test_find_files_to_compile.rb +0 -44
- data/test/test_get_specs_for_gems.rb +0 -19
data/.gemtest
ADDED
File without changes
|
data/README.rdoc
CHANGED
@@ -1,45 +1,59 @@
|
|
1
1
|
= rubygems-compile
|
2
2
|
|
3
|
-
A
|
3
|
+
A set of rubygems commands for <tt>macgem</tt> that interface with the
|
4
|
+
MacRuby compiler.
|
4
5
|
|
5
6
|
All you need to do is:
|
6
7
|
|
7
|
-
|
8
|
+
sudo macgem install rubygems-compile
|
8
9
|
|
9
|
-
And then you're off to the races!
|
10
|
+
And then you're off to the races!
|
10
11
|
|
11
|
-
==
|
12
|
+
== Commands
|
12
13
|
|
13
|
-
|
14
|
+
[+compile+] Can be used to compile, or re-compile, any gems that are already installed.
|
14
15
|
|
15
|
-
|
16
|
+
sudo macgem compile nokogiri # Compile gems based on names you provide
|
17
|
+
sudo macgem compile minitest --version 2.0.2 # Compile a specific version of a gem
|
18
|
+
sudo macgem compile --all # Compile all installed gems
|
19
|
+
sudo macgem compile rspec --no-ignore-dependencies # Also compile dependencies
|
16
20
|
|
17
|
-
|
21
|
+
[+uncompile+] Can be used to remove the compiled <tt>.rbo</tt> files if a gem does not work well when compiled.
|
22
|
+
|
23
|
+
sudo macgem uncompile nokogiri # Uncompile gems based on names you provide
|
24
|
+
sudo macgem uncompile minitest --version 2.0.2 # Compile a specific version of a gem
|
25
|
+
sudo macgem uncompile --all # Uncompile all installed gems
|
26
|
+
sudo macgem uncompile rspec --no-ignore-dependencies # Also uncompile dependencies
|
27
|
+
|
28
|
+
[+auto_compile+] Can be used to enable a post-install hook that will automatically compile gems when you install them. Call it once to turn on, call it a second time to disable it.
|
29
|
+
|
30
|
+
sudo macgem auto_compile # gems will compiled when you install them
|
31
|
+
sudo macgem auto_compile # gems will not be compiled when you install them
|
18
32
|
|
19
33
|
== Caveats
|
20
34
|
|
21
|
-
* Large gems will take a long time to compile, but these are the gems
|
22
|
-
|
23
|
-
*
|
24
|
-
|
25
|
-
*
|
35
|
+
* Large gems will take a long time to compile, but these are the gems
|
36
|
+
that will benefit the most from being compiled so please be patient
|
37
|
+
* This has only been tested on a few gems, but should not break
|
38
|
+
existing gems since we leave the original files around
|
39
|
+
* At the moment, compiled gems will not provide usable backtraces
|
40
|
+
* <tt>.rbo</tt> files take up more disk space than their <tt>.rb</tt> equivalents
|
26
41
|
|
27
|
-
== Known
|
42
|
+
== Known Issues
|
28
43
|
|
29
|
-
*
|
30
|
-
* This
|
31
|
-
* Gems that explicitly require a file with the file suffix (e.g.
|
32
|
-
*
|
44
|
+
* Source files using a non-standard suffix (e.g. <tt>mime-types</tt> has a <tt>.rb.data</tt> file) will not get compiled
|
45
|
+
* This might be addressable in a later release, but is not a big deal
|
46
|
+
* Gems that explicitly require a file with the file suffix (e.g. <tt>require 'nokogiri.rb'</tt>) will never load the compiled version of the file
|
47
|
+
* Those gems should be updated so that compiled code can be loaded
|
33
48
|
|
34
49
|
== TODO
|
35
50
|
|
36
|
-
*
|
37
|
-
|
38
|
-
*
|
39
|
-
*
|
40
|
-
* A naive implementation will not work for gems that are loaded modularly
|
41
|
-
* Files in bin/ usually don't include the file extension and are not compiled
|
51
|
+
* Support specifying a version for compile/uncompile commands
|
52
|
+
* Code parsing to WARN about gems that will have issues when compiled
|
53
|
+
* Parallel compilation to speed up compilation of large gems
|
54
|
+
* This might require changes in the MacRuby compiler
|
42
55
|
|
43
56
|
== Copyright
|
44
57
|
|
45
58
|
Copyright (c) 2011 Mark Rada. See LICENSE.txt for further details.
|
59
|
+
|
data/Rakefile
CHANGED
@@ -1,41 +1,24 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
1
|
require 'rake/testtask'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/dependency_installer'
|
4
|
+
|
5
|
+
task :default => :gem
|
6
|
+
|
5
7
|
Rake::TestTask.new(:test) do |test|
|
6
|
-
test.libs
|
7
|
-
test.pattern
|
8
|
-
test.verbose
|
8
|
+
test.libs << 'lib' << 'test'
|
9
|
+
test.pattern = 'test/**/test_*.rb'
|
10
|
+
test.verbose = true
|
11
|
+
test.ruby_opts = ['-rhelper']
|
9
12
|
end
|
10
13
|
|
11
|
-
|
14
|
+
eval IO.read('rubygems-compile.gemspec')
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
FileList["lib/**/*.rb"].each do |source|
|
17
|
-
name = File.basename source
|
18
|
-
puts "#{name} => #{name}o"
|
19
|
-
`macrubyc --arch x86_64 -C '#{source}' -o '#{source}o'`
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
desc 'Clean MacRuby binaries'
|
24
|
-
task :clean do
|
25
|
-
FileList["lib/**/*.rbo"].each do |bin|
|
26
|
-
rm bin
|
27
|
-
end
|
28
|
-
end
|
16
|
+
Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
|
17
|
+
pkg.need_zip = false
|
18
|
+
pkg.need_tar = true
|
29
19
|
end
|
30
20
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
puts `gem build -v rubygems-compile.gemspec`
|
35
|
-
end
|
36
|
-
|
37
|
-
desc 'Build the gem and install it'
|
38
|
-
task :install => :build do
|
39
|
-
puts `gem install #{Dir.glob('rubygems-compile*.gem').sort.reverse.first}`
|
40
|
-
end
|
21
|
+
desc 'Build the gem and install it'
|
22
|
+
task :install => :gem do
|
23
|
+
Gem::Installer.new("pkg/#{GEM_SPEC.file_name}").install
|
41
24
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Gem::Commands::AutoCompileCommand < Gem::Command
|
2
|
+
include Gem::UserInteraction
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
super 'auto_compile', 'Enable gem compilation at install time'
|
6
|
+
end
|
7
|
+
|
8
|
+
def description # :nodoc:
|
9
|
+
'Toggle a setting that enables compiling gems at install time.'
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage
|
13
|
+
"#{progname}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
Gem.configuration[:compile] = if Gem.configuration[:compile]
|
18
|
+
say 'Disabling automatic compilation'
|
19
|
+
false
|
20
|
+
else
|
21
|
+
say 'Enabling automatic compilation'
|
22
|
+
true
|
23
|
+
end
|
24
|
+
Gem.configuration.write
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems/dependency_list'
|
2
|
+
|
3
|
+
##
|
4
|
+
# Use the MacRuby compiler to compile installed gems.
|
5
|
+
|
6
|
+
class Gem::Commands::CompileCommand < Gem::Command
|
7
|
+
include Gem::VersionOption
|
8
|
+
include Gem::CompileMethods
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super 'compile', 'Compile (or recompile) installed gems',
|
12
|
+
ignore: true, all: false
|
13
|
+
|
14
|
+
add_version_option
|
15
|
+
add_option(
|
16
|
+
'-a', '--all', 'Compile all installed gem'
|
17
|
+
) do |all,opts| opts[:all] = all end
|
18
|
+
add_option(
|
19
|
+
'-I', '--[no-]ignore-dependencies', 'Also compile dependencies'
|
20
|
+
) do |value, options| options[:ignore] = value end
|
21
|
+
end
|
22
|
+
|
23
|
+
def arguments # :nodoc:
|
24
|
+
'GEMNAME name of the gem to compile'
|
25
|
+
end
|
26
|
+
|
27
|
+
def defaults_str # :nodoc:
|
28
|
+
super + '--ignore-dependencies'
|
29
|
+
end
|
30
|
+
|
31
|
+
def usage # :nodoc:
|
32
|
+
"#{program_name} GEMNAME [GEMNAME ...]"
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Determine which gems need to be compiled, then create and run a compiler
|
37
|
+
# object for each of them.
|
38
|
+
|
39
|
+
def execute
|
40
|
+
gems = execution_list
|
41
|
+
|
42
|
+
if gems.count >= 10
|
43
|
+
alert 'This could take a while; you might want to take a coffee break'
|
44
|
+
end
|
45
|
+
|
46
|
+
compiler = Gem::Compiler.new
|
47
|
+
gems.each { |gem| compiler.compile(gem) }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Gem::Commands::UncompileCommand < Gem::Command
|
2
|
+
include Gem::VersionOption
|
3
|
+
include Gem::CompileMethods
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super 'uncompile', 'Uncompile installed gems',
|
7
|
+
ignore: true, all: false
|
8
|
+
|
9
|
+
add_version_option
|
10
|
+
add_option(
|
11
|
+
'-a', '--all', 'Uncompile all installed gem'
|
12
|
+
) do |all,opts| opts[:all] = all end
|
13
|
+
add_option(
|
14
|
+
'-I', '--[no-]ignore-dependencies', 'Also uncompile dependencies'
|
15
|
+
) do |value, options| options[:ignore] = value end
|
16
|
+
end
|
17
|
+
|
18
|
+
def arguments # :nodoc:
|
19
|
+
'GEMNAME name of the gem to uncompile'
|
20
|
+
end
|
21
|
+
|
22
|
+
def defaults_str # :nodoc:
|
23
|
+
super + '--ignore-dependencies'
|
24
|
+
end
|
25
|
+
|
26
|
+
def usage # :nodoc:
|
27
|
+
"#{program_name} GEMNAME [GEMNAME ...]"
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Determine which gems need to be uncompiled, then create and run
|
32
|
+
# an uncompiler object for each of them.
|
33
|
+
|
34
|
+
def execute
|
35
|
+
uncompiler = Gem::Uncompiler.new
|
36
|
+
execution_list.each { |gem| uncompiler.uncompile(gem) }
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'rubygems-compile/commands/compile_command'
|
2
|
+
Gem::CommandManager.instance.register_command :compile
|
3
|
+
|
4
|
+
require 'rubygems-compile/commands/uncompile_command'
|
5
|
+
Gem::CommandManager.instance.register_command :uncompile
|
6
|
+
|
7
|
+
require 'rubygems-compile/commands/autocompile_command'
|
8
|
+
Gem::CommandManager.instance.register_command :auto_compile
|
@@ -1,22 +1,39 @@
|
|
1
1
|
module Gem
|
2
|
-
module Compile
|
3
|
-
module Methods
|
4
2
|
|
5
|
-
|
3
|
+
module CompileMethods
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
def execution_list
|
6
|
+
gems_list.map do |gem|
|
7
|
+
candidates = Gem.source_index.find_name(gem, options[:version])
|
8
|
+
|
9
|
+
if candidates.empty?
|
10
|
+
alert_error "#{gem} is not installed. Skipping."
|
11
|
+
next
|
12
|
+
end
|
13
|
+
|
14
|
+
candidates << dependencies_for(*candidates) unless options[:ignore]
|
15
|
+
candidates
|
16
|
+
end.flatten.uniq
|
17
|
+
end
|
18
|
+
|
19
|
+
def gems_list
|
20
|
+
installed_gems = Gem.source_index.all_gems
|
21
|
+
if options[:all] then
|
22
|
+
installed_gems.map { |_, spec| spec.name }
|
23
|
+
else
|
24
|
+
get_all_gem_names
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def dependencies_for *specs
|
29
|
+
specs.map { |spec|
|
30
|
+
spec.runtime_dependencies.map { |dep|
|
31
|
+
deps = Gem.source_index.find_name(dep.name,dep.requirement)
|
32
|
+
deps + dependencies_for(*deps)
|
33
|
+
}
|
34
|
+
}
|
35
|
+
end
|
12
36
|
|
13
|
-
def find_files_to_compile gem # :nodoc:
|
14
|
-
files = gem.files - gem.test_files - gem.extra_rdoc_files
|
15
|
-
files = files.reject do |file| file.match /^(?:test|spec)/ end
|
16
|
-
# this cuts out the .rb.data file in the mime-types gem
|
17
|
-
files.select do |file| file.match /\.rb$/ end
|
18
37
|
end
|
19
38
|
|
20
39
|
end
|
21
|
-
end
|
22
|
-
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Gem::Compiler
|
2
|
+
include Gem::UserInteraction
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@current_directory = []
|
6
|
+
@config = Gem.configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
def call gem
|
10
|
+
@spec = gem.is_a?(Gem::Specification) ? gem : gem.spec
|
11
|
+
|
12
|
+
if @spec.name == 'rubygems-compile'
|
13
|
+
alert 'You cannot compile rubygems-compile'
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
17
|
+
say compilation_message if @config.verbose
|
18
|
+
|
19
|
+
gem_files.each do |file|
|
20
|
+
say compile_file_msg(file) if @config.really_verbose
|
21
|
+
absolute_file_path = File.join(@spec.full_gem_path, file)
|
22
|
+
::Compiler.new(
|
23
|
+
bundle: true,
|
24
|
+
files: [absolute_file_path],
|
25
|
+
output: "#{absolute_file_path}o"
|
26
|
+
).run
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method :compile, :call
|
31
|
+
|
32
|
+
def compilation_message
|
33
|
+
slash = @config.really_verbose ? '/' : ''
|
34
|
+
"Compiling #{@spec.full_name}#{slash}"
|
35
|
+
end
|
36
|
+
|
37
|
+
# @todo get better at deciding which files to compile;
|
38
|
+
# right now we ignore the .rb.data file in the mime-types gem
|
39
|
+
# and probably some other silly edge cases that are similar
|
40
|
+
def gem_files
|
41
|
+
files = @spec.files - @spec.test_files - @spec.extra_rdoc_files
|
42
|
+
files.reject { |file| file.match /^(?:test|spec)/ }
|
43
|
+
.select { |file| file.match /\.rb$/ }
|
44
|
+
end
|
45
|
+
|
46
|
+
def compile_file_msg file
|
47
|
+
name = File.basename(file)
|
48
|
+
dirs = file.chomp(name).split(File::SEPARATOR)
|
49
|
+
tabs = "\t" * dirs.count
|
50
|
+
|
51
|
+
dirs.each_with_index do |dir, index|
|
52
|
+
unless @current_directory[index] == dir
|
53
|
+
@current_directory[index] = dir
|
54
|
+
say( "\t" * (index + 1) + dir + File::SEPARATOR)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
"#{tabs}#{name} => #{name}o"
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Gem::Uncompiler
|
2
|
+
include Gem::UserInteraction
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@config = Gem.configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
def uncompile gem
|
9
|
+
@spec = gem.is_a?(Gem::Specification) ? gem : gem.spec
|
10
|
+
|
11
|
+
say uncompilation_message if @config.verbose
|
12
|
+
|
13
|
+
gem_files.each do |file|
|
14
|
+
say "\tAsploded #{file}" if @config.really_verbose
|
15
|
+
absolute_file_path = File.join(@spec.full_gem_path, file)
|
16
|
+
FileUtils.rm absolute_file_path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def uncompilation_message
|
21
|
+
slash = @config.really_verbose ? '/' : ''
|
22
|
+
"Uncompiling #{@spec.full_name}#{slash}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def gem_files
|
26
|
+
Dir.glob(File.join(@spec.full_gem_path, '**','*.rbo')).map do |file|
|
27
|
+
file.sub /#{@spec.full_gem_path}\//, ''
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
if RUBY_VERSION.to_f < 0.11
|
2
|
+
|
3
|
+
ui = Gem::UserInteraction.new
|
4
|
+
ui.alert_warning 'rubygems-compile requires MacRuby 0.11 or newer'
|
5
|
+
ui.alert_warning 'rubygems-compile will not be loaded'
|
6
|
+
|
7
|
+
else
|
8
|
+
|
9
|
+
require 'rbconfig'
|
10
|
+
require 'fileutils'
|
11
|
+
require 'rubygems/version_option'
|
12
|
+
|
13
|
+
unless Kernel.const_defined?(:Compiler)
|
14
|
+
load File.join(RbConfig::CONFIG['bindir'], 'macrubyc')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'rubygems-compile/common_methods'
|
18
|
+
require 'rubygems-compile/compiler'
|
19
|
+
require 'rubygems-compile/uncompiler'
|
20
|
+
require 'rubygems-compile/commands'
|
21
|
+
require 'rubygems-compile/post_install_hook'
|
22
|
+
|
23
|
+
end
|
data/test/helper.rb
CHANGED
@@ -1,16 +1,7 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
|
4
1
|
require 'rubygems'
|
5
2
|
require 'rubygems/command_manager'
|
6
3
|
require 'rubygems_plugin'
|
7
4
|
|
8
|
-
gem 'minitest', '>= 2.0
|
9
|
-
require 'minitest/pride'
|
5
|
+
gem 'minitest-macruby-pride', '>= 2.2.0'
|
10
6
|
require 'minitest/autorun'
|
11
|
-
|
12
|
-
class MiniTest::Unit::TestCase
|
13
|
-
def setup
|
14
|
-
@command = Gem::Commands::CompileCommand.new
|
15
|
-
end
|
16
|
-
end
|
7
|
+
require 'minitest/pride'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class TestAutoCompile < MiniTest::Unit::TestCase
|
2
|
+
|
3
|
+
def setup
|
4
|
+
@command = Gem::Commands::AutoCompileCommand.new
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_turn_on
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_turn_on_when_already_on
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_turn_off
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_turn_off_when_already_off
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_calls_compile_on_each_gem_after_installation
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class TestCompileCommand < MiniTest::Unit::TestCase
|
2
|
+
def setup
|
3
|
+
@command = Gem::Commands::CompileCommand.new
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class Test < TestCompileCommand
|
8
|
+
def test_finds_all_files
|
9
|
+
# gets into all require dirs
|
10
|
+
# does not compile test files
|
11
|
+
end
|
12
|
+
def test_recompiles_rbos_if_they_already_exist
|
13
|
+
# to support use on nightly builds
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class TestCompileInterface < TestCompileCommand
|
18
|
+
def test_has_an_option_to_compile_all_installed_gems
|
19
|
+
# by extension, this is also needed to support nightly build users
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class TestCompileSpecialCases < TestCompileCommand
|
24
|
+
def test_refuses_to_compile_itself
|
25
|
+
# obvious
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_loads_rubyc_without_warning
|
29
|
+
# this might not be doable without upstream load guarding; minor issue
|
30
|
+
end
|
31
|
+
|
32
|
+
# important to test so we don't break rubygems
|
33
|
+
def test_skips_loading_on_older_macruby_versions
|
34
|
+
# and prints a message
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class TestUncompileCommand < MiniTest::Unit::TestCase
|
2
|
+
|
3
|
+
def setup
|
4
|
+
@command = Gem::Commands::UncompileCommand.new
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_removes_rbo_files
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_leaves_rb_files
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_can_uncompile_multiple_gems_at_once
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
metadata
CHANGED
@@ -1,81 +1,70 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygems-compile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.
|
4
|
+
prerelease: 5
|
5
|
+
version: 1.0.0beta2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mark Rada
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-05-14 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name: minitest
|
16
|
+
name: minitest-macruby-pride
|
17
17
|
prerelease: false
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - '>='
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.0
|
23
|
+
version: 2.2.0
|
24
24
|
type: :development
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
none: false
|
27
27
|
requirements:
|
28
28
|
- - '>='
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 2.0
|
31
|
-
description: 'A
|
30
|
+
version: 2.2.0
|
31
|
+
description: 'A set of rubygems commands that interface with the MacRuby compiler
|
32
32
|
|
33
33
|
'
|
34
34
|
email: mrada@marketcircle.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|
37
37
|
extra_rdoc_files:
|
38
|
-
- Rakefile
|
39
38
|
- LICENSE.txt
|
40
39
|
- README.rdoc
|
41
40
|
files:
|
41
|
+
- lib/rubygems-compile/analysis.rb
|
42
|
+
- lib/rubygems-compile/commands/autocompile_command.rb
|
43
|
+
- lib/rubygems-compile/commands/compile_command.rb
|
44
|
+
- lib/rubygems-compile/commands/uncompile_command.rb
|
45
|
+
- lib/rubygems-compile/commands.rb
|
42
46
|
- lib/rubygems-compile/common_methods.rb
|
43
|
-
- lib/rubygems-compile/
|
44
|
-
- lib/rubygems-compile/
|
45
|
-
- lib/rubygems-compile/
|
47
|
+
- lib/rubygems-compile/compiler.rb
|
48
|
+
- lib/rubygems-compile/post_install_hook.rb
|
49
|
+
- lib/rubygems-compile/uncompiler.rb
|
46
50
|
- lib/rubygems_plugin.rb
|
51
|
+
- test/helper.rb
|
52
|
+
- test/test_autocompile_command.rb
|
53
|
+
- test/test_compile_command.rb
|
54
|
+
- test/test_uncompile_command.rb
|
47
55
|
- Rakefile
|
56
|
+
- .gemtest
|
48
57
|
- LICENSE.txt
|
49
58
|
- README.rdoc
|
50
|
-
- test/test_find_files_to_compile.rb
|
51
|
-
- test/test_get_specs_for_gems.rb
|
52
|
-
- test/helper.rb
|
53
59
|
has_rdoc: true
|
54
60
|
homepage: http://github.com/ferrous26/rubygems-compile
|
55
61
|
licenses:
|
56
62
|
- MIT
|
57
|
-
post_install_message:
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
Please uninstall previous versions of this gem, or else
|
63
|
-
|
64
|
-
rubygems will try to load each version of the gem.
|
65
|
-
|
66
|
-
|
67
|
-
The functionality of this gem has changed since the 0.0.x
|
68
|
-
|
69
|
-
series. It now operates as its own command, see the README.
|
70
|
-
|
71
|
-
|
72
|
-
https://github.com/ferrous26/rubygems-compile
|
73
|
-
|
74
|
-
|
75
|
-
***********************************************************
|
76
|
-
|
77
|
-
|
78
|
-
'
|
63
|
+
post_install_message: "\n***********************************************************\n\nPlease
|
64
|
+
uninstall previous versions of this gem, or else\nrubygems will try to load each
|
65
|
+
version of the gem.\n\nThis version of rubygems-compile requires MacRuby 0.11 or\nnewer;
|
66
|
+
the functionality has changed significantly since\npre-1.0 releases, see the README:\n\n
|
67
|
+
\ https://github.com/ferrous26/rubygems-compile\n\n***********************************************************\n\n"
|
79
68
|
rdoc_options: []
|
80
69
|
require_paths:
|
81
70
|
- lib
|
@@ -88,16 +77,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
78
|
none: false
|
90
79
|
requirements:
|
91
|
-
- - '
|
80
|
+
- - '>'
|
92
81
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.
|
82
|
+
version: 1.3.1
|
94
83
|
requirements: []
|
95
84
|
rubyforge_project:
|
96
85
|
rubygems_version: 1.4.2
|
97
86
|
signing_key:
|
98
87
|
specification_version: 3
|
99
|
-
summary: A rubygems
|
88
|
+
summary: A set of rubygems commands that interface with the MacRuby compiler
|
100
89
|
test_files:
|
101
|
-
- test/test_find_files_to_compile.rb
|
102
|
-
- test/test_get_specs_for_gems.rb
|
103
90
|
- test/helper.rb
|
91
|
+
- test/test_autocompile_command.rb
|
92
|
+
- test/test_compile_command.rb
|
93
|
+
- test/test_uncompile_command.rb
|
94
|
+
- Rakefile
|
95
|
+
- .gemtest
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'rbconfig'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'rubygems/command'
|
4
|
-
require 'rubygems/commands/install_command'
|
5
|
-
require 'rubygems-compile/common_methods'
|
6
|
-
|
7
|
-
##
|
8
|
-
# Use the MacRuby compiler to compile gems at install time. This
|
9
|
-
# includes the option to remove the original *.rb files leaving
|
10
|
-
# only the compiled *.rbo files.
|
11
|
-
|
12
|
-
class Gem::Commands::CompileCommand < Gem::Commands::InstallCommand
|
13
|
-
include Gem::Compile::Methods
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
super # so that InstallCommand options are registered
|
17
|
-
@command = 'compile' # now we override certain attributes
|
18
|
-
@summary = 'Install and compile gems using the MacRuby compiler'
|
19
|
-
@program_name = 'gem compile'
|
20
|
-
|
21
|
-
defaults[:'remove-original-files'] = false
|
22
|
-
add_option( '-r', '--[no-]remove-original-files',
|
23
|
-
'Delete the original *.rb source files after compiling',
|
24
|
-
) do |value, options|
|
25
|
-
options[:'remove-original-files'] = value
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def defaults_str # :nodoc:
|
30
|
-
super + "\n--no-remove-original-files"
|
31
|
-
end
|
32
|
-
|
33
|
-
##
|
34
|
-
# Lookup the gems and their listed files. It will only compile files
|
35
|
-
# that are located in the `require_path` for a gem.
|
36
|
-
|
37
|
-
def execute
|
38
|
-
|
39
|
-
verbose = Gem.configuration.verbose
|
40
|
-
slash = verbose.is_a?(Fixnum) ? '/' : ''
|
41
|
-
post_compile = Proc.new do |_,_| end
|
42
|
-
|
43
|
-
if options[:'remove-original-files']
|
44
|
-
post_compile = Proc.new do |file, full_path|
|
45
|
-
say "\tRemoving #{file}" if verbose.is_a? Fixnum
|
46
|
-
FileUtils.rm full_path
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
Gem.post_install do |gem|
|
51
|
-
spec = gem.spec
|
52
|
-
say "Compiling #{spec.name}-#{spec.version}#{slash}" if verbose
|
53
|
-
|
54
|
-
path = spec.full_gem_path
|
55
|
-
files = find_files_to_compile spec
|
56
|
-
|
57
|
-
files.each { |file|
|
58
|
-
say "\t#{file} => #{file}o" if verbose.is_a? Fixnum
|
59
|
-
full_path = path + '/' + file
|
60
|
-
`#{MACRUBYC} -C '#{full_path}' -o '#{full_path}o'`
|
61
|
-
post_compile.call file, full_path
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
|
-
super
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
Gem::CommandManager.instance.register_command :compile
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'rubygems/command'
|
3
|
-
require 'rubygems/commands/install_command'
|
4
|
-
require 'rubygems-compile/common_methods'
|
5
|
-
|
6
|
-
##
|
7
|
-
# @todo need to look at dependencies too? use --include-dependencies option?
|
8
|
-
#
|
9
|
-
# Remove the compiled files for a gem. This is sometimes necessary for
|
10
|
-
# gems that do not work after being compiled.
|
11
|
-
|
12
|
-
class Gem::Commands::DecompileCommand < Gem::Commands::InstallCommand
|
13
|
-
include Gem::Compile::Methods
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
super
|
17
|
-
@command = 'decompile'
|
18
|
-
@summary = 'Remove compiled *.rbo files for gems, possibily reinstalling'
|
19
|
-
@program_name = 'gem decompilecompile'
|
20
|
-
end
|
21
|
-
|
22
|
-
##
|
23
|
-
# Try to only remove *.rbo files, but in the case that the original *.rb files
|
24
|
-
# are gone, we will also have to reinstall the gem.
|
25
|
-
|
26
|
-
def execute
|
27
|
-
|
28
|
-
verbose = Gem.configuration.verbose
|
29
|
-
slash = verbose.is_a?(Fixnum) ? '/' : ''
|
30
|
-
|
31
|
-
get_specs_for_gems(get_all_gem_names).each { |gem|
|
32
|
-
say "Decompiling #{gem.name}-#{gem.version}#{slash}" if verbose
|
33
|
-
|
34
|
-
path = gem.full_gem_path
|
35
|
-
files = find_files_to_compile gem
|
36
|
-
reinstall = false
|
37
|
-
|
38
|
-
files.each { |file|
|
39
|
-
say "\tRemoving #{file}o" if verbose.is_a? Fixnum
|
40
|
-
full_path = "#{path}/#{file}"
|
41
|
-
FileUtils.rm( full_path + 'o' )
|
42
|
-
reinstall = true unless File.exists? full_path
|
43
|
-
}
|
44
|
-
|
45
|
-
super if reinstall
|
46
|
-
}
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
Gem::CommandManager.instance.register_command :decompile
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestFindFilesToCompile < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
super
|
7
|
-
@test_gem = MiniTest::Mock.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_strips_test_files
|
11
|
-
@test_gem.expect :files, [
|
12
|
-
'test/file1', 'test/file2', 'spec/file1', 'spec/file2', 'setup.rb'
|
13
|
-
]
|
14
|
-
@test_gem.expect :test_files, [ 'test/file1', 'spec/file1' ]
|
15
|
-
@test_gem.expect :extra_rdoc_files, []
|
16
|
-
|
17
|
-
assert_equal [ 'setup.rb' ], @command.find_files_to_compile(@test_gem)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_strips_non_ruby_source_files
|
21
|
-
@test_gem.expect :files, [
|
22
|
-
'README.rdoc', 'LICENSE.txt', 'Gemfile', 'setup.rb'
|
23
|
-
]
|
24
|
-
@test_gem.expect :test_files, []
|
25
|
-
@test_gem.expect :extra_rdoc_files, [
|
26
|
-
'README.rdoc', 'LICENSE.txt', 'Gemfile'
|
27
|
-
]
|
28
|
-
assert_equal [ 'setup.rb' ], @command.find_files_to_compile(@test_gem)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_returns_array_of_files
|
32
|
-
source_files = [
|
33
|
-
'lib/gem.rb', 'lib/gem/helper.rb', 'ext/help/extconf.rb', 'setup.rb'
|
34
|
-
]
|
35
|
-
@test_gem.expect :files, source_files
|
36
|
-
@test_gem.expect :test_files, []
|
37
|
-
@test_gem.expect :extra_rdoc_files, []
|
38
|
-
|
39
|
-
ret = @command.find_files_to_compile @test_gem
|
40
|
-
assert_instance_of Array, ret
|
41
|
-
assert_equal source_files, ret
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestGetSpecsForGems < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
def test_doesnt_explode_with_bad_gem_names
|
6
|
-
assert_empty @command.get_specs_for_gems ['not_a_real_gem']
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_takes_an_array
|
10
|
-
assert @command.get_specs_for_gems ['minitest', 'not_a_real_gem']
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_returns_gemspecs
|
14
|
-
ret = @command.get_specs_for_gems ['minitest']
|
15
|
-
assert_instance_of Array, ret
|
16
|
-
assert_instance_of Gem::Specification, ret.first
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|