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

2065 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge b547454e98 [mtouch] Fix cache invalidation with app extensions.
Change cache invalidation so that if any app extension's cache is invalid,
then invalidate the cache for the container app and all other app extensions.

This is the safest option when we're sharing code.
2017-02-10 16:39:23 +01:00
Rolf Bjarne Kvinge 95dfdd3a00 [cache] Remove dead code. 2017-02-10 16:39:22 +01:00
Rolf Bjarne Kvinge e7ae947189 [cache] Don't use the global command line arguments to determine input.
Don't use the global command line arguments to determine input, because that's
not the input we use for app extensions anymore.

Instead explicitly pass the input arguments when creating the cache.
2017-02-10 16:39:21 +01:00
Rolf Bjarne Kvinge 02b81e3332 [cache] Fix mmp/mtouch change detection.
Since neither mtouch nor mmmp is mkbundled anymore, the installed binary is in
fact a shell script.

This means that it's quite useless to check if the shell script has been
modified; instead check if the executing assembly has been modified (which
works now that we're not mkbundled anymore).
2017-02-10 16:39:20 +01:00
Rolf Bjarne Kvinge 2973b99f51 [mtouch tests] Add support for passing --nostrip to mtouch.
And use it to make tests run faster when we don't need to strip code.
2017-02-10 16:39:20 +01:00
Rolf Bjarne Kvinge d5ebc46391 [mtouch tests] Format output spew better to make it easier to parse by mere humans. 2017-02-10 16:39:20 +01:00
Rolf Bjarne Kvinge 2a21419197 [mtouch tests] Add code sharing test. 2017-02-10 16:39:19 +01:00
Rolf Bjarne Kvinge 62c08fd233 [mtouch tests] Allow creating temporary apps/extensions multiple times without re-creating temporary directories.
Allow creating temporary apps/extensions multiple times without re-creating temporary directories.

This makes it possible for tests to call CreateTemporaryApp|Extension multiple
times with different code, and have only the actual managed assembly change
between each time (which is useful for tests that verifies that cached builds
are used properly).
2017-02-10 16:39:19 +01:00
Rolf Bjarne Kvinge 2f8064a6e4 [mtouch tests] Check if plist has changed before writing it.
This is important for rebuild tests checking filestamps.
2017-02-10 16:39:19 +01:00
Rolf Bjarne Kvinge a1a141b4ca [mtouch tests] Use a different default app name for service extensions.
Otherwise it might end up clashing with the main app's name, preventing code sharing.
2017-02-10 16:39:18 +01:00
Rolf Bjarne Kvinge 18a6bf4690 [mtouch tests] Store app extensions as MTouchTool instances. 2017-02-10 16:39:18 +01:00
Rolf Bjarne Kvinge 27289efb1a [mtouch] Fix bundling frameworks from extensions.
We must build each appex bundle before the container bundle, so that we can
compute the frameworks each appex the needs before bundling the container app.

Also there's no need to store the list of frameworks appex's need in a file,
since everything is now done in the same mtouch process.
2017-02-10 16:39:17 +01:00
Rolf Bjarne Kvinge 7e28df59c4 [mtouch] Implement support for sharing code between app extensions and container apps.
Implement support for sharing both code and resources between app extensions
and their container app:

* AOT-compiled code. Each shared assembly is only AOT-compiled once, and if
  the assembly is built to a framework or dynamic library, it will also only
  be included once in the final app (as a framework or dynamic library in the
  container app, referenced directly by the app extension). If the assemblies
  are built to static objects there won't be any size improvements in the app,
  but the build will be much faster, because the assemblies will only be AOT-
  compiled once.
* Any resources related to managed assemblies (debug files, config files,
  satellite assemblies) will be put in the container app only.

Since these improvements are significant, code sharing will be enabled by
default.

Test results
============

For an extreme test project with 7 extensions (embedded-frameworks)[1]:

             with code sharing     cycle 9     difference
build time      1m 47s               3m 33s        -1m 46s = ~50% faster
app size         26 MB               131 MB       -105 MB  = ~80% smaller

For a more normal test project (MyTabbedApplication)[2] - this is a simple application with 1 extension:

             with code sharing     cycle 9     difference
build time      0m 44s               0m 48s        -4s    = ~ 8% faster
app size         23 MB                37 MB        -15 MB = ~40% smaller

Another tvOS app with one extension also show similar gains (MyTVApp)[3]:

             with code sharing     cycle 9     difference
build time      0m 22s               0m 48s        -26s    = ~54% faster
app size         22 MB                62 MB        -40 MB  = ~65% smaller

[1]: https://github.com/rolfbjarne/embedded-frameworks
[2]: https://github.com/xamarin/xamarin-macios/tree/cycle9/msbuild/tests/MyTabbedApplication
[3]: https://github.com/xamarin/xamarin-macios/tree/cycle9/msbuild/tests/MyTVApp
2017-02-10 16:39:15 +01:00
Rolf Bjarne Kvinge 85f28fbd59 [mtouch] Warn if mtouch loads an assembly from a different location than requested.
Warn if mtouch loads an assembly from a different location than requested
(which might be because there are multiple assemblies with the same name).

Also rework the MT0023 check a bit by explicitly loading the root assembly
first, and then detecting if any loaded assemblies matches the root assembly.
This results in code that's a bit more obvious, and it also works correctly
with extensions (previously the entire MT0023 check was skipped for
extensions).
2017-02-10 16:39:15 +01:00
Rolf Bjarne Kvinge a163cb2e14 [mtouch] Make the linker accept multiple root assemblies. 2017-02-10 16:39:14 +01:00
Rolf Bjarne Kvinge e4cf717b1d [mtouch] Simplify linker code slightly by passing fewer arguments around. 2017-02-10 16:39:14 +01:00
Rolf Bjarne Kvinge 8f80ba34af [mtouch] Refactor slightly how the profiler is linked in. 2017-02-10 16:39:14 +01:00
Rolf Bjarne Kvinge ffe3cfd39e [mtouch] Include the product assembly in the '@sdk' group for assembly build targets. 2017-02-10 16:39:13 +01:00
Rolf Bjarne Kvinge 7b5c1be2b7 [mtouch] Allow the assembly build target name for frameworks to end with '.framework'.
Allow the assembly build target name for frameworks to end with '.framework',
so that the following:

    --assembly-build-target=@sdk=framework=Xamarin.Sdk.framework

doesn't end up creating Xamarin.Sdk.framework.framework.
2017-02-10 16:39:13 +01:00
Rolf Bjarne Kvinge 3ea9fddc7b [runtime] Check in container app's root directory for assemblies.
If an extension is sharing code with the container app, then assemblies may be
placed in:

* The container app's Framework directory (for assemblies whose code is
  shared, and the build action is 'framework'). We already handle this case.
