Created
April 25, 2013 22:55
-
-
Save quietfanatic/5463905 to your computer and use it in GitHub Desktop.
A sample make.pl for a perl-based build system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use FindBin; | |
BEGIN { %make:: or do { require "$FindBin::Bin/tool/make.pm"; make->import(':all') } } | |
use autodie qw(:all); | |
my $here; | |
my @modules; | |
my @cleanables; | |
workflow { | |
sub doths { "$_[0]/$_[0].hs" } | |
sub dotnes { "$_[0]/$_[0].nes" } | |
sub dotexe { "$_[0]/$_[0].exe" } | |
sub module { | |
my ($name) = @_; | |
rule dotexe($name), doths($name), sub { | |
system 'ghc', '-ilib', "-i$name", '-fno-warn-deprecated-flags', doths($name), '-o', dotexe($name); | |
}; | |
rule dotnes($name), dotexe($name), sub { | |
system(dotexe($name) . ' > ' . dotnes($name)); | |
}; | |
push @modules, dotnes($name); | |
} | |
sub ohs { | |
my ($base) = @_; | |
rule "$base.hs", ["$base.ohs", 'tool/ohs'], sub { | |
system "tool/ohs '$_[1][0]' > '$_[0][0]'"; | |
}; | |
push @cleanables, "$base.hs"; | |
} | |
ohs 'lib/NES/ASoundEngine'; | |
ohs 'lib/Assembler'; | |
ohs 'lib/ASM'; | |
ohs 'lib/ASM6502'; | |
ohs 'soundtest/soundtest'; | |
ohs 'controllertest/controllertest'; | |
ohs 'agame/Actors'; | |
ohs 'agame/agame'; | |
subdep 'lib/ASM.hs', 'lib/Assembler.hs'; | |
subdep 'lib/ASM6502.hs', 'lib/ASM.hs'; | |
subdep 'lib/NES.hs', 'lib/ASM6502.hs'; | |
subdep 'lib/NES/Reservations.hs', 'lib/NES.hs'; | |
subdep 'lib/NES/ASoundEngine.hs', 'lib/NES/Reservations.hs'; | |
subdep doths('soundtest'), 'lib/NES/ASoundEngine.hs'; | |
subdep doths('controllertest'), [qw(lib/NES.hs lib/NES/Reservations.hs lib/NES/ImageLoader.hs)]; | |
subdep dotexe('controllertest'), [qw(controllertest/sprites.png controllertest/background.bin)]; | |
subdep 'agame/Actors.hs', 'lib/NES/Reservations.hs'; | |
subdep doths('agame'), [qw(agame/Actors.hs lib/NES/Reservations.hs)]; | |
subdep dotexe('agame'), [qw(agame/sprites.png agame/background.png)]; | |
module 'soundtest'; | |
module 'controllertest'; | |
module 'agame'; | |
phony 'build', [@modules], sub { }; | |
phony 'clean', [], sub { | |
unlink glob '*/*.nes */*.exe */*.hi */*.o */*/*.hi */*/*.o'; | |
unlink @cleanables; | |
}; | |
defaults 'build'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment