Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(android): keep autolinking manifest outside build directory
Calin-Teodor25ec67101054
diff --git a/android/scripts/generate-autolinking.js b/android/scripts/generate-autolinking.jsnew file mode 100644index 0000000000..eaa6c0f934--- /dev/null+++ b/android/scripts/generate-autolinking.js@@ -0,0 +1,31 @@+/* global __dirname, process */++// Writes the RN autolinking manifest outside android/build, so `gradle clean`+// and F-Droid's build-dir cleanup keep it. LIBRE_BUILD filtering is baked in.+const { execFileSync } = require('child_process');+const fs = require('fs');+const path = require('path');++// Keep in sync with libreExcludedModules in android/settings.gradle.+const LIBRE_EXCLUDED_MODULES = [+ '@amplitude/analytics-react-native',+ '@giphy/react-native-sdk',+ '@react-native-google-signin/google-signin'+];++const root = path.resolve(__dirname, '../..');+const out = path.join(root, 'node_modules/.jitsi/autolinking.json');+const config = JSON.parse(execFileSync('npx', [ 'react-native', 'config' ], {+ cwd: root,+ encoding: 'utf8',+ maxBuffer: 64 * 1024 * 1024+}));++// Same truthy values as Groovy's String.toBoolean().+if (/^\s*(true|y|1)\s*$/i.test(process.env.LIBRE_BUILD ?? '')) {+ LIBRE_EXCLUDED_MODULES.forEach(name => delete config.dependencies[name]);+ config.libreBuild = true;+}++fs.mkdirSync(path.dirname(out), { recursive: true });+fs.writeFileSync(out, JSON.stringify(config, null, 2));diff --git a/android/sdk/build.gradle b/android/sdk/build.gradleindex aac2abb254..91f4bbaa80 100644--- a/android/sdk/build.gradle+++ b/android/sdk/build.gradle@@ -176,7 +176,9 @@ android.libraryVariants.all { def variant ->"--reset-cache","--entry-file", "index.android.js","--bundle-output", jsBundleFile,- "--assets-dest", resourcesDir)+ "--assets-dest", resourcesDir,+ // Reuse the autolinking manifest instead of re-running `react-native config`.+ "--config-cmd", "cat '${gradle.ext.autolinkingManifest}'")// Disable bundling on dev buildsenabled !devEnableddiff --git a/android/settings.gradle b/android/settings.gradleindex 8e04f6c660..ae2789f2aa 100644--- a/android/settings.gradle+++ b/android/settings.gradle@@ -15,17 +15,23 @@ def libreExcludedModules = [// Autolinked RN module paths, consumed by sdk/build.gradle.gradle.ext.autolinkedProjects = []-def autolinkingJson = file('build/generated/autolinking/autolinking.json')+def autolinkingJson = file('../node_modules/.jitsi/autolinking.json')if (!autolinkingJson.exists()) {throw new IllegalStateException("Missing ${autolinkingJson}. Run `npm run android-autolinking` before building.")}def json = new JsonSlurper().parseText(autolinkingJson.text)+def libreBuild = (System.env.LIBRE_BUILD ?: 'false').toBoolean()++if (json.libreBuild && !libreBuild) {+ logger.warn("${autolinkingJson} was generated with LIBRE_BUILD; non-free modules are excluded. " ++ 'Run `npm run android-autolinking` to include them.')+}// Filtered here so the includes below and sdk/build.gradle's codegen agree.def autolinkingManifest = autolinkingJson-if ((System.env.LIBRE_BUILD ?: 'false').toBoolean()) {+if (libreBuild) {// Fail loudly if the list above was patched away.if (libreExcludedModules.isEmpty()) {throw new IllegalStateException('LIBRE_BUILD is set but libreExcludedModules is empty.')@@ -33,7 +39,7 @@ if ((System.env.LIBRE_BUILD ?: 'false').toBoolean()) {libreExcludedModules.each { json.dependencies.remove(it) }- autolinkingManifest = file('build/generated/autolinking/autolinking-libre.json')+ autolinkingManifest = new File(autolinkingJson.parentFile, 'autolinking-libre.json')autolinkingManifest.text = JsonOutput.toJson(json)}gradle.ext.autolinkingManifest = autolinkingManifestdiff --git a/package.json b/package.jsonindex 482cdaaab4..6c5623c03e 100644--- a/package.json+++ b/package.json@@ -202,7 +202,7 @@},"license": "Apache-2.0","scripts": {- "android-autolinking": "mkdir -p android/build/generated/autolinking && npx react-native config > android/build/generated/autolinking/autolinking.json",+ "android-autolinking": "node android/scripts/generate-autolinking.js","android-clean-cmake-cache": "find android node_modules -type d -name .cxx -prune -exec rm -rf {} +","lint": "eslint --ext .js,.ts,.tsx --max-warnings 0 . && tsc --noEmit","lint:ci": "eslint --ext .js,.ts,.tsx --max-warnings 0 .",