Skip to content

Commit

Permalink
Support Windows 11 on ARM (#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahus1 committed Feb 11, 2024
1 parent 5985ee2 commit 763f7e8
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ This document provides a high-level view of the changes introduced by release.
[[releasenotes]]
== Release notes

=== 0.42.8
=== 0.41.8

- Workaround for slow EDT warning (#1533)
- Support Windows 11 on ARM (#1537)

=== 0.41.7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.asciidoc.intellij.AsciiDocExtensionService;
import org.asciidoc.intellij.AsciiDocWrapper;
import org.asciidoc.intellij.download.AsciiDocDownloaderUtil;
import org.asciidoc.intellij.download.PandocInfo;
import org.asciidoc.intellij.psi.AsciiDocUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
Expand All @@ -48,6 +50,14 @@ public boolean displayTextInToolbar() {
return true;
}

@Override
public void update(@NotNull AnActionEvent event) {
super.update(event);
if (event.getPresentation().isVisible() && !PandocInfo.identify().supported) {
event.getPresentation().setVisible(false);
}
}

@Override
public void actionPerformed(AnActionEvent event) {
project = event.getProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.asciidoc.intellij.AsciiDocBundle;
import org.asciidoc.intellij.AsciiDocWrapper;
import org.asciidoc.intellij.download.AsciiDocDownloaderUtil;
import org.asciidoc.intellij.download.PandocInfo;
import org.asciidoc.intellij.file.AsciiDocFileType;
import org.jetbrains.annotations.NotNull;

Expand All @@ -35,6 +36,14 @@ public class PasteHtmlAction extends AsciiDocAction {

private static final Logger LOG = Logger.getInstance(PasteHtmlAction.class);

@Override
public void update(@NotNull AnActionEvent event) {
super.update(event);
if (event.getPresentation().isVisible() && !PandocInfo.identify().supported) {
event.getPresentation().setVisible(false);
}
}

@Override
public void actionPerformed(AnActionEvent event) {
Project project = event.getProject();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/asciidoc/intellij/arch/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum Platform {
LINUX_ARM(OS.LINUX, Arch.ARM, "arm64"),
LINUX_INTEL_64(OS.LINUX, Arch.INTEL, "amd64"),
WINDOWS_INTEL_64(OS.WINDOWS, Arch.INTEL, "x86_64"),
WINDOWS_ARM(OS.WINDOWS, Arch.ARM, "aarch64"),
MAC_ARM64(OS.MAC, Arch.ARM, "arm64"),
MAC_INTEL_64(OS.MAC, Arch.INTEL, "x86_64"),
OTHER(null, null, "");
Expand Down
63 changes: 42 additions & 21 deletions src/main/java/org/asciidoc/intellij/download/PandocInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@

import java.io.File;

public enum PandocInfo {
@SuppressWarnings("checkstyle:VisibilityModifier")
public class PandocInfo {
// https://github.com/jgm/pandoc/releases/
WINDOWS_INTEL_64("c3541f1a352003498979f2659c2570ac6dd227ec12533b75a76c4d109e75d218", "pandoc.exe", "windows-x86_64.zip"),
LINUX_ARM("8ac04ce0aedae38f0c9f64bfe634910378cc326d091092395a2140a7ec819d54", "bin/pandoc", "linux-arm64.tar.gz"),
LINUX_INTEL_64("4e1c607f7e4e9243fa1e1f5b208cd4f1d3f6fd055d5d8c39ba0cdc38644e1c35", "bin/pandoc", "linux-amd64.tar.gz"),
MAC_ARM64("aa0eab6cf10e5d54d255d68f8fae47e08da071565a3d2b8d242be29a8c1f1460", "bin/pandoc", "arm64-macOS.zip"),
MAC_INTEL_64("72c43b1de30e67d3a2f69bfd69881e5fcf6ed3c2583c2ad22142c390d185f0b4", "bin/pandoc", "x86_64-macOS.zip"),
OTHER(null, null, null);
public static final PandocInfo WINDOWS_INTEL_64 = new PandocInfo(true, "c3541f1a352003498979f2659c2570ac6dd227ec12533b75a76c4d109e75d218", "pandoc.exe", "windows-x86_64.zip");
public static final PandocInfo LINUX_ARM = new PandocInfo(true, "8ac04ce0aedae38f0c9f64bfe634910378cc326d091092395a2140a7ec819d54", "bin/pandoc", "linux-arm64.tar.gz");
public static final PandocInfo LINUX_INTEL_64 = new PandocInfo(true, "4e1c607f7e4e9243fa1e1f5b208cd4f1d3f6fd055d5d8c39ba0cdc38644e1c35", "bin/pandoc", "linux-amd64.tar.gz");
public static final PandocInfo MAC_ARM64 = new PandocInfo(true, "aa0eab6cf10e5d54d255d68f8fae47e08da071565a3d2b8d242be29a8c1f1460", "bin/pandoc", "arm64-macOS.zip");
public static final PandocInfo MAC_INTEL_64 = new PandocInfo(true, "72c43b1de30e67d3a2f69bfd69881e5fcf6ed3c2583c2ad22142c390d185f0b4", "bin/pandoc", "x86_64-macOS.zip");

private static volatile PandocInfo myInfo;

public static final Platform PLATFORM = Platform.identify();
public static final String VERSION = "3.1.2";

public final boolean supported;
public final String hash;
public final String binary;
public final String archiveFilename;
public final String sourceUrl;
public final String extractionDir;

PandocInfo(String hash, String binary, String archiveFilename) {
PandocInfo(boolean supported, String hash, String binary, String archiveFilename) {
this.supported = supported;
this.hash = hash;
this.binary = binary;
this.extractionDir = "pandoc-" + VERSION;
Expand All @@ -31,20 +35,37 @@ public enum PandocInfo {
}

public static PandocInfo identify() {
switch (PLATFORM) {
case WINDOWS_INTEL_64:
return PandocInfo.WINDOWS_INTEL_64;
case MAC_INTEL_64:
return PandocInfo.MAC_INTEL_64;
case MAC_ARM64:
return PandocInfo.MAC_ARM64;
case LINUX_INTEL_64:
return PandocInfo.LINUX_INTEL_64;
case LINUX_ARM:
return PandocInfo.LINUX_ARM;
default:
throw new IllegalStateException("unsupported operating system/arch: " + System.getProperty("os.name"));
if (myInfo == null) {
synchronized (PandocInfo.class) {
switch (PLATFORM) {
case WINDOWS_INTEL_64:
myInfo = PandocInfo.WINDOWS_INTEL_64;
break;
case WINDOWS_ARM:
if ("Windows 10".equals(System.getProperty("os.name"))) {
myInfo = new PandocInfo(false, null, null, null);
}
// Windows 11+ on ARM is able to run unmodified x64 Windows apps
myInfo = PandocInfo.WINDOWS_INTEL_64;
break;
case MAC_INTEL_64:
myInfo = PandocInfo.MAC_INTEL_64;
break;
case MAC_ARM64:
myInfo = PandocInfo.MAC_ARM64;
break;
case LINUX_INTEL_64:
myInfo = PandocInfo.LINUX_INTEL_64;
break;
case LINUX_ARM:
myInfo = PandocInfo.LINUX_ARM;
break;
default:
myInfo = new PandocInfo(false, null, null, null);
}
}
}
return myInfo;
}

public String fullBinaryPath(String baseDir) {
Expand Down

0 comments on commit 763f7e8

Please sign in to comment.