summaryrefslogtreecommitdiff
path: root/modules/mono/build_scripts
diff options
context:
space:
mode:
authorIgnacio Roldán Etcheverry <ignalfonsore@gmail.com>2022-02-27 21:57:53 +0100
committerIgnacio Roldán Etcheverry <ignalfonsore@gmail.com>2022-08-22 03:36:51 +0200
commitd78e0a842638df9c98a8f7637b125d36e488a367 (patch)
tree5187d042301f254eb609d65695394d026b64a8b7 /modules/mono/build_scripts
parent4b90d162502d65f20a89331898cd8a0b3eea8fe2 (diff)
C#: Make GodotSharp API a NuGet package
In the past, the Godot editor distributed the API assemblies and copied them to project directories for projects to reference them. This changed with the move to .NET 5/6. Godot no longer copies the assemblies to project directories. However, the project Sdk still tried to reference them from the same location. From now on, the GodotSharp API is distributed as a NuGet package, which the Sdk can reference. Added an option to `build_assemblies.py` to copy all Godot NuGet packages to an existing local NuGet source. This will be needed during development, while packages are not published to a remote NuGet repository. This option also makes sure to remove packages of the same version installed (~/.nuget/packages). Very useful during development, when packages change, to make sure the package being used by a project is the same we just built and not one from a previous build. A local NuGet source can be created like this: ``` mkdir ~/MyLocalNuGetSource && \ dotnet nuget add source ~/MyLocalNuGetSource/ -n MyLocalNuGetSource ```
Diffstat (limited to 'modules/mono/build_scripts')
-rwxr-xr-xmodules/mono/build_scripts/build_assemblies.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/modules/mono/build_scripts/build_assemblies.py b/modules/mono/build_scripts/build_assemblies.py
index 9cf9330232..fa3be684bd 100755
--- a/modules/mono/build_scripts/build_assemblies.py
+++ b/modules/mono/build_scripts/build_assemblies.py
@@ -195,7 +195,7 @@ def run_msbuild(tools: ToolsLocation, sln: str, msbuild_args: [str] = None):
return subprocess.call(args, env=msbuild_env)
-def build_godot_api(msbuild_tool, module_dir, output_dir):
+def build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local):
target_filenames = [
"GodotSharp.dll",
"GodotSharp.pdb",
@@ -213,11 +213,15 @@ def build_godot_api(msbuild_tool, module_dir, output_dir):
targets = [os.path.join(editor_api_dir, filename) for filename in target_filenames]
+ args = ["/restore", "/t:Build", "/p:Configuration=" + build_config, "/p:NoWarn=1591"]
+ if push_nupkgs_local:
+ args += ["/p:ClearNuGetLocalCache=true", "/p:PushNuGetToLocalSource=" + push_nupkgs_local]
+
sln = os.path.join(module_dir, "glue/GodotSharp/GodotSharp.sln")
exit_code = run_msbuild(
msbuild_tool,
sln=sln,
- msbuild_args=["/restore", "/t:Build", "/p:Configuration=" + build_config, "/p:NoWarn=1591"],
+ msbuild_args=args,
)
if exit_code != 0:
return exit_code
@@ -252,9 +256,9 @@ def build_godot_api(msbuild_tool, module_dir, output_dir):
return 0
-def build_all(msbuild_tool, module_dir, output_dir, dev_debug, godot_platform):
+def build_all(msbuild_tool, module_dir, output_dir, godot_platform, dev_debug, push_nupkgs_local):
# Godot API
- exit_code = build_godot_api(msbuild_tool, module_dir, output_dir)
+ exit_code = build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local)
if exit_code != 0:
return exit_code
@@ -263,13 +267,18 @@ def build_all(msbuild_tool, module_dir, output_dir, dev_debug, godot_platform):
args = ["/restore", "/t:Build", "/p:Configuration=" + ("Debug" if dev_debug else "Release")] + (
["/p:GodotPlatform=" + godot_platform] if godot_platform else []
)
+ if push_nupkgs_local:
+ args += ["/p:ClearNuGetLocalCache=true", "/p:PushNuGetToLocalSource=" + push_nupkgs_local]
exit_code = run_msbuild(msbuild_tool, sln=sln, msbuild_args=args)
if exit_code != 0:
return exit_code
# Godot.NET.Sdk
+ args = ["/restore", "/t:Build", "/p:Configuration=Release"]
+ if push_nupkgs_local:
+ args += ["/p:ClearNuGetLocalCache=true", "/p:PushNuGetToLocalSource=" + push_nupkgs_local]
sln = os.path.join(module_dir, "editor/Godot.NET.Sdk/Godot.NET.Sdk.sln")
- exit_code = run_msbuild(msbuild_tool, sln=sln, msbuild_args=["/restore", "/t:Build", "/p:Configuration=Release"])
+ exit_code = run_msbuild(msbuild_tool, sln=sln, msbuild_args=args)
if exit_code != 0:
return exit_code
@@ -290,6 +299,7 @@ def main():
)
parser.add_argument("--godot-platform", type=str, default="")
parser.add_argument("--mono-prefix", type=str, default="")
+ parser.add_argument("--push-nupkgs-local", type=str, default="")
args = parser.parse_args()
@@ -304,7 +314,14 @@ def main():
print("Unable to find MSBuild")
sys.exit(1)
- exit_code = build_all(msbuild_tool, module_dir, output_dir, args.godot_platform, args.dev_debug)
+ exit_code = build_all(
+ msbuild_tool,
+ module_dir,
+ output_dir,
+ args.godot_platform,
+ args.dev_debug,
+ args.push_nupkgs_local,
+ )
sys.exit(exit_code)