271d1e4589
Start moving away from files.bkl as the primary source for the files -- and away from bakefile itself as the make/project file generator -- by storing the list of files in a new build/files file and provide a simple build/upmake script for updating files.bkl and the manually maintained MSVC10+ projects from this file contents. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
79 lines
1.4 KiB
Perl
79 lines
1.4 KiB
Perl
package Text::Upmake;
|
|
|
|
use strict;
|
|
use warnings;
|
|
use autodie;
|
|
|
|
use Exporter qw(import);
|
|
|
|
our @EXPORT = qw(read_files_list upmake);
|
|
|
|
=head1 NAME
|
|
|
|
Text::Upmake - Update make files.
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
=head1 AUTHOR
|
|
|
|
Vadim Zeitlin
|
|
|
|
=cut
|
|
|
|
# Reads the file containing the file lists definitions and returns a hash ref
|
|
# with variable names as keys and refs to arrays of the file names as values.
|
|
#
|
|
# Takes an (open) file handle as argument.
|
|
sub read_files_list
|
|
{
|
|
my ($fh) = @_;
|
|
|
|
my ($var, %vars);
|
|
while (<$fh>) {
|
|
chomp;
|
|
s/#.*$//;
|
|
s/^\s+//;
|
|
s/\s+$//;
|
|
next if !$_;
|
|
|
|
if (/^(\w+)\s*=$/) {
|
|
$var = $1;
|
|
} else {
|
|
die "Unexpected contents outside variable definition at line $.\n"
|
|
unless defined $var;
|
|
push @{$vars{$var}}, $_;
|
|
}
|
|
}
|
|
|
|
return \%vars;
|
|
}
|
|
|
|
# Update the file with the given name in place using the specified function and
|
|
# passing it the rest of the arguments.
|
|
#
|
|
# This is meant to be used with update_xxx() below.
|
|
sub upmake
|
|
{
|
|
my ($fname, $updater, @args) = @_;
|
|
|
|
my $fname_new = "$fname.upmake.new"; # TODO make it more unique
|
|
|
|
open my $in, '<', $fname;
|
|
open my $out, '>', $fname_new;
|
|
|
|
my $changed = $updater->($in, $out, @args);
|
|
|
|
close $in;
|
|
close $out;
|
|
|
|
if ($changed) {
|
|
rename $fname_new, $fname;
|
|
} else {
|
|
unlink $fname_new;
|
|
}
|
|
|
|
$changed
|
|
}
|
|
|
|
1;
|