Граф коммитов

1021 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Peppers b10508aa25 [Xamarin.Android.Build.Tests] Workaround broken lint.bat (#994)
Context: https://issuetracker.google.com/issues/68753324

The Windows' SDK tools v26 `lint.bat` tool installed to
`$(AndroidToolchainDirectory)\sdk\tools\bin` appears to be broken, so
a all tests which use it are failing.

This can be worked around -- allowing the `lint`-based tests to pass
on Windows -- by setting the `%JAVA_OPTS%` environment variable.
Hopefully this is a temporary workaround until a new version of the
SDK tools comes out that fixes this issue.

One other thing to note here is that the Android SDK installed by
Visual Studio uses the SDK tools version 25.x, which does not appear
to have this issue on windows.
2017-11-06 21:44:52 -05:00
Jonathan Peppers 73121ee699 [xabuild] Build .NET standard projects (#1011)
Context: https://github.com/Microsoft/msbuild/blob/master/src/Shared/BuildEnvironmentHelper.cs#L511

`xabuild.exe` did not support building .NET standard projects. It turns
out a `$MSBuildSDKPaths` environment variable needed to be set for locating
the `Sdks` directory. On Windows, this path is relative to Visual Studio /
MSBuild, but on Mac I had to hardcode the path to .NET Core. It seems to
use the same path on Linux as well.
2017-11-06 21:35:08 -05:00
Bernhard Urban 628672fee7 [mono-runtimes] Disable mono's IL interpreter (#1010)
Context: https://github.com/mono/mono/pull/5925

Mono's IL interpreter will be enabled by default in mono once the
above PR merged. Xamarin.Android doesn't need an IL interpreter --
we have a JIT! -- so disable the interpreter so that it doesn't
impact the size of `libmonosgen-2.0.so`.
2017-11-06 15:52:54 -05:00
Alexander Köplinger 1672ab073c Bump to mono/2017-10/dcbdec80; reenable tests (#1009)
The tests were fixed in Mono by:

- https://github.com/mono/mono/pull/5720
- https://github.com/mono/mono/pull/5942
2017-11-04 17:05:26 -04:00
Alexander Köplinger 8448a43bc8 Bump to mono/2017-10/56195c0c; remove corlib test linker (#999)
Context: 5a5ab38c9e

Add tests for the `*Attributes` which were being linked away by mono.
We should be able to remove the linker exclusions now.
2017-11-03 20:33:33 -04:00
Jonathan Peppers 4ee1c3d5b6 [tests] Fix issue in ProjectBuilder.Cleanup (#1005)
This method was not using the full path to the project directory, and so
it wasn't actually deleting anything. This caused test failures on
Windows in tests such as `ManifestTest.Bug12935`. This particular test
was modifying the contents of `AndroidManifest.xml`, and checking the
results of the build afterward. Since the project files were not
deleted, changes to the `AndroidManifest.xml` were not getting written
to disk during the test.
2017-11-03 22:53:17 +00:00
Jonathan Dick f11b87317d [Xamarin.Android.Build.Tasks] api.xml in @(JavaDocIndex) (#920)
Context: 806082f26b

`generator` will extract method parameter name information from a
variety of sources, including JavaDoc documentation -- via
`$(JavaDocPaths)`, `$(JavaDoc7Paths)`, `$(JavaDoc8Paths)`,
`$(DroidDocPaths)`, and `@(JavaDocJar)` (after extracting the `.jar`
file) -- all in an effort to avoid the default parameter names of
`p0`, `p1`, etc.

Java.Interop@806082f2 updated `generator` so that it would *also*
extract method parameter name information from `api.xml`-formatted
XML files:

```xml
<api>
  <package name="my.example">
    <class name="MyType">
      <method name="myMethod" returns="void">
        <parameter name="value" type="java.lang.String" />
<!-- ... -->
```

What's desired is a way to provide an `api.xml`-formatted file to the
`<ClassParse/>` task so that the generated `api.xml` contains the
desired parameter names.

Remove the `ClassParse.JavaDocPaths`, `ClassParse.Java7DocPaths`,
`ClassParse.Java8DocPaths`, `ClassParse.DroidDocPaths`, and
`ClassParse.JavaDocs` properties, replacing them with a new
`ClassParse.DocumentationPaths` property, and pass *all* of the old
values *alongside* `@(JavaDocIndex)` for
`ClassParse.DocumentationPaths`.

Thus, to manually specify method parameter names via an
`api.xml`-formatted file:

 1. Add the file to the `.csproj`, and
 2. Set the **Build action** to `@(JavaDocIndex)`

The `api.xml`-formatted file will then be provided to `<ClassParse>`,
and the desired names will be used in generated code.

*Note*: `@(JavaDocIndex)` is *only* supported when
`$(AndroidClassParser)` is set to `class-parse`. It cannot be
used with the older `jar2xml` parser, and attempting to do so will
result in an error of some sort. (No idea what it is, we haven't
tested this scenario to see what the error will be.)
2017-11-03 15:55:16 -04:00
Jonathan Peppers fe8d607c11 [Xamarin.Android.Build.Tasks] Fix Profile.g.cs rebuild (#1000)
`obj/Debug/Profile.g.cs` is getting regenerated on every build,
forcing `Xamarin.Android.Build.Tasks.csproj` to rebuild *every* time.
It looks like the `IncrementalClean` target is the culprit, in that
it deleted `obj/Debug/Profile.g.cs` file after the build completed.

The fix here is to add the *absolute path* of `Profile.g.cs` to
`@(FileWrites)`. (Non-absolute paths still result in the
`IncrementalClean` target removing the file.)

Update `$(_GenerateProfileClass)` so that it's an absolute path.
2017-11-03 12:49:15 -04:00
Radek Doulik 10f57e0a29 [tests] Measure NUnit test end times (#1007)
Added `NUnit.results` label to the default time performance definition
file. It matches NUnit line with results, which is printed out at the
end of the NUnit driven test.

This will add `NUnit.results-$(Configuration)` columns to the `Bcl`,
`Jcw`, `Locale`, and `Runtime merged` plots at:

https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/plot/Tests%20times/
2017-11-03 10:57:48 -04:00
Dean Ellis 6299c6ec5c [Xamarin.Android.Build.Tasks] ApkSigner Failed if minsdk > maxSdk (#1003)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60444

We should NOT ever pass a `//uses-sdk/@android:minSdkVersion` value
that is greater than the `//uses-sdk/@android:maxSdkVersion` value.
It results in the following error:

	Min API Level (10) > max API Level (8)

We should check the values and use the minimum value for
`//uses-sdk/@android:minSdkVersion`.
2017-11-02 17:20:39 -04:00
Dean Ellis b3e98204e4 [Xamarin.Android.ProjectTools] Fix logic error in native crash detection. (#1002)
Commit 855ad009 added logic to detect if a test had a native crash and to
retry the test. There was a flaw in the logic such that it would
run every test twice...

Fix that.
2017-11-02 12:52:06 -04:00
Jonathan Peppers 63fc278cc4 [Xamarin.Forms-Performance-Integration] Use AndroidFrameworkVersion (#1004)
Other Android projects (such as test APKs), set `$(TargetFrameworkVersion)`
by importing `Configuration.props` and using `$(AndroidFrameworkVersion)`.
`$(AndroidUseLatestPlatformSdk)` should also be set to `false`.

Not sure why this hasn't caused any issues yet, I first noticed this
causing a failure on PR #997.
2017-11-02 12:49:24 -04:00
Marek Habersack e6b85552ef [Mono.Android] Don't optimize URL encoding (#1001)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60473

In the case when the URL doesn't contain any query elements we
optimized for speed and memory by not using `UrlBuilder` to do the
encoding work on the URL. However, it causes problems with URLs
that are sent pre-encoded.

Remove the optimization and rely on `UrlBuilder` in all cases.
2017-11-02 12:43:42 -04:00
Dean Ellis d628a98c09 [Xamarin.Android.Build.Tasks] Handle unknown version from lint.bat (#996)
Turns out `lint.bat` does not always return a version number.
It returns stuff like

	lint: version unknown
	lint: unknown version

not very helpful. So we need to handle that case and return a
empty verison.
2017-11-01 13:50:14 -04:00
Dean Ellis aeec3ae4dd [Xamarin.Android.Build.Tasks] Speed up ResolveLibraryProjectImports (#955)
Rather than trying to ALWAYS unset the ReadOnly flag, lets only
do it if the directory is read only. Also use `EnumerateFiles()`
rather than `GetFiles()` to get the `.jar` files.
`EnumerateFiles()` is more efficient.
2017-11-01 10:45:08 -04:00
Dean Ellis 7f45a6d20b [Xamarin.Android.Build.Tasks] NRE getting android.jar path (#976)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60324

If an `android.jar` file does *not* exist for a target platform we
should raise a normal error. Instead we throw a
`NullReferenceException`.

	…/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Error executing task GetJavaPlatformJar: Value cannot be null.
	Parameter name: path1
	Error executing task GetJavaPlatformJar: System.ArgumentNullException: Value cannot be null.
	Parameter name: path1
	  at System.IO.Path.Combine (System.String path1, System.String path2) [0x00003] in <4656b2b94f914437bce672312dd9e44b>:0 
	  at Xamarin.Android.Tasks.GetJavaPlatformJar.Execute () [0x00188] in <3fa51b5c8b554c02b4c7f549bcabde77>:0 
	  at Microsoft.Build.BuildEngine.TaskEngine.Execute () [0x00000] in <cbad9a49d2cc4e87ad2241615dd4666c>:0 
	  at Microsoft.Build.BuildEngine.BuildTask.Execute () [0x0008d] in <cbad9a49d2cc4e87ad2241615dd4666c>:0 

Oops.

The cause is that
`AndroidSdkInfo.TryGetPlatformDirectoryFromApiLevel()` can return
`null`, which is by design. We need to handle that in the places
where it's called, and provide an XA5207 error message when
`TryGetPlatformDirectoryFromApiLevel()` returns `null`.
2017-11-01 10:43:56 -04:00
Radek Doulik 386e6cbe1b [linker] Use mono's linker submodule (#944)
Use mono's `external/linker` submodule reference instead of including
our own, separate, `linker` submodule reference.

This way we are more consistent with xamarin-macios, which also uses
mono's linker submodule.
2017-11-01 10:17:19 -04:00
Dean Ellis 855ad00931 [Xamarin.Android.Build.Tests] Retry builds on native crashes (#993)
Sometimes when running `Xamarin.Android.Build.Tests`, mono crashes:

	Stacktrace:
	
	  at <unknown> <0xffffffff>
	  at (wrapper managed-to-native) object.__icall_wrapper_mono_gc_alloc_obj (intptr,intptr) [0x00000] in <4fdc5ed61a074cafb49fa42deb20d521>:0
	  at (wrapper alloc) object.AllocSmall (intptr,intptr) <0x000fa>
	  at System.IO.FileSystemEnumerableIterator`1<TSource_REF>.CreateSearchResult (System.IO.Directory/SearchData,Microsoft.Win32.Win32Native/WIN32_FIND_DATA) [0x00023] in <4fdc5ed61a074cafb49fa42deb20d521>:0
	# Actual stack trace doesn't *really* matter, and is basically random
	...
	Native stacktrace:
	
		0   mono                                0x000000010d9df481 mono_handle_native_crash + 257
	...
	=================================================================
	Got a SIGSEGV while executing native code. This usually indicates
	a fatal error in the mono runtime or one of the native libraries 
	used by your application.
	=================================================================

This is decidedly Not Good™.

However, a significant percent of the time, the crash *also* isn't
reproducible: a re-run of the build+tests will result in all tests
passing. However, a re-run can take upwards of 2-6 *hours* --
depending mostly on whether the PR has a mono bump -- so it is
undesirable to re-run builds just to see if it's a "random" error.

Instead, update `Builder.BuildInternal()` so that if it determines
that mono crashed -- via the `Got a SIGSEGV…` message -- then we'll
re-try the crashing command. (Just once!)

This should hopefully reduce the number of test failures we need
to investigate.

The *downside* is that the #runtime team would dearly love to know
about these crashes, so *they* can investigate. This is *partially*
supported by emitting the following message into the build output
when a native crash is detected:

	Native crash detected! Running the build for … again.

This is less than ideal, and may be improved in the future.
2017-11-01 10:14:11 -04:00
Alexander Köplinger c43c5e671a Bump to mono/2017-10/7e85cfa5 (#943)
Bump to xamarin-android-api-compatibility/master/c050ba3c. Updates
expected APIs for BCL assemblies.

Use `azureedge.net` instead of `blob.core.windows.net`. It's behind
a CDN and way faster outside US.

Use the new profiler init symbol name, `mono_profiler_init()`.

Avoid dumping the content of `libmono-profiler-log.so` when tests
fail. The binary contents aren't meaningful, and needlessly bloat the
output log.

Fix `eglib` path, as mono changed it's location.

Don't skip errors from mono's `make test` target anymore.

Stop building Mono's `net_4_x` profile. It isn't required to build
the `monodroid` profile and *not* building it saves lots of time.
The tools needed by XA are taken from the new `monodroid_tools`
profile instead.

Update Mono version phrasing in `README.md`. Using an explicit
version is just a recipe for outdated info, instead rewrite it to be
generic since the build will complain on an outdated Mono anyway.

Add more exclusions to `LinkerDescription.xml` for BCL tests, which
are used in the new `System.Reflection.Emit.SaveTest()`.

Update `.gitignore` for some paths. `Xamarin.Android.Common.props` is
generated as part of the build, and the `.rawproto` files created by
gradle should be ignored.

Context: https://bugzilla.xamarin.com/show_bug.cgi?id=4786
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=5798
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=5804
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=11696
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=17325
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=23153
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=25755
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=36053
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=36634
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=40556
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=41279
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=43172
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=43563
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=44266
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=46683
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=52157
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=52621
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=55603
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=56653
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=56684
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57069
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57160
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57197
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57222
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57232
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57301
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57476
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57488
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57496
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57505
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57528
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57629
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57691
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57744
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57796
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57850
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57851
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57887
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57918
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57930
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57936
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=57959
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58100
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58168
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58210
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58291
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58317
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58344
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58361
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58379
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58399
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58411
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58421
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58423
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58454
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58612
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58621
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58728
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58738
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58770
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58782
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58793
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58809
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58829
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58877
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58901
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58911
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58965
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59039
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59154
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59180
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59235
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59281
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59364
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59436
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59608
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59664
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59824
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=60233
2017-10-31 11:55:44 -04:00
Dean Ellis 9254af3315 [Xamarin.Android.Build.Tests] Add Build Log to the Exception data. (#961)
If the build fails we get a generic message to look at the
`build.log`. This is a pain because the build log is HUGE! and takes
ages to find the problem.

It seems NUnit does not include the `FailedBuildException.BuildLog`
property. Override the `Exception.StackTrace` property to include the
`FailedBuildException.BuildLog` data.
2017-10-30 08:27:35 -04:00
Atsushi Eno b89302cae6 [msbuild] remove --dex argument and add DxExtraArguments from Dx task. (#990)
Otherwise debugging won't work with d8/r8.
2017-10-30 11:23:24 +00:00
Jonathan Peppers ab48f79d2b [build] fix for JdkInfo task in PrepareWindows.targets (#989)
On Windows after formatting my machine (don't ask),
`PrepareWindows.targets` was failing with:

	System.InvalidOperationException: Could not determine Android SDK location.

Looking into it, there appear to be two things wrong:

  * `PrepareWindows.targets` should import `Configuration.props`
  * The incoming properties are `$(AndroidSdkDirectory)` and
    `$(AndroidNdkDirectory)` not `$(AndroidSdkPath)` and
    `$(AndroidNdkPath)`.

I'm not quite sure how this *ever* worked, unless `AndroidSdkInfo`
was able to find *some* Android SDK on your machine, e.g. from a
prior Xamarin install.
2017-10-28 10:09:56 -04:00
Jonathan Pryor 4d94d34731 [build] Install mono in `make prepare-image-dependencies`
I have been told that the `prepare-image-dependencies.sh` script
should also install `mono`, to ensure that the required mono exists.
Add a `@PKG_URLS@` variable to `prepare-image-dependencies.sh.in` to
support downloading and installing our minimum specified mono version.

Additionally, I discovered that `xbuild` bugs are still around; I just
keep forgetting their specifics. Case in point:
[Jenkins build #712][xa712] uploaded
[`prepare-image-dependencies.sh`][sh], and it's not good:

[xa712]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/
[sh]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/712/Azure/processDownloadRequest/xamarin-android/prepare-image-dependencies.sh

	https://dl.google.com/android/repository/build-tools_r26.0.1-macosx.zip sdk/build-tools\$(XABuildToolsFolder)
	...
	https://dl.google.com/android/repository/android-15_r03.zip sdk/platforms\android-15

MSBuild properties contained within item metadata -- specifically
`%(AndroidSdkItem.DestDir)` -- aren't fully expanded, resulting in the
above value of `$(XABuildToolsFolder)`, which *should* be `26.0.1`.
Similarly, some install paths are using `\` (backslash) when they
should contain `/` (forward slash).

Jenkins has been updated to explicitly use `msbuild`:

	$ make prepare-image-dependencies MSBUILD=msbuild

However, `\r` characters now appear in
`prepare-image-dependencies.sh`. Fix this by having the
`PrepareImageDependencies` target emit the MSBuild-generated file into
an intermediate file, then fix it up using **tr**(1).

Finally, correct the `brew install` command so that any errors are
ignored, for if a brew package is already installed, re-installing it
will result in an error.
2017-10-27 16:50:34 -04:00
Jonathan Peppers a5fba94368 [xabuild.exe] Handle AndroidSdkDirectory like xabuild (#988)
Context: https://github.com/xamarin/xamarin-android/blob/master/tools/scripts/xabuild#L105

`xabuild`, the shell script, has some logic to set MSBuild properties
for `AndroidSdkDirectory` and `AndroidNdkDirectory`. The issue here is
on Windows, `xabuild.exe` is not invoked from this shell script. So we
need to replicate the logic in C# in `xabuild.exe`, but not break what
was fixed in #977.

Changes:

  * Check for `ANDROID_SDK_PATH` or `ANDROID_NDK_PATH` environment
    variables
  * Run `Paths.targets` via a new MSBuild process, the same way as
    `tools/scripts/xabuild`
  * Set the `AndroidSdkDirectory` and `AndroidNdkDirectory`
    properties in the config file if they are not blank
  * `AndroidSdkDirectory` and `AndroidNdkDirectory` can still be
    overridden by a user, because incoming values supersede what is
    found in the config file
2017-10-27 15:44:24 -04:00
Dean Ellis bd2640e17e [Xamarin.Android.Build.Tests] Fix BuildAppCheckDebugSymbols in monodroid (#987)
The `BuildAppCheckDebugSymbols()` test does not take into account
that when building in debug mode on monodroid the assemblies
are not embedded in the apk. As a result when trying to get
`Library1.pdb` from the apk we get a `null` back. This causes
a `NullReferenceException` when we try to get a length.

The fix is to look in the `assets` directory if we can't get
the file from the `.apk`. This will allow the test to work in
both xamarin-android and monodroid.
2017-10-27 15:05:08 -04:00
Jonathan Peppers b2cf680146 Bump to Java.Interop/master/00ad8d6 (#978)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=59472
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=59770
2017-10-27 14:59:01 -04:00
Jonathan Pryor aa9b33a4d1 [build] Add `make prepare-image-dependencies` target. (#979)
We are investigating building Xamarin.Android atop
Visual Studio Team System (VSTS) in addition to our current Jenkins
setup, and one of the issues we're running into is "bootstrapping":
VSTS is configured to create a "fresh" VM for each build.

**Pro**: It should allow builds to be more reliable, as previous build
artifacts won't be present, and thus won't cause/hide errors.

**Con**: *Previous build artifacts are not present*. Previous build
artifacts such as *downloading and extracting* the Android NDK & SDK,
using `brew` to install dependencies, building MXE...

Ensuring that the dependencies are installed through `make prepare`
can be quite time consuming. What we want is a way to ensure that the
"build image" -- *what's already installed* when the VM boots --
contains all of our desired dependencies.

Furthermore, we *don't* want to have the responsible parties checkout
and build xamarin-android in order to determine what the dependencies
should be.

Attempt to square this circle by adding a new
`make prepare-image-dependencies` target, which processes
`@(AndroidSdkItem)`, `@(AndroidNdkItem)`, `@(AntItem)`, and
`@(RequiredProgram)` to create a `prepare-image-dependencies.sh`
script which will download and install the required dependencies.

The generated shell script does *not* take the state of the machine
running `make prepare-image-dependencies` into consideration. This
allows the target to be executed on one machine, and the output run
on another.

	$ make prepare-image-dependencies
	# creates `prepare-image-dependencies.sh`

*Note*: `make prepare-image-dependencies` does not currently deal
with MXE.  (Building MXE on the VSTS VM is *very* time consuming, so
it's something we need to take care of. It is not *yet* dealt with.)
2017-10-26 20:12:18 -04:00
Dean Ellis e55d6557f6 [Xamarin.Android.Build.Tasks] Move DesignTime Cache files to designtime folder. (#986)
Fixes: https://devdiv.visualstudio.com/DevDiv/XamarinVS/_queries?id=512752%2F&triage=true&_a=edit

The DesignTime build is generally run before any nuget packages
have been restored. As a result we end up with empty cache files.
Because those files exist and are considered uptodate, when the
main build finally happens they are not re-generated.
This causes errors like

	error: Error: No resource found that matches the given name: attr 'colorAccent'.

on a new default template.

The DesignTime build should have its own set of cache files which
do not conflict with the main build. This way when the main build
runs the cache files will not be in place.
2017-10-26 19:09:54 -04:00
Dean Ellis e824170632 [Xamarin.Android.Build.Tasks] Fix VS DesignTime Build Hang (#985)
FixesL https://bugzilla.xamarin.com/show_bug.cgi?id=60080

In a previous attempt to fix an intellisense build (1cd582ec) we
caused this issue. The DesignTime build does NOT like our AsyncTask
as it locks the IDE.

This commit puts the old code back in place which skips the task
if we are in DesignTime mode. But so we can easily test it, we
emit an message that our test can pick up to ensure we are doing
the correct thing. Without the message we have no way of knowing
if the task is skipped.
2017-10-26 15:50:15 -04:00
Dean Ellis d0b7b0d5fb [Xamarin.Android.Build.Tasks] Force xbuild to behave like msbuild. (#984)
Commit 8643ded9 tried to make sure `xbuild` worked like `msbuild`
when it came to `'$(DebugType)' == 'None'`. The "fix" however
was not correct.

When `$(DebugType)` is `None` under `msbuild`, it changes to
`portable` and `$(DebugSymbols)` gets set to `true`. Additionally,
when `$(DebugType)` is *empty* it gets set to `portable` but then
`$(DebugSymbols)` is left alone.

So we need to get `xbuild` to do the same. Otherwise we get the
wrong runtimes. But by the time we get to
`Xamarin.Android.Common.targets` it is too late to change the
`$(DebugSymbols)` value: `xbuild` does not use the changes.
So we need to do this before `xbuild` gets a chance to set the
value of `$(DebugSymbols)`.

The trick is to alter the properties in
`Xamarin.Android.CSharp.targets` and
`Xamarin.Android.FSharp.targets` *before* we `<Import/>`
`Microsoft.*.targets`.
2017-10-26 11:42:39 -04:00
Dean Ellis 8a32e29ae8 [Xamarin.Android.Build.Tests] Fix Framework Path Detection. (#981)
On jenkins is appears we are getting a situation where we
are picking up an empty directory for the FrameworkPath.
As a result we always get 0 when trying to pick up the
runtime that are available. So tests which check the runtimes
fail.

This commit adds a check for a 'libmono-android.release.so' file
so can ensure the required files exist in the folder. Also added
code to pick up the `CONFIGURATION` environment variable from
the Makefile.
2017-10-26 11:27:34 -04:00
Marek Habersack 462d3730ee [android-toolchain] Use https://dl.google.com (#983)
The `dl.` CDN has more backends than `dl-ssl.` and is generally faster.

Also, change ant download to use HTTPS (in preparation for the world where plain
http is gone :P)
2017-10-26 09:18:55 -04:00
Jonathan Peppers 5c750430d7 [tests] Update to NUnit 3.7.1 (#973)
Context: https://github.com/nunit/nunit/releases/tag/3.7.1
Context: commit 6687dac5

The release notes for NUnit 3.7.1 mention a hang with parallelized
tests, so it is worth a try to see if updating fixes it the hangs
that we experienced and tried to workaround in 6687dac.
2017-10-25 22:01:50 -04:00
Dean Ellis 1645e7bcb9 [Xamarin.Android.Build.Tests] Improve Time Elapsed processing (#968)
Attempt to quasi-"optimize" `Builder.BuildInternal()`: if we're going
to read `buildLogFullPath` a line at a time *anyway* -- to collect
the log file for later parsing into `Builder.LastBuildOutput` -- then
we should also do any associated line-oriented parsing as well.

Update `buildLogFullPath` processing to use a `StringBuilder` instead
of string concatenation, and search for the `Time Elapsed` message
while reading the file, instead of separately, *after* having read
the entire build log into memory.
2017-10-25 16:09:17 -04:00
Dean Ellis 927d66de8b [Xamarin.Android.Build.Tests] DebugType="None" test changes (#974)
Commit 8643ded9 added support for running the tests in `msbuild`.
Part of that change was altering the behaviour of `xbuild` to
match that of `msbuild`, regarding the way they handle
`$(DebugType) == "None"`.

The commit altered `Xamarin.Android.Common.targets` to reset
`$(DebugType)` to `portable` if `None` is detected. It also resets
`$(DebugSymbols)` to `false` in the same senario.

As a result the code these some tests which do the same thing
should not longer be required. Remove this redundant code.
2017-10-25 16:02:43 -04:00
Jonathan Peppers 61b32353fa [tests] fix failures related to AndroidSdkDirectory property (#977)
The introduction of `xabuild` in commit f9d15dd2 omitted a design
requirement: `xabuild` needs to be runnable on a machine which does
*does not* have a xamarin-android build environment. The idea is that
e.g. Windows developers could download a Jenkins-built
`oss-xamarin.android*.zip` file, extract it, and run
`bin\Debug\bin\xabuild.exe` to use the extract artifacts *without*
requiring system-wide installation via `setup-windows.exe`.

This not-very-well-stated requirement brought along two mistakes:

 1. `xabuild.exe` should *not* set the `$(AndroidSdkDirectory)` and
    `$(AndroidNdkDirectory)` MSBuild properties. It *can't*; it could
    be executed on ~any machine, in particular one which hasn't built
    xamarin-android, so setting these properties to "build-tree"
    values doesn't make sense and will fail.

 2. Even if (1) weren't the case, commit f9d15dd2 still allowed the
    `Xamarin.Android.Build.Tests` unit tests to use `xbuild` as the
    MSBuild engine, via the `tools/scripts/xabuild` script.
    This script *does not* always set `$(AndroidSdkDirectory)` or
    `$(AndroidNdkDirectory)`.
    
As a result of (2), many unit tests *fail*:

	Error executing task ResolveSdks: System.InvalidOperationException: Could not determine Android SDK location. Please provide `androidSdkPath`.
	  at Xamarin.Android.Tools.AndroidSdkInfo..ctor (System.Action`2[T1,T2] logger, System.String androidSdkPath, System.String androidNdkPath, System.String javaSdkPath) [0x0008e] in …/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/AndroidSdkInfo.cs:28 
	  at Xamarin.Android.Tasks.MonoAndroidHelper.RefreshAndroidSdk (System.String sdkPath, System.String ndkPath, System.String javaPath) [0x00021] in …/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs:111 
	  at Xamarin.Android.Tasks.ResolveSdks.RunTask () [0x001a0] in …/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs:157 
	  at Xamarin.Android.Tasks.ResolveSdks.Execute () [0x00002] in …/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs:130 
	  at Microsoft.Build.BuildEngine.TaskEngine.Execute () [0x00000] in …/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskEngine.cs:134 
	  at Microsoft.Build.BuildEngine.BuildTask.Execute () [0x0008d] in …/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs:101 

Update `xabuild` to *never* explicitly set `$(AndroidSdkDirectory)`
and `$(AndroidNdkDirectory)`, and update `Xamarin.Android.Build.Tests`
to *always* explicitly provide these MSBuild properties. This allows
unit test execution to be more reliable, and will prevent 
`xabuild.exe` from looking at "random" non-existent directories.
2017-10-25 15:44:11 -04:00
Alexander Köplinger 6687dac5b0 [tests] Use single NUnit worker to prevent hanging msbuild tests (#972)
The `Xamarin.Android.Build.Tests` NUnit tests recently started 
hanging after the tests were done.

Run tests with a single worker as a workaround until we figure out
why, unblocking Jenkins.
2017-10-24 18:10:21 -04:00
Jonathan Peppers 5a9ba9fdff [xabuild] Print config file to stdout on error (#971)
There are cases in which diagnostic MSBuild output is not including
important information such as `$(MSBuildExtensionsPath)`.

To help debug situations like this, if `MSBuildApp.Main` returns a
non-zero exit code, we can print the contents of xabuild.exe's config
file to the console.
2017-10-24 15:04:48 -04:00
Jonathan Peppers 9324d4dea0 [xabuild] Use a temp file for MSBuild config (#969)
Context: https://github.com/xamarin/xamarin-android/pull/954
Context: https://github.com/xamarin/xamarin-android/pull/964
Context: https://github.com/xamarin/xamarin-android/pull/967

The `Xamarin.Android.Build.Tests` unit tests run `xabuild.exe` in
parallel, which causes all manner of "weirdness" as the multiple
`xabuild.exe` process all attempt to overwrite the *same* config file
used by the `MSBuildApp` class.

Fix this by creating *unique* per-process config files, stored in
`Path.GetTempFileName()`, and overriding the `$MSBUILD_EXE_PATH`
environment variable to refer to the per-process config file -- which
is what the [MSBuild Unit Tests use][msbuild-tests] to override the
`msbuild.exe.config` file used at runtime -- allowing each
`xabuild.exe` process to sanely provide separate config files
without conflicting with each other.

[msbuild-tests]: https://github.com/Microsoft/msbuild/blob/080ef97/src/Build.UnitTests/BuildEnvironmentHelper_Tests.cs#L47
2017-10-24 13:23:03 -04:00
Dean Ellis 14ad71b1bf [Xamarin.Android.Build.Tasks] Typo in Xamarin.Android.Windows.targets (#970)
Commit 286b9c28 added extra item to `@(_FilesToRegister)` as part of
the `IncrementalClean` target.

Unfortunately, one of the values omitted the `$`, resulting in an
"invalid" property name reference.

This commit fixes that issue.
2017-10-24 12:18:16 -04:00
Jonathan Pryor 8091b7dd4d [tests] Export `$USE_MSBUILD=$(USE_MSBUILD)` (#965)
Context: 8643ded9
Context: 286b9c28
Context: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/700/testReport/

`Xamarin.ProjectTools` was updated in commit 8643ded9 to use `msbuild`
(via `xabuild`) *by default*, and commit 286b9c28 updated
`Xamarin.ProjectTools` to further use `msbuild`/`xabuild` when the
`$USE_MSBUILD` environment variable is *not* `0`, and to continue
using `xbuild` when `$USE_MSBUILD` is `0`.

Meaning before 8643ded9 `xbuild` was used for
`Xamarin.Android.Build.Tests` execution, and afterward `msbuild`
was used. (This change wasn't explicitly clear to some.)

"Revert" this behavior; use `xbuild` *by default* for 
`Xamarin.Android.Build.Tests` execution, by updating the
`RUN_NUNIT_TEST` make `define` so that the `$USE_MSBUILD`
environment variable is exported to the *value of* the
`$(USE_MSBUILD)` make variable, IFF it's not the empty string.
If `$(USE_MSBUILD)` *is* the empty string, export `USE_MSBUILD=0`,
which will cause `xbuild` to be used.

What his means is that a default unit test invocation:

	make run-all-tests

will use `xbuild` to run `Xamarin.Android.Build.Tests`. However,
if `msbuild` is *explicitly opted into*, then `msbuild` is used:

	$ make run-all-tests MSBUILD=msbuild
	# -or-
	$ make run-all-tests MSBUILD=some/path/to/msbuild USE_MSBUILD=1

Furthermore, if/when we change the default MSBuild engine to
`msbuild` in the future -- by altering
`build-tools/scripts/msbuild.mk` to set `MSBUILD=msbuild` and
`USE_MSBUILD=1` by default -- then `make run-all-tests` will
*implicitly* follow suit.

With luck, "reverting" to `xbuild` use will allow the
[current `Xamarin.Android.Build.Tests` failures][xa700t] -- all 20 of
them -- to be "fixed" until such time as all
`Xamarin.Android.Build.Tests` tests *actually* pass with `msbuild`.

[xa700t]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/700/testReport/
2017-10-24 12:10:32 -04:00
Alexander Köplinger a08f8851e2 [Xamarin.Android.Build.Tasks] Correctly set build tools version in CheckSignApk test (#966)
The test failed locally for me with:

```
…/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:
error : '…/android-sdk-macosx/build-tools/23.0.0/apksigner' does not exist.
You need to install android-sdk build-tools 26.0.1 or above.
```

which is weird since it's looking into the 23.0.0 build tools which
doesn't have apksigner even though the test specifies build tools 26.0.1.

Turns out the test had a typo, it used `AndroidBuildToolsVersion`
instead of `AndroidSdkBuildToolsVersion` so it fell back to 23.0.0 :)
2017-10-24 10:05:30 -04:00
Marek Habersack c2fbd79287 [tests] Don't use obsolete NDK API levels (#962)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60185

Newer versions of NDK don't include API 4 anymore but two of our tests specified
that they required that particular version to build. This caused the tests to
fail because the android-4 platform path was nowhere to be found.

Bump the minimum SDK version to 9 (which is the lowest platform included in the NDK
as of now)
2017-10-23 16:10:24 -04:00
Dean Ellis 029c86fbb3 [Xamarin.ProjectTools] Read actual Time Elapsed from build.log (#957)
Sometimes out TimeOut tests fail if the build is a bit slow.
This is because we time the entire process of starting a new
process to bringing in ALL the output data.

So lets parse the build.log and pull our the reported MSBuild
"Time Elapsed" if we can.
2017-10-23 15:43:46 -04:00
Dean Ellis d90a2b443c [Xamarin.Android.Build.Tests] Fix DesignTime timing test message (#959)
There was a spelling mistake in the DesignTime build timing test.
Also it was reporting the wrong time! So this commit fixes that.
It also makes the test `NonParallelizable`, this is because when
its run in parallel with a bunch of other tests the timing is usually
off and the test fails.
2017-10-23 15:42:11 -04:00
Dean Ellis 2bf62cb90a [build] Support $(MonoRequiredMaximumVersion) (#960)
There are circumstances when we don't want to use the latest
and greatest version of mono. On the CI servers we will want
to keep to certain versions so that we have a stable build.
But on developer machines we will want to allow the developer
to ignore such checks.

This commit adds support for `$(MonoRequiredMaximumVersion).
By default this proeprty is ignored. But on build systems we should pass:

	/p:IgnoreMaxMonoVersion=False

to ensure that the max version is applied and we run against
a stable version of mono.
2017-10-23 15:00:03 -04:00
Dean Ellis 6c4d912550 [Xamarin.Android.Build.Tasks] Add Debug info for Lint Task (#947)
We need to output the Lint tool Path we use and the Lint Tool
version for diagnostic purposes. So if it does fail we have
the information we need to correct the issue.
2017-10-20 11:54:17 -04:00
Alexander Köplinger 572f1fbde3 [xabuild] Error if $TARGETS_DIR can't be found (#951)
Otherwise we'd continue in the script and all sorts of weirdness
would occur since `$TARGETS_DIR` is empty.
2017-10-20 11:53:49 -04:00
Dean Ellis 286b9c28e1 [Xamarin.ProjectTools] Properly use MSBuild for the tests (#953)
Commit 8643ded reworked the msbuild tests to use msbuild. But
there was a problem with the logic.

	string.IsNullOrEmpty (useMSBuild) || useMSBuild == "0"

well the Environment variable USE_MSBUILD will ALWAYS be empty.
Because we never set it. so the logic should be

	!string.IsNullOrEmpty (useMSBuild) && useMSBuild == "0"

so that if it is set it has to be "0" to allow xbuild to be
used.

Also one of the tests was using `RunningMSBuild` before it was
calculated. So it was always false. So just added some logging to
print what we are using to the console. This forces `RunningMSBuild`
to be calculated.

One final issue was with the intermediate .pdb files being cleaned
up by `IncrementalClean`. Turns out we had a fix for the .mdb files
in `Xamarin.Android.Windows.targets`. So the solution there was to
add the same work around for .pdb files.
2017-10-20 11:51:48 -04:00
Radek Doulik 9ec6a5a888 [performance measurements] Add AOT'ed assemblies sizes again (#956)
Commit 2dc5689a fixed the files location, but new size measurements definition
didn't include the AOT'ed assemblies sizes.
2017-10-20 10:17:30 -04:00