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

647 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 827591eccc
[tools] Extract the code to parse, validate and process exception marshalling arguments into the Application class. (#9492)
So that it's easier to re-use it from our .NET linker code.
2020-08-25 19:55:50 +02:00
Rolf Bjarne Kvinge b4da54ea6d Merge remote-tracking branch 'origin/main' into dotnet-partial-static-registrar 2020-08-24 17:56:42 +02:00
Rolf Bjarne Kvinge d7ab847697
[dotnet] Implement support for our different link modes. (#9460)
* [mmp] Rename LinkMode.All to LinkMode.Full.

So that we can continue to use Enum.Parse<LinkMode> to parse 'Full' as the link mode.

* [dotnet] Implement support for our different link modes.

Tell the managed linker what to do with each input assembly depending the selected
link mode (link all, link sdk, don't link).
2020-08-24 17:50:42 +02:00
Rolf Bjarne Kvinge 1f326e82bb [dotnet-linker] Rework Application creation to happen earlier.
Refactor Application creation to happen earlier, and to split out the cache
creation. This way we can create the Application instance before processing
the configuration, and as we process any configuration we can set properties
on the Application instance.
2020-08-21 10:32:56 +02:00
Rolf Bjarne Kvinge fef20f4984 [mtouch] Move the AssemblyBuildTarget enum to shared code 2020-08-21 10:32:56 +02:00
Rolf Bjarne Kvinge f43316114e [mmp] Add a few guards for code that shouldn't be executed under .NET. 2020-08-21 10:32:55 +02:00
Rolf Bjarne Kvinge 43fecd6f54 [mtouch/mmp] Improve lookup of System.Void.
If we can't find the mscorlib assembly in the list of loaded assemblies, try to load
it explicitly. If we still can't find it the mscorlib assembly, look for System.Void
in any assembly. This shouldn't be a performance bottleneck, because we cache the
System.Void type, which means the lookup is only done once.

This makes System.Void lookup work when building with .NET as well, since there's
no mscorlib.dll there.

This is required when running mtouch and mmp to generate the partial static registrar
code for .NET.
2020-08-21 10:32:55 +02:00
Rolf Bjarne Kvinge 558af9612a [dotnet] Add support for consuming binding projects. (#9376)
* Port the interdependent-binding-projects test to .NET (it's the simplest
  test project we have with binding projects).
* Add a lot of the shared source code for mtouch/mmp to dotnet-linker, and
  make it compile. Most issues were fixed by adding a few stubbed out classes,
  since there are large chunks of the mtouch/mmp code we're not using yet, so
  stubbing out while things are being implemented works fine.
* Add a step in dotnet-linker for loading the linker output (the linked
  assemblies) into our bundler code.
* Add another step in dotnet-linker to extract native resources from binding
  libraries.
* Augment the build process to take into account the native resources we found
  in any binding libraries.
2020-08-20 08:35:12 +02:00
Rolf Bjarne Kvinge d577bf7446
[mtouch] Don't validate the --target-framework argument if we're just calling mlaunch. (#9374)
This fixes an issue where mtouch would complain about a missing --target-framework argument when it's not actually needed:

    /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch  --launchsim bin/iPhoneSimulator/Release/MyApp.app [...]
  	error MT0086: A target framework (--target-framework) must be specified.

what makes this worse is that passing --target-framework to mtouch makes
mlaunch fail, because mlaunch doesn't accept a --target-framework argument.
2020-08-17 08:37:29 +02:00
Rolf Bjarne Kvinge 6f1b1c62bb [mtouch/mmp] Make it possible to compute assembly identity even if an assembly doesn't have a filename.
In .NET AssemblyDefinitions don't have MainModule.FileName set, because they're not
loaded using FileStreams.

Ref: https://github.com/mono/linker/issues/1313
2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge e83dd1071b [bundlers] Refactor code to cope with not knowing whether a particular assembly is a framework assembly or not.
Turns out we don't actually _need_ to know, in every case we use this knowledge it's
a performance improvement to not process the framework assemblies, so skip this for
now, since there's no harm done (except to the planet) to do some extra processing
by processing all assemblies in these cases.
2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge ebfc7e131c [mtouch/mmp] Simplify some code to add assemblies to a target. 2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge 17aabebb03 [dotnet-linker] Add a using so that the static registrar sees LinkContext extension methods in the Mono.Linker namespace 2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge 693f9423eb [dotnet-linker] Exclude Driver.Main from the build
The .NET linker code is a library, so it doesn't need a Main method.
2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge bb6e8d3f1b [dotnet-linker] Create compat API to make DerivedLinkContext compile. 2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge f6cf39c72b [dotnet-linker] Add a DotNetResolver.
This is just a stub to make code compile, it's not needed at runtime.
2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge c4186268b9 [dotnet-linker] Adjust ifdefs to make existing/shared code compile correctly. 2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge 08961a655b [dotnet-linker] Make Application take the input arguments, so that we can pass them to the cache to correctly determine cache validity. 2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge 33ecd581ac
[mtouch/mmp] Move Application.BuildTarget, Application.IsDeviceBuild and Application.IsSimulatorBuild to shared code. (#9363)
Also add a 'None' build target for the BuildTarget enum for when we're
building for neither simulator nor device (i.e. macOS). This means the default
value will change (since 'Simulator' is no longer the first value), but as far
as I can tell we're always assigning a specific value and not relying on the
default, so this should not make any difference.

This will be needed when the .NET code starts using these classes.
2020-08-13 15:33:13 +02:00
Rolf Bjarne Kvinge 0601d17507
[mtouch] Move Driver.IsFrameworkAvailableInSimulator to shared Application code. (#9365)
This will be needed when the .NET code starts using these classes.
2020-08-13 15:27:57 +02:00
Rolf Bjarne Kvinge b1e5a3faf8
[mtouch/mmp] Move a few Application.Is* properties to shared code. (#9364)
This will be needed when the .NET code starts using these classes.
2020-08-13 15:27:13 +02:00
Rolf Bjarne Kvinge 82c6b03d0c
[mtouch/mmp] Add CoreFoundation and GSS to our list of known frameworks. (#9338)
* [mtouch/mmp] Add CoreFoundation and GSS to our list of known frameworks.

Putting these frameworks in our known list of frameworks means we won't try to
weak link them unless needed (when the deployment target is earlier than when
they were introduced), because if we encounter a framework we don't know
about, we'll weak link them to be on the safe side.

* GSS was available in at least macOS 10.1
2020-08-11 10:37:35 +02:00
Rolf Bjarne Kvinge 855c2b09fc
[mtouch] Fix the MT0091 (now called MT0180) after recent code changes. Fixes xamarin/maccore@2280. (#9342)
Also fix a confusion between the M?0179 and M?0180 error message vs error number.

Fixes https://github.com/xamarin/maccore/issues/2280.
2020-08-10 15:49:50 -04:00
Rolf Bjarne Kvinge 2ab8d3f4f8
[mtouch/mmp] Move Application.RequiresXcodeHeaders to shared code. (#9321) 2020-08-10 17:39:33 +02:00
Rolf Bjarne Kvinge 916e79b8d2
[mtouch/mmp] Move Driver's LOCAL_BUILD_DIR and FRAMEWORK_LOCATION_VARIABLE constants to Application instance fields. (#9320) 2020-08-10 10:47:35 +02:00
Rolf Bjarne Kvinge d8665ddd63
[mtouch/mmp] Remove the Error91LinkerSuggestion and implement it using two different error codes. (#9319)
* It makes the error message localizable.
* It makes the implementation shared between mtouch and mmp.
2020-08-10 10:41:25 +02:00
Rolf Bjarne Kvinge 44b2f00b39
[mtouch/mmp] Share Assembly.CopyAssembly. (#9310)
The shared version isn't used by mmp yet as far as I can tell (mmp has its own logic
to copy assemblies), but sharing this code is the first step towards having the same
implementation as well.
2020-08-07 08:24:09 +02:00
Rolf Bjarne Kvinge ccca0cd2c7
[mtouch/mmp] Move Target.Is32Build and Target.Is64Build to shared code. (#9306)
We'll need the iOS implementation for .NET, so use that everywhere.
2020-08-07 08:11:52 +02:00
Rolf Bjarne Kvinge 264fa44f6f
[mtouch/mmp] Move the Driver.PRODUCT constant to an Application.ProductName instance field. (#9280)
A few changes are required to have an Application instance at hand when we need to
get the ProductName from it.

This is necessary for .NET, since there will be a single linker library for all platforms,
which means we can't use a constant.
2020-08-06 16:10:06 +02:00
Rolf Bjarne Kvinge 9f06e4964d
[mtouch/mmp] Share the min Xcode version. (#9279) 2020-08-06 11:11:10 +02:00
Rolf Bjarne Kvinge e03fc9d72a
[mtouch/mmp] Share a few P/Invokes. (#9278)
This is just moving code, no functional changes.
2020-08-06 11:01:06 +02:00
Rolf Bjarne Kvinge 21ee5a7f74
[mtouch] Don't try to copy invalid symbol files. (#9262)
This solves a rebuild problem if an assembly has an invalid or unsupported symbol
file, where we'd detect that the symbol file exists, and expect it to be copied,
but then the linker would drop it, causing us to always rebuild the app (this is
not the same as when a symbol file is out of date).

This happens for NUnitLite 3.12.0's nunit.framework.dll, which ships with an old-style
pdb.

Also add a warning that is shown when we detect that there's a symbol file, but it
couldn't be loaded for some reason.
2020-08-04 08:08:44 +02:00
Rolf Bjarne Kvinge 5d5a47b990 [tools] Don't link with a framework that isn't available in the simulator. 2020-07-03 11:14:03 +02:00
Rolf Bjarne Kvinge 5cfbd9fd4d [dotnet-linker] Add a GatherFrameworksStep and use the output when linking the native executable.
Add a GatherFrameworksStep that computes the frameworks an app needs, and
returns the result to the MSBuild tasks.

Then we use that list of frameworks to link the native executable correctly.
2020-06-30 19:01:07 +02:00
Rolf Bjarne Kvinge 6f0ed03515 [dotnet-linker] Make an Application instance available from the linker configuration, and add more properties to the compat Application type.
This way it's easier to reuse existing mtouch/mmp code that need an Application instance.
2020-06-30 19:01:07 +02:00
Rolf Bjarne Kvinge c3bcfac582
Unify code for executing processes. (#8848)
* Create a simple Xamarin.Utils.Execution class that can handle all our
  process execution needs:
    * Captures or streams stdout/stderr (in UTF8).
    * Supports async
    * Supports a timeout
    * Does not depend on any other source file we have, only uses BCL API.
* Have the execution helper classes from mtouch/mmp
  (Xamarin.BundlerDriver.RunCommand) and the tests
  (Xamarin.Tests.ExecutionHelper) use this new class.
* Some simplifications were made:
    * All API that took a string array for the environment now takes a
      Dictionary<string, string>.
    * The Driver.RunCommand methods were split out to a separate file. This
      file also contains a Verbosity field, which is conditioned on not being
      in mtouch nor mmp, which makes including this file from other projects
      simpler (such as bgen - in particular bgen was modified to use this
      Verbosity field instead of its own).
2020-06-18 12:34:07 +02:00
Rolf Bjarne Kvinge 374f2cf293
[tools] Fix printing failed command to print the actual arguments instead of the list itself. (#8749)
Fixes this:

    Process exited with code 1, command:
    /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tools/xibuild/xibuild System.Collections.Generic.List`1[System.String]
2020-06-04 16:40:37 +02:00
Rolf Bjarne Kvinge cb637a08a0
Merge pull request #8733 from rolfbjarne/dotnet-linker
[dotnet] Add dotnet-linker, a project to contain custom linker steps for our net5.0 build.
2020-06-03 09:11:15 +02:00
Rolf Bjarne Kvinge 3ecac56e8b
[mtouch/mmp] Add CFNetwork to our list of frameworks for iOS and macOS. (#8723)
It's already in the list for tvOS and watchOS.
2020-06-02 16:17:51 +02:00
Rolf Bjarne Kvinge 52686eab6a [tools] Add support for generating a csproj dependency file for net5.0 projects.
* Add support for using dotnet instead of msbuild to build the target project.
* cd into the target project's directory before building it, because there may
  be a global.json file there which must be taken into account.
2020-06-02 15:50:35 +02:00
Rolf Bjarne Kvinge 392200d930
[mtouch/mmp] Share numerous command-line arguments. (#8599)
* [mtouch/mmp] Share Application.IsDualBuild, Is32Build and Is64Build.

* [mtouch/mmp] Share --tls-provider and --http-message-handler.

* [mtouch/mmp] Share --force.

* [mtouch/mmp] Share --cache.

* [mtouch/mmp] Share --nolink, --linksdkonly, --linkplatform and --linkskip.

* [mtouch/mmp] Share --i18n.

* [mtouch/mmp] Share --xml.

* [mtouch/mmp] Share --registrar and --runregistrar.

* [mtouch/mmp] Share --warn-on-type-ref.

* [mtouch/mmp] Share --sdk.

* [mtouch/mmp] Share --debug.

* [mtouch/mmp] Share --reference, and deprecate -r|--ref and -a|--assembly.

* [mtouch/mmp] Share --targetver, and deprecate mmp's --minos.

* [msbuild] Adjust tests after switching to use --reference instead of -r.

* Update according to review.

* [mmp] Remove --registrar:il.

The IL generator was what MonoMac had before the dynamic/static registrar code
got shared between MonoTouch and MonoMac. The IL registrar been gone for
years, and as far as I know nobody ever used --registrar:il, even though it
was provided as a compatibility option in the beginning (we still had the IL
registrar around for a while after adding the static+dynamic registrars, until
it was completely replaced by the dynamic registrar).

So just remove this option, if anyone ever used it they can replace it with
--registrar:dynamic.

* [mtouch/mmp] Keep bundler-specific code in its corresponding file.
2020-05-19 15:30:38 +02:00
Rolf Bjarne Kvinge 76fc9dc3bf
Improve our error handling code. (#8591)
* Move much of ErrorHandler.cs into a partial class in ErrorHandler.tools.cs,
  which is referenced by mtouch and mmp (but not our runtime).
* Add ErrorHandler.runtime.cs for runtime-specific bits, including a simpler
  version of ErrorHandler.Show. In particular this gets rid of the call to
  Environment.Exit, which should never happen at runtime.
* Rename MonoTouchException and MonoMacException to ProductException, which
  allows us to remove a lot of ifdefs.
* This required moving Application.LoadSymbols and Target.LoadSymbols to
  shared mtouch/mmp code.
2020-05-14 16:45:05 +02:00
Rolf Bjarne Kvinge 3e1862ada9
[mtouch/mmp] Make --setenv available to mmp as well. (#8572)
The actual implementation will be added in a later PR, when the code to
generate main is unified between mtouch and mmp.
2020-05-13 08:50:20 +02:00
Rolf Bjarne Kvinge a4910bb0fa
[mtouch/mmp] Share --package-debug-symbols. (#8574) 2020-05-13 08:40:07 +02:00
Rolf Bjarne Kvinge 3ce9ac43d8
[mtouch/mmp] Share the mono native code. (#8564)
Also move the mono native code to the Application class from the Target
class, since it's per-Application, not per-Target.
2020-05-12 12:10:50 +02:00
Rolf Bjarne Kvinge 5193dfbf9a
[mtouch/mmp] Share --debugtrack code. (#8565) 2020-05-12 09:20:53 +02:00
Rolf Bjarne Kvinge 3d2981c130
[mtouch/mmp] Share Application.MonoGCParams. (#8566) 2020-05-12 09:20:20 +02:00
Rolf Bjarne Kvinge ea25433d75
[mtouch/mmp] Share EnableProfiling. (#8563) 2020-05-11 16:42:21 +02:00
Rolf Bjarne Kvinge b18466f7f2
[mtouch/mmp] Share Abi code. (#8562) 2020-05-11 16:27:19 +02:00
Rolf Bjarne Kvinge 44653d7553
[mtouch/mmp] Share the RegistrarMode enum. (#8553) 2020-05-11 08:57:41 +02:00