Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): 💊 make Android build script cross platform #1684

Merged
merged 4 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cordova/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ The main entrypoint to Android's Java code is `cordova-plugin-outline/android/ja
Additional requirements for Android:

- [Java Development Kit (JDK) 11](https://jdk.java.net/archive/)
- Set `JAVA_HOME` environment variable if you are building on Windows
- Latest [Android Sdk Commandline Tools](https://developer.android.com/studio/command-line) ([download](https://developer.android.com/studio#command-line-tools-only))
- Place it at `$HOME/Android/sdk/cmdline-tools/latest`
- Set `ANDROID_HOME` environment variable
- Android SDK 32 (with build-tools) via commandline `$HOME/Android/sdk/cmdline-tools/latest/bin/sdkmanager "platforms;android-32" "build-tools;32.0.0"`
- [Gradle 7.3+](https://gradle.org/install/)

Expand Down
21 changes: 13 additions & 8 deletions src/cordova/plugin/android/scripts/copy_third_party.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const child_process = require('child_process');
const fs = require('fs/promises');
const path = require('node:path');

module.exports = function(context) {
const ANDROID_LIBS_FOLDER_PATH = path.join('plugins', 'cordova-plugin-outline', 'android', 'libs');
const TUN2SOCKS_ANDROID_FOLDER_PATH = path.join('third_party', 'outline-go-tun2socks', 'android');

module.exports = async function(context) {
console.log('Copying Android third party libraries...');
child_process.execSync('mkdir -p plugins/cordova-plugin-outline/android/libs');
child_process.execSync(
`cp third_party/outline-go-tun2socks/android/tun2socks.aar plugins/cordova-plugin-outline/android/libs/`
);
child_process.execSync(
`cp -R third_party/outline-go-tun2socks/android/jni plugins/cordova-plugin-outline/android/libs/obj`
await fs.mkdir(ANDROID_LIBS_FOLDER_PATH, {recursive: true});
await fs.copyFile(
path.join(TUN2SOCKS_ANDROID_FOLDER_PATH, 'tun2socks.aar'),
path.join(ANDROID_LIBS_FOLDER_PATH, 'tun2socks.aar')
);
await fs.cp(path.join(TUN2SOCKS_ANDROID_FOLDER_PATH, 'jni'), path.join(ANDROID_LIBS_FOLDER_PATH, 'obj'), {
recursive: true,
});
};
Loading