Commit graph

85 commits

Author SHA1 Message Date
Ignacio Etcheverry ced77b1e9b C#: Switch games to MSBuild Sdks and .NET Standard
Godot.NET.Sdk
-------------

Godot uses its own custom MSBuild Sdk for game
projects. This new Sdk adds its own functionality
on top of 'Microsoft.NET.Sdk'.

The new Sdk is resolved from the NuGet package.

All the default boilerplate was moved from game
projects to the Sdk. The default csproj for
game project can now be as simple as:

```
<Project Sdk="Godot.NET.Sdk/4.0.0-dev2">
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
  </PropertyGroup>
</Project>
```

Source files are included by automatically so
Godot no longer needs to keep the csproj in sync
when creating new source files.

Define constants
----------------

Godot defines a list of constants for conditional
compilation. When exporting games, this list also
included engine 'features' and platform 'bits'.
There were a few problems with that:

- The 'features' constants were only defined when
  exporting games. Not when building the game for
  running in the editor player.
- If the project was built externally by an IDE,
  the constants wouldn't be defined at all.

The new Sdk assigns default values to these
constants when not built from the Godot editor,
i.e.: when built from an IDE or from the command
line. The default define constants are determined
from the system MSBuild is running on.

However, it's not possible for MSBuild to
determine the set of supported engine features.
It's also not possible to determine if a project
is being built to run on a 32-bit or 64-bit
Godot executable.

As such the 'features' and 'bits' constants had
to be removed.
The benefit of checking those at compile time
was questionable, and they can still be checked
at runtime.

The new list of define constants includes:

- GODOT
- GODOT_<PLATFORM>
  Defaults to the platform MSBuild is running on.
- GODOT_<PC/MOBILE/WEB>
- TOOLS
  When building with the 'Debug' configuration
  (editor and editor player).
- GODOT_REAL_T_IS_DOUBLE
  Not defined by default unless $(GodotRealTIsDouble)
  is overriden to be 'true'.

.NET Standard
-------------

The target framework of game projects was changed
to 'netstandard2.1'.
2020-07-25 19:22:01 +02:00
Ignacio Etcheverry 4a30289eee C#: Fix restore not called when building game projects 2020-07-22 14:28:47 +02:00
G'lek a5abacd1e7
Change assembly watcher after notification changes
Fixed Mono not building after #39986 was merged due to a constant that got renamed.
2020-06-30 17:41:38 -04:00
Rémi Verschelde 87d2397273
Merge pull request #39837 from neikeq/fix-invalid-unbox-long-as-int
Mono/C#: Fix InvalidCast because of attempt to unbox long as int
2020-06-26 07:56:42 +02:00
Ignacio Etcheverry 4b0c78b3ca Mono/C#: Use /restore instead of /t:restore when building
Documentation recommends not to use /t:restore
together with other targets (like /t:build),
as it messes with the environment.
2020-06-25 23:50:05 +02:00
Ignacio Etcheverry e8d632720f Mono/C#: Fix InvalidCast because of attempt to unbox long as int 2020-06-25 23:37:53 +02:00
Rémi Verschelde 04795d7f1e
Merge pull request #39739 from MichaelBelousov/fix/long-enum-fix-rider-cast
fix underlying type of enum crashing cast in RiderPathManager
2020-06-24 22:51:07 +02:00
Michael Belousov 9f61f1ed54 Mono: fix bad long casts and wrong underlying enum types in GodotTools 2020-06-24 09:35:13 -04:00
Rémi Verschelde 7d60a88888
Merge pull request #39783 from neikeq/messaging-codecompletion-localize-fix
C#: Fix completion request with case insensitive resource path
2020-06-24 01:00:05 +02:00
Ignacio Etcheverry d569b447ff C#: Fix completion request with case insensitive resource path
Sometimes Visual Studio documents have the root path all in upper case.
Since Godot doesn't support loading resource files with a case insensitive path,
this makes script resource loading to fail when the Godot editor gets code
completion requests from Visual Studio.
This fix allows the resource path part of the path to be case insensitive. It
still doesn't support cases where the rest of the path is also case insensitive.
For that we would need a proper API for comparing paths. However, this fix
should be enough for our current cases.
2020-06-23 20:29:19 +02:00
Hugo Locurcio 31b7f02a29
Remove ToolButton in favor of Button
ToolButton has no redeeming differences with Button;
it's just a Button with the Flat property enabled by default.
Removing it avoids some confusion when creating GUIs.

Existing ToolButtons will be converted to Buttons, but the Flat
property won't be enabled automatically.

