-
-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,34 @@ | |
|
||
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) | ||
|
||
if arg_config('--clean') | ||
require 'pathname' | ||
require 'fileutils' | ||
|
||
root = Pathname(ROOT) | ||
pwd = Pathname(Dir.pwd) | ||
|
||
# Skip if this is a development work tree | ||
unless (root + '.git').exist? | ||
message "Cleaning files only used during build.\n" | ||
|
||
if pwd.relative_path_from(root).fnmatch?('tmp/*') | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
knu
Author
Member
|
||
# (root + 'tmp') cannot be removed at this stage because | ||
# nokogiri.so is yet to be copied to lib. | ||
FileUtils.rm_rf(pwd + 'tmp') | ||
end | ||
|
||
if enable_config('static') | ||
# ports installation can be safely removed if statically linked. | ||
FileUtils.rm_rf(root + 'ports') | ||
else | ||
FileUtils.rm_rf(root + 'ports' + 'archives') | ||
end | ||
end | ||
|
||
exit | ||
end | ||
|
||
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby' | ||
$LIBRUBYARG_STATIC.gsub!(/-static/, '') | ||
end | ||
|
@@ -282,4 +310,16 @@ def process_recipe(name, version) | |
|
||
create_makefile('nokogiri/nokogiri') | ||
|
||
if enable_config('clean', true) | ||
# Do not clean if run in a development work tree. | ||
File.open('Makefile', 'at') { |mk| | ||
mk.print <<EOF | ||
all: clean-ports | ||
clean-ports: $(DLLIB) | ||
-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? 'enable' : 'disable'}-static | ||
EOF | ||
} | ||
end | ||
|
||
# :startdoc: |
Why remove the tmp directory only, when it's inside another tmp directory? While
gem install
the build takes place within ext/nokogiri, so this deletion step is not executed, then. On the other hand, whilerake compile
the whole clean step is skipped.If I comment this condition out, the deletion works as expected - while
gem install
but not within the development work tree. Tested with static linking on Ubuntu 13.10 with rvm and ruby 2.0.0-p247 and 1.9.3-p448.