Browse Source

Add float arg to build_assemblies.py

Almighty Laxz 3 years ago
parent
commit
c71b78bbb8

+ 1 - 1
SConstruct

@@ -167,7 +167,7 @@ opts.Add("p", "Platform (alias for 'platform')", "")
 opts.Add(BoolVariable("tools", "Build the tools (a.k.a. the Godot editor)", True))
 opts.Add(BoolVariable("tools", "Build the tools (a.k.a. the Godot editor)", True))
 opts.Add(EnumVariable("target", "Compilation target", "debug", ("debug", "release_debug", "release")))
 opts.Add(EnumVariable("target", "Compilation target", "debug", ("debug", "release_debug", "release")))
 opts.Add(EnumVariable("arch", "CPU architecture", "auto", ["auto"] + architectures, architecture_aliases))
 opts.Add(EnumVariable("arch", "CPU architecture", "auto", ["auto"] + architectures, architecture_aliases))
-opts.Add(EnumVariable("float", "Floating-point precision", "default", ("default", "32", "64")))
+opts.Add(EnumVariable("float", "Floating-point precision", "32", ("32", "64")))
 opts.Add(EnumVariable("optimize", "Optimization type", "speed", ("speed", "size", "none")))
 opts.Add(EnumVariable("optimize", "Optimization type", "speed", ("speed", "size", "none")))
 opts.Add(BoolVariable("production", "Set defaults to build Godot for use in production", False))
 opts.Add(BoolVariable("production", "Set defaults to build Godot for use in production", False))
 opts.Add(BoolVariable("use_lto", "Use link-time optimization", False))
 opts.Add(BoolVariable("use_lto", "Use link-time optimization", False))

+ 10 - 0
modules/mono/README.md

@@ -43,3 +43,13 @@ This option ensures the packages will be added to the specified local NuGet
 source and that conflicting versions of the package are removed from the
 source and that conflicting versions of the package are removed from the
 NuGet cache. It's recommended to always use this option when building the
 NuGet cache. It's recommended to always use this option when building the
 C# solutions during development to avoid mistakes.
 C# solutions during development to avoid mistakes.
+
+# Double Precision Support (REAL_T_IS_DOUBLE)
+
+Follow the above instructions but build Godot with the float=64 argument to scons
+
+When building the NuGet packages, specify `--float=64` - for example:
+```sh
+./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin \
+    --push-nupkgs-local ~/MyLocalNugetSource --float=64
+```

+ 11 - 3
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)
     return subprocess.call(args, env=msbuild_env)
 
 
 
 
-def build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local):
+def build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local, float_size):
     target_filenames = [
     target_filenames = [
         "GodotSharp.dll",
         "GodotSharp.dll",
         "GodotSharp.pdb",
         "GodotSharp.pdb",
@@ -216,6 +216,8 @@ def build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local):
         args = ["/restore", "/t:Build", "/p:Configuration=" + build_config, "/p:NoWarn=1591"]
         args = ["/restore", "/t:Build", "/p:Configuration=" + build_config, "/p:NoWarn=1591"]
         if push_nupkgs_local:
         if push_nupkgs_local:
             args += ["/p:ClearNuGetLocalCache=true", "/p:PushNuGetToLocalSource=" + push_nupkgs_local]
             args += ["/p:ClearNuGetLocalCache=true", "/p:PushNuGetToLocalSource=" + push_nupkgs_local]
+        if float_size == "64":
+            args += ["/p:GodotFloat64=true"]
 
 
         sln = os.path.join(module_dir, "glue/GodotSharp/GodotSharp.sln")
         sln = os.path.join(module_dir, "glue/GodotSharp/GodotSharp.sln")
         exit_code = run_msbuild(
         exit_code = run_msbuild(
@@ -256,9 +258,9 @@ def build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local):
     return 0
     return 0
 
 
 
 
-def build_all(msbuild_tool, module_dir, output_dir, godot_platform, dev_debug, push_nupkgs_local):
+def build_all(msbuild_tool, module_dir, output_dir, godot_platform, dev_debug, push_nupkgs_local, float_size):
     # Godot API
     # Godot API
-    exit_code = build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local)
+    exit_code = build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local, float_size)
     if exit_code != 0:
     if exit_code != 0:
         return exit_code
         return exit_code
 
 
@@ -269,6 +271,8 @@ def build_all(msbuild_tool, module_dir, output_dir, godot_platform, dev_debug, p
     )
     )
     if push_nupkgs_local:
     if push_nupkgs_local:
         args += ["/p:ClearNuGetLocalCache=true", "/p:PushNuGetToLocalSource=" + push_nupkgs_local]
         args += ["/p:ClearNuGetLocalCache=true", "/p:PushNuGetToLocalSource=" + push_nupkgs_local]
+    if float_size == "64":
+        args += ["/p:GodotFloat64=true"]
     exit_code = run_msbuild(msbuild_tool, sln=sln, msbuild_args=args)
     exit_code = run_msbuild(msbuild_tool, sln=sln, msbuild_args=args)
     if exit_code != 0:
     if exit_code != 0:
         return exit_code
         return exit_code
