aboutsummaryrefslogtreecommitdiff
path: root/builder/src/main/java/com
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@google.com>2013-11-13 14:43:16 -0800
committerXavier Ducrohet <xav@google.com>2013-11-13 18:56:55 -0800
commit2e1f7810edd76d92cee8d3e06bc4dec0c288adea (patch)
tree2955ede4f3b63c7b04d7124b5aeffad59d9fcc66 /builder/src/main/java/com
parentd3cc5cac69f3e2229a353554f6f50d969610ce3d (diff)
downloadbuild-2e1f7810edd76d92cee8d3e06bc4dec0c288adea.tar.gz
Renderscript Support Mode.
Change-Id: If469c1edc5f38671cdebc5271b14a2e1b908f428
Diffstat (limited to 'builder/src/main/java/com')
-rw-r--r--builder/src/main/java/com/android/builder/AndroidBuilder.java153
-rw-r--r--builder/src/main/java/com/android/builder/DefaultProductFlavor.java19
-rw-r--r--builder/src/main/java/com/android/builder/internal/compiler/RenderScriptProcessor.java389
3 files changed, 489 insertions, 72 deletions
diff --git a/builder/src/main/java/com/android/builder/AndroidBuilder.java b/builder/src/main/java/com/android/builder/AndroidBuilder.java
index 83e345d..feaa7c8 100644
--- a/builder/src/main/java/com/android/builder/AndroidBuilder.java
+++ b/builder/src/main/java/com/android/builder/AndroidBuilder.java
@@ -16,7 +16,6 @@
package com.android.builder;
-import com.android.SdkConstants;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.annotations.VisibleForTesting;
@@ -28,12 +27,13 @@ import com.android.builder.internal.SymbolLoader;
import com.android.builder.internal.SymbolWriter;
import com.android.builder.internal.TestManifestGenerator;
import com.android.builder.internal.compiler.AidlProcessor;
-import com.android.builder.internal.compiler.FileGatherer;
import com.android.builder.internal.compiler.LeafFolderGatherer;
+import com.android.builder.internal.compiler.RenderScriptProcessor;
import com.android.builder.internal.compiler.SourceSearcher;
import com.android.builder.internal.packaging.JavaResourceProcessor;
import com.android.builder.internal.packaging.Packager;
import com.android.builder.model.AaptOptions;
+import com.android.builder.model.ProductFlavor;
import com.android.builder.model.SigningConfig;
import com.android.builder.packaging.DuplicateFileException;
import com.android.builder.packaging.PackagerException;
@@ -55,6 +55,7 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
import com.google.common.io.Files;
import java.io.File;
@@ -85,7 +86,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
* {@link #processResources(java.io.File, java.io.File, java.io.File, java.util.List, String, String, String, String, String, com.android.builder.VariantConfiguration.Type, boolean, com.android.builder.model.AaptOptions)}
* {@link #compileAllAidlFiles(java.util.List, java.io.File, java.util.List, com.android.builder.compiling.DependencyFileProcessor)}
* {@link #convertByteCode(Iterable, Iterable, File, DexOptions, boolean)}
- * {@link #packageApk(String, String, java.util.List, String, String, boolean, SigningConfig, String)}
+ * {@link #packageApk(String, String, java.util.List, String, java.util.Collection, java.util.Set, boolean, com.android.builder.model.SigningConfig, String)}
*
* Java compilation is not handled but the builder provides the bootclasspath with
* {@link #getBootClasspath(SdkParser)}.
@@ -192,6 +193,61 @@ public class AndroidBuilder {
return classpath;
}
+ /**
+ * Returns the compile classpath for this config. If the config tests a library, this
+ * will include the classpath of the tested config
+ *
+ * @return a non null, but possibly empty set.
+ */
+ @NonNull
+ public Set<File> getCompileClasspath(@NonNull VariantConfiguration variantConfiguration) {
+ Set<File> compileClasspath = variantConfiguration.getCompileClasspath();
+
+ ProductFlavor mergedFlavor = variantConfiguration.getMergedFlavor();
+
+ if (mergedFlavor.getRenderscriptSupportMode()) {
+ File renderScriptSupportJar = RenderScriptProcessor.getSupportJar(
+ mBuildTools.getLocation().getAbsolutePath());
+
+ Set<File> fullJars = Sets.newHashSetWithExpectedSize(compileClasspath.size() + 1);
+ fullJars.addAll(compileClasspath);
+ fullJars.add(renderScriptSupportJar);
+ compileClasspath = fullJars;
+ }
+
+ return compileClasspath;
+ }
+
+ /**
+ * Returns the list of packaged jars for this config. If the config tests a library, this
+ * will include the jars of the tested config
+ *
+ * @return a non null, but possibly empty list.
+ */
+ @NonNull
+ public List<File> getPackagedJars(@NonNull VariantConfiguration variantConfiguration) {
+ List<File> packagedJars = variantConfiguration.getPackagedJars();
+
+ ProductFlavor mergedFlavor = variantConfiguration.getMergedFlavor();
+
+ if (mergedFlavor.getRenderscriptSupportMode()) {
+ File renderScriptSupportJar = RenderScriptProcessor.getSupportJar(
+ mBuildTools.getLocation().getAbsolutePath());
+
+ List<File> fullJars = Lists.newArrayListWithCapacity(packagedJars.size() + 1);
+ fullJars.addAll(packagedJars);
+ fullJars.add(renderScriptSupportJar);
+ packagedJars = fullJars;
+ }
+
+ return packagedJars;
+ }
+
+ @NonNull
+ public File getSupportNativeLibFolder() {
+ return RenderScriptProcessor.getSupportNativeLibFolder(
+ mBuildTools.getLocation().getAbsolutePath());
+ }
/**
* Returns an {@link AaptRunner} able to run aapt commands.
@@ -806,9 +862,13 @@ public class AndroidBuilder {
@NonNull List<File> importFolders,
@NonNull File sourceOutputDir,
@NonNull File resOutputDir,
+ @NonNull File objOutputDir,
+ @NonNull File libOutputDir,
int targetApi,
boolean debugBuild,
- int optimLevel)
+ int optimLevel,
+ boolean supportMode,
+ @Nullable Set<String> abiFilters)
throws IOException, InterruptedException, LoggedErrorException {
checkNotNull(sourceFolders, "sourceFolders cannot be null.");
checkNotNull(importFolders, "importFolders cannot be null.");
@@ -820,76 +880,25 @@ public class AndroidBuilder {
throw new IllegalStateException("llvm-rs-cc is missing");
}
- // gather the files to compile
- FileGatherer fileGatherer = new FileGatherer();
- SourceSearcher searcher = new SourceSearcher(sourceFolders, "rs", "fs");
- searcher.setUseExecutor(false);
- searcher.search(fileGatherer);
-
- List<File> renderscriptFiles = fileGatherer.getFiles();
-
- if (renderscriptFiles.isEmpty()) {
- return;
- }
-
- String rsPath = mBuildTools.getPath(BuildToolInfo.PathId.ANDROID_RS);
- String rsClangPath = mBuildTools.getPath(BuildToolInfo.PathId.ANDROID_RS_CLANG);
-
- // the renderscript compiler doesn't expect the top res folder,
- // but the raw folder directly.
- File rawFolder = new File(resOutputDir, SdkConstants.FD_RES_RAW);
-
- // compile all the files in a single pass
- ArrayList<String> command = Lists.newArrayList();
-
- command.add(renderscript);
-
- if (debugBuild) {
- command.add("-g");
- }
-
- command.add("-O");
- command.add(Integer.toString(optimLevel));
-
- // add all import paths
- command.add("-I");
- command.add(rsPath);
- command.add("-I");
- command.add(rsClangPath);
-
- for (File importPath : importFolders) {
- if (importPath.isDirectory()) {
- command.add("-I");
- command.add(importPath.getAbsolutePath());
- }
- }
-
- // source output
- command.add("-p");
- command.add(sourceOutputDir.getAbsolutePath());
-
- // res output
- command.add("-o");
- command.add(rawFolder.getAbsolutePath());
-
- command.add("-target-api");
- command.add(Integer.toString(targetApi < 11 ? 11 : targetApi));
-
- // input files
- for (File sourceFile : renderscriptFiles) {
- command.add(sourceFile.getAbsolutePath());
- }
-
- Map<String, String> env = null;
- if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) {
- env = Maps.newHashMap();
- env.put("DYLD_LIBRARY_PATH", mBuildTools.getLocation().getAbsolutePath());
- } else if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_LINUX) {
- env = Maps.newHashMap();
- env.put("LD_LIBRARY_PATH", mBuildTools.getLocation().getAbsolutePath());
+ if (supportMode && mBuildTools.getRevision().compareTo(new FullRevision(18,1, 0)) == -1) {
+ throw new IllegalStateException(
+ "RenderScript Support Mode requires buildToolsVersion >= 18.1");
}
- mCmdLineRunner.runCmdLine(command, env);
+ RenderScriptProcessor processor = new RenderScriptProcessor(
+ sourceFolders,
+ importFolders,
+ sourceOutputDir,
+ resOutputDir,
+ objOutputDir,
+ libOutputDir,
+ mBuildTools,
+ targetApi,
+ debugBuild,
+ optimLevel,
+ supportMode,
+ abiFilters);
+ processor.build(mCmdLineRunner);
}
/**
diff --git a/builder/src/main/java/com/android/builder/DefaultProductFlavor.java b/builder/src/main/java/com/android/builder/DefaultProductFlavor.java
index 844485f..f739a3f 100644
--- a/builder/src/main/java/com/android/builder/DefaultProductFlavor.java
+++ b/builder/src/main/java/com/android/builder/DefaultProductFlavor.java
@@ -36,6 +36,7 @@ public class DefaultProductFlavor extends BaseConfigImpl implements ProductFlavo
private int mMinSdkVersion = -1;
private int mTargetSdkVersion = -1;
private int mRenderscriptTargetApi = -1;
+ private Boolean mRenderscriptSupportMode;
private int mVersionCode = -1;
private String mVersionName = null;
private String mPackageName = null;
@@ -147,6 +148,16 @@ public class DefaultProductFlavor extends BaseConfigImpl implements ProductFlavo
mRenderscriptTargetApi = renderscriptTargetApi;
}
+ @Override
+ public boolean getRenderscriptSupportMode() {
+ // default is false
+ return mRenderscriptSupportMode != null && mRenderscriptSupportMode.booleanValue();
+ }
+
+ public void setRenderscriptSupportMode(boolean renderscriptSupportMode) {
+ mRenderscriptSupportMode = renderscriptSupportMode;
+ }
+
@NonNull
public ProductFlavor setTestPackageName(String testPackageName) {
mTestPackageName = testPackageName;
@@ -219,6 +230,8 @@ public class DefaultProductFlavor extends BaseConfigImpl implements ProductFlavo
flavor.mTargetSdkVersion = chooseInt(mTargetSdkVersion, base.mTargetSdkVersion);
flavor.mRenderscriptTargetApi = chooseInt(mRenderscriptTargetApi,
base.mRenderscriptTargetApi);
+ flavor.mRenderscriptSupportMode = chooseBoolean(mRenderscriptSupportMode,
+ base.mRenderscriptSupportMode);
flavor.mVersionCode = chooseInt(mVersionCode, base.mVersionCode);
flavor.mVersionName = chooseString(mVersionName, base.mVersionName);
@@ -266,6 +279,10 @@ public class DefaultProductFlavor extends BaseConfigImpl implements ProductFlavo
if (mMinSdkVersion != that.mMinSdkVersion) return false;
if (mTargetSdkVersion != that.mTargetSdkVersion) return false;
if (mRenderscriptTargetApi != that.mRenderscriptTargetApi) return false;
+ if (mRenderscriptSupportMode != null ?
+ !mRenderscriptSupportMode.equals(that.mRenderscriptSupportMode) :
+ that.mRenderscriptSupportMode != null)
+ return false;
if (mVersionCode != that.mVersionCode) return false;
if (mPackageName != null ?
!mPackageName.equals(that.mPackageName) :
@@ -303,6 +320,7 @@ public class DefaultProductFlavor extends BaseConfigImpl implements ProductFlavo
result = 31 * result + mMinSdkVersion;
result = 31 * result + mTargetSdkVersion;
result = 31 * result + mRenderscriptTargetApi;
+ result = 31 * result + (mRenderscriptSupportMode != null ? mRenderscriptSupportMode.hashCode() : 0);
result = 31 * result + mVersionCode;
result = 31 * result + (mVersionName != null ? mVersionName.hashCode() : 0);
result = 31 * result + (mPackageName != null ? mPackageName.hashCode() : 0);
@@ -325,6 +343,7 @@ public class DefaultProductFlavor extends BaseConfigImpl implements ProductFlavo
.add("minSdkVersion", mMinSdkVersion)
.add("targetSdkVersion", mTargetSdkVersion)
.add("renderscriptTargetApi", mRenderscriptTargetApi)
+ .add("renderscriptSupportMode", mRenderscriptSupportMode)
.add("versionCode", mVersionCode)
.add("versionName", mVersionName)
.add("packageName", mPackageName)
diff --git a/builder/src/main/java/com/android/builder/internal/compiler/RenderScriptProcessor.java b/builder/src/main/java/com/android/builder/internal/compiler/RenderScriptProcessor.java
new file mode 100644
index 0000000..80096e9
--- /dev/null
+++ b/builder/src/main/java/com/android/builder/internal/compiler/RenderScriptProcessor.java
@@ -0,0 +1,389 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package com.android.builder.internal.compiler;
+
+import com.android.SdkConstants;
+import com.android.annotations.NonNull;
+import com.android.annotations.Nullable;
+import com.android.ide.common.internal.CommandLineRunner;
+import com.android.ide.common.internal.LoggedErrorException;
+import com.android.ide.common.internal.WaitableExecutor;
+import com.android.sdklib.BuildToolInfo;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import static com.android.SdkConstants.EXT_BC;
+import static com.android.SdkConstants.FN_RENDERSCRIPT_V8_JAR;
+
+/**
+ * Compiles Renderscript files.
+ */
+public class RenderScriptProcessor {
+
+ // ABI list, as pairs of (android-ABI, toolchain-ABI)
+ private static final class Abi {
+
+ @NonNull
+ private final String mDevice;
+ @NonNull
+ private final String mToolchain;
+ @NonNull
+ private final BuildToolInfo.PathId mLinker;
+ @NonNull
+ private final String[] mLinkerArgs;
+
+ Abi(@NonNull String device,
+ @NonNull String toolchain,
+ @NonNull BuildToolInfo.PathId linker,
+ @NonNull String... linkerArgs) {
+
+ mDevice = device;
+ mToolchain = toolchain;
+ mLinker = linker;
+ mLinkerArgs = linkerArgs;
+ }
+ }
+
+ private static final Abi[] ABIS = {
+ new Abi("armeabi-v7a", "armv7-none-linux-gnueabi", BuildToolInfo.PathId.LD_ARM,
+ "-dynamic-linker", "/system/bin/linker", "-X", "-m", "armelf_linux_eabi"),
+ new Abi("mips", "mipsel-unknown-linux", BuildToolInfo.PathId.LD_MIPS, "-EL"),
+ new Abi("x86", "i686-unknown-linux", BuildToolInfo.PathId.LD_X86, "-m", "elf_i386") };
+
+ public static final String RS_DEPS = "rsDeps";
+
+ @NonNull
+ private final List<File> mSourceFolders;
+
+ @NonNull
+ private final List<File> mImportFolders;
+
+ @NonNull
+ private final File mSourceOutputDir;
+
+ @NonNull
+ private final File mResOutputDir;
+
+ @NonNull
+ private final File mObjOutputDir;
+
+ @NonNull
+ private final File mLibOutputDir;
+
+ @NonNull
+ private final BuildToolInfo mBuildToolInfo;
+
+ private final int mTargetApi;
+
+ private final boolean mDebugBuild;
+
+ private final int mOptimLevel;
+
+ private final boolean mSupportMode;
+ private final Set<String> mAbiFilters;
+
+ private final File mRsLib;
+ private final File mLibClCore;
+
+ public RenderScriptProcessor(
+ @NonNull List<File> sourceFolders,
+ @NonNull List<File> importFolders,
+ @NonNull File sourceOutputDir,
+ @NonNull File resOutputDir,
+ @NonNull File objOutputDir,
+ @NonNull File libOutputDir,
+ @NonNull BuildToolInfo buildToolInfo,
+ int targetApi,
+ boolean debugBuild,
+ int optimLevel,
+ boolean supportMode,
+ @Nullable Set<String> abiFilters) {
+ mSourceFolders = sourceFolders;
+ mImportFolders = importFolders;
+ mSourceOutputDir = sourceOutputDir;
+ mResOutputDir = resOutputDir;
+ mObjOutputDir = objOutputDir;
+ mLibOutputDir = libOutputDir;
+ mBuildToolInfo = buildToolInfo;
+ mTargetApi = targetApi;
+ mDebugBuild = debugBuild;
+ mOptimLevel = optimLevel;
+ mSupportMode = supportMode;
+ mAbiFilters = abiFilters;
+
+ if (supportMode) {
+ File rs = new File(mBuildToolInfo.getLocation(), "renderscript");
+ mRsLib = new File(rs, "lib");
+ mLibClCore = new File(mRsLib, "libclcore.bc");
+ } else {
+ mLibClCore = null;
+ mRsLib = null;
+ }
+ }
+
+ public static File getSupportJar(String buildToolsFolder) {
+ return new File(buildToolsFolder, "renderscript/lib/" + FN_RENDERSCRIPT_V8_JAR);
+ }
+
+ public static File getSupportNativeLibFolder(String buildToolsFolder) {
+ File rs = new File(buildToolsFolder, "renderscript");
+ File lib = new File(rs, "lib");
+ return new File(lib, "packaged");
+ }
+
+ public void build(@NonNull CommandLineRunner launcher)
+ throws IOException, InterruptedException, LoggedErrorException {
+
+ // gather the files to compile
+ FileGatherer fileGatherer = new FileGatherer();
+ SourceSearcher searcher = new SourceSearcher(mSourceFolders, "rs", "fs");
+ searcher.setUseExecutor(false);
+ searcher.search(fileGatherer);
+
+ List<File> renderscriptFiles = fileGatherer.getFiles();
+
+ if (renderscriptFiles.isEmpty()) {
+ return;
+ }
+
+ // get the env var
+ Map<String, String> env = Maps.newHashMap();
+ if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) {
+ env.put("DYLD_LIBRARY_PATH", mBuildToolInfo.getLocation().getAbsolutePath());
+ } else if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_LINUX) {
+ env.put("LD_LIBRARY_PATH", mBuildToolInfo.getLocation().getAbsolutePath());
+ }
+
+ doMainCompilation(renderscriptFiles, launcher, env);
+
+ if (mSupportMode) {
+ createSupportFiles(launcher, env);
+ }
+ }
+
+ private void doMainCompilation(
+ @NonNull List<File> inputFiles,
+ @NonNull CommandLineRunner launcher,
+ @NonNull Map<String, String> env)
+ throws IOException, InterruptedException, LoggedErrorException {
+
+ String renderscript = mBuildToolInfo.getPath(BuildToolInfo.PathId.LLVM_RS_CC);
+ if (renderscript == null || !new File(renderscript).isFile()) {
+ throw new IllegalStateException(BuildToolInfo.PathId.LLVM_RS_CC + " is missing");
+ }
+
+ String rsPath = mBuildToolInfo.getPath(BuildToolInfo.PathId.ANDROID_RS);
+ String rsClangPath = mBuildToolInfo.getPath(BuildToolInfo.PathId.ANDROID_RS_CLANG);
+
+ // the renderscript compiler doesn't expect the top res folder,
+ // but the raw folder directly.
+ File rawFolder = new File(mResOutputDir, SdkConstants.FD_RES_RAW);
+
+ // compile all the files in a single pass
+ ArrayList<String> command = Lists.newArrayListWithExpectedSize(26);
+
+ command.add(renderscript);
+
+ // Due to a device side bug, let's not enable this at this time.
+// if (mDebugBuild) {
+// command.add("-g");
+// }
+
+ command.add("-O");
+ command.add(Integer.toString(mOptimLevel));
+
+ // add all import paths
+ command.add("-I");
+ command.add(rsPath);
+ command.add("-I");
+ command.add(rsClangPath);
+
+ for (File importPath : mImportFolders) {
+ if (importPath.isDirectory()) {
+ command.add("-I");
+ command.add(importPath.getAbsolutePath());
+ }
+ }
+
+ if (mSupportMode) {
+ command.add("-rs-package-name=android.support.v8.renderscript");
+ }
+
+ // source output
+ command.add("-p");
+ command.add(mSourceOutputDir.getAbsolutePath());
+
+ // res output
+ command.add("-o");
+ command.add(rawFolder.getAbsolutePath());
+
+ command.add("-target-api");
+ int targetApi = mTargetApi < 11 ? 11 : mTargetApi;
+ targetApi = (mSupportMode && targetApi < 18) ? 18 : targetApi;
+ command.add(Integer.toString(targetApi));
+
+ // input files
+ for (File sourceFile : inputFiles) {
+ command.add(sourceFile.getAbsolutePath());
+ }
+
+ launcher.runCmdLine(command, env);
+ }
+
+ private void createSupportFiles(@NonNull final CommandLineRunner launcher,
+ @NonNull final Map<String, String> env)
+ throws IOException, InterruptedException, LoggedErrorException {
+ // get the generated BC files.
+ File rawFolder = new File(mResOutputDir, SdkConstants.FD_RES_RAW);
+
+ SourceSearcher searcher = new SourceSearcher(
+ Collections.singletonList(rawFolder), EXT_BC);
+ FileGatherer fileGatherer = new FileGatherer();
+ searcher.search(fileGatherer);
+
+ WaitableExecutor<Void> mExecutor = new WaitableExecutor<Void>();
+
+ for (final File bcFile : fileGatherer.getFiles()) {
+ String name = bcFile.getName();
+ final String objName = name.replaceAll("\\.bc", ".o");
+ final String soName = "librs." + name.replaceAll("\\.bc", ".so");
+
+ for (final Abi abi : ABIS) {
+ if (mAbiFilters != null && !mAbiFilters.contains(abi.mDevice)) {
+ continue;
+ }
+
+ // make sure the dest folders exist
+ final File objAbiFolder = new File(mObjOutputDir, abi.mDevice);
+ if (!objAbiFolder.isDirectory() && !objAbiFolder.mkdirs()) {
+ throw new IOException("Unable to create dir " + objAbiFolder.getAbsolutePath());
+ }
+
+ final File libAbiFolder = new File(mLibOutputDir, abi.mDevice);
+ if (!libAbiFolder.isDirectory() && !libAbiFolder.mkdirs()) {
+ throw new IOException("Unable to create dir " + libAbiFolder.getAbsolutePath());
+ }
+
+ mExecutor.execute(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ File objFile = createSupportObjFile(bcFile, abi, objName, objAbiFolder,
+ launcher, env);
+ createSupportLibFile(objFile, abi, soName, libAbiFolder, launcher, env);
+ return null;
+ }
+ });
+ }
+ }
+
+ mExecutor.waitForTasksWithQuickFail(true /*cancelRemaining*/);
+ }
+
+ private File createSupportObjFile(
+ @NonNull File bcFile,
+ @NonNull Abi abi,
+ @NonNull String objName,
+ @NonNull File objAbiFolder,
+ @NonNull CommandLineRunner launcher,
+ @NonNull Map<String, String> env)
+ throws IOException, InterruptedException, LoggedErrorException {
+
+ List<String> args = Lists.newArrayListWithExpectedSize(10);
+
+ args.add(mBuildToolInfo.getPath(BuildToolInfo.PathId.BCC_COMPAT));
+
+ args.add("-O" + Integer.toString(mOptimLevel));
+
+ File outFile = new File(objAbiFolder, objName);
+ args.add("-o");
+ args.add(outFile.getAbsolutePath());
+
+ args.add("-fPIC");
+ args.add("-shared");
+
+ args.add("-rt-path");
+ args.add(mLibClCore.getAbsolutePath());
+
+ args.add("-mtriple");
+ args.add(abi.mToolchain);
+
+ args.add(bcFile.getAbsolutePath());
+
+ launcher.runCmdLine(args, env);
+
+ return outFile;
+ }
+
+ private void createSupportLibFile(
+ @NonNull File objFile,
+ @NonNull Abi abi,
+ @NonNull String soName,
+ @NonNull File libAbiFolder,
+ @NonNull CommandLineRunner launcher,
+ @NonNull Map<String, String> env)
+ throws IOException, InterruptedException, LoggedErrorException {
+
+ File intermediatesFolder = new File(mRsLib, "intermediates");
+ File intermediatesAbiFolder = new File(intermediatesFolder, abi.mDevice);
+ File packagedFolder = new File(mRsLib, "packaged");
+ File packagedAbiFolder = new File(packagedFolder, abi.mDevice);
+
+ List<String> args = Lists.newArrayListWithExpectedSize(26);
+
+ args.add(mBuildToolInfo.getPath(abi.mLinker));
+
+ args.add("--eh-frame-hdr");
+ Collections.addAll(args, abi.mLinkerArgs);
+ args.add("-shared");
+ args.add("-Bsymbolic");
+ args.add("-z");
+ args.add("noexecstack");
+ args.add("-z");
+ args.add("relro");
+ args.add("-z");
+ args.add("now");
+
+ File outFile = new File(libAbiFolder, soName);
+ args.add("-o");
+ args.add(outFile.getAbsolutePath());
+
+ args.add("-L" + intermediatesAbiFolder.getAbsolutePath());
+ args.add("-L" + packagedAbiFolder.getAbsolutePath());
+
+ args.add("-soname");
+ args.add(soName);
+
+ args.add(objFile.getAbsolutePath());
+ args.add(new File(intermediatesAbiFolder, "libcompiler_rt.a").getAbsolutePath());
+
+ args.add("-lRSSupport");
+ args.add("-lm");
+ args.add("-lc");
+
+ launcher.runCmdLine(args, env);
+ }
+}