* The container app's root directory (for assemblies whose code is shared, and
  the build action is not 'framework'). This case we didn't handle, and we're
  now fixing it.
* In the extension (for assemblies whose code is not shared). We already
  handle this case.
2017-02-10 16:39:13 +01:00
Rolf Bjarne Kvinge 144285cd2f [src] Fix 'unused field' warning. 2017-02-10 16:39:13 +01:00
Rolf Bjarne Kvinge 29f28516b5 [tests] Don't concat environment variables, since this depends on each environment variable.
It looks like this was needed for changing PATH some time ago, but we don't
change PATH anymore for any test.
2017-02-10 16:39:12 +01:00
Rolf Bjarne Kvinge e67b9426c8 Document how code sharing between apps and app extensions work. 2017-02-10 16:39:12 +01:00
Rolf Bjarne Kvinge f82a995b21 [msbuild tests] Assemblies do not always end up in the .monotouch-[32|64] directory anymore, so update tests accordingly.
Assemblies will not end up in the .monotouch-[32|64] subdirectory anymore
(unless they must because they're different), which means that it's not easy
to detect if an assembly really ends up in the subdirectory or not.

So modify tests to accept assemblies in either the root bundle directory, or
in the .monotouch-[32|64] subdirectory.
2017-02-10 14:46:31 +01:00
Rolf Bjarne Kvinge e715ef9265 [link all tests] Improve a few tests' investigation skills when looking for assemblies.
Assemblies can now be in frameworks.

Assemblies can also be in container apps (in their root directory, as well as
in frameworks in the container app).

So use the simplest brute-force method to find assemblies: look everywhere.
2017-02-10 14:46:31 +01:00
Rolf Bjarne Kvinge f31fe09886 [link sdk tests] Determine chubbyness by actual observation.
Determine if an app is fat or not by inspecting the executable, instead of
guessing based on which directories are present (which has now changed).
2017-02-10 14:46:31 +01:00
Rolf Bjarne Kvinge 15438d3a79 [mtouch tests] We don't create symlinks for assemblies anymore, so update tests accordingly. 2017-02-10 14:46:30 +01:00
Rolf Bjarne Kvinge aa55661d3d [xharness] Add test cases for different assembly build targets. 2017-02-10 14:46:30 +01:00
Rolf Bjarne Kvinge 18f220956a [mtouch] Simplify code a little bit. 2017-02-10 14:46:30 +01:00
Rolf Bjarne Kvinge f399d464da [mtouch] Add support for creating a dot file of the build tree. 2017-02-10 14:46:30 +01:00
Rolf Bjarne Kvinge 1be313490d [mtouch] Store each assembly's location in the generated main method.
Store the location of every assembly that can't be deduced at runtime (i.e.
all assemblies that are build to frameworks, since there can be multiple
assemblies in each framework, and the framework name can be customized).
2017-02-10 14:46:30 +01:00
Rolf Bjarne Kvinge 8a6d7cd0dd [tests] Add test for bug #43689. 2017-02-10 14:46:29 +01:00
Rolf Bjarne Kvinge 617362b738 [mtouch] Detect when assemblies have native dependencies between them and link properly. Fixes bug #43689.
Detect when assemblies have native dependencies between them (which can happen
when there are multiple binding projects, and the native libraries in those
binding projects have dependencies between them), and add the proper link
arguments (this is only required when building to dynamic libraries or
frameworks, since otherwise everything is linked to one big binary and there
are no dependency problems).