@@ -277,6 +281,8 @@ def build_all(msbuild_tool, module_dir, output_dir, godot_platform, dev_debug, p
     args = ["/restore", "/t:Build", "/p:Configuration=Release"]
     args = ["/restore", "/t:Build", "/p:Configuration=Release"]
     if push_nupkgs_local:
     if push_nupkgs_local:
         args += ["/p:ClearNuGetLocalCache=true", "/p:PushNuGetToLocalSource=" + push_nupkgs_local]
         args += ["/p:ClearNuGetLocalCache=true", "/p:PushNuGetToLocalSource=" + push_nupkgs_local]
+    if float_size == "64":
+        args += ["/p:GodotFloat64=true"]
     sln = os.path.join(module_dir, "editor/Godot.NET.Sdk/Godot.NET.Sdk.sln")
     sln = os.path.join(module_dir, "editor/Godot.NET.Sdk/Godot.NET.Sdk.sln")
     exit_code = run_msbuild(msbuild_tool, sln=sln, msbuild_args=args)
     exit_code = run_msbuild(msbuild_tool, sln=sln, msbuild_args=args)
     if exit_code != 0:
     if exit_code != 0:
@@ -300,6 +306,7 @@ def main():
     parser.add_argument("--godot-platform", type=str, default="")
     parser.add_argument("--godot-platform", type=str, default="")
     parser.add_argument("--mono-prefix", type=str, default="")
     parser.add_argument("--mono-prefix", type=str, default="")
     parser.add_argument("--push-nupkgs-local", type=str, default="")
     parser.add_argument("--push-nupkgs-local", type=str, default="")
+    parser.add_argument("--float", type=str, default="32", choices=["32", "64"], help="Floating-point precision")
 
 
     args = parser.parse_args()
     args = parser.parse_args()
 
 
@@ -321,6 +328,7 @@ def main():
         args.godot_platform,
         args.godot_platform,
         args.dev_debug,
         args.dev_debug,
         args.push_nupkgs_local,
         args.push_nupkgs_local,
+        args.float,
     )
     )
     sys.exit(exit_code)
     sys.exit(exit_code)
 
 

+ 1 - 1
modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props

@@ -62,7 +62,7 @@
   </PropertyGroup>
   </PropertyGroup>
 
 
   <PropertyGroup>
   <PropertyGroup>
-    <GodotRealTIsDouble Condition=" '$(GodotRealTIsDouble)' == '' ">false</GodotRealTIsDouble>
+    <GodotFloat64 Condition=" '$(GodotFloat64)' == '' ">false</GodotFloat64>
   </PropertyGroup>
   </PropertyGroup>
 
 
   <!-- Godot DefineConstants. -->
   <!-- Godot DefineConstants. -->

+ 2 - 2
modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets

@@ -10,9 +10,9 @@
     <!--
     <!--
     Define constant to determine whether the real_t type in Godot is double precision or not.
     Define constant to determine whether the real_t type in Godot is double precision or not.
     By default this is false, like the official Godot builds. If someone is using a custom
     By default this is false, like the official Godot builds. If someone is using a custom
-    Godot build where real_t is double, they can override the GodotRealTIsDouble property.
+    Godot build where real_t is double, they can override the GodotFloat64 property.
     -->
     -->
-    <DefineConstants Condition=" '$(GodotRealTIsDouble)' == 'true' ">GODOT_REAL_T_IS_DOUBLE;$(DefineConstants)</DefineConstants>
+    <DefineConstants Condition=" '$(GodotFloat64)' == 'true' ">GODOT_REAL_T_IS_DOUBLE;$(DefineConstants)</DefineConstants>
   </PropertyGroup>
   </PropertyGroup>
 
 
   <!-- C# source generators -->
   <!-- C# source generators -->

+ 1 - 0
modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj

@@ -36,6 +36,7 @@
   </ItemGroup>
   </ItemGroup>
   <PropertyGroup>
   <PropertyGroup>
     <DefineConstants>$(DefineConstants);GODOT</DefineConstants>
     <DefineConstants>$(DefineConstants);GODOT</DefineConstants>
+    <DefineConstants Condition=" '$(GodotFloat64)' == 'true' ">REAL_T_IS_DOUBLE;$(DefineConstants)</DefineConstants>
   </PropertyGroup>
   </PropertyGroup>
   <ItemGroup>
   <ItemGroup>
     <PackageReference Include="ReflectionAnalyzers" Version="0.1.22-dev" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
     <PackageReference Include="ReflectionAnalyzers" Version="0.1.22-dev" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />

+ 1 - 0
modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj

@@ -25,6 +25,7 @@
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup>
   <PropertyGroup>
     <DefineConstants>$(DefineConstants);GODOT</DefineConstants>
     <DefineConstants>$(DefineConstants);GODOT</DefineConstants>
+    <DefineConstants Condition=" '$(GodotFloat64)' == 'true' ">REAL_T_IS_DOUBLE;$(DefineConstants)</DefineConstants>
   </PropertyGroup>
   </PropertyGroup>
   <ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\GodotSharp\GodotSharp.csproj">
     <ProjectReference Include="..\GodotSharp\GodotSharp.csproj">