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

1003 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Pryor a15ee0a70a [build] Fix GenerateJavaCallableWrappers dependencies
Commit ff28d572 updated some of the Java source code that is included
into `mono.android.jar`, which needs to be kept synchronized with the
`libmono-android*` ("libmonodroid")` native libraries.

Unfortunately, the build system didn't know about this dependency; the
`GenerateJavaCallableWrappers` target only executes when
`Mono.Android.dll` is updated, but commit ff28d572 didn't have
anything which would cause `Mono.Android.dll` to be updated.

As a result, *pre-existing build trees* that had `Mono.Android.dll`
and `mono.android.jar` files from *before* commit ff28d572, when
updated to be at ff28d572 or later, would rebuild
`src/Xamarin.Android.Build.Tasks` -- which contains
`MonoPackageManager.java` -- but would *not* rebuild
`mono.android.jar`. This would result in build-time failures when
building the unit tests:

	obj/Release/android/src/mono/MonoPackageManager.java(59,7): error :  error: incompatible types: String[] cannot be converted to String

Update the `GenerateJavaCallableWrappers` target to include
`@(JavaCallableWrapperSource)` as an input dependency, and update
`Mono.Android.targets` to include `src/Mono.Android/java/**` into
`@(JavaCallableWrapperSource)`. This will ensure that the next time
the Mono.Android-related Java sources are updated, we properly rebuild
`mono.android.jar`.
2017-09-04 13:19:01 +02:00
Jonathan Pryor b28fbfc0b5 Bump to mono/2017-04/63e8c46a (#813) 2017-09-02 15:28:36 -04:00
Jonathan Pryor 0d800426cc [Xamarin.Android.Build.Tasks] minSdkVersion checks on 32-bit (#812)
The `BuildAotApplication()` test additions from commit a953d3f1 don't
work when `supportedAbis` is a 64-bit platform such as `x86_64` or
`arm64-v8a`, because the test checks for `android-9`, which is only
going to be valid for 32-bit architectures. (64-bit architecture
support requires API-21, iirc.)

Update the minSdkVersion path check to only execute when dealing with
32-bit architectures.
2017-09-02 00:08:12 +01:00
Dean Ellis 483f8b69bf [Xamarin.Android.Build.Tests] Fix Errors in the Designer Tests (#807)
We made an assumption when the test was written that the
old `Resource.designer.cs` was going to be deleted in
projects when using `$(AndroidUseIntermediateDesignerFile)`.
The decision was changed so it would jsut be ignored.
So the existing check that is should not exist was wrong.

That said it did not fail because we did not include the `Root`
proeprty in the path so it always passed because that file
did not exist in the location we were checking.

The change to nunit3 changed that as because of the way the
working directory is set that check now failed. Because
the old incorrect path was not correct.. doh.

So a better check is to make sure that the old file is
just emtpy. We almost empty since the the project tools
write the file we end up with a Unicode marker.

We also update the XamarinAndroidApplicationProject so that
we can override the `$(EmbedAssembliesIntoApk)`. This is
required for various unit tests. The way it currently worked
was that no matter what you set.. you always got the default.
This worked for the OSS repo as we don't use the shared-runtime.
But for the monodroid stuff, we need to be able to change that
value. This was stopping the test projects doing that.
2017-09-01 13:26:10 -04:00
Daniel Cazzulino 9646b0a9a1 [create-vsix] Always version the output `.vsix` file (#806)
When the VSSDK builds the VSIX container, it generates a manifest
(`catalog.json`) placed inside it that has the resulting filename in
it. This manifest is used in alpha pack generation (by XVS) to
determine the payloads to include. This is done by invoking the VSMAN
tool (manifest generation thing) uses the contents of the catalog.

If the filename inside the catalog doesn't match the actual filename
included in the alpha pack manifest, installation fails, so we need
to ensure the filename is changed early enough in the process so that
it's consistent in the embedded manifest.
2017-09-01 11:42:57 -04:00
Dean Ellis 9e913fc834 Merge branch 'nwestfall-master' 2017-09-01 09:52:25 +01:00
Dean Ellis 6ed9bd7995 Merge branch 'master' of git://github.com/nwestfall/xamarin-android into nwestfall-master 2017-09-01 09:50:10 +01:00
Nathan Westfall fc8e48ef1f changed native library test to only x86 2017-08-31 22:50:01 -04:00
Bret Johnson 32ddcb8b87 [Xamarin.Android.Build.Tasks] Preserve set_ShadowCopyDirectories (#803)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=59115

`monodroid_create_appdomain()` requires that the
`AppDomainSetup.set_ShadowCopyDirectories` property exist, so that
it can be called.

Unfortunately, the linker may remove this property, which results in
a SIGSEGV if it's been removed:

	C  [libmonosgen-2.0.dylib+0x20bc9c]  mono_property_set_value+0xc
	C  [libmono-android.debug.dylib+0x154fe]  monodroid_property_set+0xbe
	C  [libmono-android.debug.dylib+0x15268]  monodroid_create_appdomain+0x248
	C  [libmono-android.debug.dylib+0xf159]  create_domain+0x149
	C  [libmono-android.debug.dylib+0xe439]  create_and_initialize_domain+0x69
	C  [libmono-android.debug.dylib+0xe89d]  Java_mono_android_Runtime_createNewContext+0x7d

Add `AppDomainSetup.set_ShadowCopyDirectories` to the linker's
preserve list, so that the Android Designer can work as intended.
2017-08-31 14:41:46 -04:00
Marek Habersack 79989b7c3c [Mono.Android-Tests] Fix stat(1) arguments on Linux (#801)
macOS uses *BSD command-line tools which often take different parameters
than the Linux ones. This is the case with **stat**(1) which not only expects
different command line parameters but also has different meaning of various
format placeholders (in this case `%z` means "file size in bytes" on macOS
but "file time stamp timezone in human readable format").

This fixes **stat**(1) invocation on Linux.
2017-08-31 10:40:12 -04:00
Jonathan Pryor 6b54d6dd26 Bump $(ProductVersion) to 8.0.99
We (try to) base Xamarin.Android product versions on the latest
Android versions. Android 8.0 Oreo™ [has been announced][0], and since
the xamarin-android/d15-4 branch includes an API-26/v8.0 binding, the
overall product version for d15-4 should *also* be bumped to v8.0.

[0]: https://www.android.com/versions/oreo-8-0/

As xamarin-android/master is tracking the *next* Xamarin.Android
version, bump `$(ProductVersion)` to v8.0.99 for eventual release as
v8.1.0.
2017-08-31 10:28:32 -04:00
Jonathan Pryor a953d3f1f0 [Xamarin.Android.Build.Tasks] AOT+LLVM needs minSdkVersion (#795)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58029

Scenario: Build a project with:

  * `$(Configuration)`=Release
  * `$(AotAssemblies)`=True
  * `$(EnableLLVM)`=True
  * `$(TargetFrameworkVersion)`=v7.1 (API-25)
  * `//uses-sdk/@android:minSdkVersion`=10 (in `AndroidManifest.xml`)
  * with Android NDK r12b or later
  * on particular hardware devices, e.g. a Nexus 5.

Actual results: the app runs, but the AOT'd images aren't used:

	AOT: image 'Xamarin.Android.Support.v7.AppCompat.dll.so' not found: dlopen failed: cannot locate symbol "__aeabi_memset" referenced by "/data/app/com.companyname.App1-1/lib/arm/libaot-Xamarin.Android.Support.v7.AppCompat.dll.so"...

The `__aeabi_memset` symbol can't be found, preventing e.g.
`Xamarin.Android.Support.v7.AppCompat.dll.so` from being used. Meaning
the app pays the build overhead and size penalty of AOT+LLVM, but
doesn't get anything out of it; only the JIT is used.

The [cause of the missing `__aeabi_memset` symbol][0] is that we're
using the NDK paths which corresponds with `$(TargetFrameworkVersion)`,
*not* the NDK paths which correspond with
`//uses-sdk/@android:minSdkVersion`. Because of this, if you use the
`.apk` on a platform which is >= `minSdkVersion` but less than
`$(TargetFrameworkVersion)`, the AOT images won't be used.

[0]: https://github.com/android-ndk/ndk/issues/126

Fix this by updating the `<Aot/>` task to instead use the
`//uses-sdk/@android:minSdkVersion` value. This ensures that we use
NDK paths which correspond to the app's minimum supported API level,
which should allow the AOT images to be loaded on downlevel devices.
2017-08-31 14:41:00 +01:00
Jonathan Pryor b8dc73286e [Xamarin.Android.Build.Tasks] GenerateJavaStubs Rebuilds (#799)
Commit 9d131af4 introduced a [unit test failure][m573] on
xamarin-android/master:

[m573]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/573/

	Xamarin.Android.Build.Tests.BuildTest.XA4212
	Expected: String containing "warning XA4"
	 But was: <log file contents...>

Aside: The XA4212 test creates a project with a bad `IJavaObject`
type, builds the project -- which triggers an XA4212 error, which *is*
observed in the unit test -- then *rebuilds* the project, but this
time with `$(AndroidErrorOnCustomJavaObject)`=False.

The intention is that the second build should instead elicit an XA4212
*warning*, but otherwise continue just fine.

What's interesting about the log file contents is that it shows that
the `<GenerateJavaStubs/>` task isn't executed *at all*, but it's the
`<GenerateJavaStubs/>` task which is supposed to emit the warning!

	Skipping target "_GenerateJavaStubs" because its outputs are up-to-date.

Update the `<GenerateJavaStubs/>` task so that if it errors out, it
*removes* any `<GenerateJavaStubs/>` output files. This will ensure
that on subsequent builds, the `_GenerateJavaStubs` target won't be
inadvertently skipped.

(This issue *should* have been caught during the
[**macOS+xbuild PR builder** build for PR #797][pr1491]. It *wasn't*,
because the `Xamarin.Android.Build.Tests` tests weren't reported. For
example, PR #1491 ran 869 tests, while PR #1492 ran 1085! I'm not sure
what can be done to better detect and prevent this in the future.)

[pr1491]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-pr-builder/1491/
2017-08-31 09:29:38 +01:00
Jonathan Peppers bb808ad906 [System.EnterpriseServices] Allow loading .csproj in VS (#798)
When opening Xamarin.Android.sln in Visual Studio 2017, you are
presented with a dialog box saying `.NETFramework,v8.0` is not
installed.

The fix is to setup the project like OpenTK's csproj: make it an Android
Library project with the appropriate `ProjectTypeGuids` and import
`Xamarin.Android.CSharp.targets`. These changes allow VS to load the
project.
2017-08-30 16:56:50 -04:00
Nathan Westfall d9013148a0 add unit tests to confirm correct native libraries are added to apk for https://bugzilla.xamarin.com/show_bug.cgi?id=47607 2017-08-30 16:45:02 -04:00
Jonathan Pryor 9d131af4f8 [Xamarin.Android.Build.Tasks] Add `$(AndroidErrorOnCustomJavaObject)` (#797)
Fixes:  https://bugzilla.xamarin.com/show_bug.cgi?id=56819

Bumps to Java.Interop/master/ab3c2b26.

Nothing *prevents* "anybody" from custom implementing `IJavaObject`:

	class MyBadClass : Android.Runtime.IJavaObject {
	    public IntPtr Handle {
	        get {return IntPtr.Zero;}
	    }

	    public void Dispose () {}
	}

The problem is that the above doesn't actually work: the
`IJavaObject.Handle` value contains the JNI Object Reference to pass
into JNI. The above code will thus result in always passing `null`
into Java code, which could result in a `NullPointerException`, but
will always result in *not* doing what was intended.

While it is *theoretically* possible to manually implement
`IJavaObject`, it's not something *I* would want to contemplate, nor
is it for the faint of heart, so long ago we decided to emit a warning
if we encounter a type which:

 1. Implements `Android.Runtime.IJavaObject`, and
 2. Does *not* also inherit `Java.Lang.Object` or
    `Java.Lang.Throwable`.

As such, the above `MyBadClass` elicits the warning:

	Type 'MyBadClass' implements Android.Runtime.IJavaObject but does not inherit from Java.Lang.Object. It is not supported.

This is all well and good, but (effectively) *nobody* reads warnings,
*especially* since our toolchain emits so many warnings that enabling
`/warnaserror` is for the truly foolhardy, so *lots* of warnings is,
unfortunately, normal.

Which brings us to Bug #56819: Could we make this an error?

Answer: Of course we can. That said, I have no idea how much existing
code this will *break* if we turned it into an error. That might be
good and useful, but if there's no way to *disable* the error,
existing apps which (appear to) work will no longer build.

That's not desirable.

Add a new `$(AndroidErrorOnCustomJavaObject)` MSBuild property to
control what happens when such custom `IJavaObject` implementations
are found. When True, the default, emit a new XA4212 *error*.
The error can be turned back into a warning by setting
`$(AndroidErrorOnCustomJavaObject)` within the `App.csproj`:

	<!-- Within App.csproj -->
	<PropertyGroup>
	  <AndroidErrorOnCustomJavaObject>False</AndroidErrorOnCustomJavaObject>
	</PropertyGroup>
2017-08-30 21:34:18 +01:00
Nathan Westfall 919fdcf8ee If building only for x86 or armeabi, x86_64 and armeabi-v7a native libaries are still pulled in when building the APK because the names are being checked using 'contains'. This causes issues when deploying to x86_64 device, but only building for x86 because android will start the VM for x86_64 and get a runtime error because it will be missing the libmonodroid.so.
See bug https://bugzilla.xamarin.com/show_bug.cgi?id=47607
2017-08-30 10:49:23 -04:00
Jonathan Peppers 1242e19d91 [Xamarin.Android.Build.Tasks] No scripts needed on Windows (#794)
I discovered this target failing when building with VS Community
edition instead of Enterprise.

It is calling:

    chmod +x [output]\Windows\mono-symbolicate

It turns out we can skip this target completely on Windows.
2017-08-30 09:57:49 -04:00
Dean Ellis 0434ef8e28 [Xamarin.Android.Build.Tasks] DesignTimeBuild failure on Rebuilds (#757)
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58682

Seeing a new seemingly DesignTimeBuild-related build failure when 
invoking the `Rebuild` msbuild target.

The `$(DesignTimeBuild)` value was empty when running under mac.
This cuases the error

	error MSB4044: The "GetAdditionalResourcesFromAssemblies" task was not given a value for the required parameter "DesignTimeBuild".

So we need to make sure that the value is set before we get to
`GetAdditionalResourcesFromAssemblies`. The reason we got the error
is before we used `$(DesignTimeBuild)` only in conditionals. However
when moving to use it as a property of a task it cannot be empty.
So we need to make sure we call `_SetupDesignTimeBuildForBuild`
early in the build process.
2017-08-29 11:05:48 -04:00
Dean Ellis ff28d572f2 [Xamarin.Android.Build.Tasks] No .dll's in Release if Optimize != True (#749)
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58580

Unable to locate assemblies when running projects when
`$(Configuration)`=Release and `$(Optimize)` != True.

Commit edabe8ac reworked the build logic so that `$(Optimize)`
controls the deployment of the debug or release runtimes.

	Input Property:                                                      || Output Property
	DebugSymbols    | DebugType  | EmbedAssembliesIntoApk   | Optimize   || AndroidIncludeDebugSymbols
	================+============+==========================+============++===========================
	True              *any*        True                       True          False      (Release runtime)
	True              *any*        True                       False         True       (Debug runtime)
	True              *any*        False                      True          True       (Debug runtime)
	True              *any*        False                      False         True       (Debug runtime)
	True              *empty*      True                       True          True       (Debug runtime)
	True              *empty*      True                       False         True       (Debug runtime)
	True              *empty*      False                      True          True       (Debug runtime)
	True              *empty*      False                      False         True       (Debug runtime)
	False             -            -                          -             False      (Release runtime)
	*empty*           *any*        *empty*                    False         True       (Debug runtime)

In this scenario, `$(DebugSymols)` and `$(EmbedAssembliesIntoApk)` are both empty.
As a result `$(EmbedAssembliesIntoApk)` gets a default value of 'False'.
But because `$(DebugSymols)` is empty we fall through the MSBuild case statement
and end up with `$(AndroidIncludeDebugSymbols)` = `True`. Which is NOT what we want in this case.
So if `$(EmbedAssembliesIntoApk)` we should always default `$(AndroidIncludeDebugSymbols)`
to false.

In addition there was a weird issue with the way we install debug apps.
If the app is using the Shared Runtime the deployment process sends a
broadcast to the Shared Runtime app which returns the external storage
directory. This tends to be something like

	/mnt/shell/emulated/0/

So when we deploy our debug assemblies we do so to a directory like

	/mnt/shell/emulated/0/Android/data/$(PackageName)/files/.__override__

This works as expected. Now if we try to debug an app without using the Shared
Runtime it will work as expected.. unless the Shared Runtime was not installed.
In this case the broadcast fails and we fall back to getting the external storage
using

	adb shell echo -b ${EXTERNAL_STORAGE}

This returns

	/mnt/shell/emulated/legacy

so we end up deploying the debug assemblies to

	/mnt/shell/emulated/legacy/Android/data/$(PackageName)/files/.__override__

So all is well and good. However problems start in our runtime and the
MonoPackageManager. We use

	android.os.Environment.getExternalStorageDirectory ();

to get the external storage directory. In this case it ALWAYS returns

	/mnt/shell/emulated/0/

So if we are debugging without the Shared Runtime being installed, we will
NEVER find the fast deployed assebmies. So the app will crash. The fix in
this case is to check both directories when we are running the debug
runtime.
2017-08-29 10:35:57 -04:00
Radek Doulik fff81b0315 [tests] Measure .apk sizes and selected content (#791)
- extracted parts of `ProcessLogcatTiming` into new base class called
   `ProcessPlotInput`

 - we measure and process the apk sizes now to observe the changes and
   possible regressions on Jenkins CI

 - it is now possible to add results to cvs plot files, so we can
   merge values from multiple test runs. we do that with apk size
   values and we will do it with startup times in future
2017-08-29 09:27:29 -04:00
Jonathan Pryor 9ead8486d7 [Xamarin.Android.Build.Tasks] Insert newlines between types (#790)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=59036

When building a project with `$(AndroidEnableMultiDex)`=True, an
`obj/$(Configuration)/multidex.keep` file is generated, which is a
list of Java classes, one per line, which should be placed into the
"main" `.dex` file for the application.

Unfortunately, commit 6829b7d1 results in a `multidex.keep` file which
places all types onto a single line, instead of one class per line.
This results in *breaking* multidex, as when this happens, nothing
ensures that the required types are in the main `.dex` file, which
could prevent the app from launching on the target device.

Fix the `<CreateMultiDexMainDexClassList/>` task by always appending a
newline after every type which should be preserved.
2017-08-28 14:58:30 -04:00
Jon Douglas 3e1f02da41 [README] MSBuild 15+ is needed on Windows (#792)
This commit is inspired by the known issue of finding a compatible
MSBuild given that VS 2017 has SxS support and additionally installs
various versions of MSBuild (such as MSBuild 15 and MSBuild 4
depending on payloads installed).

People may try to build using an incompatible MSBuild version that
lacks proper C# feature support.

Update `README.md` to explicitly specify that MSBuild 15+ is required.
2017-08-25 21:04:52 -04:00
Jonathan Peppers 46409cf7dd [build] Windows alternative to `make prepare` (#785)
On Windows you can now do:

    msbuild build-tools\scripts\PrepareWindows.targets

Using `PrepareWindows.targets` does the following:

- `git submodule update --init --recursive`
- Sets up the required `.props` files for your system
- Downloads `.nuget/NuGet.exe`
- Runs `nuget restore`
2017-08-25 15:21:05 -04:00
Jonathan Pryor bb02dffd1d [api-compatibility] Use d15-4 API definitions
The [most recent xamarin-android/master build is not green][xa564],
because of a failure in the `api-compatibility` tests:

[xa564]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/564/

	ABI BREAK IN: mscorlib.dll
	<!-- start namespace System.Collections.Generic --> <div>
	<h2>Namespace System.Collections.Generic</h2>
	<h3>Removed Type <span class='breaking' data-is-breaking>System.Collections.Generic.CollectionExtensions</span></h3>
	</div> <!-- end namespace System.Collections.Generic -->

The cause for the breakage is that
[xamarin-andorid-api-compatibility was updated for mono/2017-06][0],
and `mscorlib.dll` is incompatible between mono/2017-04 and
mono/2017-06.

[0]: ed8d914d08

Since Xamarin.Android d15-4 and current master are both using
mono/2017-04, the result is the above "ABI BREAK" message...
*all the time*.

Update xamarin-android/master to use
[xamarin-android-api-compatibility/d15-4][1], fixing the ABI BREAK
build error.

[1]: https://github.com/xamarin/xamarin-android-api-compatibility/tree/d15-4
2017-08-25 09:59:29 -04:00
Marek Habersack 956d42765f [android-toolchain] Bump build-tools to 26.0.1 (#783)
26.0.0-rc2 is no longer available (26.0.0 was released a while ago)
and the latest version is 26.0.1
2017-08-24 21:01:05 -04:00
Marek Habersack eaf991922c [xabuild] Always Override SDK/NDK dir for in-tree builds (#784)
In-tree XA builds should always override the `$ANDROID_NDK_PATH` and
`$ANDROID_SDK_PATH` environment variables because code that handles
Android SDK components installation (in `build/android-toolchain`)
is destructive in that it first removes the entire SDK/NDK trees and
installs everything from scratch. This has bad effects if the
developer's machine has a separate SDK/NDK tree not managed by XA
build system: build removes the directories but it requires tools
that were in them and, in effect, crashes.
2017-08-24 21:00:01 -04:00
Jonathan Peppers 6a3f76ead7 [libzip-windows] Copy Windows binaries from NuGet (#777)
LibZipSharp is pulling `libzip.dll` and `zlib.dll` from NuGet on
Windows, so we can use these in favor of building
`libzip-windows.mdproj`.

We also need to add a `@(ProjectReference)` to `libzip-windows.mdproj` in
`Xamarin.Android.Tools.BootstrapTasks`.
2017-08-24 18:07:18 -04:00
Jonathan Pryor 89371f4e33 [build] Improve Visual Studio for Mac support (#782)
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58994

When loading `Xamarin.Android.sln` into Visual Studio for Mac, the
Solution Panel indicates an error on the `Mono.Android` and
`Mono.Android.Export` projects:

	Project does not support framework 'MonoAndroid,v1.0'.

Fix this warning by adding `$(ProjectTypeGuids)` to
`Mono.Android.csproj` and `Mono.Android.Export.csproj`.

Additionally, some projects such as
`src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj`
*do not build* within Visual Studio for Mac, because Visual Studio for
Mac doesn't appear to support the use of MSBuild properties within
`<Import/>`s -- at least not *our* property use. Specifically, this:

	<Import
	    Project="$(JavaInteropFullPath)\src\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings.projitems"
	    Label="Shared"
	    Condition="Exists('$(JavaInteropFullPath)\src\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings.projitems')"
	/>

is *completely ignored*, which results in multiple C# compiler errors
as types which are provided by that shared project cannot be found.

Appease Visual Studio for Mac by *removing* use of such properties
within `.csproj` files, and instead hardcoding relative paths.

Unfortunately this kills the idea from commit d205cab2:

> Allow the Java.Interop checkout directory to be specified by
> overriding the `$(JavaInteropSourceDirectory)` MSBuild property.
> ...
> Normally `$(JavaInteropSourceDirectory)` wouldn't need to be
> overridden; the current use case is to allow a CI-like environment
> which grabs the latest commit of every referenced module to make sure
> they all work together. (Note: such a "CI-like environment"
> DOES NOT (yet) EXIST. This commit is to help *permit* such a thing.)

Such a "CI-like environment" still doesn't exist, and is arguably
moot/silly, as Jenkins has an option to
**Update tracking submodules to tip of branch**, which is more-or-
less what was being advocated for here.

Using e.g. `$(JavaInteropFullPath)` -- the value of which was based
off of `$(JavaInteropSourceDirectory)` -- actively prevents
Visual Studio for Mac from building projects, so remove that use.

Finally, Visual Studio for Mac is *still* unable to do a toplevel
Build, even after all of these changes: Visual Studio for Mac doesn't
like `@(ProjectReference)` items which are `Condition`al, and we have
those all over the place (for now).

The changes in this commit *improve*, but **do not** "fix",
Visual Studio for Mac use.

Just build projects individually, with Command+K. :-)
2017-08-24 18:06:01 -04:00
Atsushi Eno 420f7e12af [Mono.Android] Fix NotificationVisibility enumification. (#771)
It was `getLockscreenVisibility`, not `getLockScreenVisibility`...
2017-08-24 15:43:00 -04:00
Marek Habersack 503352986d Enable building LLVM cross-compilers on Linux (#760)
Linux doesn't need to build MXE since the distributions we support at
this point have mingw packaged and we rely on the packages to provide
cross-compilation environment for Windows. Neither does Linux build
require the Mono Windows environments to be built.

Previously, when one enable the Windows LLVM build the Mono Windows
runtime was attempted to build as well. The attempt would fail since
some Windows-only libraries required by Mono/libmonodroid aren't available
as packages on Linux.

This commit disables building of Mono Windows runtimes while making it
possible to build the LLVM Windows cross compiler.
2017-08-24 11:56:46 -04:00
Dean Ellis b75f8607a3 [Xamarin.Android.Build.Tasks] Add PathToLongException context (#754)
If we hit a PathToLongException when extracting embedded resources
we currently do not get any information about the file where
actually caused the problem.

This commit adds handling for that case so that the error message
includes the file and path of the file that was being extracted.
2017-08-24 10:41:28 -04:00
Radek Doulik fbfcd46b4c [tests] use different filenames for logcat output (#774)
- so that we don't overwrite the logcat file on run of the different
   tests/configurations
2017-08-24 06:49:54 -04:00
Jonathan Pryor de332d3561 Bump to mono/2017-04/54108f95 (#778)
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58829
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58834
2017-08-23 22:55:57 -04:00
Jonathan Pryor 770430eec3 [build] `make framework-assemblies` uses `$(_SLN_BUILD)`
Commit 8942eca0 broke the build. Commit a1bf2deb attempted to fix it,
but was incomplete; [we now get][xa556]:

[xa556]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/556/

	error XA0000: Could not determine $(TargetFrameworkVersion) for API level '10.'

Commit a1bf2deb had the right idea -- we got further in the build! --
but didn't go far enough: as soon as we use `$(MSBUILD)`, we
incorrectly use the system libraries -- which cannot work -- and
re-introduce the XA0000 error.

The fix: expunge `$(MSBUILD)` from `BuildEverything.mk`, and use
`$(_SLN_BUILD)` instead. This ensures that we use the in-tree
`bin/Debug/lib/xamarin.android/xbuild*` directories and not the
pre-installed system equivalents.
2017-08-23 22:54:50 -04:00
Dean Ellis 89a6d68771 [Xamarin.Android.Build.Tasks] Library project C# changes & Rebuilds (#764)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58865

Consider a project with an `App.csproj` and a referenced
`Lib.csproj`. Not all changes to C# sources within `Lib.csproj`
should require rebuilding and redeploying the `.apk` when
Fast Deployment is enabled; only those that result in changes
to Java Callable Wrappers should require rebuilding and
redeploying the `.apk`.

Unfortunately, that wasn't the case: *any* change to `Lib.csproj`
would result rebuilding and redeploying the `.apk`, because
`AndroidManifest.xml` was constantly being modified, which would
cause the `_CompileToDalvikWithDx` target to be invoked, resulting
in a `.apk` rebuild + redeploy.

The item

	<meta-data android:name="android.support.VERSION" android:value="25.4.0" />

was constantly being duplicated in the manifest. As a result it
was always newer and was triggering a change of build targets.

So we need to double check we are NOT adding 100% duplicate
values to the manifest.
2017-08-23 22:21:21 -04:00
Radek Doulik 845b5432e1 Bump to linker/master/07b07ef7 (#775)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id= 58740

- the commit:

    commit 07b07ef75fa1858253af45af6fe30812a5a1655c
    Author: Marek Safar <marek.safar@gmail.com>
    Date:   Wed Aug 23 00:44:47 2017 +0200

        Don't crash on any wrong type forwader reference
2017-08-23 15:13:31 -04:00
Jonathan Pryor a1bf2deb48 [build] `make leeroy-all` uses `$(_SLN_BUILD)`
Commit 8942eca0 [broke the build][xa554]:

[xa554]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/554/

	error XA0000: Could not determine $(TargetFrameworkVersion) for API level '26.'

The cause of the failure is that we're using `xbuild` within the
`make leeroy-all` target, but [we need to use `xabuild`][xbuild-paths]:

[xbuild-paths]: https://github.com/xamarin/xamarin-android/pull/599#issuecomment-319543023

	Task "GetReferenceAssemblyPaths"
	  Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
	  Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks'
	  Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0'
	Done executing task "GetReferenceAssemblyPaths"

`xbuild` is trying to use the *system-wide*
`/Library/Frameworks/Mono.framework/External/xbuild-frameworks`
directory, which *cannot* contain the now-required
`AndroidApiInfo.xml` files which are needed for probing.

Fix the `make leeroy-all` target to use `$(_SLN_BUILD)`, just as the
`make all` target does, so that the correct paths are used.
2017-08-23 12:48:09 -04:00
Jonathan Peppers 467f42de3c [android-toolchain] Windows build support (#743)
* Bump LibZipSharp for Windows fixes

Problems fixed on Windows:

  - Many `RequiredPrograms` are n/a on Windows
  - Setup `AndroidSdkItem` for Windows downloads
  - `AcceptAndroidSdkLicenses` should run `.bat` file on Windows
  - `UnzipDirectoryChildren` was running `/bin/mv` and hitting
    `PathTooLongException` while using `ZipFile.ExtractToDirectory`
  - references to `libzip.mdproj` are conditional on Windows, will be
    getting `libzip` from NuGet in the future

UnzipDirectoryChildren:

  - on Windows we are using `System.IO.Compression` to extract
    directly into the destination and avoid `%TEMP%` to
    workaround `MAX_PATH`
  - Other platforms continue to use `unzip`, in order to preserve
    file attributes

General changes:

    - gitignore for VS 2017
2017-08-23 11:27:35 -04:00
Dean Ellis 920450650e [Xamarin.Android.Build.Tasks] Use UTC in ResolveLibraryProjectImports (#768)
We were not using UTC for allot of the date time comparisons in
the `<ResolveLibraryProjectImports/>` task. We really should be
since it means we should not hit any issues with LocalTimes.
2017-08-23 10:06:40 -04:00
Jérémie Laval e13fd6c782 Merge pull request #773 from dellis1972/DesignerImports
[Xamarin.Android.Build.Tasks] Fix up _ResolveAssemblies to support the Designer
2017-08-23 09:12:09 -04:00
Jonathan Pryor 8942eca00a [Xamarin.Android.Build.Utilities] Add AndroidVersions (#599)
Commit 8e7d37bb is a sign of duplication: in order to use a
`Mono.Android.dll` binding assembly, not only do we need to *build*
the binding assembly, but we *also* need to update
`Xamarin.Android.Build.Utilities.dll` to "know" about the new binding
version (to map API level to `$(TargetFrameworkVersion)`).

Even "better" (worse), if the new API level is a *preview*, there is
no *consistent* API level. For example, with API-O, `android.jar`
isn't at
`$(AndroidSdkDirectory)\platforms\android-@API_LEVEL@\android.jar`,
where `@API_LEVEL@` is 26 (because various codepaths require that the
"api level" be an integer). Instead, it's installed at
`$(AndroidSdkDirectory)\platforms\android-O\android.jar`, where
`O` is the "id" of the preview API level.

This "id" is "leaky", in turn requiring that
`Xamarin.Android.Build.Tasks.dll` *also* be updated to deal with the
mappings.

Even "better" (worse), if we *forget* to cross all our our 't's and
dot all of our 'i's, we'll have a binding assembly which can't be
used. (Which is why we needed commit 8e7d37bb; without it, the API-O
binding can't be used!)

This is all obviously madness. ;-)

Clean this mess up:

 1. Update `src/Mono.Android` to create a new `AndroidApiInfo.xml`
    file within the `$(TargetFrameworkVersion)` directory.
    This will contain all the information needed to map Android API
    levels to Ids and Android OS versions and
    `$(TargetFrameworkVersion)` values.

    ```xml
    <AndroidApiInfo>
      <Id>10</Id>
      <Level>10</Level>
      <Name>Gingerbread</Name>
      <Version>v2.3</Version>
    </AndroidApiInfo>
    ```

 2. Add a new `Xamarin.Android.Build.Utilities.AndroidVersions` type
    which looks for and parses these new `AndroidApiInfo.xml` files.

 3. Fixup all the other places using `AndroidVersion.KnownVersions`
    and related members to instead use `AndroidVersions`.

 4. Remove all the old APIs which rely on hardcoded data.

The advantage to all this is that we can support new API level
bindings by just building a new `Mono.Android.dll` and placing an
`AndroidApiInfo.xml` into the appropriate location (next to
`Mono.Android.dll`). No further code changes would be required.

Related: The build system still has a nasy habit of using system-wide
directories to resolve files we'd really rather it not, e.g. in
[xamarin-android/master build #503][m503]:

[m503]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/503/consoleText

	Building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it.
	  Target _GetReferenceAssemblyPaths:
	  Task "GetReferenceAssemblyPaths"
	    Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
	    Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks'
	    Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0'
	  Done executing task "GetReferenceAssemblyPaths"
	  Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj".
	Done building target "_GetReferenceAssemblyPaths" in project "/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj" ("/Users/builder/jenkins/workspace/xamarin-android/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "_SetLatestTargetFrameworkVersion" depends on it.
	  Target _SetLatestTargetFrameworkVersion:
	  Task "ResolveSdks"
	    ReferenceAssemblyPaths:
	      /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/

Note the use of the path
`/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0`.

This *was* "fine" -- if undesirable -- but with the introduction of
`AndroidVersions` and `AndroidApiInfo.xml` files within the frameworks
directory, everything falls apart, becuase the system install
*does not have* the `AndroidApiInfo.xml` files, so
*NO API LEVELS ARE FOUND*.

Oops.

The only way to fix this is to use `$XBUILD_FRAMEWORK_FOLDERS_PATH`,
and the sanest way to do *that* is to use `tools/scripts/xabuild` for
the primary build.

Unfortunately, using `xabuild` for the primary build breaks the
`msbuild`-based build, as it can't resolve the
`.NETFramework,Version=v4.6.1` framework.

Context: https://github.com/xamarin/xamarin-android/pull/599#issuecomment-319801330

Split the difference here by introducing `$(_SLN_BUILD)`: use
`xabuild` when building with `xbuild`, and continue using `msbuild`
when building with `msbuild`.
2017-08-23 07:19:11 -04:00
Jonathan Peppers 9aeacdd3ca [windows] Fix paths in JavaCallableWrappers.targets (#766)
When running `<Exec>` on Windows, a trailing slash on the end of a path
before a quote can actually escape the quote. This breaks a call to
`jcw-gen.exe` where a proper list of directories wasn’t getting passed
in.

There were also some failing `javac` calls on Windows. `javac` uses a
semi-colon to delimit jar files on Windows and a colon on Linux/MacOS.

Changes:

  - `$(_LibDirs)` needs to ensure there aren’t trailing slashes on
    directories passed to `jcw-gen`
  - Added a `$(PathSeparator)` property in `Configuration.props` to
    use the right path separator on each platform.
2017-08-23 07:18:06 -04:00
Jonathan Pryor 82f6e22339 Bump to Java.Interop/master/33436346 (#770)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=57828
2017-08-23 07:16:36 -04:00
Jonathan Peppers 9d0e4ffe0c [Xamarin.Android.NUnitLite] Set $(NoStdLib)=True (#772)
When running the build on Windows you see:

    FrameworkPathOverride = \bin\Debug\lib\xamarin.android\xbuild-frameworksMonoAndroid\v1.0

set during the build. Turns out we need to set `$(NoStdLib)`=true since we
are using a custom `mscorlib.dll`. This prevents the path getting messed
up on Windows.
2017-08-23 07:13:57 -04:00
Dean Ellis 88936a2831 [Xamarin.Android.Build.Tasks] _UpdateAndroidResgen is throwing new APT0000 errors in d15-4 (#769)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58889
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58890

Commit 0667a2b6 and ea6b9b45 added support for short path names.
However during the rework we added code to replace

	library_project_imports/

with an empty string. Some of the Nuget Support packages seem
to include a `__AndroidLibraryProjects__.zip` which uses
windows path sepatators rather than unix ones. So the code
to strip off the `library_project_imports/` does not work.
We end up with a directory structure like

	__library_projects__/[dllname]/library_project_imports/library_project_imports

which a) does not get picked up by our tasks and b) takes up
a bunch of additional characters in our already long path..

The result is the two errors above... one to do with missing resources
the other a PathToLong error.

Because the nuget packages have already shipped and will be in use,
we need to handle BOTH cases.
2017-08-23 07:12:23 -04:00
Dean Ellis a06e0e3cb7 [Xamarin.Android.Build.Tasks] Fix up _ResolveAssemblies to support the Designer
We are going to add a bunch of new targets for the designer.
This is so if we make changes to the file structure there will
be no need for the designer to alter code.

However we do need to alter the targets a bit. In this case we
only want to pass the `$(OutDir)$(TargetFileName)` if it exists.
Otherwise the task will error. In the case of the designer this
will happen quite allot because the project might not have been
built yet.
2017-08-23 10:37:31 +01:00
Jonathan Pryor 3294a50eea [test] Check for "Unknown has vcpu" emulator message
The Jenkins emulator-based tests are hanging -- again (see also
db668ba) -- this time with a new message:

	[emulator stderr] Unknown hax vcpu return 1

I don't know what it means, other than "nothing is going to happen for
hours on end." Add an `emulator` stderr check for the above message,
and bail out early if it's seen so that we don't lose hours waiting
for a Job timeout to occur...
2017-08-22 14:28:37 +02:00
Jonathan Pryor bafb47cbd9 [Xamarin.Android.Build.Utilities] "O" is now officially Oreo (#765) 2017-08-22 16:19:47 +09:00
Jonathan Peppers 3b5955d7d5 [monodroid] Remove use of `xxd` (#762)
`monodroid.mdproj` was generating `jni/config.include` and
`jni/machine.config.include`  using the `xxd` and `sed` commands,
which will not work on Windows.

Changes:

  * Added a new MSBuild task, `GenerateMonoDroidIncludes` that
    replicates the `xxd` output in C#
  * Cleaned up the `<ItemGroup>` to have `@(_EmbeddedBlobSource)` and
    `@(_EmbeddedBlobDestination)`
  * We are no longer using `xxd` anywhere so this can be removed from
    `dependencies.projitems`, `linux-prepare-Arch.sh`, and `README.md`
2017-08-21 15:22:11 -04:00