Commits

Shlomi Fish committed e4c3593

Add the build-deps script.

Comments (0)

Files changed (4)

 lib/htmls/The-Enemy-English-rev5.html-part
 lib/htmls/The-Enemy-English-rev6.html-part
 lib/htmls/The-Enemy-rev5.html-part
+lib/make/build-deps/build-deps.stamp
 lib/make/docbook/sf-fictions.mak
 lib/make/docbook/sf-homepage-docbooks-generated.mak
 lib/make/docbook/sf-screenplays.mak

bin/gen-build-deps

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Getopt::Long (qw( GetOptions ));
+
+use IO::All;
+use File::Which ( qw( which ) );
+use YAML::XS ( qw( LoadFile ) );
+
+my $out_fn;
+my $exes_fn;
+my $modules_fn;
+
+GetOptions(
+    'o|output=s' => \$out_fn,
+    'exes-conf=s' => \$exes_fn,
+    'modules-conf=s' => \$modules_fn,
+)
+    or die "Failed - $!";
+
+{
+    my @not_found;
+
+    foreach my $cmd (
+        io->file($exes_fn)->chomp->getlines()
+    )
+    {
+        if (not
+            (
+                ($cmd =~ m{\A/})
+                ? (-e $cmd)
+                : (defined(scalar(which($cmd))))
+            )
+        )
+        {
+            push @not_found, $cmd;
+        }
+    }
+
+    if (@not_found)
+    {
+        print "The following commands could not be found:\n\n";
+        foreach my $cmd (sort { $a cmp $b } @not_found)
+        {
+            print "$cmd\n";
+        }
+        exit(-1);
+    }
+}
+
+{
+    my ($yaml_data) = LoadFile($modules_fn);
+
+    my $required_modules = $yaml_data->{required}->{modules};
+
+    my @not_found;
+
+    foreach my $m (sort { $a cmp $b } keys(%$required_modules))
+    {
+        my $v = $required_modules->{$m};
+        local $SIG{__WARN__} = sub {};
+        my $verdict = eval( "use $m " . ($v ||'') . ';' );
+        my $Err = $@;
+
+        if ($Err)
+        {
+            push @not_found, $m;
+        }
+    }
+
+    if (@not_found)
+    {
+        print "The following modules could not be found:\n\n";
+        foreach my $module (@not_found)
+        {
+            print "$module\n";
+        }
+        exit(-1);
+    }
+}
+
+io->file($out_fn)->print("Success!");
+
+exit(0);
 
 use List::MoreUtils;
 
+if (system("make", "--silent", "-f", "lib/make/build-deps/build-deps.mak"))
 {
-    my @not_found;
-
-    foreach my $cmd (
-        io->file("./bin/needed-executables.txt")->chomp->getlines()
-    )
-    {
-        if (not
-            (
-                ($cmd =~ m{\A/})
-                ? (-e $cmd)
-                : (defined(scalar(which($cmd))))
-            )
-        )
-        {
-            push @not_found, $cmd;
-        }
-    }
-
-    if (@not_found)
-    {
-        print "The following commands could not be found:\n\n";
-        foreach my $cmd (sort { $a cmp $b } @not_found)
-        {
-            print "$cmd\n";
-        }
-        exit(-1);
-    }
-}
-
-{
-    my ($yaml_data) = LoadFile("./bin/required-modules.yml");
-
-    my $required_modules = $yaml_data->{required}->{modules};
-
-    my @not_found;
-
-    foreach my $m (sort { $a cmp $b } keys(%$required_modules))
-    {
-        my $v = $required_modules->{$m};
-        local $SIG{__WARN__} = sub {};
-        my $verdict = eval( "use $m " . ($v ||'') . ';' );
-        my $Err = $@;
-
-        if ($Err)
-        {
-            push @not_found, $m;
-        }
-    }
-
-    if (@not_found)
-    {
-        print "The following modules could not be found:\n\n";
-        foreach my $module (@not_found)
-        {
-            print "$module\n";
-        }
-        exit(-1);
-    }
+    die "build-deps failed!";
 }
 
 my $generator =

lib/make/build-deps/build-deps.mak

+EXES_LIST = bin/needed-executables.txt
+
+MODULES_LIST = bin/required-modules.yml
+
+BIN = ./bin/gen-build-deps
+
+STAMP = lib/make/build-deps/build-deps.stamp
+
+all: $(STAMP)
+
+$(STAMP): $(BIN) $(EXES_LIST) $(MODULES_LIST)
+	$(BIN) -o $@ --exes-conf $(EXES_LIST) --modules-conf $(MODULES_LIST)
+
+clean:
+	rm -f $(STAMP)