Changeset 19030 in josm


Ignore:
Timestamp:
2024-04-04T19:24:39+02:00 (5 weeks ago)
Author:
taylor.smock
Message:

Fix #21533, see #23600: Native Apple Silicon Support

When building on macOS, the macos-jpackage.sh script now takes two arguments:

  1. The JOSM revision
  2. An additional JDK to build against (this should be of a different architecture)

If an additional JDK is specified, it is assumed that it is a different
architecture, and the two built apps are combined using lipo for a universal binary.

ant.yml does have some changes to make it easier to debug packaging issues in
PRs; the PR does still need to upload the specific package and add its branch to
the triggers.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/ant-test.yml

    r18993 r19030  
    2020      matrix:
    2121        # test against latest update of each major Java version, as well as specific updates of LTS versions:
    22         java: [8, 11, 17, 21, 22-ea]
     22        java: [8, 11, 17, 21, 22]
    2323        os: [ubuntu-latest, macos-latest, windows-latest]
    2424    name: Java ${{ matrix.java }} on ${{ matrix.os }}
     
    4444
    4545      - name: Install Ant
    46         uses: JOSM/JOSMPluginAction/actions/setup-ant@v1
     46        uses: JOSM/JOSMPluginAction/actions/setup-ant@v2
    4747
    4848      - name: Test with Ant
  • trunk/.github/workflows/ant.yml

    r18993 r19030  
    11name: Java CI Build
    22env:
    3   junit_platform_version: '1.9.3'
    43  JAVAFX_VERSION: '17.0.7'
    54on:
     
    6059          draft: false
    6160          prerelease: ${{ env.josm_prerelease }}
     61        if: github.ref == 'refs/heads/master'
    6262
    6363  build:
     
    7070      matrix:
    7171        # test against latest update of each major Java version, as well as specific updates of LTS versions:
    72         java: [8, 11, 17, 21, 22-ea]
    73         os: [ubuntu-latest, macos-latest, windows-latest]
     72        java: [8, 11, 17, 21, 22]
     73        os: [ubuntu-latest, macos-14, windows-latest]
    7474    name: Java ${{ matrix.java }} on ${{ matrix.os }}
    7575    steps:
     
    9393          java-version: ${{ matrix.java }}
    9494
     95      - name: Setup x64 Java (Mac) ${{ matrix.java }}
     96        if: ${{ runner.os == 'macos' && runner.arch == 'ARM64' && always() }}
     97        uses: actions/setup-java@v4
     98        with:
     99          distribution: 'zulu'
     100          java-version: ${{ matrix.java }}
     101          architecture: x64
     102
    95103      - name: Install Ant
    96         uses: JOSM/JOSMPluginAction/actions/setup-ant@v1
     104        uses: JOSM/JOSMPluginAction/actions/setup-ant@v2
    97105
    98106      - name: Optimise images
     
    114122        # Calls ant with -Dreleasebuild=true if we're a 'tested' build
    115123        run: |
    116           export SIGN_KEYSTORE=certificate.p12
    117           echo "$SIGN_CERT" | base64 --decode > $SIGN_KEYSTORE
     124          if [ ! -z "${SIGN_CERT}" ]; then
     125            export SIGN_KEYSTORE=certificate.p12
     126            echo "$SIGN_CERT" | base64 --decode > $SIGN_KEYSTORE
     127          fi
    118128          if [ "${{ needs.createrelease.outputs.josm_prerelease }}" == "true" ]; then
    119129            ANT="ant"
     
    122132          fi
    123133          $ANT dist
    124           rm $SIGN_KEYSTORE
     134          if [ ! -z "${SIGN_KEYSTORE}" ]; then rm $SIGN_KEYSTORE; fi
    125135
    126136      - name: Upload jar
    127         if: ${{ always() }}
     137        if: ${{ always() && needs.createrelease.outputs.upload_url }}
    128138        env:
    129139          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
     
    144154          APPLE_ID_TEAM: ${{ secrets.APPLE_ID_TEAM }}
    145155        run: |
    146           if [ ! -f tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip ]; then
    147             curl -o tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_osx-x64_bin-jmods.zip
    148           fi
    149           unzip tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip
    150           mv javafx-jmods-${JAVAFX_VERSION}/*.jmod $JAVA_HOME/jmods/
    151           ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
     156          function setup_openjfx() {
     157            if [ ! -f tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}_${2}-jmods.zip ]; then
     158              curl -o tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}_${2}-jmods.zip https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_osx-${1}_bin-jmods.zip
     159            fi
     160            unzip tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}_${2}-jmods.zip
     161            mv javafx-jmods-${JAVAFX_VERSION}/*.jmod $JAVA_HOME/jmods/
     162          }
     163
     164          if [ ${{ runner.arch }} == "ARM64" ]; then
     165            JAVA_HOME="${JAVA_HOME_${{ matrix.java }}_ARM64}" PATH="${JAVA_HOME_${{ matrix.java }}_ARM64}/bin:${PATH}" setup_openjfx aarch64 ARM64
     166            JAVA_HOME="${JAVA_HOME_${{ matrix.java }}_X64}" PATH="${JAVA_HOME_${{ matrix.java }}_X64}/bin:${PATH}" setup_openjfx x64 X64
     167            JAVA_HOME="${JAVA_HOME_${{ matrix.java }}_ARM64}" ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }} "${JAVA_HOME_${{ matrix.java }}_X64}"
     168          else
     169            setup_openjfx x64 X64
     170            ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
     171          fi
    152172
    153173      - name: Setup Windows PATH
     
    173193
    174194      - name: Upload macOS app
    175         if: ${{ runner.os == 'macos' && matrix.java != '8' && matrix.java != '11' && always() }}
     195        if: ${{ runner.os == 'macos' && matrix.java != '8' && matrix.java != '11' && always() && needs.createrelease.outputs.upload_url }}
    176196        uses: actions/upload-release-asset@v1
    177197        env:
     
    183203          asset_content_type: application/zip
    184204
     205      - name: Upload macOS app (x64)
     206        if: ${{ runner.os == 'macos' && matrix.java != '8' && matrix.java != '11' && always() && runner.arch == 'ARM64' && needs.createrelease.outputs.upload_url }}
     207        uses: actions/upload-release-asset@v1
     208        env:
     209          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
     210        with:
     211          upload_url: ${{ needs.createrelease.outputs.upload_url }} # This pulls from the CREATE RELEASE job above, referencing its ID to get its outputs object, which include a `upload_url`.
     212          asset_path: app/JOSM_${{ matrix.java }}_x86_64.zip
     213          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}-x64.zip
     214          asset_content_type: application/zip
     215
     216      - name: Upload macOS app (aarch64)
     217        if: ${{ runner.os == 'macos' && matrix.java != '8' && matrix.java != '11' && always() && runner.arch == 'ARM64' && needs.createrelease.outputs.upload_url }}
     218        uses: actions/upload-release-asset@v1
     219        env:
     220          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
     221        with:
     222          upload_url: ${{ needs.createrelease.outputs.upload_url }} # This pulls from the CREATE RELEASE job above, referencing its ID to get its outputs object, which include a `upload_url`.
     223          asset_path: app/JOSM_${{ matrix.java }}_arm64.zip
     224          asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}-aarch64.zip
     225          asset_content_type: application/zip
     226
    185227      - name: Upload Windows Installer executable
    186         if: ${{ runner.os == 'windows' && matrix.java != '8' && matrix.java != '11' && always() }}
     228        if: ${{ runner.os == 'windows' && matrix.java != '8' && matrix.java != '11' && always() && needs.createrelease.outputs.upload_url }}
    187229        uses: actions/upload-release-asset@v1
    188230        env:
     
    195237
    196238      - name: Upload Windows Installer package
    197         if: ${{ runner.os == 'windows' && matrix.java != '8' && matrix.java != '11' && always() }}
     239        if: ${{ runner.os == 'windows' && matrix.java != '8' && matrix.java != '11' && always() && needs.createrelease.outputs.upload_url }}
    198240        uses: actions/upload-release-asset@v1
    199241        env:
  • trunk/native/macosx/macos-jpackage.sh

    r18904 r19030  
    1616if [ -z "${1-}" ]
    1717then
    18     echo "Usage: $0 josm_revision"
     18    echo "Usage: $0 josm_revision [other_arch_jdk]"
    1919    exit 1
    2020fi
     
    5353set -u
    5454
    55 echo "Building and signing app"
    56 # We specifically need the options to not be quoted -- we _want_ the word splitting.
    57 # shellcheck disable=SC2086
    58 jpackage $JPACKAGEOPTIONS -n "JOSM" --input dist --main-jar josm-custom.jar \
    59     --main-class org.openstreetmap.josm.gui.MainApplication \
    60     --icon ./native/macosx/JOSM.icns --type app-image --dest app \
    61     --java-options "--add-modules java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web" \
    62     --java-options "--add-exports=java.base/sun.security.action=ALL-UNNAMED" \
    63     --java-options "--add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED" \
    64     --java-options "--add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED" \
    65     --java-options "--add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED" \
    66     --java-options "--add-opens=java.base/java.lang=ALL-UNNAMED" \
    67     --java-options "--add-opens=java.base/java.nio=ALL-UNNAMED" \
    68     --java-options "--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED" \
    69     --java-options "--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED" \
    70     --java-options "--add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED" \
    71     --java-options "--add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED" \
    72     --java-options "--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED" \
    73     --app-version "$1" \
    74     --copyright "JOSM, and all its integral parts, are released under the GNU General Public License v2 or later" \
    75     --vendor "JOSM" \
    76     --mac-package-identifier de.openstreetmap.josm \
    77     --mac-package-signing-prefix de.openstreetmap.josm \
    78     --file-associations native/file-associations/bz2.properties \
    79     --file-associations native/file-associations/geojson.properties \
    80     --file-associations native/file-associations/gpx.properties \
    81     --file-associations native/file-associations/gz.properties \
    82     --file-associations native/file-associations/jos.properties \
    83     --file-associations native/file-associations/joz.properties \
    84     --file-associations native/file-associations/osm.properties \
    85     --file-associations native/file-associations/xz.properties \
    86     --file-associations native/file-associations/zip.properties \
    87     --add-modules java.compiler,java.base,java.datatransfer,java.desktop,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.sql,java.transaction.xa,java.xml,jdk.crypto.ec,jdk.jfr,jdk.jsobject,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom,javafx.controls,javafx.media,javafx.swing,javafx.web
     55function do_jpackage() {
     56  echo "Building app (${JAVA_HOME})"
     57  # We specifically need the options to not be quoted -- we _want_ the word splitting.
     58  # shellcheck disable=SC2086
     59  "${JAVA_HOME}/bin/jpackage" $JPACKAGEOPTIONS -n "JOSM" --input dist --main-jar josm-custom.jar \
     60      --main-class org.openstreetmap.josm.gui.MainApplication \
     61      --icon ./native/macosx/JOSM.icns --type app-image --dest app \
     62      --java-options "--add-modules java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web" \
     63      --java-options "--add-exports=java.base/sun.security.action=ALL-UNNAMED" \
     64      --java-options "--add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED" \
     65      --java-options "--add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED" \
     66      --java-options "--add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED" \
     67      --java-options "--add-opens=java.base/java.lang=ALL-UNNAMED" \
     68      --java-options "--add-opens=java.base/java.nio=ALL-UNNAMED" \
     69      --java-options "--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED" \
     70      --java-options "--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED" \
     71      --java-options "--add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED" \
     72      --java-options "--add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED" \
     73      --java-options "--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED" \
     74      --app-version "$1" \
     75      --copyright "JOSM, and all its integral parts, are released under the GNU General Public License v2 or later" \
     76      --vendor "JOSM" \
     77      --mac-package-identifier de.openstreetmap.josm \
     78      --mac-package-signing-prefix de.openstreetmap.josm \
     79      --file-associations native/file-associations/bz2.properties \
     80      --file-associations native/file-associations/geojson.properties \
     81      --file-associations native/file-associations/gpx.properties \
     82      --file-associations native/file-associations/gz.properties \
     83      --file-associations native/file-associations/jos.properties \
     84      --file-associations native/file-associations/joz.properties \
     85      --file-associations native/file-associations/osm.properties \
     86      --file-associations native/file-associations/xz.properties \
     87      --file-associations native/file-associations/zip.properties \
     88      --add-modules java.compiler,java.base,java.datatransfer,java.desktop,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.sql,java.transaction.xa,java.xml,jdk.crypto.ec,jdk.jfr,jdk.jsobject,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom,javafx.controls,javafx.media,javafx.swing,javafx.web
     89  echo "Building done (${JAVA_HOME})."
     90}
     91function do_signapp() {
     92  echo "Compressing app (${1})"
     93  ditto -c -k --zlibCompressionLevel 9 --keepParent "app/${1}.app" "app/${1}.zip"
     94  if $SIGNAPP; then
     95      echo "Signing app (${1})"
     96      echo "Preparing for notarization"
     97      echo "Uploading to Apple"
     98      xcrun notarytool submit --apple-id "$APPLE_ID" --password "$APPLE_ID_PW" --team-id "$APPLE_ID_TEAM" --wait "app/${1}.zip"
     99  fi
     100}
    88101
    89 echo "Building done."
     102function merge() {
     103  if [ "$(command -v lipo)" ]; then
     104    lipo -create -output "${1}" "${2}" "${3}"
     105  elif [ "$(command -v llvm-lipo-15)" ]; then
     106    llvm-lipo-15 -create -output "${1}" "${2}" "${3}"
     107  fi
     108}
    90109
    91 if $SIGNAPP; then
    92     echo "Preparing for notarization"
    93     ditto -c -k --zlibCompressionLevel 9 --keepParent app/JOSM.app app/JOSM.zip
     110function copy() {
     111  # Trim the root path
     112  FILE="${1#*/}"
     113  if [ ! -e "${2}/${FILE}" ]; then
     114    # Only make directories if we aren't looking at the root files
     115    if [[ "${FILE}" == *"/"* ]]; then mkdir -p "${2}/${FILE%/*}"; fi
     116    if file "${1}" | grep -q 'Mach-O' ; then
     117      merge "${2}/${FILE}" "${3}/${FILE}" "${4}/${FILE}"
     118      if file "${1}" | grep -q 'executable'; then
     119        chmod 755 "${2}/${FILE}"
     120      fi
     121    else
     122      cp -a "${1}" "${2}/${FILE}"
     123    fi
     124  fi
     125}
    94126
    95     echo "Uploading to Apple"
    96     xcrun notarytool submit --apple-id "$APPLE_ID" --password "$APPLE_ID_PW" --team-id "$APPLE_ID_TEAM" --wait app/JOSM.zip
     127function directory_iterate() {
     128  while IFS= read -r -d '' file
     129  do
     130    copy "${file}" "${2}" "${3}" "${4}" &
     131  done <   <(find "${1}" -type f,l -print0)
     132  wait
     133}
     134
     135do_jpackage "${1}"
     136if [ -n "${2}" ]; then
     137  function get_name() {
     138    echo "$("${JAVA_HOME}/bin/java" --version | head -n1 | awk '{print $2}' | awk -F'.' '{print $1}')_$(file "${JAVA_HOME}/bin/java" | awk -F' executable ' '{print $2}')"
     139  }
     140  first="$(get_name)"
     141  JAVA_HOME="${2}" second="$(get_name)"
     142  mv app/JOSM.app "app/JOSM_${first}.app"
     143  JAVA_HOME="${2}" do_jpackage "${1}"
     144  mv app/JOSM.app "app/JOSM_${second}.app"
     145  mkdir app/JOSM.app
     146  (cd app
     147  directory_iterate "JOSM_${first}.app" "JOSM.app" "JOSM_${first}.app" "JOSM_${second}.app"
     148  directory_iterate "JOSM_${second}.app" "JOSM.app" "JOSM_${first}.app" "JOSM_${second}.app"
     149  )
     150  do_signapp "JOSM_${first}"
     151  do_signapp "JOSM_${second}"
    97152fi
     153do_signapp JOSM
Note: See TracChangeset for help on using the changeset viewer.