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

65 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge b7d3e54f26 [mtouch] Don't pass -fembed-bitcode[-marker] to the compiler on later Xcode versions. 2024-07-09 10:22:36 +02:00
Steve Hawley a36cd71174
[dotnet] Integrate class handle rewriting into static registrar process. (#18456)
Integrate class handle rewriting into static registrar.
2023-06-23 10:12:35 -04:00
Rolf Bjarne Kvinge 36af029204
Change all null checking expressions to use 'is' and 'is not'. (#18176)
Change all null checking expressions to use 'is null' and 'is not null'
instead of '== null' and '!= null'.

This was mostly done with sed, so code can probably be improved in many
other ways with manual inspection, but that will come over time.

Also add code to the autoformat script to automatically fix these issues in the future.
2023-05-05 17:52:19 +02:00
Steve Hawley 2ec000df27
[dotnet] Use the type_map_path arg (#18175)
Removed the default argument value
Added `Application.ClassMapPath`
Added options and setter for `ClassMapPath`
Integrated usage.
2023-05-01 14:48:09 -04:00
Rolf Bjarne Kvinge 1296e35205
[registrar] Deduplicate the code to compute the initialization method name for the generated static registrar code. (#16649)
This is a step towards having a registration map (and initialization method) for each assembly.

Ref: https://github.com/xamarin/xamarin-macios/issues/11309

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-11-10 08:56:37 +01:00
Rolf Bjarne Kvinge 2d9f9c3d1f
[autoformat] Add mtouch.csproj. (#16316)
This also required modifying mtouch.csproj, otherwise the wrong settings would
be applied.
2022-10-13 10:42:41 +02:00
VS MobileTools Engineering Service 2 abae256b40
[main] [mtouch] Automatically disable bitcode if using Xcode 14+. Fixes #15210. (#16054)
Apple has deprecated bitcode, and will apparently reject app submissions
containing bitcode starting with Xcode 14. So automatically disable bitcode if
building using Xcode 14+ (and show a warning so that app developers can remove
the 'MtouchEnableBitcode' property from their project files).

Fixes https://github.com/xamarin/xamarin-macios/issues/15210.

Backport of #15804

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-09-22 07:32:33 +02:00
Rolf Bjarne Kvinge a94e575806
[tools] Unify Application.link_flags and Application.gcc_flags from mtouch and mmp into Application.CustomLinkFlags. (#13509)
* [tools] Unify Application.link_flags and Application.gcc_flags from mtouch and mmp into Application.CustomLinkFlags.

* [tests] Update mtouch tests according to mtouch changes.
2021-12-09 17:16:45 +01:00
Rolf Bjarne Kvinge 2972e1b715
Fix some whitespace issues in various files. (#12399)
* Remove BOM
* Add EOL at end of file.
2021-08-11 10:06:46 +02:00
Rolf Bjarne Kvinge ff57778c38 [mtouch] Use the correct native compiler/linker flags for catalyst apps 2020-12-03 10:42:26 +01:00
Rolf Bjarne Kvinge d039a8ecd3 [tools] Create a Target.GenerateMain function that wraps the iOS/macOS variants and avoids duplicating some code. 2020-10-23 11:46:09 +02:00
Rolf Bjarne Kvinge 6240e848f3 [mtouch] Move mtouch's GenerateMain to shared Target code.
This means moving a lot of supporting code to shared code as well.
2020-10-23 11:46:09 +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 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 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 e4f8460277
[mmp/mtouch] Share more code. (#8394)
* Rearrange files in Xamarin.Mac a bit to ease code sharing between mmp and
  mtouch, by putting mono's static and dynamic libraries in
  /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Sdks/Xamarin.macOS.sdk
  to match how Xamarin.iOS does it.

* Don't use 'usr' as an intermediate directory. This removes another special
  case.

* Share many of the functions and properties that return specific directories,
  and document (as comments) what each function/property is supposed to
  return.
2020-04-16 14:19:45 +02:00
Rolf Bjarne Kvinge 8feb3c29e6
[mtouch] Handle a failure to launch the native linker better by showing better error messages. (#8391)
* [mtouch] Handle a failure to launch the native linker better by showing better error messages.

dotnet will throw a Win32Exception if the command line is too long, so handle
that scenario. Also handle any other Win32Exceptions and show a better error
message.

* Make MT5217 an error to avoid multiple potentially confusing errors.
2020-04-16 14:18:43 +02:00
Waleed Chaudhry 00985a55e2
[Localization] mtouch/mmp C# (#7710) 2020-01-31 15:02:52 -05:00
Rolf Bjarne Kvinge a8fdf6db6e
Implement a different escaping/quoting algorithm for arguments to System.Diagnostics.Process. (#7177)
* Implement a different escaping/quoting algorithm for arguments to System.Diagnostics.Process.

mono changed how quotes should be escaped when passed to
System.Diagnostic.Process, so we need to change accordingly.

The main difference is that single quotes don't have to be escaped anymore.

This solves problems like this:

    System.ComponentModel.Win32Exception : ApplicationName='nuget', CommandLine='restore '/Users/vsts/agent/2.158.0/work/1/s/tests/sampletester/bin/Debug/repositories/ios-samples/WorkingWithTables/Part 3 - Customizing a Table\'s appearance/3 - CellCustomTable/CellCustomTable.sln' -Verbosity detailed -SolutionDir '/Users/vsts/agent/2.158.0/work/1/s/tests/sampletester/bin/Debug/repositories/ios-samples/WorkingWithTables/Part 3 - Customizing a Table\'s appearance/3 - CellCustomTable'', CurrentDirectory='/Users/vsts/agent/2.158.0/work/1/s/tests/sampletester/bin/Debug/repositories', Native error= Cannot find the specified file
      at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0029f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/System/System.Diagnostics/Process.cs:778

ref: https://github.com/mono/mono/pull/15047

* Rework process arguments to pass arrays/lists around instead of quoted strings.

And then only convert to a string at the very end when we create the Process
instance.

In the future there will be a ProcessStartInfo.ArgumentList property we can
use to give the original array/list of arguments directly to the BCL so that
we can avoid quoting at all. These changes gets us almost all the way there
already (except that the ArgumentList property isn't available quite yet).

We also have to bump to target framework version v4.7.2 from v4.5 in several
places because of 'Array.Empty<T> ()' which is now used in more places.

* Parse linker flags from LinkWith attributes.

* [sampletester] Bump to v4.7.2 for Array.Empty<T> ().

* Fix typo.

* Rename GetVerbosity -> AddVerbosity.

* Remove unnecessary string interpolation.

* Remove unused variable.

* [mtouch] Simplify code a bit.

* Use implicitly typed arrays.
2019-10-14 16:18:46 +02:00
Bernhard Urban 26ec2826aa ARM64_32 Debug Mode (#7012)
* [builds] add arm64_32 cross compiler

* [mtouch] force --interpreter on arm64_32 debug mode build

* [mtouch] include debug check for arm64_32 and reflect error codes in documentation
2019-09-24 17:24:49 +02:00
Rolf Bjarne Kvinge 0b4fc12f32 [tests] Fix several issues that show up in the mtouch and introspection tests on macOS 10.15. (#6929)
* [introspection] Fix several issues that show up on macOS 10.15.

* [tests][mtouch] Fix a few tests according to recent changes.
2019-09-06 20:57:40 -04:00
Rolf Bjarne Kvinge ec09193daf
Build native code with -std=c++14. (#6864)
* Build native code with -std=c++14.

Apple's headers now require -std=c++14 to compile their headers in C++ mode.

This fixes a compile error that would occur with the PhotosUI framework when
compiling code for C++.

* [mmp] Use -std=c++14 when compiling.

* Fix command line output.

* [mmp] Add all source files at the end, so they all get the -x clang argument applied.

* Limit when using c++14 in mtouch according to language.
2019-08-29 08:49:06 -07:00
Rolf Bjarne Kvinge b8e9c83ce0
[mtouch] Detect when we run into the 32-bit arm size limitation, and report a better error. Fixes #6526. (#6855)
Also limit the output from the native compiler, so that we don't overload the
IDEs with output if the native compiler produces tens of thousands of errors.

Fixes https://github.com/xamarin/xamarin-macios/issues/6526.
2019-08-28 04:54:26 -07:00
monojenkins 2d8396d0a0 [mtouch/mmp] Make the mono native mode a Target-specific variable. (#6037)
The arm64_32 slice for watchOS apps will always use the 'unified' mode, while
the armv7k can be both 'unified' and 'compat' depending on the deployment
target, so we need to keep track of this per Target.

This PR does not change anything related to arm64_32, that will come in a
later PR.
2019-05-10 15:40:17 +02:00
Rolf Bjarne Kvinge 2ff07b6f3a
[mtouch] Don't use the native linker to create fat executables. (#5629)
* [mtouch] Don't use the native linker to create fat executables.

Don't use the native linker to create fat executables, instead link each
architecture separately, and then manually lipo everything together at the
end. This requires a few changes since we need to keep track of the linker
flags per architecture.

The problem is that bitcode files (.bc) do not correspond with a particular
architecture, so the linker can't distinguish between .bc files for armv7k and
.bc files for arm64_32. So if we pass all together to the linker, the linker
will add all .bc files to both architectures, thus duplicating everything (and
the linking fails with duplicate symbols errors).

* [mtouch] Fix building symlinked simulator executables.

* [mtouch] Fix several assumptions about each Target only producing a single executable.
2019-02-21 14:39:02 +01:00
Rolf Bjarne Kvinge 2bc18499b5
[mtouch] Quote MONO_PATH if needed in debug spew. (#5607)
Makes c&p commands easier.
2019-02-14 16:33:18 +01:00
Chris Hamons 3119129ab7 Remove references to bugzilla and replace with github (#4920)
https://github.com/xamarin/xamarin-macios/issues/3647
2018-10-04 09:43:55 -04:00
Rolf Bjarne Kvinge 7f966cfc74
[mtouch] Don't pass -read_only_relocs to clang when compiling 64-bit code. Fixes #4735. (#4809)
Fixes this ld warning:

    ld : warning : -read_only_relocs cannot be used with arm64

Fixes https://github.com/xamarin/xamarin-macios/issues/4735.
2018-09-14 07:35:53 +02:00
Sebastien Pouliot 4509e66168
[mtouch] Fix Xamarin.Sdk not to link with private frameworks. Fixes #61039 (#3118)
We can't trust Apple's native linker to pick the right (non private)
framework when an older TargetVersion is used. It just prefer what's
available - even if specified with a WeakFramework :(

That was already dealt with for applications. However the native linking
of the Xamarin.Sdk.framework (code sharing with extensions) is done with
the `LinkTask` instead of the `NativeLinkTask` so it did not have the
"auto correct" code.

Unit test added.

reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=61039
2017-12-22 10:28:29 -05:00
Sebastien Pouliot 05eb96d0a7 Merge branch 'xcode9' into xcode9-master-merge 2017-09-15 11:05:30 -04:00
Sebastien Pouliot a74174eb65 [iosurface] IOSurface is not usable before iOS/tvOS 11. Fixes #59201 (#2706)
Apple rejects apps that links with the previously private IOSurface.framework.
We were not sure about this [1] and had it disabled (this is removed).

However another bug stopped our adjustment logic [2] from being executed. This
is needed since `clang` picks up the private framework if it does not find the
public one (even when asking for a weak framework),

[1] https://bugzilla.xamarin.com/show_bug.cgi?id=59201
[2] Added a while ago for JavascriptCore
2017-09-14 23:34:55 -04:00
Timothy Risi 25468bf617 Merge Quote methods into a single class instead of multiple versions (#2153) 2017-06-06 12:32:25 -08:00
Rolf Bjarne Kvinge d17cb6556a [mtouch] Improve how we make sure native symbols aren't stripped away. Fixes #51710 and #54417. (#2162)
* [mtouch] Improve how we make sure native symbols aren't stripped away. Fixes #51710 and #54417.

* Refactor required symbol collection to store more information about each
  symbol (field, function, Objective-C class), and in general make the code
  more straight forward.
* Implement support for generating source code that references these symbols,
  and do this whenever we can't ask the native linker to keep these symbols
  (when using bitcode). Additionally make it possible to do this manually, so
  that the source code can be generated for non-bitcode platforms too (which
  is useful if the number of symbols is enormous, in which case we might
  surpass the maximum command-line length).
* Also make it possible to completely ignore native symbols, or ignore them on
  a per-symbol basis. This provides a fallback for users if we get something
  right and we try to preserve something that shouldn't be preserved (for
  instance if it doesn't exist), and the user ends up with unfixable linker
  errors.
* Don't collect Objective-C classes unless they're in an assembly with
  LinkWith attributes. We don't need to preserve Objective-C classes in any
  other circumstances.
* Implement everything for both Xamarin.iOS and Xamarin.Mac, and share the
  code between them.
* Remove previous workaround for bug #51710, since it's no longer needed.
* Add tests.

https://bugzilla.xamarin.com/show_bug.cgi?id=54417
https://bugzilla.xamarin.com/show_bug.cgi?id=51710

* [mtouch] Make sure to only keep symbols from the current app when code sharing.

This fixes a build problem with the interdependent-binding-projects test when
testing in Today Extension mode.
2017-06-02 18:29:19 +02:00
Rolf Bjarne Kvinge 294668fa54 [mtouch] Fix compiling assemblies to frameworks on watchOS. (#2038)
* [runtime] Fix Xamarin-debug.framework's install name.

This makes building to frameworks work in debug mode.

* [mtouch] Fix check to add frameworks to watchKit extensions.

* [mtouch] Never pass -read_only_relocs to the native linker when bitcode is enabled.

* [mtouch] Bitcode requires linking with c++.

This particular case applies to shared libraries/frameworks (we already link
with c++ when building statically).
2017-04-25 17:39:58 +02:00
Sebastien Pouliot d9fc5cf837 [mtouch] Update code that only considered .mdb (not .pdb) (#2003)
Also stop using `mdb` as the name for debug symbols and remove

> static MdbReader mdb_reader;

since we're not mkbundl'ing mtouch anymore.

Related to https://github.com/xamarin/xamarin-macios/pull/2002 for mmp
2017-04-17 12:48:35 +02:00
Rolf Bjarne Kvinge 6e90f92773 [mtouch] Rename a few variables to make them clearer. 2017-02-17 10:20:30 +01:00
Rolf Bjarne Kvinge 8f91bb163e [mtouch] Re-AOT an assembly if its .mdb or .config files changed. 2017-02-10 16:39:25 +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 96637b5e13 [mtouch] Remove dead code. 2017-02-10 14:46:29 +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 da0a7ffdd3 [mtouch] Make sure output directory exists. 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 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
Rolf Bjarne Kvinge 1f7ce2e445 [mtouch] Fix the error message for 'CompileTask'.
The AOT-compilation occurs in the AOT-task now, and then we compile the result
using CompileTask.

This means that the error message in CompileTask was slightly incorrect, so
rectify it.
2017-02-10 14:46:25 +01:00
Rolf Bjarne Kvinge fea1fc6447 [mtouch] Teach about source files to CompilerFlags. 2017-02-10 14:46:25 +01:00
Rolf Bjarne Kvinge 024d5a92ca [mtouch] Add target-specific error messages.
This removes a little bit of duplicated code, and gives us slightly better error messages.
2017-02-10 14:46:25 +01:00
Rolf Bjarne Kvinge 9e7cec490f [mtouch] Move native linking to a separate task. 2017-02-10 14:42:11 +01:00