2 # Write out a Makefile and a build.xml file based on the *.inputs files
3 # in the current directory. Steve Wainstead, April 2001.
5 # read in all the input files, loop over each one and build up
6 # text blocks that we will subsitute into the skeletons for Makefile
10 # sun's java sdk, http://java.sun.com/j2se/
11 # httpunit, http://httpunit.sf.net
12 # ant, http://jakarta.apache.org/builds/jakarta-ant/release/
15 # copy the httpunit jars to this path or add them to your CLASSPATH
16 # fix the url below for your server
17 # run makemakebuild.pl, this creates Makefile (gnu make) and build.xml (ant)
18 # run make, this compiles the classes and runs ant.
19 # if your classpath is wrong run ant separately to test.
20 # run ant for each test. both ant and make can run independently.
22 #my $my_wikiurl = 'http://reini/phpwiki/'; # this will replace steve's url below if defined
23 #-----------------------------------------
25 my $ori_wikiurl = 'http://127.0.0.1:8080/~swain/phpwiki/';
26 my @files = <*.inputs>;
27 chomp(@files); # prolly unnecessary, but oh well.
29 print "Found ", scalar(@files), " input files.\n";
31 foreach $inputfile (@files) {
32 $inputfile =~ m/\.inputs$/;
33 $javafile = "$`.java";
35 if ($my_wikiurl and ($my_wikiurl ne $ori_wikiurl)) {
37 open IN, "< $inputfile";
39 `perl -i.orig -pe 's|$ori_wikiurl|$my_wikiurl|' $inputfile` if $contents =~ m|$ori_wikiurl|;
42 $test_make_target_names .= "$javafile ";
43 $test_make_targets .=<<"EOLN";
45 \tmaketest.pl $inputfile
49 $test_ant_targets .= <<"EOLN";
50 <target name="$classname">
51 <echo message="Testing with $classname..."/>
52 <java classname="$classname"></java>
57 push @test_dependency_names, $classname;
61 $test_dependency_names = join(',', @test_dependency_names);
63 # print <<"SHOW_RESULTS";
64 # make's targets: $test_make_target_names
66 # make's acutual targets:
69 # ant's target names: $test_dependency_names
77 # these are the skeleton files for the Makefile and the build.xml file
79 $makefile = <<MAKEFILE_SKEL;
80 # Generate new test classes if their input files have changed.
81 # This makefile is called from an Ant build.xml though you can run
84 .SUFFIXES: .inputs .java .class .zip
85 .PHONY: all clean buildtests dotest
87 tests = $test_make_target_names
89 # ANT_HOME=P:\\ant # path style os dependent!
90 CLASSPATH="httpunit.jar:Tidy.jar:classes.zip"
92 testsrc = \$(wildcard *.inputs)
93 javas = \$(testsrc:.inputs=.java)
94 classes = \$(javas:.java=.class)
95 tests = \$(javas:.java=)
97 all: buildtests classes.zip dotest
100 \texport CLASSPATH=\$(CLASSPATH)
102 #\tjava -classpath "\$(CLASSPATH):\${ANT_HOME}\\lib\\ant.jar" -Dant.home="\${ANT_HOME}" org.apache.tools.ant.Main \$(<:.class=)
104 buildtests: \$(javas) classes.zip
106 classes.zip: \$(classes)
110 \t-rm -f \$(javas) \$(classes) classes.zip
116 \tjavac -classpath httpunit.jar \$<
121 $buildxml = <<"BUILDXML_SKEL";
122 <project name="test" default="all">
126 depends="init,generate,compile,test">
134 <target name="generate" depends="init">
135 <exec executable="make">
136 <arg line="buildtests"/>
142 <target name="compile" depends="generate">
143 <javac srcdir="." destdir="." />
147 <target name="test" depends="compile,$test_dependency_names">
151 <target name="clean">
153 <exec executable="make">
158 <fileset dir="." includes="*.class"/>
164 <!-- individual test files are compiled here -->
172 print "Writing Makefile...\n";
173 open MAKEFILE, ">./Makefile" or die $!;
174 print MAKEFILE $makefile;
176 print "Writing build.xml...\n";
177 open BUILDXML, ">./build.xml" or die $!;
178 print BUILDXML $buildxml;