55import static io .quarkus .dev .console .QuarkusConsole .IS_WINDOWS ;
66
77import io .quarkus .builder .item .MultiBuildItem ;
8+ import io .smallrye .common .cpu .CPU ;
9+ import io .smallrye .common .os .OS ;
810
911/**
1012 * Native-image might not be supported for a particular
1113 * extension on a given OS or architecture.
1214 */
1315public final class UnsupportedOSBuildItem extends MultiBuildItem {
1416
17+ @ Deprecated (forRemoval = true , since = "3.26.0" )
1518 public static String ARCH = System .getProperty ("os.arch" );
1619
20+ /**
21+ * @deprecated Use {@link OS} instead
22+ */
23+ @ Deprecated (forRemoval = true , since = "3.26.0" )
1724 public enum Os {
1825 WINDOWS (IS_WINDOWS ),
1926 MAC (IS_MAC ),
@@ -27,6 +34,10 @@ public enum Os {
2734 }
2835 }
2936
37+ /**
38+ * @deprecated Use {@link CPU} instead
39+ */
40+ @ Deprecated (forRemoval = true , since = "3.26.0" )
3041 public enum Arch {
3142 AMD64 ("amd64" .equalsIgnoreCase (ARCH )),
3243 AARCH64 ("aarch64" .equalsIgnoreCase (ARCH )),
@@ -39,40 +50,91 @@ public enum Arch {
3950 }
4051 }
4152
42- public final Os os ;
43- public final Arch arch ;
44- public final String error ;
53+ private final OS os ;
54+ private final CPU cpu ;
55+ private final String error ;
4556
57+ /**
58+ * @deprecated Use {@link UnsupportedOSBuildItem#UnsupportedOSBuildItem(io.smallrye.common.os.OS, java.lang.String)} instead
59+ */
60+ @ Deprecated (forRemoval = true , since = "3.26.0" )
4661 public UnsupportedOSBuildItem (Os os , String error ) {
47- this .os = os ;
48- this .arch = Arch .NONE ;
62+ this .os = switch (os ) {
63+ case WINDOWS -> OS .WINDOWS ;
64+ case MAC -> OS .MAC ;
65+ case LINUX -> OS .LINUX ;
66+ case NONE -> null ;
67+ };
68+ this .cpu = null ;
4969 this .error = error ;
5070 }
5171
72+ /**
73+ * @deprecated Use {@link UnsupportedOSBuildItem#UnsupportedOSBuildItem(io.smallrye.common.cpu.CPU, java.lang.String)}
74+ * instead
75+ */
76+ @ Deprecated (forRemoval = true , since = "3.26.0" )
5277 public UnsupportedOSBuildItem (Arch arch , String error ) {
53- this .os = Os .NONE ;
54- this .arch = arch ;
78+ this .os = null ;
79+ this .cpu = switch (arch ) {
80+ case AMD64 -> CPU .x64 ;
81+ case AARCH64 -> CPU .aarch64 ;
82+ case NONE -> null ;
83+ };
5584 this .error = error ;
5685 }
5786
87+ /**
88+ * @deprecated Use
89+ * {@link UnsupportedOSBuildItem#UnsupportedOSBuildItem(io.smallrye.common.os.OS, io.smallrye.common.cpu.CPU, java.lang.String)}
90+ * instead
91+ */
92+ @ Deprecated (forRemoval = true , since = "3.26.0" )
5893 public UnsupportedOSBuildItem (Os os , Arch arch , String error ) {
94+ this .os = switch (os ) {
95+ case WINDOWS -> OS .WINDOWS ;
96+ case MAC -> OS .MAC ;
97+ case LINUX -> OS .LINUX ;
98+ case NONE -> null ;
99+ };
100+ this .cpu = switch (arch ) {
101+ case AMD64 -> CPU .x64 ;
102+ case AARCH64 -> CPU .aarch64 ;
103+ case NONE -> null ;
104+ };
105+ this .error = error ;
106+ }
107+
108+ public UnsupportedOSBuildItem (OS os , String error ) {
109+ this (os , null , error );
110+ }
111+
112+ public UnsupportedOSBuildItem (CPU cpu , String error ) {
113+ this (null , cpu , error );
114+ }
115+
116+ public UnsupportedOSBuildItem (OS os , CPU cpu , String error ) {
59117 this .os = os ;
60- this .arch = arch ;
118+ this .cpu = cpu ;
61119 this .error = error ;
62120 }
63121
64122 public boolean triggerError (boolean isContainerBuild ) {
65123 return
66124 // When the host OS is unsupported, it could have helped to
67125 // run in a Linux builder image (e.g. an extension unsupported on Windows).
68- ((os . active && !isContainerBuild ) ||
126+ ((os != null && os == OS . current () && !isContainerBuild ) ||
69127 // If Linux is the OS the extension does not support,
70128 // it fails in a container build regardless the host OS,
71129 // because we have only Linux based builder images.
72- (isContainerBuild && os == Os .LINUX )) ||
130+ (isContainerBuild && os == OS .LINUX )) ||
73131 // We don't do cross-compilation, even builder images have to be
74132 // of the same arch, e.g. aarch64 Mac using aarch64 Linux builder image.
75133 // So if the arch is unsupported, it fails.
76- arch .active ;
134+ cpu != null && cpu == CPU .host ();
135+ }
136+
137+ public String error () {
138+ return error ;
77139 }
78140}
0 commit comments