diff options
46 files changed, 1112 insertions, 840 deletions
diff --git a/doc/generated/builders.gen b/doc/generated/builders.gen index ada4e43..680f72f 100644 --- a/doc/generated/builders.gen +++ b/doc/generated/builders.gen @@ -572,75 +572,77 @@ env.Jar(target = 'bar.jar', <function>env.Java()</function> </term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Builds one or more Java class files. -The sources may be any combination of explicit -<filename>.java</filename> files, -or directory trees which will be scanned -for <filename>.java</filename> files. -</para> - -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -SCons will parse each source <filename>.java</filename> file -to find the classes -(including inner classes) -defined within that file, -and from that figure out the -target <filename>.class</filename> files that will be created. -The class files will be placed underneath -the specified target directory. -</para> - -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -SCons will also search each Java file -for the Java package name, -which it assumes can be found on a line -beginning with the string -<literal>package</literal> -in the first column; -the resulting <filename>.class</filename> files -will be placed in a directory reflecting -the specified package name. -For example, -the file -<filename>Foo.java</filename> -defining a single public -<classname>Foo</classname> -class and -containing a package name of -<classname>sub.dir</classname> -will generate a corresponding -<filename>sub/dir/Foo.class</filename> -class file. -</para> - -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Examples: -</para> - -<example_commands xmlns="http://www.scons.org/dbxsd/v1.0"> -env.Java(target = 'classes', source = 'src') -env.Java(target = 'classes', source = ['src1', 'src2']) -env.Java(target = 'classes', source = ['File1.java', 'File2.java']) -</example_commands> - -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Java source files can use the native encoding for the underlying OS. -Since SCons compiles in simple ASCII mode by default, -the compiler will generate warnings about unmappable characters, -which may lead to errors as the file is processed further. -In this case, the user must specify the <literal>LANG</literal> -environment variable to tell the compiler what encoding is used. -For portibility, it's best if the encoding is hard-coded -so that the compile will work if it is done on a system -with a different encoding. -</para> - -<example_commands xmlns="http://www.scons.org/dbxsd/v1.0"> -env = Environment() -env['ENV']['LANG'] = 'en_GB.UTF-8' -</example_commands> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Builds one or more Java class files. + The sources may be any combination of explicit + <filename>.java</filename> + files, + or directory trees which will be scanned + for <filename>.java</filename> files. + </para> + + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + SCons will parse each source <filename>.java</filename> file + to find the classes + (including inner classes) + defined within that file, + and from that figure out the + target <filename>.class</filename> files that will be created. + The class files will be placed underneath + the specified target directory. + </para> + + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + SCons will also search each Java file + for the Java package name, + which it assumes can be found on a line + beginning with the string + <literal>package</literal> + in the first column; + the resulting <filename>.class</filename> files + will be placed in a directory reflecting + the specified package name. + For example, + the file + <filename>Foo.java</filename> + defining a single public + <classname>Foo</classname> + class and + containing a package name of + <classname>sub.dir</classname> + will generate a corresponding + <filename>sub/dir/Foo.class</filename> + class file. + </para> + + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Examples: + </para> + + <example_commands xmlns="http://www.scons.org/dbxsd/v1.0"> + env.Java(target = 'classes', source = 'src') + env.Java(target = 'classes', source = ['src1', 'src2']) + env.Java(target = 'classes', source = ['File1.java', 'File2.java']) + </example_commands> + + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Java source files can use the native encoding for the underlying OS. + Since SCons compiles in simple ASCII mode by default, + the compiler will generate warnings about unmappable characters, + which may lead to errors as the file is processed further. + In this case, the user must specify the + <literal>LANG</literal> + environment variable to tell the compiler what encoding is used. + For portibility, it's best if the encoding is hard-coded + so that the compile will work if it is done on a system + with a different encoding. + </para> + + <example_commands xmlns="http://www.scons.org/dbxsd/v1.0"> + env = Environment() + env['ENV']['LANG'] = 'en_GB.UTF-8' + </example_commands> + </listitem> </varlistentry> <varlistentry id="b-JavaH"> <term> diff --git a/doc/generated/examples/caching_ex-random_1.xml b/doc/generated/examples/caching_ex-random_1.xml index 18b04eb..3009e65 100644 --- a/doc/generated/examples/caching_ex-random_1.xml +++ b/doc/generated/examples/caching_ex-random_1.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <screen xmlns="http://www.scons.org/dbxsd/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">% <userinput>scons -Q</userinput> -cc -o f3.o -c f3.c cc -o f5.o -c f5.c -cc -o f4.o -c f4.c cc -o f2.o -c f2.c +cc -o f4.o -c f4.c cc -o f1.o -c f1.c +cc -o f3.o -c f3.c cc -o prog f1.o f2.o f3.o f4.o f5.o </screen> diff --git a/doc/generated/examples/troubleshoot_explain1_3.xml b/doc/generated/examples/troubleshoot_explain1_3.xml index 064fdcb..56a7417 100644 --- a/doc/generated/examples/troubleshoot_explain1_3.xml +++ b/doc/generated/examples/troubleshoot_explain1_3.xml @@ -3,5 +3,5 @@ cp file.in file.oout scons: warning: Cannot find target file.out after building -File "/home/bdbaddog/scons/git/scons/bootstrap/src/script/scons.py", line 201, in <module> +File "/home/bdeegan/devel/scons/scons-bugfixes-1/bootstrap/src/script/scons.py", line 201, in <module> </screen> diff --git a/doc/generated/tools.gen b/doc/generated/tools.gen index f858aa4..01fb559 100644 --- a/doc/generated/tools.gen +++ b/doc/generated/tools.gen @@ -586,10 +586,10 @@ Sets construction variables for the <application xmlns="http://www.scons.org/dbx <varlistentry id="t-javac"> <term>javac</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Sets construction variables for the <application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> compiler. -</para> -<para>Sets: &cv-link-JAVABOOTCLASSPATH;, &cv-link-JAVAC;, &cv-link-JAVACCOM;, &cv-link-JAVACFLAGS;, &cv-link-JAVACLASSPATH;, &cv-link-JAVACLASSSUFFIX;, &cv-link-JAVASOURCEPATH;, &cv-link-JAVASUFFIX;.</para><para>Uses: &cv-link-JAVACCOMSTR;.</para></listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Sets construction variables for the <application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> compiler. + </para> + <para>Sets: &cv-link-JAVABOOTCLASSPATH;, &cv-link-JAVAC;, &cv-link-JAVACCOM;, &cv-link-JAVACFLAGS;, &cv-link-JAVACLASSPATH;, &cv-link-JAVACLASSSUFFIX;, &cv-link-JAVAINCLUDES;, &cv-link-JAVASOURCEPATH;, &cv-link-JAVASUFFIX;.</para><para>Uses: &cv-link-JAVACCOMSTR;.</para></listitem> </varlistentry> <varlistentry id="t-javah"> <term>javah</term> @@ -778,19 +778,19 @@ Sets construction variables for the </para> <para>Sets: &cv-link-AS;, &cv-link-ASCOM;, &cv-link-ASFLAGS;, &cv-link-ASPPCOM;, &cv-link-ASPPFLAGS;.</para><para>Uses: &cv-link-ASCOMSTR;, &cv-link-ASPPCOMSTR;.</para></listitem> </varlistentry> - <varlistentry id="t-Packaging"> - <term>Packaging</term> + <varlistentry id="t-packaging"> + <term>packaging</term> <listitem> <para xmlns="http://www.scons.org/dbxsd/v1.0"> -Sets construction variables for the <function xmlns="http://www.scons.org/dbxsd/v1.0">Package</function> Builder. +A framework for building binary and source packages. </para> </listitem> </varlistentry> - <varlistentry id="t-packaging"> - <term>packaging</term> + <varlistentry id="t-Packaging"> + <term>Packaging</term> <listitem> <para xmlns="http://www.scons.org/dbxsd/v1.0"> -A framework for building binary and source packages. +Sets construction variables for the <function xmlns="http://www.scons.org/dbxsd/v1.0">Package</function> Builder. </para> </listitem> </varlistentry> diff --git a/doc/generated/tools.mod b/doc/generated/tools.mod index 1209d74..f9bc1d7 100644 --- a/doc/generated/tools.mod +++ b/doc/generated/tools.mod @@ -78,8 +78,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. <!ENTITY t-mwcc "<literal xmlns='http://www.scons.org/dbxsd/v1.0'>mwcc</literal>"> <!ENTITY t-mwld "<literal xmlns='http://www.scons.org/dbxsd/v1.0'>mwld</literal>"> <!ENTITY t-nasm "<literal xmlns='http://www.scons.org/dbxsd/v1.0'>nasm</literal>"> -<!ENTITY t-Packaging "<literal xmlns='http://www.scons.org/dbxsd/v1.0'>Packaging</literal>"> <!ENTITY t-packaging "<literal xmlns='http://www.scons.org/dbxsd/v1.0'>packaging</literal>"> +<!ENTITY t-Packaging "<literal xmlns='http://www.scons.org/dbxsd/v1.0'>Packaging</literal>"> <!ENTITY t-pdf "<literal xmlns='http://www.scons.org/dbxsd/v1.0'>pdf</literal>"> <!ENTITY t-pdflatex "<literal xmlns='http://www.scons.org/dbxsd/v1.0'>pdflatex</literal>"> <!ENTITY t-pdftex "<literal xmlns='http://www.scons.org/dbxsd/v1.0'>pdftex</literal>"> @@ -186,8 +186,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. <!ENTITY t-link-mwcc "<link linkend='t-mwcc' xmlns='http://www.scons.org/dbxsd/v1.0'><literal>mwcc</literal></link>"> <!ENTITY t-link-mwld "<link linkend='t-mwld' xmlns='http://www.scons.org/dbxsd/v1.0'><literal>mwld</literal></link>"> <!ENTITY t-link-nasm "<link linkend='t-nasm' xmlns='http://www.scons.org/dbxsd/v1.0'><literal>nasm</literal></link>"> -<!ENTITY t-link-Packaging "<link linkend='t-Packaging' xmlns='http://www.scons.org/dbxsd/v1.0'><literal>Packaging</literal></link>"> <!ENTITY t-link-packaging "<link linkend='t-packaging' xmlns='http://www.scons.org/dbxsd/v1.0'><literal>packaging</literal></link>"> +<!ENTITY t-link-Packaging "<link linkend='t-Packaging' xmlns='http://www.scons.org/dbxsd/v1.0'><literal>Packaging</literal></link>"> <!ENTITY t-link-pdf "<link linkend='t-pdf' xmlns='http://www.scons.org/dbxsd/v1.0'><literal>pdf</literal></link>"> <!ENTITY t-link-pdflatex "<link linkend='t-pdflatex' xmlns='http://www.scons.org/dbxsd/v1.0'><literal>pdflatex</literal></link>"> <!ENTITY t-link-pdftex "<link linkend='t-pdftex' xmlns='http://www.scons.org/dbxsd/v1.0'><literal>pdftex</literal></link>"> diff --git a/doc/generated/variables.gen b/doc/generated/variables.gen index 9246249..17aab7b 100644 --- a/doc/generated/variables.gen +++ b/doc/generated/variables.gen @@ -3269,107 +3269,111 @@ by default. <varlistentry id="cv-JAVABOOTCLASSPATH"> <term>JAVABOOTCLASSPATH</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Specifies the list of directories that -will be added to the -<application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> command line -via the <option>-bootclasspath</option> option. -The individual directory names will be -separated by the operating system's path separate character -(<filename>:</filename> on UNIX/Linux/POSIX, -<filename>;</filename> on Windows). -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Specifies the list of directories that + will be added to the + <application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> command line + via the <option>-bootclasspath</option> option. + The individual directory names will be + separated by the operating system's path separate character + (<filename>:</filename> on UNIX/Linux/POSIX, + <filename>;</filename> + on Windows). + </para> + </listitem> </varlistentry> <varlistentry id="cv-JAVAC"> <term>JAVAC</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -The Java compiler. -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + The Java compiler. + </para> + </listitem> </varlistentry> <varlistentry id="cv-JAVACCOM"> <term>JAVACCOM</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -The command line used to compile a directory tree containing -Java source files to -corresponding Java class files. -Any options specified in the <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-JAVACFLAGS"><envar>$JAVACFLAGS</envar></link> construction variable -are included on this command line. -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + The command line used to compile a directory tree containing + Java source files to + corresponding Java class files. + Any options specified in the <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-JAVACFLAGS"><envar>$JAVACFLAGS</envar></link> construction variable + are included on this command line. + </para> + </listitem> </varlistentry> <varlistentry id="cv-JAVACCOMSTR"> <term>JAVACCOMSTR</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -The string displayed when compiling -a directory tree of Java source files to -corresponding Java class files. -If this is not set, then <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-JAVACCOM"><envar>$JAVACCOM</envar></link> (the command line) is displayed. -</para> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + The string displayed when compiling + a directory tree of Java source files to + corresponding Java class files. + If this is not set, then <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-JAVACCOM"><envar>$JAVACCOM</envar></link> (the command line) is displayed. + </para> -<example_commands xmlns="http://www.scons.org/dbxsd/v1.0"> -env = Environment(JAVACCOMSTR = "Compiling class files $TARGETS from $SOURCES") -</example_commands> -</listitem> + <example_commands xmlns="http://www.scons.org/dbxsd/v1.0"> + env = Environment(JAVACCOMSTR = "Compiling class files $TARGETS from $SOURCES") + </example_commands> + </listitem> </varlistentry> <varlistentry id="cv-JAVACFLAGS"> <term>JAVACFLAGS</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -General options that are passed to the Java compiler. -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + General options that are passed to the Java compiler. + </para> + </listitem> </varlistentry> <varlistentry id="cv-JAVACLASSDIR"> <term>JAVACLASSDIR</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -The directory in which Java class files may be found. -This is stripped from the beginning of any Java .class -file names supplied to the -<literal>JavaH</literal> -builder. -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + The directory in which Java class files may be found. + This is stripped from the beginning of any Java .class + file names supplied to the + <literal>JavaH</literal> + builder. + </para> + </listitem> </varlistentry> <varlistentry id="cv-JAVACLASSPATH"> <term>JAVACLASSPATH</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Specifies the list of directories that -will be searched for Java -<filename>.class</filename> file. -The directories in this list will be added to the -<application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> and <application xmlns="http://www.scons.org/dbxsd/v1.0">javah</application> command lines -via the <option>-classpath</option> option. -The individual directory names will be -separated by the operating system's path separate character -(<filename>:</filename> on UNIX/Linux/POSIX, -<filename>;</filename> on Windows). -</para> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Specifies the list of directories that + will be searched for Java + <filename>.class</filename> + file. + The directories in this list will be added to the + <application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> and <application xmlns="http://www.scons.org/dbxsd/v1.0">javah</application> command lines + via the <option>-classpath</option> option. + The individual directory names will be + separated by the operating system's path separate character + (<filename>:</filename> on UNIX/Linux/POSIX, + <filename>;</filename> + on Windows). + </para> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Note that this currently just adds the specified -directory via the <option>-classpath</option> option. -<application xmlns="http://www.scons.org/dbxsd/v1.0">SCons</application> does not currently search the -<envar xmlns="http://www.scons.org/dbxsd/v1.0">$JAVACLASSPATH</envar> directories for dependency -<filename>.class</filename> files. -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Note that this currently just adds the specified + directory via the <option>-classpath</option> option. + <application xmlns="http://www.scons.org/dbxsd/v1.0">SCons</application> does not currently search the + <envar xmlns="http://www.scons.org/dbxsd/v1.0">$JAVACLASSPATH</envar> directories for dependency + <filename>.class</filename> + files. + </para> + </listitem> </varlistentry> <varlistentry id="cv-JAVACLASSSUFFIX"> <term>JAVACLASSSUFFIX</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -The suffix for Java class files; -<filename>.class</filename> -by default. -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + The suffix for Java class files; + <filename>.class</filename> + by default. + </para> + </listitem> </varlistentry> <varlistentry id="cv-JAVAH"> <term>JAVAH</term> @@ -3413,65 +3417,77 @@ for Java classes. </para> </listitem> </varlistentry> + <varlistentry id="cv-JAVAINCLUDES"> + <term>JAVAINCLUDES</term> + <listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Include path for Java header files (such as jni.h) + </para> + </listitem> + </varlistentry> <varlistentry id="cv-JAVASOURCEPATH"> <term>JAVASOURCEPATH</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Specifies the list of directories that -will be searched for input -<filename>.java</filename> file. -The directories in this list will be added to the -<application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> command line -via the <option>-sourcepath</option> option. -The individual directory names will be -separated by the operating system's path separate character -(<filename>:</filename> on UNIX/Linux/POSIX, -<filename>;</filename> on Windows). -</para> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Specifies the list of directories that + will be searched for input + <filename>.java</filename> + file. + The directories in this list will be added to the + <application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> command line + via the <option>-sourcepath</option> option. + The individual directory names will be + separated by the operating system's path separate character + (<filename>:</filename> on UNIX/Linux/POSIX, + <filename>;</filename> + on Windows). + </para> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Note that this currently just adds the specified -directory via the <option>-sourcepath</option> option. -<application xmlns="http://www.scons.org/dbxsd/v1.0">SCons</application> does not currently search the -<envar xmlns="http://www.scons.org/dbxsd/v1.0">$JAVASOURCEPATH</envar> directories for dependency -<filename>.java</filename> files. -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Note that this currently just adds the specified + directory via the <option>-sourcepath</option> option. + <application xmlns="http://www.scons.org/dbxsd/v1.0">SCons</application> does not currently search the + <envar xmlns="http://www.scons.org/dbxsd/v1.0">$JAVASOURCEPATH</envar> directories for dependency + <filename>.java</filename> + files. + </para> + </listitem> </varlistentry> <varlistentry id="cv-JAVASUFFIX"> <term>JAVASUFFIX</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -The suffix for Java files; -<filename>.java</filename> -by default. -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + The suffix for Java files; + <filename>.java</filename> + by default. + </para> + </listitem> </varlistentry> <varlistentry id="cv-JAVAVERSION"> <term>JAVAVERSION</term> <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Specifies the Java version being used by the <function xmlns="http://www.scons.org/dbxsd/v1.0">Java</function> builder. -This is <emphasis>not</emphasis> currently used to select one -version of the Java compiler vs. another. -Instead, you should set this to specify the version of Java -supported by your <application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> compiler. -The default is <literal>1.4</literal>. -</para> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + Specifies the Java version being used by the <function xmlns="http://www.scons.org/dbxsd/v1.0">Java</function> builder. + This is <emphasis>not</emphasis> currently used to select one + version of the Java compiler vs. another. + Instead, you should set this to specify the version of Java + supported by your <application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> compiler. + The default is <literal>1.4</literal>. + </para> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -This is sometimes necessary because -Java 1.5 changed the file names that are created -for nested anonymous inner classes, -which can cause a mismatch with the files -that <application xmlns="http://www.scons.org/dbxsd/v1.0">SCons</application> expects will be generated by the <application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> compiler. -Setting <envar xmlns="http://www.scons.org/dbxsd/v1.0">$JAVAVERSION</envar> to <literal>1.5</literal> -(or <literal>1.6</literal>, as appropriate) -can make <application xmlns="http://www.scons.org/dbxsd/v1.0">SCons</application> realize that a Java 1.5 or 1.6 -build is actually up to date. -</para> -</listitem> + <para xmlns="http://www.scons.org/dbxsd/v1.0"> + This is sometimes necessary because + Java 1.5 changed the file names that are created + for nested anonymous inner classes, + which can cause a mismatch with the files + that <application xmlns="http://www.scons.org/dbxsd/v1.0">SCons</application> expects will be generated by the <application xmlns="http://www.scons.org/dbxsd/v1.0">javac</application> compiler. + Setting <envar xmlns="http://www.scons.org/dbxsd/v1.0">$JAVAVERSION</envar> to + <literal>1.5</literal> + (or <literal>1.6</literal>, as appropriate) + can make <application xmlns="http://www.scons.org/dbxsd/v1.0">SCons</application> realize that a Java 1.5 or 1.6 + build is actually up to date. + </para> + </listitem> </varlistentry> <varlistentry id="cv-LATEX"> <term>LATEX</term> @@ -6615,16 +6631,6 @@ Example <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-SHLIBVERSION"> </para> </listitem> </varlistentry> - <varlistentry id="cv-SHLIBVERSIONFLAGS"> - <term>SHLIBVERSIONFLAGS</term> - <listitem> -<para xmlns="http://www.scons.org/dbxsd/v1.0"> -Extra flags added to <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-SHLINKCOM"><envar>$SHLINKCOM</envar></link> when building versioned -<link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="b-SharedLibrary"><function>SharedLibrary</function></link>. These flags are only used when <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-SHLIBVERSION"><envar>$SHLIBVERSION</envar></link> is -set. -</para> -</listitem> - </varlistentry> <varlistentry id="cv-_SHLIBVERSIONFLAGS"> <term>_SHLIBVERSIONFLAGS</term> <listitem> @@ -6638,6 +6644,16 @@ and some extra dynamically generated options (such as </para> </listitem> </varlistentry> + <varlistentry id="cv-SHLIBVERSIONFLAGS"> + <term>SHLIBVERSIONFLAGS</term> + <listitem> +<para xmlns="http://www.scons.org/dbxsd/v1.0"> +Extra flags added to <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-SHLINKCOM"><envar>$SHLINKCOM</envar></link> when building versioned +<link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="b-SharedLibrary"><function>SharedLibrary</function></link>. These flags are only used when <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-SHLIBVERSION"><envar>$SHLIBVERSION</envar></link> is +set. +</para> +</listitem> + </varlistentry> <varlistentry id="cv-SHLINK"> <term>SHLINK</term> <listitem> diff --git a/doc/generated/variables.mod b/doc/generated/variables.mod index 52ee4e1..9106e94 100644 --- a/doc/generated/variables.mod +++ b/doc/generated/variables.mod @@ -232,6 +232,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. <!ENTITY cv-JAVAHCOM "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$JAVAHCOM</envar>"> <!ENTITY cv-JAVAHCOMSTR "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$JAVAHCOMSTR</envar>"> <!ENTITY cv-JAVAHFLAGS "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$JAVAHFLAGS</envar>"> +<!ENTITY cv-JAVAINCLUDES "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$JAVAINCLUDES</envar>"> <!ENTITY cv-JAVASOURCEPATH "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$JAVASOURCEPATH</envar>"> <!ENTITY cv-JAVASUFFIX "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$JAVASUFFIX</envar>"> <!ENTITY cv-JAVAVERSION "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$JAVAVERSION</envar>"> @@ -496,8 +497,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. <!ENTITY cv-_SHLIBSONAME "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$_SHLIBSONAME</envar>"> <!ENTITY cv-SHLIBSUFFIX "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$SHLIBSUFFIX</envar>"> <!ENTITY cv-SHLIBVERSION "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$SHLIBVERSION</envar>"> -<!ENTITY cv-SHLIBVERSIONFLAGS "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$SHLIBVERSIONFLAGS</envar>"> <!ENTITY cv-_SHLIBVERSIONFLAGS "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$_SHLIBVERSIONFLAGS</envar>"> +<!ENTITY cv-SHLIBVERSIONFLAGS "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$SHLIBVERSIONFLAGS</envar>"> <!ENTITY cv-SHLINK "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$SHLINK</envar>"> <!ENTITY cv-SHLINKCOM "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$SHLINKCOM</envar>"> <!ENTITY cv-SHLINKCOMSTR "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$SHLINKCOMSTR</envar>"> @@ -862,6 +863,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. <!ENTITY cv-link-JAVAHCOM "<link linkend='cv-JAVAHCOM' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$JAVAHCOM</envar></link>"> <!ENTITY cv-link-JAVAHCOMSTR "<link linkend='cv-JAVAHCOMSTR' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$JAVAHCOMSTR</envar></link>"> <!ENTITY cv-link-JAVAHFLAGS "<link linkend='cv-JAVAHFLAGS' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$JAVAHFLAGS</envar></link>"> +<!ENTITY cv-link-JAVAINCLUDES "<link linkend='cv-JAVAINCLUDES' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$JAVAINCLUDES</envar></link>"> <!ENTITY cv-link-JAVASOURCEPATH "<link linkend='cv-JAVASOURCEPATH' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$JAVASOURCEPATH</envar></link>"> <!ENTITY cv-link-JAVASUFFIX "<link linkend='cv-JAVASUFFIX' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$JAVASUFFIX</envar></link>"> <!ENTITY cv-link-JAVAVERSION "<link linkend='cv-JAVAVERSION' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$JAVAVERSION</envar></link>"> @@ -1126,8 +1128,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. <!ENTITY cv-link-_SHLIBSONAME "<link linkend='cv-_SHLIBSONAME' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$_SHLIBSONAME</envar></link>"> <!ENTITY cv-link-SHLIBSUFFIX "<link linkend='cv-SHLIBSUFFIX' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$SHLIBSUFFIX</envar></link>"> <!ENTITY cv-link-SHLIBVERSION "<link linkend='cv-SHLIBVERSION' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$SHLIBVERSION</envar></link>"> -<!ENTITY cv-link-SHLIBVERSIONFLAGS "<link linkend='cv-SHLIBVERSIONFLAGS' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$SHLIBVERSIONFLAGS</envar></link>"> <!ENTITY cv-link-_SHLIBVERSIONFLAGS "<link linkend='cv-_SHLIBVERSIONFLAGS' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$_SHLIBVERSIONFLAGS</envar></link>"> +<!ENTITY cv-link-SHLIBVERSIONFLAGS "<link linkend='cv-SHLIBVERSIONFLAGS' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$SHLIBVERSIONFLAGS</envar></link>"> <!ENTITY cv-link-SHLINK "<link linkend='cv-SHLINK' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$SHLINK</envar></link>"> <!ENTITY cv-link-SHLINKCOM "<link linkend='cv-SHLINKCOM' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$SHLINKCOM</envar></link>"> <!ENTITY cv-link-SHLINKCOMSTR "<link linkend='cv-SHLINKCOMSTR' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$SHLINKCOMSTR</envar></link>"> diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 95738b3..d5b9251 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -48,6 +48,9 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE will be used and the default paths below will be ignored. - Default path for clang/clangxx : C:\Program Files\LLVM\bin - Default path for mingw : c:\MinGW\bin + - Fix Java tools to search reasonable default paths for Win32, Linux, macOS. Add required paths + for swig and java native interface to JAVAINCLUDES. You should add these to your CPPPATH if you need + to compile with them. This handles spaces in paths in default Java paths on windows. From Andrew Featherstone - Removed unused --warn options from the man page and source code. diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index 23cc43b..3a472a9 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -32,6 +32,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import os.path import re +import glob java_parsing = 1 @@ -391,6 +392,78 @@ else: """ return os.path.split(fn) + + +java_win32_version_dir_glob = 'C:/Program Files*/Java/jdk%s*/bin' +java_win32_dir_glob = 'C:/Program Files*/Java/jdk*/bin' + +java_macos_include_dir = '/System/Library/Frameworks/JavaVM.framework/Headers/' +java_macos_version_include_dir = '/System/Library/Frameworks/JavaVM.framework/Versions/%s*/Headers/' + +java_linux_include_dirs = ['/usr/lib/jvm/default-java/include', + '/usr/lib/jvm/java-*-oracle/include'] +java_linux_version_include_dirs = ['/usr/lib/jvm/java-*-sun-%s*/include', + '/usr/lib/jvm/java-%s*-openjdk*/include', + '/usr/java/jdk%s*/include'] + + + +def get_java_install_dirs(platform, version=None): + """ + Using patterns above find the java jdk install dir + :param platform: + :param version: If specified, only look for java sdk's of this version + :return: list of default paths for java. + """ + paths = [] + if platform == 'win32': + if version: + paths = glob.glob(java_win32_version_dir_glob%version) + else: + paths = glob.glob(java_win32_dir_glob) + else: + # do nothing for now + pass + + paths=sorted(paths) + + return paths + +def get_java_include_paths(env, javac, version): + """ + Return java include paths + :param platform: + :param javac: + :return: + """ + paths = [] + if env['PLATFORM'] == 'win32': + javac_bin_dir = os.path.dirname(javac) + java_inc_dir = os.path.normpath(os.path.join(javac_bin_dir, '..', 'include')) + paths = [java_inc_dir, os.path.join(java_inc_dir, 'win32')] + elif env['PLATFORM'] == 'darwin': + if not version: + paths = [java_macos_include_dir] + else: + paths = sorted(glob.glob(java_macos_version_include_dir%version)) + else: + base_paths=[] + if not version: + for p in java_linux_include_dirs: + base_paths.extend(glob.glob(p)) + else: + for p in java_linux_version_include_dirs: + base_paths.extend(glob.glob(p%version)) + + for p in base_paths: + paths.extend([p, os.path.join(p,'linux')]) + + #print("PATHS:%s"%paths) + return paths + + + + # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py index 481f8f5..e0a6a69 100644 --- a/src/engine/SCons/Tool/jar.py +++ b/src/engine/SCons/Tool/jar.py @@ -32,11 +32,13 @@ selection method. # __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import SCons.Subst import SCons.Util from SCons.Node.FS import _my_normcase -import os +from SCons.Tool.JavaCommon import get_java_install_dirs + def jarSources(target, source, env, for_signature): """Only include sources that are not a manifest file.""" @@ -206,6 +208,14 @@ def generate(env): env.AddMethod(Jar) + if env['PLATFORM'] == 'win32': + # Ensure that we have a proper path for clang + jar = SCons.Tool.find_program_path(env, 'jar', + default_paths=get_java_install_dirs(env['PLATFORM'])) + if jar: + jar_bin_dir = os.path.dirname(jar) + env.AppendENVPath('PATH', jar_bin_dir) + env['JAR'] = 'jar' env['JARFLAGS'] = SCons.Util.CLVar('cf') env['_JARFLAGS'] = jarFlags diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py index 72c48f7..8d98b54 100644 --- a/src/engine/SCons/Tool/javac.py +++ b/src/engine/SCons/Tool/javac.py @@ -39,7 +39,7 @@ from collections import OrderedDict import SCons.Action import SCons.Builder from SCons.Node.FS import _my_normcase -from SCons.Tool.JavaCommon import parse_java_file +from SCons.Tool.JavaCommon import parse_java_file, get_java_install_dirs, get_java_include_paths import SCons.Util def classname(path): @@ -208,6 +208,21 @@ def generate(env): env.AddMethod(Java) + version = env.get('JAVAVERSION', None) + + javac = SCons.Tool.find_program_path(env, 'javac') + if env['PLATFORM'] == 'win32': + # Ensure that we have a proper path for javac + paths=get_java_install_dirs(env['PLATFORM'], version=version) + javac = SCons.Tool.find_program_path(env, 'javac', + default_paths=paths) + if javac: + javac_bin_dir = os.path.dirname(javac) + env.AppendENVPath('PATH', javac_bin_dir) + + env['JAVAINCLUDES'] = get_java_include_paths(env, javac, version) + + env['JAVAC'] = 'javac' env['JAVACFLAGS'] = SCons.Util.CLVar('') env['JAVABOOTCLASSPATH'] = [] diff --git a/src/engine/SCons/Tool/javac.xml b/src/engine/SCons/Tool/javac.xml index 543d669..97ec7d2 100644 --- a/src/engine/SCons/Tool/javac.xml +++ b/src/engine/SCons/Tool/javac.xml @@ -7,279 +7,298 @@ See its __doc__ string for a discussion of the format. --> <!DOCTYPE sconsdoc [ -<!ENTITY % scons SYSTEM '../../../../doc/scons.mod'> -%scons; -<!ENTITY % builders-mod SYSTEM '../../../../doc/generated/builders.mod'> -%builders-mod; -<!ENTITY % functions-mod SYSTEM '../../../../doc/generated/functions.mod'> -%functions-mod; -<!ENTITY % tools-mod SYSTEM '../../../../doc/generated/tools.mod'> -%tools-mod; -<!ENTITY % variables-mod SYSTEM '../../../../doc/generated/variables.mod'> -%variables-mod; -]> + <!ENTITY % scons SYSTEM '../../../../doc/scons.mod'> + %scons; + <!ENTITY % builders-mod SYSTEM '../../../../doc/generated/builders.mod'> + %builders-mod; + <!ENTITY % functions-mod SYSTEM '../../../../doc/generated/functions.mod'> + %functions-mod; + <!ENTITY % tools-mod SYSTEM '../../../../doc/generated/tools.mod'> + %tools-mod; + <!ENTITY % variables-mod SYSTEM '../../../../doc/generated/variables.mod'> + %variables-mod; + ]> <sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd"> -<tool name="javac"> -<summary> -<para> -Sets construction variables for the &javac; compiler. -</para> -</summary> -<sets> -<item>JAVAC</item> -<item>JAVACFLAGS</item> -<item>JAVACCOM</item> -<item>JAVACLASSSUFFIX</item> -<item>JAVASUFFIX</item> -<item>JAVABOOTCLASSPATH</item> -<item>JAVACLASSPATH</item> -<item>JAVASOURCEPATH</item> -</sets> -<uses> -<item>JAVACCOMSTR</item> -</uses> -</tool> + <tool name="javac"> + <summary> + <para> + Sets construction variables for the &javac; compiler. + </para> + </summary> + <sets> + <item>JAVAC</item> + <item>JAVACFLAGS</item> + <item>JAVACCOM</item> + <item>JAVACLASSSUFFIX</item> + <item>JAVAINCLUDES</item> + <item>JAVASUFFIX</item> + <item>JAVABOOTCLASSPATH</item> + <item>JAVACLASSPATH</item> + <item>JAVASOURCEPATH</item> + </sets> + <uses> + <item>JAVACCOMSTR</item> + </uses> + </tool> -<builder name="Java"> -<summary> -<para> -Builds one or more Java class files. -The sources may be any combination of explicit -<filename>.java</filename> files, -or directory trees which will be scanned -for <filename>.java</filename> files. -</para> + <builder name="Java"> + <summary> + <para> + Builds one or more Java class files. + The sources may be any combination of explicit + <filename>.java</filename> + files, + or directory trees which will be scanned + for <filename>.java</filename> files. + </para> -<para> -SCons will parse each source <filename>.java</filename> file -to find the classes -(including inner classes) -defined within that file, -and from that figure out the -target <filename>.class</filename> files that will be created. -The class files will be placed underneath -the specified target directory. -</para> + <para> + SCons will parse each source <filename>.java</filename> file + to find the classes + (including inner classes) + defined within that file, + and from that figure out the + target <filename>.class</filename> files that will be created. + The class files will be placed underneath + the specified target directory. + </para> -<para> -SCons will also search each Java file -for the Java package name, -which it assumes can be found on a line -beginning with the string -<literal>package</literal> -in the first column; -the resulting <filename>.class</filename> files -will be placed in a directory reflecting -the specified package name. -For example, -the file -<filename>Foo.java</filename> -defining a single public -<classname>Foo</classname> -class and -containing a package name of -<classname>sub.dir</classname> -will generate a corresponding -<filename>sub/dir/Foo.class</filename> -class file. -</para> + <para> + SCons will also search each Java file + for the Java package name, + which it assumes can be found on a line + beginning with the string + <literal>package</literal> + in the first column; + the resulting <filename>.class</filename> files + will be placed in a directory reflecting + the specified package name. + For example, + the file + <filename>Foo.java</filename> + defining a single public + <classname>Foo</classname> + class and + containing a package name of + <classname>sub.dir</classname> + will generate a corresponding + <filename>sub/dir/Foo.class</filename> + class file. + </para> -<para> -Examples: -</para> + <para> + Examples: + </para> -<example_commands> -env.Java(target = 'classes', source = 'src') -env.Java(target = 'classes', source = ['src1', 'src2']) -env.Java(target = 'classes', source = ['File1.java', 'File2.java']) -</example_commands> + <example_commands> + env.Java(target = 'classes', source = 'src') + env.Java(target = 'classes', source = ['src1', 'src2']) + env.Java(target = 'classes', source = ['File1.java', 'File2.java']) + </example_commands> -<para> -Java source files can use the native encoding for the underlying OS. -Since SCons compiles in simple ASCII mode by default, -the compiler will generate warnings about unmappable characters, -which may lead to errors as the file is processed further. -In this case, the user must specify the <literal>LANG</literal> -environment variable to tell the compiler what encoding is used. -For portibility, it's best if the encoding is hard-coded -so that the compile will work if it is done on a system -with a different encoding. -</para> + <para> + Java source files can use the native encoding for the underlying OS. + Since SCons compiles in simple ASCII mode by default, + the compiler will generate warnings about unmappable characters, + which may lead to errors as the file is processed further. + In this case, the user must specify the + <literal>LANG</literal> + environment variable to tell the compiler what encoding is used. + For portibility, it's best if the encoding is hard-coded + so that the compile will work if it is done on a system + with a different encoding. + </para> -<example_commands> -env = Environment() -env['ENV']['LANG'] = 'en_GB.UTF-8' -</example_commands> -</summary> -</builder> + <example_commands> + env = Environment() + env['ENV']['LANG'] = 'en_GB.UTF-8' + </example_commands> + </summary> + </builder> -<cvar name="JAVABOOTCLASSPATH"> -<summary> -<para> -Specifies the list of directories that -will be added to the -&javac; command line -via the <option>-bootclasspath</option> option. -The individual directory names will be -separated by the operating system's path separate character -(<filename>:</filename> on UNIX/Linux/POSIX, -<filename>;</filename> on Windows). -</para> -</summary> -</cvar> + <cvar name="JAVABOOTCLASSPATH"> + <summary> + <para> + Specifies the list of directories that + will be added to the + &javac; command line + via the <option>-bootclasspath</option> option. + The individual directory names will be + separated by the operating system's path separate character + (<filename>:</filename> on UNIX/Linux/POSIX, + <filename>;</filename> + on Windows). + </para> + </summary> + </cvar> -<cvar name="JAVAC"> -<summary> -<para> -The Java compiler. -</para> -</summary> -</cvar> + <cvar name="JAVAINCLUDES"> + <summary> + <para> + Include path for Java header files (such as jni.h) + </para> + </summary> + </cvar> -<cvar name="JAVACCOM"> -<summary> -<para> -The command line used to compile a directory tree containing -Java source files to -corresponding Java class files. -Any options specified in the &cv-link-JAVACFLAGS; construction variable -are included on this command line. -</para> -</summary> -</cvar> + <cvar name="JAVAC"> + <summary> + <para> + The Java compiler. + </para> + </summary> + </cvar> -<cvar name="JAVACCOMSTR"> -<summary> -<para> -The string displayed when compiling -a directory tree of Java source files to -corresponding Java class files. -If this is not set, then &cv-link-JAVACCOM; (the command line) is displayed. -</para> + <cvar name="JAVACCOM"> + <summary> + <para> + The command line used to compile a directory tree containing + Java source files to + corresponding Java class files. + Any options specified in the &cv-link-JAVACFLAGS; construction variable + are included on this command line. + </para> + </summary> + </cvar> -<example_commands> -env = Environment(JAVACCOMSTR = "Compiling class files $TARGETS from $SOURCES") -</example_commands> -</summary> -</cvar> + <cvar name="JAVACCOMSTR"> + <summary> + <para> + The string displayed when compiling + a directory tree of Java source files to + corresponding Java class files. + If this is not set, then &cv-link-JAVACCOM; (the command line) is displayed. + </para> -<cvar name="JAVACFLAGS"> -<summary> -<para> -General options that are passed to the Java compiler. -</para> -</summary> -</cvar> + <example_commands> + env = Environment(JAVACCOMSTR = "Compiling class files $TARGETS from $SOURCES") + </example_commands> + </summary> + </cvar> -<cvar name="JAVACLASSDIR"> -<summary> -<para> -The directory in which Java class files may be found. -This is stripped from the beginning of any Java .class -file names supplied to the -<literal>JavaH</literal> -builder. -</para> -</summary> -</cvar> + <cvar name="JAVACFLAGS"> + <summary> + <para> + General options that are passed to the Java compiler. + </para> + </summary> + </cvar> -<cvar name="JAVACLASSPATH"> -<summary> -<para> -Specifies the list of directories that -will be searched for Java -<filename>.class</filename> file. -The directories in this list will be added to the -&javac; and &javah; command lines -via the <option>-classpath</option> option. -The individual directory names will be -separated by the operating system's path separate character -(<filename>:</filename> on UNIX/Linux/POSIX, -<filename>;</filename> on Windows). -</para> + <cvar name="JAVACLASSDIR"> + <summary> + <para> + The directory in which Java class files may be found. + This is stripped from the beginning of any Java .class + file names supplied to the + <literal>JavaH</literal> + builder. + </para> + </summary> + </cvar> -<para> -Note that this currently just adds the specified -directory via the <option>-classpath</option> option. -&SCons; does not currently search the -&cv-JAVACLASSPATH; directories for dependency -<filename>.class</filename> files. -</para> -</summary> -</cvar> + <cvar name="JAVACLASSPATH"> + <summary> + <para> + Specifies the list of directories that + will be searched for Java + <filename>.class</filename> + file. + The directories in this list will be added to the + &javac; and &javah; command lines + via the <option>-classpath</option> option. + The individual directory names will be + separated by the operating system's path separate character + (<filename>:</filename> on UNIX/Linux/POSIX, + <filename>;</filename> + on Windows). + </para> -<cvar name="JAVACLASSSUFFIX"> -<summary> -<para> -The suffix for Java class files; -<filename>.class</filename> -by default. -</para> -</summary> -</cvar> + <para> + Note that this currently just adds the specified + directory via the <option>-classpath</option> option. + &SCons; does not currently search the + &cv-JAVACLASSPATH; directories for dependency + <filename>.class</filename> + files. + </para> + </summary> + </cvar> -<cvar name="JAVASOURCEPATH"> -<summary> -<para> -Specifies the list of directories that -will be searched for input -<filename>.java</filename> file. -The directories in this list will be added to the -&javac; command line -via the <option>-sourcepath</option> option. -The individual directory names will be -separated by the operating system's path separate character -(<filename>:</filename> on UNIX/Linux/POSIX, -<filename>;</filename> on Windows). -</para> + <cvar name="JAVACLASSSUFFIX"> + <summary> + <para> + The suffix for Java class files; + <filename>.class</filename> + by default. + </para> + </summary> + </cvar> -<para> -Note that this currently just adds the specified -directory via the <option>-sourcepath</option> option. -&SCons; does not currently search the -&cv-JAVASOURCEPATH; directories for dependency -<filename>.java</filename> files. -</para> -</summary> -</cvar> + <cvar name="JAVASOURCEPATH"> + <summary> + <para> + Specifies the list of directories that + will be searched for input + <filename>.java</filename> + file. + The directories in this list will be added to the + &javac; command line + via the <option>-sourcepath</option> option. + The individual directory names will be + separated by the operating system's path separate character + (<filename>:</filename> on UNIX/Linux/POSIX, + <filename>;</filename> + on Windows). + </para> -<cvar name="JAVASUFFIX"> -<summary> -<para> -The suffix for Java files; -<filename>.java</filename> -by default. -</para> -</summary> -</cvar> + <para> + Note that this currently just adds the specified + directory via the <option>-sourcepath</option> option. + &SCons; does not currently search the + &cv-JAVASOURCEPATH; directories for dependency + <filename>.java</filename> + files. + </para> + </summary> + </cvar> -<cvar name="JAVAVERSION"> -<summary> -<para> -Specifies the Java version being used by the &b-Java; builder. -This is <emphasis>not</emphasis> currently used to select one -version of the Java compiler vs. another. -Instead, you should set this to specify the version of Java -supported by your &javac; compiler. -The default is <literal>1.4</literal>. -</para> + <cvar name="JAVASUFFIX"> + <summary> + <para> + The suffix for Java files; + <filename>.java</filename> + by default. + </para> + </summary> + </cvar> -<para> -This is sometimes necessary because -Java 1.5 changed the file names that are created -for nested anonymous inner classes, -which can cause a mismatch with the files -that &SCons; expects will be generated by the &javac; compiler. -Setting &cv-JAVAVERSION; to <literal>1.5</literal> -(or <literal>1.6</literal>, as appropriate) -can make &SCons; realize that a Java 1.5 or 1.6 -build is actually up to date. -</para> -</summary> -</cvar> + <cvar name="JAVAVERSION"> + <summary> + <para> + Specifies the Java version being used by the &b-Java; builder. + This is <emphasis>not</emphasis> currently used to select one + version of the Java compiler vs. another. + Instead, you should set this to specify the version of Java + supported by your &javac; compiler. + The default is <literal>1.4</literal>. + </para> + + <para> + This is sometimes necessary because + Java 1.5 changed the file names that are created + for nested anonymous inner classes, + which can cause a mismatch with the files + that &SCons; expects will be generated by the &javac; compiler. + Setting &cv-JAVAVERSION; to + <literal>1.5</literal> + (or <literal>1.6</literal>, as appropriate) + can make &SCons; realize that a Java 1.5 or 1.6 + build is actually up to date. + </para> + </summary> + </cvar> </sconsdoc> diff --git a/src/engine/SCons/Tool/javah.py b/src/engine/SCons/Tool/javah.py index c092273..f514479 100644 --- a/src/engine/SCons/Tool/javah.py +++ b/src/engine/SCons/Tool/javah.py @@ -40,6 +40,8 @@ import SCons.Builder import SCons.Node.FS import SCons.Tool.javac import SCons.Util +from SCons.Tool.JavaCommon import get_java_install_dirs + def emit_java_headers(target, source, env): """Create and return lists of Java stub header files that will @@ -120,6 +122,14 @@ def generate(env): java_javah = SCons.Tool.CreateJavaHBuilder(env) java_javah.emitter = emit_java_headers + if env['PLATFORM'] == 'win32': + # Ensure that we have a proper path for clang + javah = SCons.Tool.find_program_path(env, 'javah', + default_paths=get_java_install_dirs(env['PLATFORM'])) + if javah: + javah_bin_dir = os.path.dirname(javah) + env.AppendENVPath('PATH', javah_bin_dir) + env['_JAVAHOUTFLAG'] = JavaHOutFlagGenerator env['JAVAH'] = 'javah' env['JAVAHFLAGS'] = SCons.Util.CLVar('') diff --git a/src/engine/SCons/Tool/rmic.py b/src/engine/SCons/Tool/rmic.py index 4d1bd28..173ef5f 100644 --- a/src/engine/SCons/Tool/rmic.py +++ b/src/engine/SCons/Tool/rmic.py @@ -40,6 +40,9 @@ import SCons.Builder import SCons.Node.FS import SCons.Util +from SCons.Tool.JavaCommon import get_java_install_dirs + + def emit_rmic_classes(target, source, env): """Create and return lists of Java RMI stub and skeleton class files to be created from a set of class files. @@ -105,6 +108,18 @@ def generate(env): """Add Builders and construction variables for rmic to an Environment.""" env['BUILDERS']['RMIC'] = RMICBuilder + if env['PLATFORM'] == 'win32': + version = env.get('JAVAVERSION', None) + default_paths=get_java_install_dirs(env['PLATFORM'], version=version) + + # Ensure that we have a proper path for rmic + rmic = SCons.Tool.find_program_path(env, 'rmic', default_paths=default_paths) + + # print("RMIC: %s"%rmic) + if rmic: + rmic_bin_dir = os.path.dirname(rmic) + env.AppendENVPath('PATH', rmic_bin_dir) + env['RMIC'] = 'rmic' env['RMICFLAGS'] = SCons.Util.CLVar('') env['RMICCOM'] = '$RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} -classpath ${SOURCE.attributes.java_classdir} ${SOURCES.attributes.java_classname}' diff --git a/test/Java/JAR.py b/test/Java/JAR.py index faf01a3..1eae9eb 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -26,6 +26,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import TestSCons +import sys _python_ = TestSCons._python_ @@ -119,22 +120,13 @@ test.run(arguments='classes.jar') test.must_match('classes.jar', 'cvfm classes.jar foo.mf -C testdir bar.class\n', mode='r') - - -where_javac, java_version = test.java_where_javac() -where_jar = test.java_where_jar() - - - test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ DefaultEnvironment(tools=[]) -foo = Environment(tools = ['javac', 'jar'], - JAVAC = r'%(where_javac)s', - JAR = r'%(where_jar)s') -jar = foo.Dictionary('JAR') -bar = foo.Clone(JAR = r'%(_python_)s wrapper_with_args.py ' + jar) +foo = Environment(tools = ['javac', 'jar']) +# jar = foo.Dictionary('JAR') +bar = foo.Clone(JAR = r'%(_python_)s wrapper_with_args.py jar') foo.Java(target = 'classes', source = 'com/sub/foo') bar.Java(target = 'classes', source = 'com/sub/bar') foo.Jar(target = 'foo', source = 'classes/com/sub/foo') @@ -232,7 +224,7 @@ public class Example6 test.run(arguments = '.') -expected_wrapper_out = "wrapper_with_args.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" +expected_wrapper_out = "wrapper_with_args.py jar cf bar.jar classes/com/sub/bar\n" expected_wrapper_out = expected_wrapper_out.replace('/', os.sep) test.must_match('wrapper.out', expected_wrapper_out % locals(), mode='r') @@ -310,14 +302,16 @@ public class JavaFile3 } """) -test.run(chdir='testdir2') # check the output and make sure the java files got converted to classes -if("jar cf foo.jar " + - "-C com/javasource/JavaFile1 com/javasource/JavaFile1.class " + - "-C com/javasource/JavaFile2 com/javasource/JavaFile2.class " + - "-C com/javasource/JavaFile3 com/javasource/JavaFile3.class" not in test.stdout()): - test.fail_test() +# use regex . for dirsep so this will work on both windows and other platforms. +expect = ".*jar cf foo.jar -C com.javasource.JavaFile1 com.javasource.JavaFile1.class -C com.javasource.JavaFile2 com.javasource.JavaFile2.class -C com.javasource.JavaFile3 com.javasource.JavaFile3.class.*" + +test.run(chdir='testdir2', + match=TestSCons.match_re_dotall, + stdout = expect) + + #test single target jar test.must_exist(['testdir2','foobar.jar']) diff --git a/test/Java/JARCHDIR.py b/test/Java/JARCHDIR.py index d574fe7..e602fad 100644 --- a/test/Java/JARCHDIR.py +++ b/test/Java/JARCHDIR.py @@ -39,16 +39,10 @@ import TestSCons test = TestSCons.TestSCons() -where_javac, java_version = test.java_where_javac() -where_jar = test.java_where_jar() - - - test.write('SConstruct', """ +DefaultEnvironment(tools=[]) dir = 'dist' env = Environment(tools = ['javac', 'jar'], - JAVAC = r'%(where_javac)s', - JAR = r'%(where_jar)s', JARCHDIR = dir) bin = env.Java(dir, Dir('./')) jar = env.Jar(File('c.jar', dir), bin) @@ -58,8 +52,9 @@ jar = env.Jar(File('c.jar', dir), bin) env = env.Clone(JARCHDIR = '.') inner = env.Jar('inner.jar', 'Inner$$Class.class') -target_env = env.Clone(JARCHDIR = '${TARGET.dir}') -target_env.Jar('out/t.jar', 'in/t.class') +# Commented out as this logic doesn't work as is. +# target_env = env.Clone(JARCHDIR = '${TARGET.dir}') +# target_env.Jar('out/t.jar', 'in/t.class') source_env = env.Clone(JARCHDIR = '${SOURCE.dir}') source_env.Jar('out/s.jar', 'in/s.class') @@ -67,8 +62,6 @@ source_env.Jar('out/s.jar', 'in/s.class') Default(bin, jar, inner) """ % locals()) - - test.subdir('in') test.write('a.java', """\ @@ -98,21 +91,19 @@ test.write(['in', 's.class'], "s.class\n") # don't blow up (i.e., validates that we pass the right arguments to # env.subst() in the code that handle jar). -p = test.workpath('out') -for d in test.workpath('in').split(os.sep): - p = p + d - test.subdir(p) - p = p + os.sep +# p = test.workpath('out') +# for d in test.workpath('in').split(os.sep): +# p = p + d +# test.subdir(p) +# p = p + os.sep -test.write([p, 't.class'], "t.class\n") +# test.write([p, 't.class'], "t.class\n") test.write(['in', 't.class'], "t.class\n") test.write('Inner$Class.class', "Inner$Class.class\n") test.run(arguments = '.') - - test.pass_test() # Local Variables: diff --git a/test/Java/JARFLAGS.py b/test/Java/JARFLAGS.py index c0ae627..e89d02b 100644 --- a/test/Java/JARFLAGS.py +++ b/test/Java/JARFLAGS.py @@ -32,15 +32,8 @@ test = TestSCons.TestSCons() test.subdir('src') -where_javac, java_version = test.java_where_javac() -where_jar = test.java_where_jar() - - - test.write('SConstruct', """ env = Environment(tools = ['javac', 'jar'], - JAVAC = r'%(where_javac)s', - JAR = r'%(where_jar)s', JARFLAGS = 'cvf') env['JARFLAGS'] = 'cvf' class_files = env.Java(target = 'classes', source = 'src') @@ -62,13 +55,12 @@ public class Example1 """) expect = test.wrap_stdout("""\ -%(where_javac)s -d classes -sourcepath src src/Example1\.java -%(where_jar)s cvf test.jar -C classes src/Example1\.class +javac -d classes -sourcepath src src.Example1\.java +jar cvf test.jar -C classes src.Example1\.class .* -adding: src/Example1\.class.* +adding: src.Example1\.class.* """ % locals()) -expect = expect.replace('/', os.sep) test.run(arguments = '.', match=TestSCons.match_re_dotall, diff --git a/test/Java/JAVABOOTCLASSPATH.py b/test/Java/JAVABOOTCLASSPATH.py index 6913c6a..196cc54 100644 --- a/test/Java/JAVABOOTCLASSPATH.py +++ b/test/Java/JAVABOOTCLASSPATH.py @@ -42,7 +42,6 @@ where_javah = test.java_where_javah() test.write('SConstruct', """ env = Environment(tools = ['javac', 'javah'], - JAVAC = r'%(where_javac)s', JAVABOOTCLASSPATH = ['dir1', 'dir2']) j1 = env.Java(target = 'class', source = 'com/Example1.java') j2 = env.Java(target = 'class', source = 'com/Example2.java') @@ -85,11 +84,11 @@ public class Example2 bootclasspath = os.pathsep.join(['dir1', 'dir2']) expect = """\ -%(where_javac)s -bootclasspath %(bootclasspath)s -d class -sourcepath com com/Example1.java -%(where_javac)s -bootclasspath %(bootclasspath)s -d class -sourcepath com com/Example2.java +javac -bootclasspath %(bootclasspath)s -d class -sourcepath com com.Example1\.java +javac -bootclasspath %(bootclasspath)s -d class -sourcepath com com.Example2\.java """ % locals() -test.run(arguments = '-Q -n .', stdout = expect) +test.run(arguments = '-Q -n .', stdout = expect, match=TestSCons.match_re) test.pass_test() diff --git a/test/Java/JAVACFLAGS.py b/test/Java/JAVACFLAGS.py index 6afd1b9..28c58c1 100644 --- a/test/Java/JAVACFLAGS.py +++ b/test/Java/JAVACFLAGS.py @@ -36,7 +36,6 @@ test.subdir('src') test.write('SConstruct', """ env = Environment(tools = ['javac'], - JAVAC = r'%(where_javac)s', JAVACFLAGS = '-O') env.Java(target = 'classes', source = 'src') """ % locals()) @@ -55,7 +54,7 @@ public class Example1 } """) -expected_wrapper_out = "%(where_javac)s -O -d classes -sourcepath src src/Example1.java\n" +expected_wrapper_out = "javac -O -d classes -sourcepath src src/Example1.java\n" expected_wrapper_out = expected_wrapper_out.replace('/', os.sep) test.run(arguments = '.', stdout = test.wrap_stdout(expected_wrapper_out % locals())) diff --git a/test/Java/JAVACLASSPATH.py b/test/Java/JAVACLASSPATH.py index bc3bb21..fb2b33f 100644 --- a/test/Java/JAVACLASSPATH.py +++ b/test/Java/JAVACLASSPATH.py @@ -40,17 +40,15 @@ where_javac, java_version = test.java_where_javac() where_javah = test.java_where_javah() test.write('SConstruct', """ -env = Environment(tools = ['javac', 'javah'], - JAVAC = r'%(where_javac)s', - JAVAH = r'%(where_javah)s') -j1 = env.Java(target = 'class1', source = 'com1/Example1.java') -j2 = env.Java(target = 'class2', source = 'com2/Example2.java') +env = Environment(tools = ['javac', 'javah']) +j1 = env.Java(target = 'class1', source = 'com.1/Example1.java') +j2 = env.Java(target = 'class2', source = 'com.2/Example2.java') env.JavaH(target = 'outdir', source = [j1, j2], JAVACLASSPATH = 'class2') """ % locals()) -test.subdir('com1', 'com2') +test.subdir('com.1', 'com.2') -test.write(['com1', 'Example1.java'], """\ +test.write(['com.1', 'Example1.java'], """\ package com; public class Example1 @@ -64,7 +62,7 @@ public class Example1 } """) -test.write(['com2', 'Example2.java'], """\ +test.write(['com.2', 'Example2.java'], """\ package com; public class Example2 diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index f07ebb9..c7ac334 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -108,9 +108,7 @@ if test.javac_is_gcj: test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ -foo = Environment(tools = ['javac', 'javah', 'install'], - JAVAC = r'%(where_javac)s', - JAVAH = r'%(where_javah)s') +foo = Environment(tools = ['javac', 'javah', 'install']) jv = %(java_version)s if jv: foo['JAVAVERSION'] = jv @@ -282,7 +280,7 @@ class Private { test.run(arguments = '.') -test.must_match('wrapper.out', "wrapper_with_args.py %(where_javah)s -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals(), +test.must_match('wrapper.out', "wrapper_with_args.py javah -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals(), mode='r') test.must_exist(['outdir1', 'com_sub_foo_Example1.h']) diff --git a/test/Java/JAVASOURCEPATH.py b/test/Java/JAVASOURCEPATH.py index 5f19004..8e7b762 100644 --- a/test/Java/JAVASOURCEPATH.py +++ b/test/Java/JAVASOURCEPATH.py @@ -39,8 +39,7 @@ test = TestSCons.TestSCons() where_javac, java_version = test.java_where_javac() test.write('SConstruct', """ -env = Environment(tools = ['javac', 'javah'], - JAVAC = r'%(where_javac)s') +env = Environment(tools = ['javac', 'javah']) bar = env.Java(target = 'bar/classes', source = 'bar/src/TestBar.java', JAVASOURCEPATH = ['foo/src']) diff --git a/test/Java/Java-1.6.py b/test/Java/Java-1.6.py index 04a9155..7bda650 100644 --- a/test/Java/Java-1.6.py +++ b/test/Java/Java-1.6.py @@ -35,258 +35,19 @@ import TestSCons _python_ = TestSCons._python_ test = TestSCons.TestSCons() +test.dir_fixture('java_version_image') -where_javac, java_version = test.java_where_javac('1.6') +version = '1.6' +where_javac, java_version = test.java_where_javac(version) +javac_path=os.path.dirname(where_javac) +# test.verbose_set(1) +if ' ' in javac_path: + javac_path ='"%s"'%javac_path +java_arguments=["--javac_path=%s"%javac_path,"--java_version=%s"%version] -test.write('SConstruct', """ -env = Environment(tools = ['javac'], - JAVAVERSION = '1.6', - JAVAC = r'%(where_javac)s') -env.Java(target = 'class1', source = 'com/sub/foo') -env.Java(target = 'class2', source = 'com/sub/bar') -env.Java(target = 'class3', source = ['src1', 'src2']) -env.Java(target = 'class4', source = ['src4']) -env.Java(target = 'class5', source = ['src5']) -env.Java(target = 'class6', source = ['src6']) -""" % locals()) - -test.subdir('com', - ['com', 'sub'], - ['com', 'sub', 'foo'], - ['com', 'sub', 'bar'], - 'src1', - 'src2', - 'src4', - 'src5', - 'src6') - -test.write(['com', 'sub', 'foo', 'Example1.java'], """\ -package com.sub.foo; - -public class Example1 -{ - - public static void main(String[] args) - { - - } - -} -""") - -test.write(['com', 'sub', 'foo', 'Example2.java'], """\ -package com.other; - -public class Example2 -{ - - public static void main(String[] args) - { - - } - -} -""") - -test.write(['com', 'sub', 'foo', 'Example3.java'], """\ -package com.sub.foo; - -public class Example3 -{ - - public static void main(String[] args) - { - - } - -} -""") - -test.write(['com', 'sub', 'bar', 'Example4.java'], """\ -package com.sub.bar; - -public class Example4 -{ - - public static void main(String[] args) - { - - } - -} -""") - -test.write(['com', 'sub', 'bar', 'Example5.java'], """\ -package com.other; - -public class Example5 -{ - - public static void main(String[] args) - { - - } - -} -""") - -test.write(['com', 'sub', 'bar', 'Example6.java'], """\ -package com.sub.bar; - -public class Example6 -{ - - public static void main(String[] args) - { - - } - -} -""") - -test.write(['src1', 'Example7.java'], """\ -public class Example7 -{ - - public static void main(String[] args) - { - - } - -} -""") - -# Acid-test file for parsing inner Java classes, courtesy Chad Austin. -test.write(['src2', 'Test.java'], """\ -class Empty { -} - -interface Listener { - public void execute(); -} - -public -class -Test { - class Inner { - void go() { - use(new Listener() { - public void execute() { - System.out.println("In Inner"); - } - }); - } - String s1 = "class A"; - String s2 = "new Listener() { }"; - /* class B */ - /* new Listener() { } */ - } - - public static void main(String[] args) { - new Test().run(); - } - - void run() { - use(new Listener() { - public void execute() { - use(new Listener( ) { - public void execute() { - System.out.println("Inside execute()"); - } - }); - } - }); - - new Inner().go(); - } - - void use(Listener l) { - l.execute(); - } -} - -class Private { - void run() { - new Listener() { - public void execute() { - } - }; - } -} -""") - -# Testing nested anonymous inner classes, courtesy Brandon Mansfield. -test.write(['src4', 'NestedExample.java'], """\ -// import java.util.*; - -public class NestedExample -{ - public NestedExample() - { - new Thread() { - public void start() - { - new Thread() { - public void start() - { - try {Thread.sleep(200);} - catch (Exception e) {} - } - }; - while (true) - { - try {Thread.sleep(200);} - catch (Exception e) {} - } - } - }; - } - - - public static void main(String argv[]) - { - new NestedExample(); - } -} -""") - -# Test not finding an anonymous class when the second token after a -# "new" is a closing brace. This duplicates a test from the unit tests, -# but lets us make sure that we correctly determine that everything is -# up-to-date after the build. -test.write(['src5', 'TestSCons.java'], """\ -class TestSCons { - public static void main(String[] args) { - Foo[] fooArray = new Foo[] { new Foo() }; - } -} - -class Foo { } -""") - -# Test private inner class instantiation, courtesy Tilo Prutz: -# https://github.com/SCons/scons/issues/1594 -test.write(['src6', 'TestSCons.java'], """\ -class test -{ - test() - { - super(); - new inner(); - } - - static class inner - { - private inner() {} - } -} -""") - - - -test.run(arguments = '.') +test.run(arguments = ['.']+java_arguments) expect_1 = [ test.workpath('class1', 'com', 'other', 'Example2.class'), @@ -362,9 +123,10 @@ classes_must_match('class6', expect_6) test.fail_test(failed) -test.up_to_date(options='--debug=explain', arguments = '.') +test.up_to_date(options=["--debug=explain"]+java_arguments, + arguments = '.') -test.run(arguments = '-c .') +test.run(arguments = ['-c','.']+java_arguments) classes_must_not_exist('class1', expect_1) classes_must_not_exist('class2', expect_2) diff --git a/test/Java/Java-1.8.py b/test/Java/Java-1.8.py new file mode 100644 index 0000000..8e85889 --- /dev/null +++ b/test/Java/Java-1.8.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test Java compilation with a live Java 1.8 "javac" compiler. +""" + +import os +import sys + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() +test.dir_fixture('java_version_image') + +version = '1.8' +where_javac, java_version = test.java_where_javac(version) +javac_path=os.path.dirname(where_javac) + +# test.verbose_set(1) + +if ' ' in javac_path: + javac_path ='"%s"'%javac_path +java_arguments=["--javac_path=%s"%javac_path,"--java_version=%s"%version] + +test.run(arguments = ['.']+java_arguments) + +expect_1 = [ + test.workpath('class1', 'com', 'other', 'Example2.class'), + test.workpath('class1', 'com', 'sub', 'foo', 'Example1.class'), + test.workpath('class1', 'com', 'sub', 'foo', 'Example3.class'), +] + +expect_2 = [ + test.workpath('class2', 'com', 'other', 'Example5.class'), + test.workpath('class2', 'com', 'sub', 'bar', 'Example4.class'), + test.workpath('class2', 'com', 'sub', 'bar', 'Example6.class'), +] + +expect_3 = [ + test.workpath('class3', 'Empty.class'), + test.workpath('class3', 'Example7.class'), + test.workpath('class3', 'Listener.class'), + test.workpath('class3', 'Private$1.class'), + test.workpath('class3', 'Private.class'), + test.workpath('class3', 'Test$1$1.class'), + test.workpath('class3', 'Test$1.class'), + test.workpath('class3', 'Test$Inner$1.class'), + test.workpath('class3', 'Test$Inner.class'), + test.workpath('class3', 'Test.class'), +] + +expect_4 = [ + test.workpath('class4', 'NestedExample$1$1.class'), + test.workpath('class4', 'NestedExample$1.class'), + test.workpath('class4', 'NestedExample.class'), +] + +expect_5 = [ + test.workpath('class5', 'Foo.class'), + test.workpath('class5', 'TestSCons.class'), +] + +expect_6 = [ + test.workpath('class6', 'test$1.class'), + test.workpath('class6', 'test$inner.class'), + test.workpath('class6', 'test.class'), +] + +failed = None + +def classes_must_match(dir, expect): + global failed + got = test.java_get_class_files(test.workpath(dir)) + if expect != got: + sys.stderr.write("Expected the following class files in '%s':\n" % dir) + for c in expect: + sys.stderr.write(' %s\n' % c) + sys.stderr.write("Got the following class files in '%s':\n" % dir) + for c in got: + sys.stderr.write(' %s\n' % c) + failed = 1 + +def classes_must_not_exist(dir, expect): + global failed + present = [path for path in expect if os.path.exists(path)] + if present: + sys.stderr.write("Found the following unexpected class files in '%s' after cleaning:\n" % dir) + for c in present: + sys.stderr.write(' %s\n' % c) + failed = 1 + +classes_must_match('class1', expect_1) +classes_must_match('class2', expect_2) +classes_must_match('class3', expect_3) +classes_must_match('class4', expect_4) +classes_must_match('class5', expect_5) +classes_must_match('class6', expect_6) + +test.fail_test(failed) + +test.up_to_date(options=["--debug=explain"]+java_arguments, + arguments = '.') + +test.run(arguments = ['-c','.']+java_arguments) + +classes_must_not_exist('class1', expect_1) +classes_must_not_exist('class2', expect_2) +classes_must_not_exist('class3', expect_3) +classes_must_not_exist('class4', expect_4) +classes_must_not_exist('class5', expect_5) +# This test case should pass, but doesn't. +# The expect_6 list contains the class files that the Java compiler +# actually creates, apparently because of the "private" instantiation +# of the "inner" class. Our parser doesn't currently detect this, so +# it doesn't know to remove that generated class file. +#classes_must_not_exist('class6', expect_6) + +test.fail_test(failed) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py index 19e799e..021f666 100644 --- a/test/Java/RMIC.py +++ b/test/Java/RMIC.py @@ -32,6 +32,8 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() +# test.verbose_set(1) + test.write('myrmic.py', r""" import os import sys @@ -74,7 +76,6 @@ test.run(arguments = '.', stderr = None) test.must_match(['outdir', 'test1.class'], "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): - test.write('SConstruct', """\ env = Environment(tools = ['rmic'], RMIC = r'%(_python_)s myrmic.py') @@ -103,6 +104,12 @@ if java_version.count('.') == 1: curver = (int(major), int(minor)) except: pass +elif java_version.count('.') == 0: + # java 11? + try: + curver = (int(java_version), 0) + except: + pass # Check the version of the found Java compiler. # If it's 1.8 or higher, we skip the further RMIC test @@ -118,9 +125,7 @@ if curver < (1, 8): test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ -foo = Environment(tools = ['javac', 'rmic'], - JAVAC = r'%(where_javac)s', - RMIC = r'%(where_rmic)s') +foo = Environment(tools = ['javac', 'rmic']) foo.Java(target = 'class1', source = 'com/sub/foo') foo.RMIC(target = 'outdir1', source = ['class1/com/sub/foo/Example1.class', @@ -161,7 +166,7 @@ package com.sub.foo; import java.rmi.Naming; import java.rmi.RemoteException; -import java.rmi.RMISecurityManager; +import java.lang.SecurityManager; import java.rmi.server.UnicastRemoteObject; public class Example1 extends UnicastRemoteObject implements Hello { @@ -178,7 +183,7 @@ public class Example1 extends UnicastRemoteObject implements Hello { public static void main(String args[]) { if (System.getSecurityManager() == null) { - System.setSecurityManager(new RMISecurityManager()); + System.setSecurityManager(new SecurityManager()); } try { @@ -200,7 +205,7 @@ package com.sub.foo; import java.rmi.Naming; import java.rmi.RemoteException; -import java.rmi.RMISecurityManager; +import java.lang.SecurityManager; import java.rmi.server.UnicastRemoteObject; public class Example2 extends UnicastRemoteObject implements Hello { @@ -217,7 +222,7 @@ public class Example2 extends UnicastRemoteObject implements Hello { public static void main(String args[]) { if (System.getSecurityManager() == null) { - System.setSecurityManager(new RMISecurityManager()); + System.setSecurityManager(new SecurityManager()); } try { @@ -250,7 +255,7 @@ package com.sub.bar; import java.rmi.Naming; import java.rmi.RemoteException; -import java.rmi.RMISecurityManager; +import java.lang.SecurityManager; import java.rmi.server.UnicastRemoteObject; public class Example3 extends UnicastRemoteObject implements Hello { @@ -267,7 +272,7 @@ public class Example3 extends UnicastRemoteObject implements Hello { public static void main(String args[]) { if (System.getSecurityManager() == null) { - System.setSecurityManager(new RMISecurityManager()); + System.setSecurityManager(new SecurityManager()); } try { @@ -289,7 +294,7 @@ package com.sub.bar; import java.rmi.Naming; import java.rmi.RemoteException; -import java.rmi.RMISecurityManager; +import java.lang.SecurityManager; import java.rmi.server.UnicastRemoteObject; public class Example4 extends UnicastRemoteObject implements Hello { @@ -306,7 +311,7 @@ public class Example4 extends UnicastRemoteObject implements Hello { public static void main(String args[]) { if (System.getSecurityManager() == null) { - System.setSecurityManager(new RMISecurityManager()); + System.setSecurityManager(new SecurityManager()); } try { @@ -326,7 +331,7 @@ public class Example4 extends UnicastRemoteObject implements Hello { test.run(arguments = '.') test.must_match('wrapper.out', - "wrapper_with_args.py %s -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n" % where_rmic, + "wrapper_with_args.py rmic -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n", mode='r') test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example1_Stub.class')) diff --git a/test/Java/java_version_image/SConstruct b/test/Java/java_version_image/SConstruct new file mode 100644 index 0000000..945c864 --- /dev/null +++ b/test/Java/java_version_image/SConstruct @@ -0,0 +1,35 @@ + +AddOption('--javac_path', + dest='javac_path', + action='store', + default='/usr/bin', + type='string') + +AddOption('--java_version', + dest='java_version', + action='store', + default='1.6', + type='string') + +path=GetOption('javac_path') +if path[0] == "'": + path = path[1:-1] + +version = GetOption('java_version') + +env = Environment(tools = ['javac'], + JAVAVERSION = version, + ) + + +env.AppendENVPath('PATH',path) + +# print('PATH:%s'%env['ENV']['PATH']) + + +env.Java(target = 'class1', source = 'com/sub/foo') +env.Java(target = 'class2', source = 'com/sub/bar') +env.Java(target = 'class3', source = ['src1', 'src2']) +env.Java(target = 'class4', source = ['src4']) +env.Java(target = 'class5', source = ['src5']) +env.Java(target = 'class6', source = ['src6']) diff --git a/test/Java/java_version_image/class6/test$1.class b/test/Java/java_version_image/class6/test$1.class Binary files differnew file mode 100644 index 0000000..dd58d98 --- /dev/null +++ b/test/Java/java_version_image/class6/test$1.class diff --git a/test/Java/java_version_image/com/sub/bar/Example4.java b/test/Java/java_version_image/com/sub/bar/Example4.java new file mode 100644 index 0000000..0748d54 --- /dev/null +++ b/test/Java/java_version_image/com/sub/bar/Example4.java @@ -0,0 +1,11 @@ +package com.sub.bar; + +public class Example4 +{ + + public static void main(String[] args) + { + + } + +} diff --git a/test/Java/java_version_image/com/sub/bar/Example5.java b/test/Java/java_version_image/com/sub/bar/Example5.java new file mode 100644 index 0000000..69d2937 --- /dev/null +++ b/test/Java/java_version_image/com/sub/bar/Example5.java @@ -0,0 +1,11 @@ +package com.other; + +public class Example5 +{ + + public static void main(String[] args) + { + + } + +} diff --git a/test/Java/java_version_image/com/sub/bar/Example6.java b/test/Java/java_version_image/com/sub/bar/Example6.java new file mode 100644 index 0000000..1811b80 --- /dev/null +++ b/test/Java/java_version_image/com/sub/bar/Example6.java @@ -0,0 +1,11 @@ +package com.sub.bar; + +public class Example6 +{ + + public static void main(String[] args) + { + + } + +} diff --git a/test/Java/java_version_image/com/sub/foo/Example1.java b/test/Java/java_version_image/com/sub/foo/Example1.java new file mode 100644 index 0000000..82aac2e --- /dev/null +++ b/test/Java/java_version_image/com/sub/foo/Example1.java @@ -0,0 +1,11 @@ +package com.sub.foo; + +public class Example1 +{ + + public static void main(String[] args) + { + + } + +} diff --git a/test/Java/java_version_image/com/sub/foo/Example2.java b/test/Java/java_version_image/com/sub/foo/Example2.java new file mode 100644 index 0000000..6349ac9 --- /dev/null +++ b/test/Java/java_version_image/com/sub/foo/Example2.java @@ -0,0 +1,11 @@ +package com.other; + +public class Example2 +{ + + public static void main(String[] args) + { + + } + +} diff --git a/test/Java/java_version_image/com/sub/foo/Example3.java b/test/Java/java_version_image/com/sub/foo/Example3.java new file mode 100644 index 0000000..092f0cd --- /dev/null +++ b/test/Java/java_version_image/com/sub/foo/Example3.java @@ -0,0 +1,11 @@ +package com.sub.foo; + +public class Example3 +{ + + public static void main(String[] args) + { + + } + +} diff --git a/test/Java/java_version_image/src1/Example7.java b/test/Java/java_version_image/src1/Example7.java new file mode 100644 index 0000000..80d94f2 --- /dev/null +++ b/test/Java/java_version_image/src1/Example7.java @@ -0,0 +1,9 @@ +public class Example7 +{ + + public static void main(String[] args) + { + + } + +} diff --git a/test/Java/java_version_image/src2/Test.java b/test/Java/java_version_image/src2/Test.java new file mode 100644 index 0000000..6f224b0 --- /dev/null +++ b/test/Java/java_version_image/src2/Test.java @@ -0,0 +1,55 @@ +class Empty { +} + +interface Listener { + public void execute(); +} + +public +class +Test { + class Inner { + void go() { + use(new Listener() { + public void execute() { + System.out.println("In Inner"); + } + }); + } + String s1 = "class A"; + String s2 = "new Listener() { }"; + /* class B */ + /* new Listener() { } */ + } + + public static void main(String[] args) { + new Test().run(); + } + + void run() { + use(new Listener() { + public void execute() { + use(new Listener( ) { + public void execute() { + System.out.println("Inside execute()"); + } + }); + } + }); + + new Inner().go(); + } + + void use(Listener l) { + l.execute(); + } +} + +class Private { + void run() { + new Listener() { + public void execute() { + } + }; + } +} diff --git a/test/Java/java_version_image/src4/NestedExample.java b/test/Java/java_version_image/src4/NestedExample.java new file mode 100644 index 0000000..531f2e9 --- /dev/null +++ b/test/Java/java_version_image/src4/NestedExample.java @@ -0,0 +1,31 @@ +// import java.util.*; + +public class NestedExample +{ + public NestedExample() + { + new Thread() { + public void start() + { + new Thread() { + public void start() + { + try {Thread.sleep(200);} + catch (Exception e) {} + } + }; + while (true) + { + try {Thread.sleep(200);} + catch (Exception e) {} + } + } + }; + } + + + public static void main(String argv[]) + { + new NestedExample(); + } +} diff --git a/test/Java/java_version_image/src5/TestSCons.java b/test/Java/java_version_image/src5/TestSCons.java new file mode 100644 index 0000000..46572c4 --- /dev/null +++ b/test/Java/java_version_image/src5/TestSCons.java @@ -0,0 +1,7 @@ +class TestSCons { + public static void main(String[] args) { + Foo[] fooArray = new Foo[] { new Foo() }; + } +} + +class Foo { } diff --git a/test/Java/java_version_image/src6/TestSCons.java b/test/Java/java_version_image/src6/TestSCons.java new file mode 100644 index 0000000..1aeed2f --- /dev/null +++ b/test/Java/java_version_image/src6/TestSCons.java @@ -0,0 +1,13 @@ +class test +{ + test() + { + super(); + new inner(); + } + + static class inner + { + private inner() {} + } +} diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index 01a3163..33e2a5f 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -35,6 +35,7 @@ import os import TestSCons test = TestSCons.TestSCons() +# test.verbose_set(1) where_javac, java_version = test.java_where_javac() where_javah = test.java_where_javah() @@ -50,9 +51,6 @@ if not swig: if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') - - - test.subdir(['src'], ['src', 'HelloApplet'], ['src', 'HelloApplet', 'com'], @@ -75,9 +73,7 @@ test.subdir(['src'], test.write(['SConstruct'], """\ import os,sys env=Environment(tools = ['default', 'javac', 'javah', 'swig'], - CPPPATH=%(where_java_include)s, - JAVAC = r'%(where_javac)s', - JAVAH = r'%(where_javah)s') + CPPPATH=["$JAVAINCLUDES"]) Export('env') env.PrependENVPath('PATH',os.environ.get('PATH',[])) env['INCPREFIX']='-I' @@ -154,6 +150,9 @@ public class Hello extends Applet { test.write(['src', 'javah', 'MyID.cc'], """\ #include "MyID.h" +#ifdef _MSC_VER +__declspec(dllexport) +#endif int getMyID() { return 0; diff --git a/test/Java/no-JARCHDIR.py b/test/Java/no-JARCHDIR.py index 2037524..11754c0 100644 --- a/test/Java/no-JARCHDIR.py +++ b/test/Java/no-JARCHDIR.py @@ -35,13 +35,12 @@ import TestSCons test = TestSCons.TestSCons() +# will skip tests when needed tools not present. where_javac, java_version = test.java_where_javac() where_jar = test.java_where_jar() test.subdir('src') - - test.write(['src', 'a.java'], """\ package foo.bar; public class a {} @@ -52,20 +51,13 @@ package foo.bar; public class b {} """) - - test.write('SConstruct', """\ -env = Environment(tools = ['javac', 'jar'], - JAVAC = r'%(where_javac)s', - JAR = r'%(where_jar)s') +env = Environment(tools = ['javac', 'jar']) jar = env.Jar('x.jar', env.Java(target = 'classes', source = 'src')) """ % locals()) test.run(arguments = '.') - - - test.run(program = where_jar, arguments = 'tf x.jar') expect = """\ @@ -75,16 +67,10 @@ foo/bar/b.class test.must_contain_all_lines(test.stdout(), [expect]) - - test.run(arguments = '-c') - - test.write('SConstruct', """\ env = Environment(tools = ['javac', 'jar'], - JAVAC = r'%(where_javac)s', - JAR = r'%(where_jar)s', JARCHDIR = None) jar = env.Jar('x.jar', env.Java(target = 'classes', source = 'src')) @@ -92,8 +78,6 @@ jar = env.Jar('x.jar', env.Java(target = 'classes', source = 'src')) test.run(arguments = '.') - - test.run(program = where_jar, arguments = 'tf x.jar') expect = """\ @@ -102,9 +86,6 @@ classes/foo/bar/b.class """ test.must_contain_all_lines(test.stdout(), [expect]) - - - test.pass_test() # Local Variables: diff --git a/test/Java/source-files.py b/test/Java/source-files.py index bf263cf..ab395a0 100644 --- a/test/Java/source-files.py +++ b/test/Java/source-files.py @@ -35,12 +35,8 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -where_javac, java_version = test.java_where_javac() - - test.write('SConstruct', """ -env = Environment(tools = ['javac', 'javah'], - JAVAC = r'%(where_javac)s') +env = Environment(tools = ['javac', 'javah']) env.Java(target = 'class1', source = 'com/Example1.java') env.Java(target = 'class2', source = ['com/Example2.java', 'com/Example3.java']) """ % locals()) diff --git a/test/Java/swig-dependencies.py b/test/Java/swig-dependencies.py index bd7a576..a3af9ec 100644 --- a/test/Java/swig-dependencies.py +++ b/test/Java/swig-dependencies.py @@ -40,7 +40,6 @@ if not swig: where_javac, java_version = test.java_where_javac() where_javah = test.java_where_javah() -#where_jar = test.java_where_jar() where_java_include=test.java_where_includes() @@ -51,12 +50,10 @@ test.subdir(['foo'], test.write(['SConstruct'], """\ import os -env = Environment(ENV = os.environ, - CPPPATH=%(where_java_include)s, - JAVAC = r'%(where_javac)s', - JAVAH = r'%(where_javah)s') - -env.Append(CPPFLAGS = ' -g -Wall') +env = Environment(ENV = os.environ) +if env['PLATFORM'] != 'win32': + env.Append(CPPFLAGS = ' -g -Wall') +env['CPPPATH'] ='$JAVAINCLUDES' Export('env') @@ -79,13 +76,28 @@ int fooAdd(int a, int b) { """) test.write(['foo', 'foo.h'], """\ +#ifdef _MSC_VER +__declspec(dllexport) +#endif int fooAdd(int, int); """) test.write(['java', 'Java_foo_interface.i'], """\ #include "foo.h" +#include <windows.i> + %module foopack + +%{ + +#ifdef _MSC_VER +__declspec(dllexport) +#endif +int hello(){ + return 1; +} +%} """) test.write(['java', 'SConscript'], """\ @@ -103,7 +115,7 @@ libadd = ['foo',] libpath = ['#foo',] #swigflags = '-c++ -java -Wall -package foopack -Ifoo' -swigflags = '-c++ -java -Wall -Ifoo' +swigflags = '-c++ -java -Wall -Ifoo -DTEST_$PLATFORM' Java_foo_interface = env.SharedLibrary( 'Java_foo_interface', diff --git a/test/Libs/SharedLibrary.py b/test/Libs/SharedLibrary.py index eac575c..cc3fa66 100644 --- a/test/Libs/SharedLibrary.py +++ b/test/Libs/SharedLibrary.py @@ -30,6 +30,7 @@ import sys import TestSCons test = TestSCons.TestSCons() +test.verbose_set(1) test.write('SConstruct', """ import sys diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index 9499ff4..96b8b5d 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -1612,7 +1612,8 @@ class TestCmd(object): new = os.path.join(self.workdir, sub) try: os.mkdir(new) - except OSError: + except OSError as e: + print("Got error :%s"%e) pass else: count = count + 1 diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py index 6b4b0bd..ca4a147 100644 --- a/testing/framework/TestCommon.py +++ b/testing/framework/TestCommon.py @@ -264,11 +264,16 @@ class TestCommon(TestCmd): if options: if arguments is None: return options + + # If not list, then split into lists + # this way we're not losing arguments specified with + # Spaces in quotes. if isinstance(options, str): - options = [options] + options = options.split() if isinstance(arguments, str): - arguments = [arguments] - arguments = ' '.join(options + arguments) + arguments = arguments.split() + arguments = options + arguments + return arguments def must_be_writable(self, *files): diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index bf6aabb..feadef9 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -418,6 +418,10 @@ class TestSCons(TestCommon): # TestCommon.run(self, *args, **kw) def up_to_date(self, arguments = '.', read_str = "", **kw): + """Asserts that all of the targets listed in arguments is + up to date, but does not make any assumptions on other targets. + This function is most useful in conjunction with the -n option. + """ s = "" for arg in arguments.split(): s = s + "scons: `%s' is up to date.\n" % arg @@ -853,11 +857,15 @@ class TestSCons(TestCommon): fmt = "Could not find javac for Java version %s, skipping test(s).\n" self.skip_test(fmt % version) else: - m = re.search(r'javac (\d\.\d)', self.stderr()) + m = re.search(r'javac (\d\.*\d)', self.stderr()) + # Java 11 outputs this to stdout + if not m: + m = re.search(r'javac (\d\.*\d)', self.stdout()) + if m: version = m.group(1) self.javac_is_gcj = False - elif self.stderr().find('gcj'): + elif self.stderr().find('gcj') != -1: version='1.2' self.javac_is_gcj = True else: |