@@ -159,19 +159,19 @@ String getVersion() {
159159
160160 if (versionResult. getV3() != 0 ) {
161161 throw new Exception (
162- ' An error occured while trying to detect the version: process exited with exit code: ' +
162+ ' An error occurred while trying to detect the version: process exited with exit code: ' +
163163 versionResult. getV3() +
164164 ' and stderr:\n ' +
165165 versionResult. getV2(). join(" \n " )
166166 );
167167 }
168168
169169 if (versionResult. getV2() != null && ! versionResult. getV2(). isEmpty()) {
170- throw new Exception (' An error occured while trying to detect the version (code 1): ' + versionResult. getV2(). join(" \n " ));
170+ throw new Exception (' An error occurred while trying to detect the version (code 1): ' + versionResult. getV2(). join(" \n " ));
171171 }
172172
173173 if (versionResult. getV1() == null || versionResult. getV1(). size() != 1 ) {
174- throw new Exception (' An error occured while trying to detect the version (code 2): ' + versionResult. getV1(). join(" \n " ));
174+ throw new Exception (' An error occurred while trying to detect the version (code 2): ' + versionResult. getV1(). join(" \n " ));
175175 }
176176
177177 String version = versionResult. getV1()[0 ];
@@ -182,7 +182,7 @@ String getVersion() {
182182
183183 for (version1 in versions) {
184184 if (version != version1) {
185- throw new Exception (" Recievd two versions, that didn't match: " + version1 + " != " + version);
185+ throw new Exception (" Received two versions, that didn't match: " + version1 + " != " + version);
186186 }
187187 }
188188
@@ -192,7 +192,7 @@ String getVersion() {
192192
193193
194194 if (versions. size() == 0 ) {
195- throw new Exception (" ERROR: at least one version has to be detected (at least one abi has to be returend by 'getAndroidABIs()')" );
195+ throw new Exception (" ERROR: at least one version has to be detected (at least one abi has to be returned by 'getAndroidABIs()')" );
196196 }
197197
198198 // we guarantee, that every string in there is the same, and that it has at least one entry
@@ -224,7 +224,81 @@ Boolean shouldBuildUniversalApk(List<String> abisToUse) {
224224
225225 return true ;
226226
227+ }
228+
229+
230+ /**
231+ * get the meson build type
232+ * @return String
233+ */
234+ String getMesonBuildType () {
235+ List<String > abis = getAndroidABIs();
236+ List<String > buildtypes = new ArrayList<String > ();
237+
238+ for (abi in abis) {
239+ File abiDir = getABIDir(abi);
240+
241+ Tuple3<List<String > , List<String > , Integer > buildtypeResult = executePipeline(Arrays . asList(
242+ Arrays . asList(" meson" , " introspect" , " --buildoptions" , abiDir. getAbsolutePath()),
243+ Arrays . asList(" jq" , " -r" , " .[] | select(.name == \" buildtype\" ) | .value" )
244+ ));
245+
246+ if (buildtypeResult. getV3() != 0 ) {
247+ throw new Exception (
248+ ' An error occurred while trying to detect the buildtype: process exited with exit code: ' +
249+ buildtypeResult. getV3() +
250+ ' and stderr:\n ' +
251+ buildtypeResult. getV2(). join(" \n " )
252+ );
253+ }
254+
255+ if (buildtypeResult. getV2() != null && ! buildtypeResult. getV2(). isEmpty()) {
256+ throw new Exception (' An error occurred while trying to detect the buildtype (code 1): ' + buildtypeResult. getV2(). join(" \n " ));
257+ }
258+
259+ if (buildtypeResult. getV1() == null || buildtypeResult. getV1(). size() != 1 ) {
260+ throw new Exception (' An error occurred while trying to detect the buildtype (code 2): ' + buildtypeResult. getV1(). join(" \n " ));
261+ }
262+
263+ String buildtype = buildtypeResult. getV1()[0 ];
227264
265+ if (buildtype == " " ) {
266+ throw new Exception (" Auto detection of buildtype returned invalid buildtype: '" + version + " '" );
267+ }
268+
269+ for (buildtype1 in buildtypes) {
270+ if (buildtype != buildtype1) {
271+ throw new Exception (" Received two buildtypes, that didn't match: " + buildtype1 + " != " + buildtype);
272+ }
273+ }
274+
275+ buildtypes. add(buildtype);
276+
277+ }
278+
279+
280+ if (buildtypes. size() == 0 ) {
281+ throw new Exception (" ERROR: at least one buildtype has to be detected (at least one abi has to be returned by 'getAndroidABIs()')" );
282+ }
283+
284+ // we guarantee, that every string in there is the same, and that it has at least one entry
285+ return buildtypes[0 ];
286+
287+ }
288+
289+ /**
290+ * Returns the aar file for discord
291+ * @return File
292+ */
293+ File getDiscordLib () {
294+ String target = getMesonBuildType() == ' release' ? ' release' : ' debug'
295+ String path = " ../../../../subprojects/discord_social_sdk/lib/" + target + " /discord_partner_sdk.aar" ;
296+ File file = project. file(project. getLayout(). getBuildDirectory(). file(path));
297+ if (! file. exists()){
298+ throw new Exception (" ERROR: discord aar is not present at the location we expected it to be!" )
299+ }
300+
301+ return file;
228302}
229303
230304
@@ -315,4 +389,5 @@ android {
315389
316390dependencies {
317391 implementation fileTree(include : [' *.jar' ], dir : ' libs' )
392+ implementation files(getDiscordLib())
318393}
0 commit comments