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

15 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Peppers 763959e5b2 [tests] `gradlew` needs JAVA_HOME set on Windows (#870)
Context: commit 3dc37379

Failing build at: https://devdiv.visualstudio.com/DevDiv/_build/index?buildId=999607

    ##[error]EXEC(0,0): Error : JAVA_HOME is not set and no 'java' command could be found in your PATH.

Export `%JAVA_HOME%` so that `gradlew` executes properly.
2017-09-19 08:25:34 -04:00
Jonathan Peppers 1b72a18425 [tests] Xamarin.Android-Tests.sln builds on Windows (#853)
- Needed to `nuget restore Xamarin.Android-Tests.sln`
  - Added `$(XAIntegratedTests)` property which defaults to True.
    Windows will need to set this property in order to build
    `Xamarin.Android-Tests.sln`
  - Some project references in `Mono.Android-Tests.csproj` should
     be conditional against `$(XAIntegratedTests)`==True
  - Usage of `zip -r` is replaced with `jar cf` using `$(JarPath)`
    (Windows doesn't have `zip`)
  - `Xamarin.Android.Build.Tasks.csproj` had a file-locking issue
    similar to `create-vsix.csproj` (2bca09d1): the
    `_GenerateXACommonProps` target needs to depend on `ResolveReferences`

Other changes:

- Update README
- Update .gitignore for `.gradle/` and `*.user` files
2017-09-14 19:45:08 -04:00
Jonathan Peppers 3dc373794a [jdk] Don't require `javac`/`jar` in $PATH (#800)
Windows machines do not include `java` in their path by default, so it is
a better experience to not require it for the build.

Changes to make this happen:

  - `$(JavaCPath)` and `$(JarPath)` are configured in
    `Configuration.OperatingSystem.props`
  - Usage of `javac` and `jar` across the repo use appropriate
    variables now
  - `generate-os-info` needs to set `$(JavaCPath)` and `$(JarPath)`
  - Created a new `<Ant>` MSBuild task
  - A couple places, Windows needs `%JAVA_HOME%` to be set, so we
    are doing this via `Environment.SetEnvironmentVariable()` in the
    `<AcceptAndroidSdkLicenses/>` and `<Ant/>` tasks.
  - `Configuration.OperatingSystem.props` is conditional, so it is
    possible to build xa-prep-tasks without it
  - `<Which/>` needs to accept files without extensions last for
    Windows; `$PATHEXT` should be empty on Unix
2017-09-08 11:44:12 -04:00
Radek Doulik 064840b47d [build] Remove autogenerated resource files and clean a bit (#831)
And add them to .gitignore. It will make the 'git diff' output
lucider.

Added few more performance measurement files to .gitignore as well
2017-09-08 11:26:12 -04:00
Radek Doulik 09ba1ee45d [tests] Xamarin.Forms-Performance-Integration test (#818)
Add `tests/Xamarin.Forms-Performance-Integration` to measure UI app
startup times.

Add a new `<RunUITests/>` task to start an app/activity.

Rename `@(UnitTestApk)` to `@(TestApk)`, as it also handles UI tests.

Update `<ProcessLogcatTiming/>` to be able to process the
`adb logcat` output of started Android Activity processes.
2017-09-07 12:35:08 -04:00
Jonathan Peppers 03407251f7 [build] fix `Exists` check for `ndk-build` on Windows (#828)
Checks for `Exists ('$(AndroidNdkDirectory)\ndk-build')` will not work
on Windows, since the file is named `ndk-build.cmd`.

To fix this, I created a new `NdkBuildPath` property to be used
throughout the build, which will have the correct value on Windows.
2017-09-07 06:35:24 -04:00
Radek Doulik 320d773824 [tests] Merge runtime test timing measurements into one plot (#815)
- also dump logcat only once per target run, we don't need to
    differentiate it for various tests, as they are batched over one
    emulator instance
2017-09-05 15:17:00 -04:00
Jonathan Pryor ada479b1d6 [Mono.Android] Define JavaCollection before ICollection (#741)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58303

Background: It is possible for a Java type to have
"aliasing bindings": two or more managed types which claim to bind
the same Java type:

	// C#
	namespace Android.Runtime {
	  [Register ("java/util/HashMap", DoNotRegisterAcw=true)]
	  partial class JavaDictionary {
	  }
	}
	namespace Java.Util {
	  [Register ("java/util/HashMap", DoNotRegisterAcw=true)]
	  partial class HashMap {
	  }
	}

These can't be realistically forbidden.

Enter a new-to-bind Java type:

	// Java
	public class Bxc58383 extends java.util.HashMap implements java.util.Map {
	}

In order to bind the above `Bxc58383` type, `generator` needs to
determine the appropriate binding type to use for `java.util.HashMap`.
`generator`'s approach to supporting aliasing types is (largely) to
ignore the problem (almost) entirely: There Can Be Only One™ mapping
from a Java type to a managed type, so `generator` needs to pick one.
It does so by using the *last* definition encountered in the assembly.

Consequently, for the above set of C# declarations, when `generator`
needs to find the managed type which binds `java.util.HashMap`,
`Java.Util.HashMap` will be chosen, as it is the last declared type.

Unfortunately, "real life" is a bit more complicated:
`Mono.Android.dll` is made up of *thousands* of files, and the order
of types within an assembly is a compiler implementation detail.
As such...the current `Mono.Android.dll` has `JavaDictionary` defined
*after* `HashMap`:

	# output truncated for relevance
	$ monodis --typedef bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v7.1/Mono.Android.dll | grep 'Dictionary\|HashMap'
	1270: Java.Util.Dictionary (flist=12611, mlist=29569, flags=0x100081, extends=0x20b8)
	1287: Java.Util.HashMap (flist=12662, mlist=29806, flags=0x100001, extends=0x1388)
	3992: Android.Runtime.JavaDictionary (flist=32135, mlist=85344, flags=0x100001, extends=0x20b8)

Because `JavaDictionary` is defined *after* `HashMap`, and both of
those types have `[Register]` attributes which declare that they bind
the *same* Java type, the result is that the binding of `Bxc58383` is
horrifically broken:

	// C#
	partial class Bxc58383 : global::Android.Runtime.JavaDictionary, global::Java.Util.IMap {
	}

Unfortunately, `JavaDictionary` doesn't itself implement `IMap`, so:

	error CS0535: 'Bxc58383' does not implement interface member 'IMap.ContainsKey(Object)'

along with 10 other related errors.

Update the `src/Mono.Android` build process so that `JavaDictionary`
and related types will be defined within `Mono.Android.dll` *before*
all the generated types. This allows `HashMap` to be defined last,
allowing `Bxc58383` to be bound without error:

	# output truncated
	$ monodis --typedef bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v7.1/Mono.Android.dll | grep 'Dictionary\|HashMap'
	3703: Android.Runtime.JavaDictionary (flist=34089, mlist=78134, flags=0x100001, extends=0x4e08)
	4170: Java.Util.Dictionary (flist=39685, mlist=91737, flags=0x100081, extends=0x4e08)
	4187: Java.Util.HashMap (flist=39736, mlist=91974, flags=0x100001, extends=0x40d8)
2017-08-11 19:27:52 +01:00
Peter Collins f2eb704677 [tests/Codegen-Binding] Use a variable for the 'gradlew' invocation in BuildJavaLibs (#696)
This fixes a 'gradlew' failure which is encountered on Windows only. Unfortunately, the 'gradlew' invocation prefixes the 'sdk.dir' value read from 'local.properties' with the path of the working directory.
As a result, we encounter a failure along the following lines on Windows:

```
    * What went wrong:
      A problem occurred configuring project ':library'.
      > The SDK directory 'C:\Users\xamarinqa\git\xamarin-android\tests\CodeGen-Binding\Xamarin.Android.LibraryProjectZip-LibBinding\java\JavaLib\C:Program Files (x86)Androidandroid-sdk' does not exist
```

This can be avoided by exporting ANDROID_HOME in the Exec portion of the BuildJavaLibs target, rather than writing this information to a file and expecting 'gradlew' to process it correctly.
2017-07-19 06:18:41 -07:00
Jonathan Pryor 0917dea838 [CodeGen-Binding] Use `com.android.tools.build:gradle:2.3.0` (#580)
Fix a [build][0] [break][1]:

	Executing: ./gradlew assembleDebug --stacktrace
	...
	The android gradle plugin version 2.4.0-alpha3 is too old, please update to the latest version.
	To override this check from the command line please set the ANDROID_DAILY_OVERRIDE environment variable to "ea6ce2cbbbfb0e0a68b85eb08916733d4367c4dd"
	FAILURE: Build failed with an exception

For a change, this break on Jenkins wasn't *directly* caused by a
commit; it was *indirectly* caused by commit 571546a1, which specified
`com.android.tools.build:gradle:2.4.0-alpha3`.

Turns Out™, `gradle:2.4.0-alpha3` has a builtin "expiration date",
*presumably* of 2017-Apr-30, meaning that when you build after the
expiration date, it doesn't actually build.

The result is the above error from `gradlew assembleDebug`.

The fix? Don't use preview packages if they can be avoided. The
`gradle:2.3.0` package appears to work Just Fine™, with the added
benefit that it's *not* a preview package.

[0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/371/
[1]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/371/consoleText
2017-05-01 11:36:43 -04:00
Atsushi Eno 571546a1a6 [Mono.Android] Android API-O Preview support (#514)
First step towards support for Android-O Preview API.

The changes are big due to the structural changes in Android SDK,
particularly that "android" command line tool is gone and they had to
be rewritten. Samples that depended on "create" or "update" command
had to be checked in as already-created state so that they don't have
to bring further dependencies.

Changes in the library (Mono.Android) itself is not very big at all.

`src/Mono.Android/Profiles/api-O.xml.in` comes from API-O DP 1's
`android.jar`.
2017-04-25 16:06:32 -04:00
Jonathan Pryor bc29f4d6de [Xamarin.Android.Build.Tasks] Default $(AndroidClassParser) is jar2xml (#356)
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=45203
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=47582
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=48588

In an ideal world, we'd use `class-parse` to parse `.jar` files when
producing binding assemblies, as `class-parse` is significantly better
and more reliable that `jar2xml`.

...then we hit the problem of "compatibility": there is a reasonable
expectation that currently existing projects will continue to build in
new product versions. It would anger developers if they upgraded
Xamarin.Android and then their binding projects no longer built.

Which is precisely what *will* happen if we change the default
`$(AndroidClassParser)` value to `class-parse`, as per
Bugs #45203, #47582, and #48588: `class-parse` does a much better job
at finding Java types and members, which means *more* types and
members are present in `class-parse` output (compared to `jar2xml`),
which means there's a higher likelihood of encountering `generator`
bugs. These bugs were likely previously worked around when using
`jar2xml`, but *requiring* that those same projects be fixed *again*
is a bridge too far.

Meaning `class-parse` needs to be an "opt-in" feature, not an
"opt-out" feature.

Change the default `$(AndroidClassParser)` value to `jar2xml` so that
existing projects continue to use `jar2xml` when binding.

We will update the default template for *new* projects to use
`class-parse` in the IDEs, so *new* projects will get improved
behavior.
2017-01-09 14:12:43 +00:00
Dean Ellis ae3c3308f4 [Xamarin.Android.Build.Tasks] Add AndroidPrepareForBuild for unit tests (#350)
Add a new `AndroidPrepareForBuild` target for unit test use.

Some of our unit tests dont need to build but do need to resolve
the android SDK and other properties. We did us the `_ValidateAndroidPackageProperties`
target to make sure all of the required properties were in place.

However commit 8337d21e altered the build process so that target is
run earlier in the build process. As a result the required properties
are not initialised.

This commit adds a new `AndroidPrepareForBuild` target which ensures that
the correct targets are run for tests.
2017-01-09 09:05:45 -05:00
Jonathan Pryor aa3906e158 [android-toolchain, tests] Install and use `ant` (#324)
A "funny thing" happened with commit 6e48bca5:
[it built on the PR builder][0], but
[not on the main builder][1].

The cause of the breakage? The PR builders have `ant` installed and
available in `$PATH`; the main builder did not:

	.../xamarin-android/tests/CodeGen-Binding/Xamarin.Android.LibraryProjectZip-LibBinding/Xamarin.Android.LibraryProjectZip-LibBinding.targets:
	error : Command 'ant debug' exited with code: 127.

Exit code 127 means "This program cannot be found."

This was fixed by installing `ant` on the build machine, but this
isn't a great answer, in part because README.md doesn't mention the
fact that `ant` is required for the build.

Extend the `android-toolchain` mechanism so that Apache Ant 1.9.7 is
downloaded and installed into the `$(AndroidToolchain)` directory.
This allows the build system to "know" and maintain it going forward.

Update `Xamarin.Android.LibraryProjectZip-LibBinding.targets` to use
`$(AndroidToolchain)\ant\bin\ant` instead of `ant` for builds.

[0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-pr-builder/331/
[1]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/167/
2016-12-05 19:34:39 +00:00
Jonathan Pryor 6e48bca5e7 [tests] Import tests/codegen from monodroid/5fc80f27
`tests/CodeGen-Binding` is a full-stack integration jack for JNI
bindings, ensuring that `generator.exe` and company work as expected.
It is *somewhat* duplicative of the Java.Interop `generator` unit
tests, except these are actually executed, while the `generator` tests
are *not* executed.

`tests/CodeGen-MkBundle` is a test for the "Bundle assemblies into
native code" feature, but isn't part of the "proper" unit test
infrastructure, as it doesn't yet contain an `Instrumentation` type.

TODO: Add an `Instrumentation` type to `tests/CodeGen-MkBundle`.
2016-12-01 09:09:44 -05:00