Sort source/header entries in Makefile.am
Add maintenance script.
MODIFY
Makefile.am
Makefile.am
@@ -28,6 +28,7 @@ liblcf_la_LDFLAGS = \
-no-undefined
liblcf_la_SOURCES = \
src/data.cpp \
+ src/encoder.cpp \
src/ini.cpp \
src/inireader.cpp \
src/ldb_equipment.cpp \
@@ -40,7 +41,6 @@ liblcf_la_SOURCES = \
src/lmu_movecommand.cpp \
src/lmu_reader.cpp \
src/lsd_reader.cpp \
- src/encoder.cpp \
src/reader_flags.cpp \
src/reader_lcf.cpp \
src/reader_util.cpp \
@@ -50,8 +50,8 @@ liblcf_la_SOURCES = \
src/writer_lcf.cpp \
src/writer_xml.cpp \
src/generated/ldb_actor.cpp \
- src/generated/ldb_animationcelldata.cpp \
src/generated/ldb_animation.cpp \
+ src/generated/ldb_animationcelldata.cpp \
src/generated/ldb_animationframe.cpp \
src/generated/ldb_animationtiming.cpp \
src/generated/ldb_attribute.cpp \
@@ -64,10 +64,10 @@ liblcf_la_SOURCES = \
src/generated/ldb_class.cpp \
src/generated/ldb_commonevent.cpp \
src/generated/ldb_database.cpp \
- src/generated/ldb_enemyaction.cpp \
src/generated/ldb_enemy.cpp \
- src/generated/ldb_itemanimation.cpp \
+ src/generated/ldb_enemyaction.cpp \
src/generated/ldb_item.cpp \
+ src/generated/ldb_itemanimation.cpp \
src/generated/ldb_learning.cpp \
src/generated/ldb_music.cpp \
src/generated/ldb_skill.cpp \
@@ -80,25 +80,25 @@ liblcf_la_SOURCES = \
src/generated/ldb_testbattler.cpp \
src/generated/ldb_troop.cpp \
src/generated/ldb_troopmember.cpp \
- src/generated/ldb_trooppagecondition.cpp \
src/generated/ldb_trooppage.cpp \
+ src/generated/ldb_trooppagecondition.cpp \
src/generated/ldb_variable.cpp \
src/generated/lmt_encounter.cpp \
src/generated/lmt_mapinfo.cpp \
src/generated/lmt_start.cpp \
src/generated/lmu_event.cpp \
- src/generated/lmu_eventpagecondition.cpp \
src/generated/lmu_eventpage.cpp \
+ src/generated/lmu_eventpagecondition.cpp \
src/generated/lmu_map.cpp \
src/generated/lmu_moveroute.cpp \
+ src/generated/lsd_save.cpp \
src/generated/lsd_saveactor.cpp \
src/generated/lsd_savecommonevent.cpp \
- src/generated/lsd_save.cpp \
src/generated/lsd_saveeventcommands.cpp \
src/generated/lsd_saveeventdata.cpp \
src/generated/lsd_saveinventory.cpp \
- src/generated/lsd_savemapeventbase.cpp \
src/generated/lsd_savemapevent.cpp \
+ src/generated/lsd_savemapeventbase.cpp \
src/generated/lsd_savemapinfo.cpp \
src/generated/lsd_savepanorama.cpp \
src/generated/lsd_savepartylocation.cpp \
@@ -116,54 +116,57 @@ liblcf_la_SOURCES = \
pkginclude_HEADERS = \
src/command_codes.h \
src/data.h \
+ src/encoder.h \
+ src/enum_tags.h \
src/ini.h \
src/inireader.h \
- src/scope_guard.h \
src/lcf_options.h \
src/lcf_saveopt.h \
src/ldb_reader.h \
src/lmt_reader.h \
src/lmu_reader.h \
src/lsd_reader.h \
- src/encoder.h \
src/reader_lcf.h \
src/reader_struct.h \
src/reader_struct_impl.h \
src/reader_util.h \
src/reader_xml.h \
+ src/scope_guard.h \
src/writer_lcf.h \
src/writer_xml.h \
- src/enum_tags.h \
src/generated/ldb_chunks.h \
+ src/generated/ldb_terrain_flags.h \
+ src/generated/ldb_trooppagecondition_flags.h \
src/generated/lmt_chunks.h \
src/generated/lmu_chunks.h \
+ src/generated/lmu_eventpagecondition_flags.h \
src/generated/lsd_chunks.h \
+ src/generated/lsd_savepicture_flags.h \
src/generated/rpg_actor.h \
+ src/generated/rpg_animation.h \
src/generated/rpg_animationcelldata.h \
src/generated/rpg_animationframe.h \
- src/generated/rpg_animation.h \
src/generated/rpg_animationtiming.h \
src/generated/rpg_attribute.h \
src/generated/rpg_battlecommand.h \
src/generated/rpg_battlecommands.h \
+ src/generated/rpg_battleranimation.h \
src/generated/rpg_battleranimationdata.h \
src/generated/rpg_battleranimationextension.h \
- src/generated/rpg_battleranimation.h \
src/generated/rpg_chipset.h \
src/generated/rpg_class.h \
src/generated/rpg_commonevent.h \
src/generated/rpg_database.h \
src/generated/rpg_encounter.h \
- src/generated/rpg_enemyaction.h \
src/generated/rpg_enemy.h \
+ src/generated/rpg_enemyaction.h \
src/generated/rpg_equipment.h \
- src/generated/rpg_eventcommand.h \
src/generated/rpg_event.h \
- src/generated/rpg_eventpagecondition.h \
- src/generated/lmu_eventpagecondition_flags.h \
+ src/generated/rpg_eventcommand.h \
src/generated/rpg_eventpage.h \
- src/generated/rpg_itemanimation.h \
+ src/generated/rpg_eventpagecondition.h \
src/generated/rpg_item.h \
+ src/generated/rpg_itemanimation.h \
src/generated/rpg_learning.h \
src/generated/rpg_map.h \
src/generated/rpg_mapinfo.h \
@@ -172,19 +175,18 @@ pkginclude_HEADERS = \
src/generated/rpg_music.h \
src/generated/rpg_parameters.h \
src/generated/rpg_rect.h \
+ src/generated/rpg_save.h \
src/generated/rpg_saveactor.h \
src/generated/rpg_savecommonevent.h \
src/generated/rpg_saveeventcommands.h \
src/generated/rpg_saveeventdata.h \
- src/generated/rpg_save.h \
src/generated/rpg_saveinventory.h \
- src/generated/rpg_savemapeventbase.h \
src/generated/rpg_savemapevent.h \
+ src/generated/rpg_savemapeventbase.h \
src/generated/rpg_savemapinfo.h \
src/generated/rpg_savepanorama.h \
src/generated/rpg_savepartylocation.h \
src/generated/rpg_savepicture.h \
- src/generated/lsd_savepicture_flags.h \
src/generated/rpg_savescreen.h \
src/generated/rpg_savesystem.h \
src/generated/rpg_savetarget.h \
@@ -198,14 +200,12 @@ pkginclude_HEADERS = \
src/generated/rpg_system.h \
src/generated/rpg_terms.h \
src/generated/rpg_terrain.h \
- src/generated/ldb_terrain_flags.h \
src/generated/rpg_testbattler.h \
src/generated/rpg_treemap.h \
src/generated/rpg_troop.h \
src/generated/rpg_troopmember.h \
- src/generated/rpg_trooppagecondition.h \
- src/generated/ldb_trooppagecondition_flags.h \
src/generated/rpg_trooppage.h \
+ src/generated/rpg_trooppagecondition.h \
src/generated/rpg_variable.h
check_PROGRAMS = test_runner

