Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
* [Android] Build cpp/so in integration machine (#2301)
Browse files Browse the repository at this point in the history
* * [Android] Add so to build git ignore, and build it from integration environment.

* * [Android] Remove project.buildCpp and ARMEABI_Size in build.gradle
  • Loading branch information
YorkShen authored and Darin726 committed Apr 10, 2019
1 parent f3f08b6 commit a0222db
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 81 deletions.
7 changes: 7 additions & 0 deletions android/sdk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ assets/main.js
assets/weex-main-jsfm.js
assets/weex-rax-api.js
.externalNativeBuild

/libs/armeabi/libweexcore.so
/libs/armeabi/libweexjss.so
/libs/armeabi-v7a/libweexcore.so
/libs/armeabi-v7a/libweexjss.so
/libs/x86/libweexcore.so
/libs/x86/libweexjss.so
83 changes: 10 additions & 73 deletions android/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ android {
}
}

def ARMEABI_Size = new File(projectDir,"libs/armeabi/libweexcore.so").length();
def ARMEABIV7_Size = new File(projectDir,"libs/armeabi-v7/libweexcore.so").length();
def X86_Size = new File(projectDir,"libs/x86/libweexcore.so").length();
def ndkversion = 16;
def api_level = "";
def compile_tool = "clang";
Expand All @@ -128,14 +125,8 @@ android {
} else {
api_level = "android-19";
}
println "ARMEABI_Size: "+ARMEABI_Size;
println "ARMEABIV7_Size:" + ARMEABIV7_Size;
println "X86_Size:" + X86_Size;

defaultConfig {
buildConfigField "long", "ARMEABI_Size", "${ARMEABI_Size}"
buildConfigField "long", "ARMEABIV7_Size", "${ARMEABIV7_Size}"
buildConfigField "long", "X86_Size", "${X86_Size}"
buildConfigField "String", "buildJavascriptFrameworkVersion", "\"${jsfmVersion}\""
buildConfigField "String", "buildVersion", "\"${version}\""
minSdkVersion project.minSdkVersion
Expand All @@ -152,15 +143,13 @@ android {
abiFilters "armeabi-v7a", "armeabi", "x86"
}
}
if(project.buildCpp) {
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=' + "${api_level}",
'-DANDROID_TOOLCHAIN=' + "${compile_tool}",
'-DANDROID_STL=' + "${cxx_stl}",
'-DCMAKE_BUILD_TYPE=Release',
'-DENABLE_ASAN=false'
}
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=' + "${api_level}",
'-DANDROID_TOOLCHAIN=' + "${compile_tool}",
'-DANDROID_STL=' + "${cxx_stl}",
'-DCMAKE_BUILD_TYPE=Release',
'-DENABLE_ASAN=false'
}
}
}
Expand All @@ -181,11 +170,9 @@ android {
}
}

if(project.buildCpp) {
externalNativeBuild {
cmake {
path '../../weex_core/CMakeLists.txt'
}
externalNativeBuild {
cmake {
path '../../weex_core/CMakeLists.txt'
}
}

Expand Down Expand Up @@ -371,54 +358,4 @@ bintray {
name = project.version
}
}
}

def copy_so_and_backup() {
def cpu_list = ["armeabi", "armeabi-v7a", "x86"]
cpu_list.forEach { cpu_name ->
File so_file = new File(project.buildDir, "/intermediates/bundles/default/jni/" + cpu_name)
if (so_file.exists()) {
println(so_file.getAbsolutePath())
copy {
from so_file.getAbsolutePath()
into new File("libs/" + cpu_name)
include 'libweexjss.so', 'libweexcore.so'
}

if(cpu_name == "armeabi") {
File back_file = new File(project.buildDir, "/intermediates/cmake/release/obj/armeabi/")
//backup so to project'parent's path
File backup_des = new File(project.buildDir.parentFile.parentFile.parentFile.parentFile,"weex_so_armeabi")
if(backup_des.exists()){
backup_des.deleteDir()
backup_des.mkdir()
}
println(backup_des.absolutePath)

println("so backup to "+ backup_des.absolutePath)
copy {
from back_file.getAbsolutePath()
into backup_des
include 'libweexjss.so', 'libweexcore.so'
}
}
}
}
}

task deleteLibs(type: Delete){ item->
project.android.defaultConfig.ndk.abiFilters.each{
item.delete "libs/${it}/libweexcore.so", "libs/${it}/libweexjss.so"
}
}

afterEvaluate { project ->
project.tasks.find { (it.name.contains("assembleRelease")) }?.doLast {
println("begin_copy_so")
copy_so_and_backup()
}

if(project.buildCpp){
transformNativeLibsWithStripDebugSymbolForRelease.dependsOn deleteLibs
}
}
Binary file removed android/sdk/libs/armeabi-v7a/libweexcore.so
Binary file not shown.
Binary file removed android/sdk/libs/armeabi-v7a/libweexjss.so
Binary file not shown.
Binary file removed android/sdk/libs/armeabi/libweexcore.so
Binary file not shown.
Binary file removed android/sdk/libs/armeabi/libweexjss.so
Binary file not shown.
Binary file removed android/sdk/libs/x86/libweexcore.so
Binary file not shown.
Binary file removed android/sdk/libs/x86/libweexjss.so
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.system.ErrnoException;
import android.system.Os;
import android.text.TextUtils;

import com.taobao.weex.IWXStatisticsListener;
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.adapter.IWXSoLoaderAdapter;
import com.taobao.weex.adapter.IWXUserTrackAdapter;
import com.taobao.weex.common.WXErrorCode;

import dalvik.system.PathClassLoader;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.File;
Expand All @@ -48,8 +45,6 @@
import java.util.zip.ZipException;
import java.util.zip.ZipFile;

import dalvik.system.PathClassLoader;


/**
* Utility class for managing so library, including load native library and version management.
Expand All @@ -76,8 +71,6 @@ public class WXSoInstallMgrSdk {
private final static String STARTUPSO = "/libweexjsb.so";
private final static String STARTUPSOANDROID15 = "/libweexjst.so";

private final static int ARMEABI_Size = 3583820;
private final static int X86_Size = 4340864;

static Context mContext = null;
private static IWXSoLoaderAdapter mSoLoader = null;
Expand Down

0 comments on commit a0222db

Please sign in to comment.