rewrite for os.arch changes, remove incomplete cross-builds, update RPi and Linux deb

This commit is contained in:
Ben Fry
2022-01-23 11:55:41 -05:00
parent d0683c39a1
commit 838c9387e7
+147 -153
View File
@@ -30,39 +30,11 @@
<property name="examples.dir"
location="../../processing-docs/content/examples" />
<!-- detect Raspberry Pi (TODO move this, jdk.data.model is set later) -->
<condition property="linux-arm32" value="linux-arm32">
<and>
<equals arg1="${target-platform}" arg2="linux" />
<equals arg1="${os.arch}" arg2="arm" />
<equals arg1="${jdk.data.model}" arg2="32" />
</and>
</condition>
<condition property="linux-arm64" value="linux-arm64">
<and>
<equals arg1="${target-platform}" arg2="linux" />
<equals arg1="${os.arch}" arg2="aarch64" />
<equals arg1="${jdk.data.model}" arg2="64" />
</and>
</condition>
<!-- there is currently no JRE available for ARM -->
<target name="check-linux-arm32" if="linux-arm32">
<property name="jdk.download.jdk" value="true" />
<property name="jdk.downloader" value="linux-arm32-vfp-hflt.tar.gz" />
<property name="linux.dist" value="linux/processing-${version}-linux-armv6hf.tgz" />
<property name="launch4j.variant" value="linux-armv6hf" />
</target>
<target name="check-linux-arm64" if="linux-arm64">
<property name="jdk.download.jdk" value="true" />
<property name="jdk.downloader" value="linux-arm64-vfp-hflt.tar.gz" />
<property name="linux.dist" value="linux/processing-${version}-linux-arm64.tgz" />
</target>
<!-- 17.0.1+12 -->
<property name="jdk.train" value="17" />
<property name="jdk.detail" value="${jdk.train}.0.1" />
<property name="jdk.build" value="12" />
<property name="jdk.folder" value="jdk-${jdk.detail}+${jdk.build}" />
<!-- Require Java ${train} everywhere. -->
@@ -77,9 +49,12 @@
</condition>
</fail>
<!-- Identify optional JDK files that can be removed to save space. -->
<fileset dir="macos/work/Processing.app/Contents" id="jdk-optional-macos">
<!-- src.zip is 52 MB and we absolutely do not need it -->
<include name="PlugIns/jdk-${jdk.detail}+${jdk.build}/Contents/Home/lib/src.zip" />
<include name="PlugIns/${jdk.folder}/Contents/Home/lib/src.zip" />
</fileset>
<fileset dir="windows/work" id="jdk-optional-windows">
@@ -90,30 +65,40 @@
<include name="java/lib/src.zip" />
</fileset>
<!-- Macro to help set the platform ant vars appropriately -->
<!--
<macrodef name="set-target">
<attribute name="platform"/>
<attribute name="datamodel"/>
<attribute name="platform" />
<attribute name="arch" />
<sequential>
<property name="host-platform" value="${platform}" />
<!-- Set a property named macos, linux, or windows.
The 'value' chosen is arbitrary. -->
<!- - set the target plaform to the platform attribute passed in - ->
<property name="target-platform" value="@{platform}" />
<!- - Set a property named macos, linux, or windows.
The 'value' chosen is arbitrary. - ->
<property name="${target-platform}" value="${target-platform}" />
<!-- JDK archive saved as .zip on Windows, .tgz on macOS and Linux -->
<condition property="jdk.archive.ext" value="zip" else="tgz">
<os family="windows" />
</condition>
<property name="jdk.archive.path" value="${target-platform}/jdk-${jdk.detail}.${jdk.archive.ext}" />
<property name="jdk.data.model" value="@{datamodel}" />
</sequential>
</macrodef>
-->
<!-- Downloading the JDK -->
<target name="jdk-check">
<!-- JDK archive saved as .zip on Windows, .tgz on macOS and Linux -->
<condition property="jdk.archive.ext" value="zip" else="tgz">
<os family="windows" />
</condition>
<property name="jdk.archive.path"
value="${platform}/jdk-${jdk.detail}.${jdk.archive.ext}" />
<echo message="Checking for ${jdk.archive.path}" />
<available file="${jdk.archive.path}" property="jdk.archive.downloaded" />
<!-- <echo message="Result: ${jdk.archive.downloaded}" /> -->
@@ -122,12 +107,13 @@
<target name="jdk-download" depends="jdk-check"
unless="jdk.archive.downloaded">
<!-- Windows is the outlier with the .zip extension (the others are .tar.gz) -->
<!-- Windows is the outlier with the .zip extension (the other downloads
are .tar.gz). Different from jdk.archive.ext which uses .tgz) -->
<condition property="jdk.download.ext" value="zip" else="tar.gz">
<os family="windows" />
</condition>
<!-- platform prop works for Windows and Linux, but 'macos' needs to be 'mac' -->
<!-- ${platform} ok for Windows/Linux, but 'macos' needs to be 'mac' -->
<condition property="jdk.download.os" value="mac" else="${platform}">
<os family="mac" />
</condition>
@@ -163,7 +149,7 @@
</target>
<!-- Set the version of Java that must be present to build. -->
<property name="jdk.path.macos" value="macos/jdk-${jdk.detail}+${jdk.build}" />
<property name="jdk.path.macos" value="macos/${jdk.folder}" />
<available file="${jdk.path.macos}" property="macos_jdk_found" />
<!--
@@ -196,40 +182,62 @@
</fileset>
<target name="build" description="Build Processing.">
<set-target platform="${platform}" datamodel="${sun.arch.data.model}" />
<antcall target="${platform}-build" />
</target>
<!--
<target name="build" description="Build Processing.">
<set-target platform="${platform}" arch="${os.arch}" />
<antcall target="${target-platform}-build" />
</target>
<target name="cross-build-macos" description="Build Processing.">
<set-target platform="macos" datamodel="64" />
<target name="cross-build-macos-aarch64"
description="Cross-build Processing for Apple Silicon">
<set-target platform="macos" arch="aarch64" />
<antcall target="macos-build" />
</target>
<target name="cross-build-linux-x64" description="Build Processing.">
<set-target platform="linux" datamodel="64" />
<target name="cross-build-macos-x86_64"
description="Cross-build Processing for macOS (64-bit Intel)">
<set-target platform="macos" arch="x86_64" />
<antcall target="macos-build" />
</target>
<target name="cross-build-linux-amd64"
description="Cross-build Processing for Linux (64-bit Intel)">
<set-target platform="linux" arch="amd64" />
<antcall target="linux-build" />
</target>
<target name="cross-build-linux-aarch64" description="Build Processing.">
<set-target platform="linux" datamodel="Arm" />
<target name="cross-build-linux-aarch64"
description="Cross-build Processing for Linux (64-bit ARM)">
<set-target platform="linux" arch="aarch64" />
<antcall target="linux-build" />
</target>
<target name="cross-build-windows" description="Build Processing.">
<set-target platform="windows" datamodel="64" />
<target name="cross-build-linux-arm"
description="Cross-build Processing for Linux (32-bit ARM)">
<set-target platform="linux" arch="arm" />
<antcall target="linux-build" />
</target>
<target name="cross-build-windows"
description="Cross-build Processing for Windows (64-bit Intel)">
<set-target platform="windows" arch="amd64" />
<antcall target="windows-build" />
</target>
<target name="run" description="Run Processing.">
<set-target platform="${platform}" datamodel="${sun.arch.data.model}" />
<set-target platform="${platform}" arch="${os.arch}" />
<antcall target="${target-platform}-run" />
</target>
-->
<!-- Run the app in a more "native" manner, i.e. no additional
console for debugging. Ensures that double-clicking shortcuts
and other desktop integration features work properly. -->
<target name="app" description="Run Processing w/o console.">
<antcall target="${target-platform}-run-app" />
<antcall target="${platform}-run-app" />
</target>
<target name="dist" depends="revision-check, test"
@@ -246,7 +254,7 @@
<arg line="pull" />
</exec>
<antcall target="${target-platform}-dist" />
<antcall target="${platform}-dist" />
</target>
<!-- "§$§$&, ant doesn't have a built-in help target :( -->
@@ -456,7 +464,7 @@
<mkdir dir="macos/work" />
<!-- Extract JDK -->
<echo message="Target jdk: ${jdk.archive.path}"/>
<echo message="Extracting JDK from ${jdk.archive.path}"/>
<exec executable="tar" dir="macos">
<!-- Change directory -->
<!--
@@ -468,9 +476,6 @@
<arg value="../${jdk.archive.path}"/>
</exec>
<!-- does not appear to be in use -->
<!-- <property name="jdk.dir" value="macos/work/jdk-${jdk.detail}+${jdk.build}.jdk/" /> -->
<!-- https://github.com/processing/processing4/issues/284 -->
<copy file="macos/appbundler-${os.arch}.jar"
tofile="macos/appbundler.jar" />
@@ -618,22 +623,22 @@
Unix systems, we need to use <exec executable="cp" ... > instead -->
<exec executable="cp">
<arg value="-r"/>
<arg line="${jdk.path.macos}/Contents/Home/bin macos/work/Processing.app/Contents/PlugIns/jdk-${jdk.detail}+${jdk.build}/Contents/Home/bin"/>
<arg line="${jdk.path.macos}/Contents/Home/bin macos/work/Processing.app/Contents/PlugIns/${jdk.folder}/Contents/Home/bin"/>
</exec>
<exec executable="cp">
<arg value="-r"/>
<arg line="${jdk.path.macos}/Contents/Home/jmods macos/work/Processing.app/Contents/PlugIns/jdk-${jdk.detail}+${jdk.build}/Contents/Home/jmods"/>
<arg line="${jdk.path.macos}/Contents/Home/jmods macos/work/Processing.app/Contents/PlugIns/${jdk.folder}/Contents/Home/jmods"/>
</exec>
<exec executable="cp">
<arg value="-r"/>
<arg line="${jdk.path.macos}/Contents/Home/legal macos/work/Processing.app/Contents/PlugIns/jdk-${jdk.detail}+${jdk.build}/Contents/Home/legal"/>
<arg line="${jdk.path.macos}/Contents/Home/legal macos/work/Processing.app/Contents/PlugIns/${jdk.folder}/Contents/Home/legal"/>
</exec>
<exec executable="cp">
<arg value="-r"/>
<arg line="${jdk.path.macos}/Contents/Home/conf macos/work/Processing.app/Contents/PlugIns/jdk-${jdk.detail}+${jdk.build}/Contents/Home/conf"/>
<arg line="${jdk.path.macos}/Contents/Home/conf macos/work/Processing.app/Contents/PlugIns/${jdk.folder}/Contents/Home/conf"/>
</exec>
<property name="contents.dir"
@@ -737,7 +742,7 @@
<arg value="--entitlements" />
<arg value="../ffs.entitlements" />
<arg value="Processing.app/Contents/PlugIns/jdk-${jdk.detail}+${jdk.build}" />
<arg value="Processing.app/Contents/PlugIns/${jdk.folder}" />
</exec>
<!-- codesign can't work inside jars? so instead temporarily unpack the files
@@ -1010,12 +1015,10 @@
<arg value="../${jdk.archive.path}"/>
</exec>
<property name="jdk.dir" value="jdk-${jdk.detail}+${jdk.build}/" />
<exec executable="rsync" dir="linux">
<arg value="-a" />
<arg value="--delete" />
<arg value="${jdk.dir}" />
<arg value="${jdk.folder}/" />
<arg value="work/java/" />
</exec>
@@ -1026,7 +1029,7 @@
<exec executable="rm">
<arg value="-r"/>
<arg line="linux/jdk-${jdk.detail}+${jdk.build}"/>
<arg line="linux/${jdk.folder}"/>
</exec>
</target>
@@ -1070,97 +1073,89 @@
</target>
<target name="deb" depends="dist"
description="Build .deb of linux version">
description="Build .deb of the Linux version">
<!-- start with a clean debian folder -->
<delete dir="linux/debian" quiet="true" />
<!-- start with a clean debian folder -->
<delete dir="linux/debian" quiet="true" />
<!-- setup the file structure -->
<mkdir dir="linux/debian/opt" />
<mkdir dir="linux/debian/usr/bin" />
<mkdir dir="linux/debian/usr/share/applications/" />
<mkdir dir="linux/debian/usr/share/mime/packages/" />
<!-- rename the work folder temporarily -->
<move file="linux/work" tofile="linux/debian/opt/processing" />
<symlink link="linux/debian/usr/bin/processing"
resource="../../opt/processing/processing" />
<symlink link="linux/debian/usr/bin/processing-java"
resource="../../opt/processing/processing-java" />
<!-- setup the file structure -->
<mkdir dir="linux/debian/opt" />
<mkdir dir="linux/debian/usr/bin" />
<mkdir dir="linux/debian/usr/share/applications/" />
<mkdir dir="linux/debian/usr/share/mime/packages/" />
<!-- rename the work folder temporarily -->
<move file="linux/work" tofile="linux/debian/opt/processing" />
<symlink link="linux/debian/usr/bin/processing"
resource="../../opt/processing/processing" />
<symlink link="linux/debian/usr/bin/processing-java"
resource="../../opt/processing/processing-java" />
<!-- place .desktop and .sharedmimeinfo file -->
<copy file="linux/processing.desktop"
tofile="linux/debian/usr/share/applications/processing.desktop">
<filterchain>
<replacetokens>
<token key="version" value="${version}" />
</replacetokens>
</filterchain>
</copy>
<copy file="linux/processing.sharedmimeinfo"
tofile="linux/debian/usr/share/mime/packages/processing.xml" />
<!-- place .desktop and .sharedmimeinfo file -->
<copy file="linux/processing.desktop"
tofile="linux/debian/usr/share/applications/processing.desktop">
<filterchain>
<replacetokens>
<token key="version" value="${version}" />
</replacetokens>
</filterchain>
</copy>
<!-- Set properties for DEBIAN/control file -->
<condition property="linux.deb" value="linux/processing-${version}-linux-armv6hf.deb">
<equals arg1="${linux-arm32}" arg2="linux-arm32" />
</condition>
<condition property="linux.deb" value="linux/processing-${version}-linux-arm64.deb">
<equals arg1="${linux-arm64}" arg2="linux-arm64" />
</condition>
<property name="linux.deb" value="linux/processing-${version}-linux${jdk.data.model}.deb" />
<copy file="linux/processing.sharedmimeinfo"
tofile="linux/debian/usr/share/mime/packages/processing.xml" />
<!-- Raspbian seems to borrow armhf for armv6hf, so this works -->
<condition property="deb.arch" value="armhf">
<equals arg1="${linux-arm32}" arg2="linux-arm32" />
</condition>
<condition property="deb.arch" value="arm64">
<equals arg1="${linux-arm64}" arg2="linux-arm64" />
</condition>
<condition property="deb.arch" value="i386">
<equals arg1="${jdk.data.model}" arg2="32" />
</condition>
<condition property="deb.arch" value="amd64">
<equals arg1="${jdk.data.model}" arg2="64" />
</condition>
<!-- Set properties for DEBIAN/control file -->
<length property="deb.bsize" >
<fileset dir="linux/debian" />
</length>
<!-- Testing on a Model 3 (not plus), 4, and 400,
uname is armv7l with raspios dated 2021-10-30.
For most platforms, use os.arch, but use "armv7l" for
32-bit pi because just "arm" is unhelpful/ambiguous. -->
<condition property="deb.arch" value="armv7l" else="${os.arch}">
<equals arg1="${os.arch}" arg2="arm" />
</condition>
<script language="javascript">
<![CDATA[
var length_bytes = project.getProperty("deb.bsize");
var length_kbytes = Math.ceil(length_bytes / 1024);
project.setNewProperty("deb.kbsize", length_kbytes);
]]>
</script>
<property name="linux.deb"
value="linux/processing-${version}-linux-${deb.arch}.deb" />
<!-- place DEBIAN/control file. -->
<mkdir dir="linux/debian/DEBIAN" />
<copy file="linux/control" tofile="linux/debian/DEBIAN/control" >
<filterchain>
<replacetokens >
<token key="version" value="${version}" />
<token key="size" value="${deb.kbsize}" />
<token key="arch" value="${deb.arch}" />
</replacetokens>
</filterchain >
</copy >
<copy file="linux/copyright" tofile="linux/debian/DEBIAN/copyright" />
<length property="deb.bsize" >
<fileset dir="linux/debian" />
</length>
<!-- Create .deb file -->
<exec executable="fakeroot" dir="linux" failonerror="true">
<arg value="dpkg-deb" />
<arg value="--build" />
<arg value="debian" />
<arg value="../${linux.deb}" />
</exec>
<!-- guessing that this will not be working with Java 17 w/o JS -->
<script language="javascript">
<![CDATA[
var length_bytes = project.getProperty("deb.bsize");
var length_kbytes = Math.ceil(length_bytes / 1024);
project.setNewProperty("deb.kbsize", length_kbytes);
]]>
</script>
<!-- put... the candle... back -->
<!-- (rename the debian processing version to work) -->
<move file="linux/debian/opt/processing" tofile="linux/work" />
<!-- place DEBIAN/control file. -->
<mkdir dir="linux/debian/DEBIAN" />
<copy file="linux/control" tofile="linux/debian/DEBIAN/control" >
<filterchain>
<replacetokens>
<token key="version" value="${version}" />
<token key="size" value="${deb.kbsize}" />
<token key="arch" value="${deb.arch}" />
</replacetokens>
</filterchain >
</copy >
<copy file="linux/copyright" tofile="linux/debian/DEBIAN/copyright" />
<!-- cleanup -->
<delete dir="linux/debian" />
<!-- Create .deb file -->
<exec executable="fakeroot" dir="linux" failonerror="true">
<arg value="dpkg-deb" />
<arg value="--build" />
<arg value="debian" />
<arg value="../${linux.deb}" />
</exec>
<!-- put... the candle... back -->
<!-- (rename the debian processing version to work) -->
<move file="linux/debian/opt/processing" tofile="linux/work" />
<!-- cleanup -->
<delete dir="linux/debian" />
<echo>
========================================================
@@ -1289,11 +1284,10 @@
src="${jdk.archive.path}"
overwrite="false" />
<property name="jdk.dir" value="windows/work/jdk-${jdk.detail}+${jdk.build}/" />
<!-- Rename the unpacked JDK to just 'java' and move to dist -->
<move file="windows/work/${jdk.folder}" tofile="windows/work/java" />
<move file="${jdk.dir}" tofile="windows/work/java" />
<!-- Remove unused JRE bloat. -->
<!-- Remove unused Java bloat -->
<delete failonerror="true">
<fileset refid="jdk-optional-windows" />
</delete>