ADD
builds/sources2buildsystem.pl
+#!/bin/perl
+
+# sources2buildsystem.pl - maintainer utility script to keep the
+# source/header file list for our build systems organized and up-to-date.
+# by carstene1ns 2018, released under the MIT license
+
+use strict;
+use warnings;
+use File::Find;
+
+print "Searching for source/header files and adding them to the buildsystems...\n";
+
+# process source directory
+my @files;
+find(\&wanted, "src");
+@files = sort @files;
+
+# put generated files after others
+my @generated = grep(/\/generated\//, @files);
+my @others = grep(!/\/generated\//, @files);
+@files = (@others, @generated);
+
+# cmake
+my $files_formatted = format_files(0, @files);
+my $buildsystem_file = "CMakeLists.txt";
+my $data = slurp($buildsystem_file);
+$data =~ s/^(add_library\(lcf\n).*?(\n\))$/$1$files_formatted$2/sm;
+burp($buildsystem_file, $data);
+
+# autotools (needs split)
+my @headers = grep(/\.h$/, @files);
+my @sources = grep(/\.cpp$/, @files);
+my $sources_formatted = format_files(1, @sources);
+my $headers_formatted = format_files(1, @headers);
+$buildsystem_file = "Makefile.am";
+$data = slurp($buildsystem_file);
+$data =~ s/^(liblcf_la_SOURCES = \\\n).*?\.cpp$/$1$sources_formatted/sm;
+$data =~ s/^(pkginclude_HEADERS = \\\n).*?\.h$/$1$headers_formatted/sm;
+burp($buildsystem_file, $data);
+
+print "done.\n";
+
+# - - - - - -
+
+sub wanted {
+ return unless -f;
+ return unless /\.(cpp|h)$/;
+
+ push @files, $File::Find::name;
+}
+
+sub format_files {
+ my $needs_slash = shift;
+ my $formatted;
+ foreach my $f (@_) {
+ my $is_last = (\$f == \$_[-1]);
+ $formatted .= "\t$f";
+ $formatted .= " \\" if (! $is_last && $needs_slash);
+ $formatted .= "\n" if (! $is_last)
+ }
+ return $formatted;
+}
+
+sub slurp {
+ my $file = shift;
+ open my $fh, '<:encoding(UTF-8)', $file or die "Could not open file $file for reading!";
+ local $/ = undef;
+ my $cont = <$fh>;
+ close $fh;
+ return $cont;
+}
+
+sub burp {
+ my $file = shift;
+ my $data = shift;
+ open my $fh, '>:encoding(UTF-8)', $file or die "Could not open file $file for writing!";
+ print $fh $data;
+ close $fh;
+}

Sort source/header entries in Makefile.am
Add maintenance script.