Skip to content

Commit

Permalink
refactor: extract extconf config into methods
Browse files Browse the repository at this point in the history
One small step towards a Config object that we can extract.
  • Loading branch information
flavorjones committed Mar 9, 2021
1 parent 332f74f commit fa08f31
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ext/nokogiri/extconf.rb
Expand Up @@ -149,6 +149,18 @@
#
# utility functions
#
def config_clean?
enable_config('clean', true)
end

def config_static?
enable_config("static", true)
end

def config_cross_build?
enable_config("cross-build")
end

def config_system_libraries?
enable_config("system-libraries", ENV.key?("NOKOGIRI_USE_SYSTEM_LIBRARIES")) do |_, default|
arg_config('--use-system-libraries', default)
Expand Down Expand Up @@ -524,7 +536,7 @@ def do_clean
FileUtils.rm_rf(dir, verbose: true)
end

if enable_config('static')
if config_static?
# ports installation can be safely removed if statically linked.
FileUtils.rm_rf(root + 'ports', verbose: true)
else
Expand Down Expand Up @@ -618,10 +630,10 @@ def do_clean
else
message "Building nokogiri using packaged libraries.\n"

static_p = enable_config("static", true)
static_p = config_static?
message "Static linking is #{static_p ? 'enabled' : 'disabled'}.\n"

cross_build_p = enable_config("cross-build")
cross_build_p = config_cross_build?
message "Cross build is #{cross_build_p ? 'enabled' : 'disabled'}.\n"

require 'yaml'
Expand Down Expand Up @@ -876,7 +888,7 @@ def compile

create_makefile('nokogiri/nokogiri')

if enable_config('clean', true)
if config_clean?
# Do not clean if run in a development work tree.
File.open('Makefile', 'at') do |mk|
mk.print(<<~EOF)
Expand Down

0 comments on commit fa08f31

Please sign in to comment.