From c185edf71cdd9aa4b72ffd9059534d8ac0cb1249 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 24 Mar 2017 21:44:33 +0000 Subject: Extract core logic of write_configure_cache to write_config_file. --- make/common.pm | 14 ++++++++++++++ make/configure.pm | 7 +------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/make/common.pm b/make/common.pm index d5a2f06c7..f0174e0b3 100644 --- a/make/common.pm +++ b/make/common.pm @@ -31,10 +31,13 @@ use Exporter qw(import); use File::Path qw(mkpath); use File::Spec::Functions qw(rel2abs); +use make::console; + our @EXPORT = qw(create_directory get_cpu_count get_version read_config_file + write_config_file module_installed); sub create_directory($$) { @@ -121,4 +124,15 @@ sub read_config_file($) { return %config; } +sub write_config_file($%) { + my $path = shift; + my %config = @_; + open(my $fh, '>', $path) or print_error "unable to write to $path: $!"; + while (my ($key, $value) = each %config) { + $value //= ''; + say $fh "$key $value"; + } + close $fh; +} + 1; diff --git a/make/configure.pm b/make/configure.pm index ed03f5b24..a10493318 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -222,12 +222,7 @@ sub write_configure_cache(%) { print_format "Writing <|GREEN ${\CONFIGURE_CACHE_FILE}|> ...\n"; my %config = @_; - open(CACHE, '>', CONFIGURE_CACHE_FILE) or print_error "unable to write ${\CONFIGURE_CACHE_FILE}: $!"; - while (my ($key, $value) = each %config) { - $value //= ''; - say CACHE "$key $value"; - } - close(CACHE); + write_config_file CONFIGURE_CACHE_FILE, %config; } sub get_compiler_info($) { -- cgit v1.2.3