3 # Write out a Makefile and a build.xml file based on the *.inputs files
4 # in the current directory. Steve Wainstead, April 2001.
6 # $Id: makemakebuild.pl,v 1.1 2001-09-20 20:52:22 wainstead Exp $
8 # read in all the input files, loop over each one and build up
9 # text blocks that we will subsitute into the skeletons for Makefile
12 my @files = <*.inputs>;
13 chomp(@files); # prolly unnecessary, but oh well.
15 print "Found ", scalar(@files), " input files.\n";
17 foreach $inputfile (@files) {
18 $inputfile =~ m/\.inputs$/;
19 $javafile = "$`.java";
22 $test_make_target_names .= "$javafile ";
23 $test_make_targets .=<<"EOLN";
25 \tmaketest.pl $inputfile
29 $test_ant_targets .= <<"EOLN";
30 <target name="$classname">
31 <echo message="Testing with $classname..."/>
32 <java classname="$classname"></java>
37 push @test_dependency_names, $classname;
41 $test_dependency_names = join(',', @test_dependency_names);
43 # print <<"SHOW_RESULTS";
44 # make's targets: $test_make_target_names
46 # make's acutual targets:
49 # ant's target names: $test_dependency_names
57 # these are the skeleton files for the Makefile and the build.xml file
59 $makefile = <<MAKEFILE_SKEL;
60 # Generate new test classes if their input files have changed.
61 # This makefile is called from an Ant build.xml though you can run
64 tests = $test_make_target_names
77 $buildxml = <<"BUILDXML_SKEL";
78 <project name="test" default="all">
82 depends="init,generate,compile,test">
90 <target name="generate" depends="init">
91 <exec executable="make">
97 <target name="compile" depends="generate">
98 <javac srcdir="." destdir="." />
102 <target name="test" depends="compile,$test_dependency_names">
106 <target name="clean">
108 <exec executable="make">
113 <fileset dir="." includes="*.class"/>
119 <!-- individual test files are compiled here -->
127 print "Writing Makefile...\n";
128 open MAKEFILE, ">./Makefile" or die $!;
129 print MAKEFILE $makefile;
131 print "Writing build.xml...\n";
132 open BUILDXML, ">./build.xml" or die $!;
133 print BUILDXML $buildxml;