Skip to content

[msbuild] Prepare for d8 (new dex compiler) #793

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

Merged
merged 1 commit into from
Sep 4, 2017
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
11 changes: 7 additions & 4 deletions src/Xamarin.Android.Build.Tasks/Tasks/CompileToDalvik.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class CompileToDalvik : JavaToolTask

public string DxJarPath { get; set; }

public string DxExtraArguments { get; set; }

public string JavaToolPath { get; set; }

[Required]
Expand Down Expand Up @@ -59,6 +61,7 @@ public override bool Execute ()
Log.LogDebugMessage (" ToolExe: {0}", ToolExe);
Log.LogDebugMessage (" ToolPath: {0}", ToolPath);
Log.LogDebugMessage (" UseDx: {0}", UseDx);
Log.LogDebugMessage (" DxExtraArguments: {0}", DxExtraArguments);
Log.LogDebugMessage (" MultiDexEnabled: {0}", MultiDexEnabled);
Log.LogDebugMessage (" MultiDexMainDexListFile: {0}", MultiDexMainDexListFile);
Log.LogDebugTaskItems (" JavaLibrariesToCompile:", JavaLibrariesToCompile);
Expand Down Expand Up @@ -97,23 +100,23 @@ protected override string GenerateCommandLineCommands ()
cmd.AppendSwitchIfNotNull("-Xmx", JavaMaximumHeapSize);

cmd.AppendSwitchIfNotNull ("-jar ", Path.Combine (DxJarPath));
cmd.AppendSwitch ("--no-strict");
}

cmd.AppendSwitch ("--dex");
cmd.AppendSwitch (DxExtraArguments);

if (MultiDexEnabled) {
cmd.AppendSwitch ("--multi-dex");
cmd.AppendSwitchIfNotNull ("--main-dex-list=", MultiDexMainDexListFile);
}
cmd.AppendSwitchIfNotNull ("--output=", Path.GetDirectoryName (ClassesOutputDirectory));
cmd.AppendSwitchIfNotNull ("--output ", Path.GetDirectoryName (ClassesOutputDirectory));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get away without the = on this? Any idea how this will effect builds on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried a quick command run on Windows; java -jar c:\path\to\dx.jar --dex --no-strict --output foobar "path\to\mono.android.jar" worked fine.



// .jar files
if (File.Exists (OptionalObfuscatedJarFile))
cmd.AppendFileNameIfNotNull (OptionalObfuscatedJarFile);
else {
cmd.AppendFileNameIfNotNull (ClassesOutputDirectory);
foreach (var cls in Directory.GetFiles (ClassesOutputDirectory, "*.class", SearchOption.AllDirectories))
cmd.AppendFileNameIfNotNull (cls);
foreach (var jar in JavaLibrariesToCompile)
cmd.AppendFileNameIfNotNull (jar.ItemSpec);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,13 @@ because xbuild doesn't support framework reference assemblies.
Condition="'$(DxJarPath)' == ''"
/>
</CreateProperty>

<CreateProperty Value="--dex --no-strict">
<Output TaskParameter="Value" PropertyName="DxExtraArguments"
Condition="'$(DxExtraArguments)' == ''"
/>
</CreateProperty>

<CreateProperty Value="$(AndroidSdkBuildToolsPath)\">
<Output TaskParameter="Value" PropertyName="DxToolPath"
Condition="'$(UseDx)' == 'True' And '$(DxToolPath)' == ''"
Expand Down Expand Up @@ -2029,6 +2036,7 @@ because xbuild doesn't support framework reference assemblies.
<!-- Compile java code to dalvik -->
<CompileToDalvik
DxJarPath="$(DxJarPath)"
DxExtraArguments="$(DxExtraArguments)"
JavaToolPath="$(JavaToolPath)"
JavaMaximumHeapSize="$(JavaMaximumHeapSize)"
JavaOptions="$(JavaOptions)"
Expand Down