This closes https://github.com/godotengine/godot-proposals/issues/1081.
2020-06-19 20:49:49 +02:00
Ignacio Etcheverry 54df72dcc6 C#: Add VisualStudio support 2020-06-15 21:29:16 +02:00
Maganty Rushyendra 3d03be7a56 Update Mono C# warning to reflect latest list of platforms supported
Simple fix for #38627. iOS (#20268) and HTML5 (#20270) removed from list of exceptions
for platforms supported in warning message.
2020-05-26 09:19:45 +08:00
Ignacio Etcheverry dcf1dc4fe0 C#: Support for building with the dotnet CLI
By adding a reference to the 'Microsoft.NETFramework.ReferenceAssemblies' nuget
package, we can build projects targeting .NET Framework with the dotnet CLI.
By referencing this package we also don't need to install Mono on Linux/macOS
or .NET Framework on Windows, as the assemblies are taken from the package.
2020-05-11 08:17:37 +02:00
Ignacio Etcheverry 3ce09246d1 C#: Rewrite GodotTools messaging protocol 2020-05-09 21:49:40 +02:00
Ignacio Etcheverry f3bcd5f8dd C#: Use Sdks in GodotTools csprojs and switch to nuget Microsoft.Build 2020-05-09 21:36:31 +02:00
Ignacio Etcheverry b61ffef0ab Mono: Use msbuild instead of nuget.exe for restoring
- Make GodotTools output directly to the SCons output directory.
- Removed xbuild_fallback from the build system.
2020-05-09 19:45:04 +02:00
Ignacio Roldán Etcheverry 3ad9652a5d
Merge pull request #38110 from neikeq/csproj-safer-migration
C#: Save copy of sln and csproj before applying fixes
2020-04-22 17:27:07 +02:00
Ignacio Etcheverry 93d7ec8836 C#: Save copy of sln and csproj before applying fixes 2020-04-22 16:50:43 +02:00
Ignacio Etcheverry 71fc87e101 Mono/C#: Allow debugging exported games
- Include PDB files in exported games.
- Release export templates also allow debugging now.

Right now the only way to enable debugging in exported games is with the  environment variables, which may be cumbersome or not even possible on some platforms.
2020-04-22 16:44:03 +02:00
Ignacio Etcheverry 27ddb27da8 Fix C# bindings after recent breaking changes 2020-04-03 01:38:48 +02:00
Ignacio Etcheverry 77dd061345 Mono/C#: Add iOS support
Right now, games only work on devices when exported with FullAOT+Interpreter.
There are some issues left that need to addressed for FullAOT alone. Right now,
it's giving issues with the Godot.NativeCalls static constructor.
2020-03-31 09:37:16 +02:00
Mateo Kuruk Miccino f387b9b4f4 Multiple changes to DisplayServerX11
- Travis: Change x11 to linuxbsd
- SCons: Change x11 plataform to linuxbsd
- Plugins: Remove ; to avoid fallthrough warning
- DisplayServerX11: Implement set_icon
- DisplayServerX11: Fix X11 bug when a window was erased from windows
  map, all the changes from that erased windows are sending to the main
  window
- DisplayServerX11: Reorder create_window commands
- DisplayServerX11: Change every Size2 to Size2i and Rect2 to Rect2i
  where it belongs

