Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
bump xharness cli, use cmake config
  • Loading branch information
EgorBo committed May 14, 2020
commit d4cd2e986f4a0da087a3d1c4190e1ddda6457e41
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]
},
"microsoft.dotnet.xharness.cli": {
"version": "1.0.0-prerelease.20254.3",
"version": "1.0.0-prerelease.20264.2",
"commands": [
"xharness"
]
Expand Down
21 changes: 15 additions & 6 deletions src/mono/msbuild/AndroidAppBuilder/ApkBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,25 @@ public class ApkBuilder
.Replace("%EntryPointLibName%", Path.GetFileName(entryPointLib));
File.WriteAllText(Path.Combine(OutputDir, "runtime-android.c"), runtimeAndroidSrc);

string cmakeArgs = $"-DCMAKE_TOOLCHAIN_FILE={androidToolchain} -DANDROID_ABI=\"{abi}\" -DANDROID_STL=none " +
string cmakeGenArgs = $"-DCMAKE_TOOLCHAIN_FILE={androidToolchain} -DANDROID_ABI=\"{abi}\" -DANDROID_STL=none " +
$"-DANDROID_NATIVE_API_LEVEL={MinApiLevel} -B runtime-android";

string cmakeBuildArgs = "--build runtime-android";

if (StripDebugSymbols)
{
// Makefile prints a warrning "clang: warning: argument unused during compilation: '-s'"
// but it does use it and calls `android-%abi%-strip` from NDK
cmakeArgs+= " -DCMAKE_C_FLAGS=-s";
// Use "-s" to strip debug symbols, it complains it's unused but it works
cmakeGenArgs+= " -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_C_FLAGS=\"-s -Wno-unused-command-line-argument\"";
cmakeBuildArgs += " --config MinSizeRel";
}
else
{
cmakeGenArgs += " -DCMAKE_BUILD_TYPE=Debug";
cmakeBuildArgs += " --config Debug";
}

Utils.RunProcess(cmake, workingDir: OutputDir, args: cmakeArgs);
Utils.RunProcess("make", workingDir: Path.Combine(OutputDir, "runtime-android"));
Utils.RunProcess(cmake, workingDir: OutputDir, args: cmakeGenArgs);
Utils.RunProcess(cmake, workingDir: OutputDir, args: cmakeBuildArgs);

// 2. Compile Java files

Expand Down Expand Up @@ -197,6 +204,8 @@ public class ApkBuilder
continue;
}

// NOTE: we can run android-strip tool from NDK to shrink native binaries here even more.

string destRelative = Path.Combine("lib", abi, dynamicLibName);
File.Copy(dynamicLib, Path.Combine(OutputDir, destRelative), true);
Utils.RunProcess(aapt, $"add {apkFile} {destRelative}", workingDir: OutputDir);
Expand Down