3 # Write out a Makefile and a build.xml file based on the *.inputs files
4 # in the current directory. Steve Wainstead, April 2001.
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
13 # sun's java sdk, http://java.sun.com/j2se/
14 # httpunit, http://httpunit.sf.net
15 # ant, http://jakarta.apache.org/builds/jakarta-ant/release/
18 # copy the httpunit jars to this path or add them to your CLASSPATH
19 # fix the url below for your server
20 # run makemakebuild.pl, this creates Makefile (gnu make) and build.xml (ant)
21 # run make, this compiles the classes and runs ant.
22 # if your classpath is wrong run ant seperately to test.
23 # run ant for each test. both ant and make can run independently.
25 #my $my_wikiurl = 'http://reini/phpwiki/'; # this will replace steve's url below if defined
26 #-----------------------------------------
28 my $ori_wikiurl = 'http://127.0.0.1:8080/~swain/phpwiki/';
29 my @files = <*.inputs>;
30 chomp(@files); # prolly unnecessary, but oh well.
32 print "Found ", scalar(@files), " input files.\n";
34 foreach $inputfile (@files) {
35 $inputfile =~ m/\.inputs$/;
36 $javafile = "$`.java";
38 if ($my_wikiurl and ($my_wikiurl ne $ori_wikiurl)) {
40 open IN, "< $inputfile";
42 `perl -i.orig -pe 's|$ori_wikiurl|$my_wikiurl|' $inputfile` if $contents =~ m|$ori_wikiurl|;
45 $test_make_target_names .= "$javafile ";
46 $test_make_targets .=<<"EOLN";
48 \tmaketest.pl $inputfile
52 $test_ant_targets .= <<"EOLN";
53 <target name="$classname">
54 <echo message="Testing with $classname..."/>
55 <java classname="$classname"></java>
60 push @test_dependency_names, $classname;
64 $test_dependency_names = join(',', @test_dependency_names);
66 # print <<"SHOW_RESULTS";
67 # make's targets: $test_make_target_names
69 # make's acutual targets:
72 # ant's target names: $test_dependency_names
80 # these are the skeleton files for the Makefile and the build.xml file
82 $makefile = <<MAKEFILE_SKEL;
83 # Generate new test classes if their input files have changed.
84 # This makefile is called from an Ant build.xml though you can run
87 .SUFFIXES: .inputs .java .class .zip
88 .PHONY: all clean buildtests dotest
90 tests = $test_make_target_names
92 # ANT_HOME=P:\\ant # path style os dependent!
93 CLASSPATH="httpunit.jar:Tidy.jar:classes.zip"
95 testsrc = \$(wildcard *.inputs)
96 javas = \$(testsrc:.inputs=.java)
97 classes = \$(javas:.java=.class)
98 tests = \$(javas:.java=)
100 all: buildtests classes.zip dotest
103 \texport CLASSPATH=\$(CLASSPATH)
105 #\tjava -classpath "\$(CLASSPATH):\${ANT_HOME}\\lib\\ant.jar" -Dant.home="\${ANT_HOME}" org.apache.tools.ant.Main \$(<:.class=)
107 buildtests: \$(javas) classes.zip
109 classes.zip: \$(classes)
113 \t-rm -f \$(javas) \$(classes) classes.zip
119 \tjavac -classpath httpunit.jar \$<
124 $buildxml = <<"BUILDXML_SKEL";
125 <project name="test" default="all">
129 depends="init,generate,compile,test">
137 <target name="generate" depends="init">
138 <exec executable="make">
139 <arg line="buildtests"/>
145 <target name="compile" depends="generate">
146 <javac srcdir="." destdir="." />
150 <target name="test" depends="compile,$test_dependency_names">
154 <target name="clean">
156 <exec executable="make">
161 <fileset dir="." includes="*.class"/>
167 <!-- individual test files are compiled here -->
175 print "Writing Makefile...\n";
176 open MAKEFILE, ">./Makefile" or die $!;
177 print MAKEFILE $makefile;
179 print "Writing build.xml...\n";
180 open BUILDXML, ">./build.xml" or die $!;
181 print BUILDXML $buildxml;