+ More X11 fixes which have been integrated directly back into reduz's
original commits while rebasing the branch.
2020-03-26 15:49:54 +01:00
Ivan.Shakhov 05946be2f1 Fix warning: Property not found: mono/editor/editor_path_optional (#36995) 2020-03-21 15:33:14 +01:00
Rémi Verschelde 194d2ccb72
Merge pull request #37116 from neikeq/issue-12917
Sync csproj when files are changed from the Godot FileSystem dock
2020-03-18 16:07:49 +01:00
Ignacio Etcheverry 40f8de4c1e Sync csproj when files are changed from the Godot FileSystem dock 2020-03-18 15:06:41 +01:00
Ignacio Roldán Etcheverry f62fc10bb6
Merge pull request #37131 from van800/master
fix RiderPathLocator - searching for toolbox on Mac
2020-03-18 14:25:02 +01:00
Ivan.Shakhov dc16b8742a fix RiderPathLocator - searching for toolbox on Mac 2020-03-18 09:23:29 +01:00
Ignacio Etcheverry 6a85cdf640 Fix C# bindings after recent breaking changes
Implementation for new Variant types Callable, Signal, StringName.
Added support for PackedInt64Array and PackedFloat64Array.

Add generation of signal members as events, as well as support for
user created signals as events.
NOTE: As of now, raising such events will not emit the signal. As such,
one must use `EmitSignal` instead of raising the event directly.

Removed old ThreadLocal fallback class. It's safe to use thread_local now since
it's supported on all minimum versions of compilers we support.
2020-03-17 16:30:04 +01:00
Ignacio Etcheverry 1b634785b5 C#: Replace uses of old Configuration and update old csprojs 2020-03-14 19:01:29 +01:00
Ivan Shakhov ce01b83c4a reorder solution configurations + migration 2020-03-11 17:22:12 +01:00
Ivan Shakhov c95e20a089 On Windows find Rider installed for CurrentUser 2020-02-28 21:34:20 +01:00
Rémi Verschelde 5c4878191a
Merge pull request #36602 from van800/jetbrains_msbuild
Allow using Rider MSBuild on Windows, when Rider is selected as external editor
2020-02-27 20:46:50 +01:00
Ivan Shakhov a9c2ab81cf use Rider MSBuild on Windows, when Rider is selected as external editor 2020-02-27 15:32:35 +01:00
Ivan Shakhov 33af53c1a6 Support toolbox custom "Tools install location", by reading .settings.json 2020-02-27 15:22:12 +01:00
Fabio Alessandrelli cbc450c0e5 Huge Debugger/EditorDebugger refactor. 2020-02-21 11:12:03 +01:00
Rémi Verschelde 702976cd7a Mono: Fix build after ObjectID and Texture2D changes 2020-02-18 11:36:48 +01:00
Rémi Verschelde cadf946863
Merge pull request #35478 from neikeq/issue-32260
Mono/C#: Add setting to include I18N assemblies in the exported game
2020-01-23 18:24:15 +01:00
Ignacio Etcheverry 59ec19d5a8 Mono/C#: Add setting to include I18N assemblies in the exported game 2020-01-23 17:47:09 +01:00
Ignacio Etcheverry d9ff5f7fc2 Mono/C#: Default to net47 for new projects 2020-01-23 15:57:47 +01:00
Ignacio Etcheverry d53c15b12c Make script class parser errors to not abort the build
As our script class parser is error prone, we should not impede the build from continuing because of a parsing error.
This should be reverted in the future once we switch to Roslyn.
2020-01-21 20:07:26 +01:00
Ignacio Etcheverry e4330e33e6 Mono/C#: Fix error when parsing nested generics
Also fixed the editor not including the parse error message in the error.
2020-01-20 19:08:08 +01:00
Ignacio Etcheverry 86274b9fc9 Mono/C#: Re-structure API solution and GodotTools post-build target
Previously we had a placeholder solution called 'Managed' to benefit from
tooling while editing the a part of the C# API.
Later the bindings generator would create the final 'GodotSharp' solution
including these C# files as well as the auto-generated C# API.
Now we replaced the 'Managed' solution with the final 'GodotSharp' solution
which is no longer auto-generated, and the bindings generator only takes
care of the auto-generated C# API.
This has the following benefits:
- It's less confusing as there will no longer be two versions of the same file
(the original and a generated copy of it). Now there's only one.
- We no longer need placeholder for auto-generated API classes, like Node or
Resource. We used them for benefiting from tooling. Now we can just use the
auto-generated API itself.
- Simplifies the build system and bindings generator. Removed lot of code
that is not needed anymore.

Also added a post-build target to the GodotTools project to copy the output to
the data dir. This makes it easy to iterate when doing changes to GodotTools,
as SCons doesn't have to be executed anymore just to copy these new files.
2019-12-28 20:48:55 +01:00
Ivan.Shakhov 682dd04b2d fix Rider path on Mac 2019-12-25 00:14:31 +01:00
Dan Kramer 097d1c9383 add suggested fix 2019-12-21 13:26:29 -05:00
Rémi Verschelde a10449bbbc
Merge pull request #34514 from neikeq/remove-dep-on-mono-posix
Mono/C#: Remove GodotTools dependency on the Mono.Posix assembly
2019-12-21 17:07:18 +01:00
Ignacio Etcheverry 5a3ccf4f14 Mono/C#: Remove GodotTools dependency on the Mono.Posix assembly
MSBuild on Windows uses the system .NET Framework BCL instead of Mono's. Because
of this, it may not be able to find the Mono.Posix assembly, so it's better
not to depend on it. We needed Mono.Posix to call Syscall.access, so we can
replace this with an internal call that does the same in C++.
2019-12-21 15:55:45 +01:00
Ignacio Etcheverry 98dc07f25f Mono/C#: Fix Variant -> MonoString* when type is Variant:NIL
`Variant::operator String()` returns "Null" if the type is `Variant:NIL`.
We must consider that and return a null `MonoString*` instead when marshalling.
This was also causing a "Null" error to be displayed when exporting a game
because null string members would be set to "Null" during hot-reload.
2019-12-19 16:51:32 +01:00
Ignacio Etcheverry 20d7013c60 Mono/C#: Fix project export and fix FindLast/GetFile regression
d09193b08a introduced a regression in
StringExtensions.FindLast. StringExtensions.GetFile was also affected as it
relies on FindLast. This in turn broke the project exporter as it uses GetFile.
The cause of the regression is that now FindLast is calling LastIndexOf
with 'startIndex: 0'. This should be 'startIndex: str.Length - 1' instead.

Also fixed another regression in the project exporter:
de7c2ad21b moved 'GodotTools/GodotSharpExport.cs'
to 'GodotTools/Export/ExportPlugin.cs' and in doing so accidently reverted
the changes from commit e439581198.
2019-12-17 13:06:41 +01:00
Aaron Franke 5771f9959c
Mono formatting
No space for casting, add spaces inside braces, 4 space indentation, remove trailing indentation, remove BOM.
2019-12-11 16:32:47 -05:00