Permalink
Browse files

Replace upmake and dependent modules with a monolithic script

Remove the Perl modules composing upmake from wxWidgets repository, it's too
difficult to maintain them both here and at https://github.com/vadz/upmake and
just keep the wxWidgets-specific upmake_script.pl here and generate
build/upmake_script itself from it using fatpack.

This also updates upmake to the latest 0.3 version, as a side effect.
  • Loading branch information...
1 parent e5754d0 commit 4b12516d42b6ec003d22cc78746992ebc0abc367 @vadz vadz committed Oct 3, 2015
View
@@ -33,3 +33,6 @@ config.guess eol=lf
config.sub eol=lf
configure eol=lf
configure.in eol=lf
+
+# Ignore changes in the generated files.
+build/upmake -diff
@@ -1,78 +0,0 @@
-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;
@@ -1,97 +0,0 @@
-package Text::Upmake::Bakefile0;
-
-use Exporter qw(import);
-our @EXPORT = qw(update_bakefile_0);
-
-=head1 NAME
-
-Text::Upmake::Bakefile0 - Update bakefile-0.x files list.
-
-=head1 SYNOPSIS
-
-This is used exclusively to update wxWidgets C<files.bkl> and is probably not
-useful outside of wxWidgets project.
-
- use Text::Upmake::Bakefile0;
- Text::Upmake::upmake('bakefiles/files.bkl', \&update_bakefile_0, $vars);
-
-=head1 SEE ALSO
-
-Text::Upmake
-
-=head1 AUTHOR
-
-Vadim Zeitlin
-
-=cut
-
-# Update file with variable definitions in bakefile-0 format with the data
-# from the hash ref containing all the file lists.
-#
-# Takes the (open) file handles of the files to read and to write and the file
-# lists hash ref as arguments.
-#
-# Returns 1 if any changes were made.
-#
-# The caller must take care of actually renaming the second file to the first
-# one.
-sub update_bakefile_0
-{
- my ($in, $out, $vars) = @_;
-
- # Variable whose contents is being currently replaced.
- my $var;
-
- # Hash with files defined for the specified variable as keys and 0 or 1
- # depending on whether we have seen them in the input file as values.
- my %files;
-
- # Set to 1 if we made any changes.
- my $changed = 0;
- while (<$in>) {
- chomp;
-
- if (/<set var="(\w+)" hints="files">/ && exists $vars->{$1}) {
- $var = $1;
- %files = map { $_ => 0 } @{$vars->{$var}};
- } elsif (defined $var) {
- local $_ = $_;
- s/<!-- .* -->//;
- s/^\s+//;
- s/\s+$//;
- if (m{</set>}) {
- # Check if we have any new files.
- #
- # TODO Insert them in alphabetical order.
- while (my ($file, $seen) = each(%files)) {
- if (!$seen) {
- # This file was wasn't present in the input, add it.
- # TODO Use proper indentation.
- print $out " $file\n";
-
- $changed = 1;
- }
- }
-
- undef $var;
- } elsif ($_) {
- if (not exists $files{$_}) {
- # This file was removed.
- $changed = 1;
- next;
- }
-
- if ($files{$_}) {
- warn qq{Duplicate file "$_" in the definition of the } .
- qq{variable "$var" at line $.\n}
- } else {
- $files{$_} = 1;
- }
- }
- }
-
- print $out "$_\n";
- }
-
- $changed
-}
Oops, something went wrong.

0 comments on commit 4b12516

Please sign in to comment.