[Jython-checkins] jython: Further tweaks to "snapshot" and properties logic in build.xml

jeff.allen jython-checkins at python.org
Mon Aug 26 15:52:50 EDT 2019


https://hg.python.org/jython/rev/684117a13ee3
changeset:   8283:684117a13ee3
user:        Jeff Allen <ja.py at farowl.co.uk>
date:        Mon Aug 26 15:05:21 2019 +0100
summary:
  Further tweaks to "snapshot" and properties logic in build.xml

Logic leading to the "snapshot" version of the readme is fixed.
Placeholders are gone from the manifests of JARs (#2613 fix verified).
We avoid repeated calls to hg and the building of a JAR when we can,
and sometimes when we can't (but a clean build sorts it out).

files:
  NEWS      |    1 +
  build.xml |  192 ++++++++++++++++++++++++-----------------
  2 files changed, 115 insertions(+), 78 deletions(-)


diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@
 
 Development tip
   Bugs fixed
+    - [ 2613 ] MANIFEST.MF contains unfilled placeholders
     - [ 2330 ] full-build fails to copy CPython License
     - [ 2651 ] Travis builds failing with *** buffer overflow detected ***
     - [ 2703 ] JycompileAntTask cannot find ...ant.taskdefs.MatchingTask
diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -74,18 +74,16 @@
         </echo>
     </target>
 
-    <target name="jarless" depends="compile, pycompile"/>
-
     <target name="developer-build"
-            depends="init, jar, copy-javalib, copy-bin, copy-lib, copy-dev, pycompile"
+            depends="jar, copy-dev, pycompile"
             description="a local build for developers" />
 
     <target name="installer"
-            depends="installer-preinit, init, jar-installer"
+            depends="installer-preinit, jar-installer"
             description="build a snapshot installer from the current state" />
 
     <target name="full-build"
-            depends="full-preinit, full-check, init, all-jars, jar-installer"
+            depends="clean, full-preinit, full-check, all-jars, jar-installer"
             description="build releasable artefacts. (Use a fresh checkout for a real release)" />
 
     <target name="common-config" depends="common-constants">
@@ -316,17 +314,16 @@
 
     <target name="installer-preinit" depends="common-config">
         <property name="snapshot.name" value="SNAPSHOT"/>
-        <property name="full-build" value="true" />
         <property name="jar.update" value="true" />
+        <!-- Ensure we regenerate version.properties -->
+        <property name="brand-up-to-date" value="false" />
     </target>
 
     <target name="full-preinit" depends="common-config">
         <!-- What is this? Why here in the full build only? -->
         <property name="cpptasks.jar.dir" value="${basedir}/extlibs/cpptasks/cpptasks.jar" />
-
-        <!-- We define this property to distinguish a full-build from a developer-build -->
-        <property name="full-build" value="true" />
         <property name="jar.update" value="false" />
+        <property name="brand-up-to-date" value="false" />
     </target>
 
     <target name="full-check" depends="full-preinit, force-snapshot-if-polluted, init, full-dump"
@@ -389,7 +386,8 @@
         <!-- <echo>test.classpath            = '${ant.refid:test.classpath}'</echo> -->
     </target>
 
-    <target name="full-dump" depends="dump">
+    <target name="full-dump"
+            depends="dump, hg-is-unmodified, hg-is-clean, hg-is-tagged, hg-branch" >
         <echo>--- properties only used for a full-build ---</echo>
         <echo>hg.present                = '${hg.present}'</echo>
         <echo>build.hg.is_unmodified    = '${build.hg.is_unmodified}'</echo>
@@ -425,23 +423,57 @@
     <target name="force-snapshot-if-polluted" depends="hg-is-unmodified, hg-is-clean, hg-is-tagged">
         <!-- Ensure that a snapshot name is provided, if the workspace is not a pure checkout.
              This only works before init is called, since it will set a value. -->
+
+        <!-- Check for conditions that will force us to a snapshot build. -->
+        <local name="diagnosis" />
+        <condition property="diagnosis"
+                   value="The working directory is not a Mercurial repository">
+            <not><istrue value="${hg.present}"/></not>
+        </condition>
+        <condition property="diagnosis"
+                   value="Version-controlled files have been edited since the last commit">
+            <not><isset property="build.hg.is_unmodified"/></not>
+        </condition>
+        <condition property="diagnosis"
+                   value="Workspace contains uncontrolled files">
+            <not><isset property="build.hg.is_clean"/></not>
+        </condition>
+        <condition property="diagnosis"
+                   value="Change set ${build.hg.version} is not tagged v${jython.release}">
+            <not><isset property="build.hg.is_tagged"/></not>
+        </condition>
+
+        <!-- If there was any kind of defect, make this a snapshot build. -->
         <condition property="snapshot.name" value="SNAPSHOT">
-            <not><and>
-                <isset property="build.hg.is_unmodified"/>
-                <isset property="build.hg.is_clean"/>
-                <isset property="build.hg.is_tagged"/>
-            </and></not>
+            <isset property="diagnosis"/>
         </condition>
+
         <!-- Now set the suffix as well, before init gets to try. (Our else is different.) -->
         <condition property="snapshot.suffix" value="-${snapshot.name}" else="">
             <isset property="snapshot.name"/>
         </condition>
+
+        <!-- Produce a message about that. -->
+        <local name="message" />
+        <condition property="message"
+                   value="${diagnosis} - build is a snapshot."
+                   else ="Build is for release of ${jython.release}.">
+            <isset property="diagnosis"/>
+        </condition>
+        <echo>
+${message}
+
+${build.hg.status}
+        </echo>
+
     </target>
 
-    <target name="hg-diagnosis" depends="common-version-strings, hg-metadata">
-        <!-- Diagnose when the checked-out source is polluted, using hg commands. Such pollution
-             does not prevent a full build running, but it forces it to be a snapshot build. -->
-
+    <target name="hg-is-unmodified" depends="hg-present" if="${hg.present}">
+        <!-- Set build.hg.version, and if it has no + at the end, set build.hg.is_unmodified -->
+        <!-- Get the identity of the change set. -->
+        <exec executable="hg" outputproperty="build.hg.version">
+            <arg line="identify -i"/>
+        </exec>
         <!-- Check there have been no modifications to controlled files. -->
         <condition property="build.hg.is_unmodified">
             <and>
@@ -449,7 +481,13 @@
                 <not><contains string="${build.hg.version}" substring="+" /></not>
             </and>
         </condition>
+    </target>
 
+    <target name="hg-is-clean" depends="hg-present" if="${hg.present}">
+        <!-- Set build.hg.status, and if it lists no files, set build.hg.is_clean -->
+        <exec executable="hg" outputproperty="build.hg.status">
+            <arg line="status" />
+        </exec>
         <!-- Check there are no extra files (except as per .hgignore) to catch in the build. -->
         <condition property="build.hg.is_clean">
             <and>
@@ -457,7 +495,13 @@
                 <length string="${build.hg.status}" trim="true" length="0" />
             </and>
         </condition>
+    </target>
 
+    <target name="hg-is-tagged" depends="hg-present, common-version-strings" if="${hg.present}">
+        <!-- Set build.hg.tag, and if it matches this version, set build.hg.is_tagged -->
+        <exec executable="hg" outputproperty="build.hg.tag">
+            <arg line="identify -t"/>
+        </exec>
         <!-- Check we are at a tag matching the release claimed in the configuration. -->
         <condition property="build.hg.is_tagged">
             <and>
@@ -467,64 +511,53 @@
         </condition>
     </target>
 
-    <target name="hg-metadata" depends="hg-present">
-        <!-- Get the branch, version (meaning identity) and tag of the change set. -->
+    <target name="hg-branch" depends="hg-present" if="${hg.present}">
+        <!-- Set build.hg.branch. -->
         <exec executable="hg" outputproperty="build.hg.branch">
             <arg line="identify -b"/>
         </exec>
-        <exec executable="hg" outputproperty="build.hg.version">
-            <arg line="identify -i"/>
+    </target>
+
+    <target name="hg-present" depends="common-dirs">
+        <condition property="hg.present" else="false">
+             <available file="${basedir}/.hg" type="dir" />
+        </condition>
+    </target>
+
+    <target name="brand-up-to-date" depends="common-paths, hg-is-unmodified">
+        <!-- Check freshness of generated version.properties file. -->
+        <condition property="brand-up-to-date" else="false">
+            <!-- The branding (version.properties) is adequately up to date if ... -->
+            <and>
+                <!-- The file exists (and we can't have edited the version info in build.xml). -->
+                <uptodate targetfile="${compile.dir}/org/python/version.properties">
+                    <srcfiles file="build.xml" />
+                </uptodate>
+                <!-- *and* there are things we have not checked in. -->
+                <not><isset property="build.hg.is_unmodified"/></not>
+            </and>
+        </condition>
+    </target>
+
+    <target name="brand-version" depends="brand-up-to-date, init" unless="${brand-up-to-date}">
+        <!-- Update version.properties, but only if something significant has changed.
+             We're lazy about this (in a bad way) when making a developer build,
+             as a change to this one file causes the JAR to be rebuilt. -->
+
+        <!-- build.hg.version already set by dependency brand-up-to-date. -->
+        <exec executable="hg" outputproperty="build.hg.branch">
+            <arg line="identify -b"/>
         </exec>
         <exec executable="hg" outputproperty="build.hg.tag">
             <arg line="identify -t"/>
         </exec>
-        <exec executable="hg" outputproperty="build.hg.status">
-            <arg line="status" />
-        </exec>
-        <!-- 
+
+        <echo>Writing hg and build metadata to version.properties.</echo>
+        <echo>jython.version        = ${jython.version}</echo>
         <echo>build.hg.branch       = ${build.hg.branch}</echo>
         <echo>build.hg.version      = ${build.hg.version}</echo>
         <echo>build.hg.tag          = ${build.hg.tag}</echo>
-        -->
-        <!-- <echo>build.hg.status       = ${build.hg.status}</echo> -->
-    </target>
 
-    <target name="hg-present">
-        <condition property="hg.present" else="false">
-             <available file=".hg" type="dir" />
-        </condition>
-    </target>
-
-    <target name="hg-is-unmodified" depends="hg-diagnosis" unless="build.hg.is_unmodified">
-        <echo level="warning">
-Version-controlled files have been edited since the last commit - build is a snapshot.
-
-${build.hg.status}
-        </echo>
-    </target>
-
-    <target name="hg-is-clean" depends="hg-diagnosis"
-        if="build.hg.is_unmodified" unless="build.hg.is_clean">
-        <echo level="warning">
-Workspace contains uncontrolled files - build is a snapshot.
-
-${build.hg.status}
-        </echo>
-    </target>
-
-    <target name="hg-is-tagged" depends="hg-diagnosis"
-        if="build.hg.is_clean" unless="build.hg.is_tagged">
-        <echo level="warning">
-Change set ${build.hg.version} is not tagged v${jython.release} - build is a snapshot.
-        </echo>
-    </target>
-
-    <!-- skip-brand can be set in ant.properties or as a system property to keep from updating the
-         version.properties file and making the jar on every developer build. -->
-    <target name="brand-version" depends="hg-metadata, init" unless="skip-brand">
-        <property name="build.hg.branch" value=""/>
-        <property name="build.hg.tag" value=""/>
-        <property name="build.hg.version" value=""/>
         <tstamp>
             <format property="build.date" pattern="MMM d yyyy" offset="0"/>
             <format property="build.time" pattern="HH:mm:ss" offset="0"/>
@@ -549,6 +582,7 @@
         <copy file="${basedir}/README.txt" todir="${dist.dir}" overwrite="true" />
 
         <!-- An article and adjective to precede "release" to appear in README.txt -->
+        <local name="readme.release" />
         <condition property="readme.release" value="an alpha">
             <equals arg1="${jython.release_level}" arg2="${PY_RELEASE_LEVEL_ALPHA}" />
         </condition>
@@ -560,18 +594,18 @@
         </condition>
 
         <!-- README.txt contains this paragraph if this is a snapshot build. -->
-        <local name="snapshot.banner" />
-        <property name="snapshot.banner">
+        <local name="snapshot.banner.active" />
+        <property name="snapshot.banner.active">
 -------------------------------------------------------------------------
 This is a snapshot build. It reflects the current development status.
-The text for the next official release will continue ...
+The text for an official release would continue like ...
 -------------------------------------------------------------------------
         </property>
 
         <!-- Change README.txt to replace placeholders with version-specific information. -->
-        <local name="snapshot.warning" />
-        <condition property="snapshot.warning" value="${snapshot.banner}" else="">
-            <equals arg1="${snapshot.name}" arg2="" />
+        <local name="snapshot.banner" />
+        <condition property="snapshot.banner" value="" else="${snapshot.banner.active}">
+            <equals arg1="${snapshot.suffix}" arg2="" />
         </condition>
         <replace file="${dist.dir}/README.txt" encoding="UTF-8">
             <replacefilter token="@jython.version@" value="${jython.version}" />
@@ -645,6 +679,8 @@
         -->
     </target>
 
+    <target name="jarless" depends="compile, pycompile"/>
+
     <target name="compile" depends="init, antlr-gen, brand-version">
         <javac destdir="${compile.dir}"
                target="${jdk.target.version}"
@@ -722,7 +758,6 @@
          </cc>
     </target>
 
-
     <target name="expose" depends="compile">
         <taskdef name="expose" classname="org.python.expose.generate.ExposeTask">
             <classpath>
@@ -850,7 +885,7 @@
                 </section>
             </manifest>
             <!-- FIXME: Because the standalone JAR may be distributed separately from the
-                 installer JAR, it ought really to include necessary licences (ours, Apache, etc.),
+                 installer JAR, it ought really to include necessary licences (Apache, etc.),
                  at least by reference.
             -->
         </jar>
@@ -953,9 +988,7 @@
         </copy>
     </target>
 
-    <target name="copy-full"
-            depends="copy-bin, copy-lib, brand-readme, copy-misc-files"
-            if="full-build">
+    <target name="copy-full" depends="copy-bin, copy-lib, brand-readme, copy-misc-files">
         <!-- sources: todir has to correspond with installer/**/JarInstaller.java -->
         <echo>copy sources from ${basedir}</echo>
         <copy todir="${dist.dir}" preservelastmodified="true">
@@ -1075,7 +1108,7 @@
     <!-- Compile the installer and wrap the build into it. Some contents are required through
          dependencies named, while others (source, javadoc) depend on the history so far. -->
     <target name="jar-installer"
-        depends="init, jar, jar-standalone, copy-full" >
+        depends="jar-standalone, copy-full" >
 
         <echo>compiling installer from ${installer.src.dir}</echo>
         <javac srcdir="${installer.src.dir}"
@@ -1128,6 +1161,9 @@
             <manifest>
                 <attribute name="Main-Class" value="org.python.util.install.Installation" />
                 <attribute name="Built-By" value="${user.name}" />
+                <attribute name="Implementation-Vendor" value="Python Software Foundation"/>
+                <attribute name="Implementation-Title" value="Jython installer"/>
+                <attribute name="Implementation-Version" value="${jython.version}"/>
                 <!-- section for the installer program -->
                 <section name="Jython">
                     <attribute name="version" value="${jython.version}" />

-- 
Repository URL: https://hg.python.org/jython


More information about the Jython-checkins mailing list