22#include <rtl/ustring.hxx>
23#include <rtl/instance.hxx>
24#include <rtl/bootstrap.hxx>
25#include <osl/diagnose.h>
35 const OUString & StrOperatingSystem()
37 static const OUString theOS = []()
39 OUString os(
"$_OS" );
40 ::rtl::Bootstrap::expandMacros( os );
46 const OUString & StrCPU()
48 static const OUString theCPU = []()
50 OUString arch(
"$_ARCH" );
51 ::rtl::Bootstrap::expandMacros( arch );
58 const OUString & StrPlatform()
60 static const OUString thePlatform = StrOperatingSystem() +
"_" + StrCPU();
64 bool checkOSandCPU(std::u16string_view os, std::u16string_view cpu)
66 return (os == StrOperatingSystem())
70 bool isPlatformSupported( std::u16string_view token )
75 else if (token ==
u"windows_x86")
76 ret = checkOSandCPU(
u"Windows",
u"x86");
77 else if (token ==
u"windows_x86_64")
78 ret = checkOSandCPU(
u"Windows",
u"X86_64");
79 else if (token ==
u"windows_aarch64")
80 ret = checkOSandCPU(
u"Windows",
u"AARCH64");
81 else if (token ==
u"solaris_sparc")
82 ret = checkOSandCPU(
u"Solaris",
u"SPARC");
83 else if (token ==
u"solaris_sparc64")
84 ret = checkOSandCPU(
u"Solaris",
u"SPARC64");
85 else if (token ==
u"solaris_x86")
86 ret = checkOSandCPU(
u"Solaris",
u"x86");
87 else if (token ==
u"macosx_aarch64")
88 ret = checkOSandCPU(
u"MacOSX",
u"AARCH64");
89 else if (token ==
u"macosx_x86_64")
90 ret = checkOSandCPU(
u"MacOSX",
u"X86_64");
91 else if (token ==
u"linux_x86")
92 ret = checkOSandCPU(
u"Linux",
u"x86");
93 else if (token ==
u"linux_x86_64")
94 ret = checkOSandCPU(
u"Linux",
u"X86_64");
95 else if (token ==
u"linux_sparc")
96 ret = checkOSandCPU(
u"Linux",
u"SPARC");
97 else if (token ==
u"linux_sparc64")
98 ret = checkOSandCPU(
u"Linux",
u"SPARC64");
99 else if (token ==
u"linux_powerpc")
100 ret = checkOSandCPU(
u"Linux",
u"PowerPC");
101 else if (token ==
u"linux_powerpc64")
102 ret = checkOSandCPU(
u"Linux",
u"PowerPC_64");
103 else if (token ==
u"linux_powerpc64_le")
104 ret = checkOSandCPU(
u"Linux",
u"PowerPC_64_LE");
105 else if (token ==
u"linux_arm_eabi")
106 ret = checkOSandCPU(
u"Linux",
u"ARM_EABI");
107 else if (token ==
u"linux_arm_oabi")
108 ret = checkOSandCPU(
u"Linux",
u"ARM_OABI");
109 else if (token ==
u"linux_mips_el")
110 ret = checkOSandCPU(
u"Linux",
u"MIPS_EL");
111 else if (token ==
u"linux_mips64_el")
112 ret = checkOSandCPU(
u"Linux",
u"MIPS64_EL");
113 else if (token ==
u"linux_mips_eb")
114 ret = checkOSandCPU(
u"Linux",
u"MIPS_EB");
115 else if (token ==
u"linux_mips64_eb")
116 ret = checkOSandCPU(
u"Linux",
u"MIPS64_EB");
117 else if (token ==
u"linux_ia64")
118 ret = checkOSandCPU(
u"Linux",
u"IA64");
119 else if (token ==
u"linux_m68k")
120 ret = checkOSandCPU(
u"Linux",
u"M68K");
121 else if (token ==
u"linux_s390x")
122 ret = checkOSandCPU(
u"Linux",
u"S390x");
123 else if (token ==
u"linux_hppa")
124 ret = checkOSandCPU(
u"Linux",
u"HPPA");
125 else if (token ==
u"linux_alpha")
126 ret = checkOSandCPU(
u"Linux",
u"ALPHA");
127 else if (token ==
u"linux_aarch64")
128 ret = checkOSandCPU(
u"Linux",
u"AARCH64");
129 else if (token ==
u"linux_riscv64")
130 ret = checkOSandCPU(
u"Linux",
u"RISCV64");
131 else if (token ==
u"linux_loongarch64")
132 ret = checkOSandCPU(
u"Linux",
u"LOONGARCH64");
133 else if (token ==
u"freebsd_x86")
134 ret = checkOSandCPU(
u"FreeBSD",
u"x86");
135 else if (token ==
u"freebsd_x86_64")
136 ret = checkOSandCPU(
u"FreeBSD",
u"X86_64");
137 else if (token ==
u"freebsd_powerpc")
138 ret = checkOSandCPU(
u"FreeBSD",
u"PowerPC");
139 else if (token ==
u"freebsd_powerpc64")
140 ret = checkOSandCPU(
u"FreeBSD",
u"PowerPC64");
141 else if (token ==
u"kfreebsd_x86")
142 ret = checkOSandCPU(
u"kFreeBSD",
u"x86");
143 else if (token ==
u"kfreebsd_x86_64")
144 ret = checkOSandCPU(
u"kFreeBSD",
u"X86_64");
145 else if (token ==
u"netbsd_x86")
146 ret = checkOSandCPU(
u"NetBSD",
u"x86");
147 else if (token ==
u"netbsd_x86_64")
148 ret = checkOSandCPU(
u"NetBSD",
u"X86_64");
149 else if (token ==
u"openbsd_x86")
150 ret = checkOSandCPU(
u"OpenBSD",
u"x86");
151 else if (token ==
u"openbsd_x86_64")
152 ret = checkOSandCPU(
u"OpenBSD",
u"X86_64");
153 else if (token ==
u"dragonfly_x86")
154 ret = checkOSandCPU(
u"DragonFly",
u"x86");
155 else if (token ==
u"dragonfly_x86_64")
156 ret = checkOSandCPU(
u"DragonFly",
u"X86_64");
159 OSL_FAIL(
"Extension Manager: The extension supports an unknown platform. "
160 "Check the platform in the description.xml");
171 return StrPlatform();
179 const std::u16string_view token(
183 (token.find(
'_' ) == std::u16string_view::npos &&
197 for (
const OUString& s : platformStrings)
199 if ( isPlatformSupported( s ) )
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool platform_fits(std::u16string_view platform_string)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool hasValidPlatform(css::uno::Sequence< OUString > const &platformStrings)
determines if the current platform corresponds to one of the platform strings.
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString const & getPlatformString()
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)