https://bugzilla.xamarin.com/show_bug.cgi?id=43689
2017-02-10 14:46:29 +01:00
Rolf Bjarne Kvinge 96637b5e13 [mtouch] Remove dead code. 2017-02-10 14:46:29 +01:00
Rolf Bjarne Kvinge f9e3cbdf57 [mtouch] Incremental builds (--fastdev) is the same as compiling all assemblies to dynamic libraries. 2017-02-10 14:46:29 +01:00
Rolf Bjarne Kvinge 473c6092b6 [mtouch] Add support for compiling the pinvoke wrappers to a framework. 2017-02-10 14:46:29 +01:00
Rolf Bjarne Kvinge e620caefe2 [mtouch] Implement support for creating frameworks from assemblies.
Implement support for linking the output from AOT compilation to frameworks,
and then bundling those frameworks.
2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge 894ebebce0 [mtouch] Treat aot data as a file related to the assembly, and copy it at the same time. 2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge 422c389ce1 [mtouch] Remove dead code. 2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge d24a4e3b62 [mtouch] Rework how tasks are built.
The previous build system kept a forward-pointing single linked list of tasks
to execute: task X had a list of subsequent tasks to execute. If task X was
up-to-date, it was not created (and the next tasks were directly added to the
list of tasks to execute).

In this world it became complicated to merge output from tasks (for instance
if the output of task X and task Y should be a consumed by a single task
producing a single output, since the corresponding task would end up in both
X's and Y's list of subsequent tasks).

Example: creating a single framework from the aot-compiled output of multiple
assemblies.

So I've reversed the logic: now we keep track of the final output, and then
each task has a list of dependencies that must be built.

This makes it trivial to create merging tasks (for the previous example, there
could for instance be a CreateFrameworkTask, where its dependencies would be
all the corresponding AotTasks).

We also always create every task, and then each task decides when its executed
whether it should do anything or not. This makes it unnecessary to 'forward-
delete' files when creating tasks (say you have three tasks, A, B, C; B
depends on A, and C depends on B; if A's output isn't up-to-date, it has to
delete its own output if it exists, otherwise B would not detect that it would
have to re-execute, because at task *creation* time, B's input hadn't
changed).

Additionally make it based on async/await, since much of the work happens in
externel processes (and we don't need to spin up additional threads just to
run external processes). This makes us have less code run on background
threads, which makes any issues with thread-safety less likely.
2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge 0ac6b4fc15 [mtouch] Refactor 'BuildApp' into multiple methods. 2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge ee0de7de52 [mtouch] Use BuildTask's logic to check if the task needs to be updated. 2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge da0a7ffdd3 [mtouch] Make sure output directory exists. 2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge dc70a0e254 [mtouch] Rename parameter to be more descriptive. 2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge c2ad1ac499 [mtouch] Don't pass '-read_only_relocs suppress' to the native linker when compiling to asm-only bitcode either.
It fails to link.
2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge 6e2648e125 [mtouch] Make sure CompilerFlags always have a Target. 2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge 2f380ae509 [mtouch] Remove unused field. 2017-02-10 14:46:26 +01:00
Rolf Bjarne Kvinge 038705eb25 [mtouch] Use BuildTask's logic to check if the task needs to be updated. 2017-02-10 14:46:26 +01:00
Rolf Bjarne Kvinge 04a6f585c5 [mtouch] Make the install_name logic a bit more flexible. 2017-02-10 14:46:26 +01:00
Rolf Bjarne Kvinge a52f18ec3b [mtouch] Give BuildTasks enough information to determine if the task is up-to-date or not. 2017-02-10 14:46:26 +01:00