Skip to content

Commit

Permalink
Merge pull request #18 from DmitriySalnikov/dummy_test
Browse files Browse the repository at this point in the history
Added dummy library
  • Loading branch information
DmitriySalnikov authored Jul 19, 2023
2 parents 9a05247 + 6ba4fff commit d7f7933
Show file tree
Hide file tree
Showing 23 changed files with 205 additions and 119 deletions.
3 changes: 3 additions & 0 deletions .github/actions/compile_gdextension/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ runs:
git apply --ignore-space-change --ignore-whitespace ../patches/1165.patch
cd ..
scons platform=${{inputs.platform}} arch=${{inputs.arch}} target=${{inputs.target}} addon_output_dir=${{inputs.output_libs_path}} ${{inputs.additional}}
if [ "${{inputs.target}}" == "template_release" ] && [ "${{inputs.platform}}" != "android" ]; then
scons platform=${{inputs.platform}} arch=${{inputs.arch}} target=${{inputs.target}} addon_output_dir=${{inputs.output_libs_path}} force_enabled_dd3d=yes ${{inputs.additional}}
fi
echo "::endgroup::"
- name: Prepare artifact Unix
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/gdextension_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fail-fast: false
matrix:
arch: [x86_64]
target: [editor, template_debug, template_release]
target: [template_debug, template_release]

steps:
- name: Checkout
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
fail-fast: false
matrix:
arch: [x86_64]
target: [editor, template_debug, template_release]
target: [template_debug, template_release]

steps:
- name: Checkout
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
fail-fast: false
matrix:
arch: [universal]
target: [editor, template_debug, template_release]
target: [template_debug, template_release]

steps:
- name: Checkout
Expand Down
8 changes: 6 additions & 2 deletions addons/debug_draw_3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ Besides `DebugDraw`, you can also use `Dbg3`.

But unfortunately at the moment `GDExtension` does not support adding documentation.

<!-- ## Exporting a project
## Exporting a project

Most likely, when exporting the release version of the game, you will not want to export the debugging library with it. So you will need to make additional configuration of the project. -->
Most likely, when exporting a release version of a game, you don't want to export the debug library along with it. But since there is still no `Conditional Compilation` in `GDScript`, so I decided to create a `dummy` library that has the same API as a regular library, but has minimal impact on performance, even if calls to its methods occur. The `dummy` library is used by default in the release version. However if you need to use debug rendering in the release version, then you can add the `forced_dd3d` feature when exporting. In this case, the release library with all the functionality will be used.

![export_features](/images/export_features.png)

<!-- ### For GDScript
Expand Down Expand Up @@ -161,6 +163,8 @@ The entire text overlay can only be placed in one corner, unlike DataGraphs.

[Frustum of Camera3D does not take into account the window size from ProjectSettings](https://github.com/godotengine/godot/issues/70362).

**The version for Godot 4.0 requires explicitly specifying the exact data types, otherwise errors may occur.**

**The C# binding is not ready yet.**

## More screenshots
Expand Down
21 changes: 15 additions & 6 deletions addons/debug_draw_3d/debug_draw_3d.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ compatibility_minimum = "4.1"

# example.x86_64 = { "relative or absolute path to the dependency" : "the path relative to the exported project", }

macos.editor = { }
windows.editor.x86_64 = { }
linux.editor.x86_64 = { }
# macos.editor = { }
# windows.editor.x86_64 = { }
# linux.editor.x86_64 = { }

macos = { }
windows.x86_64 = { }
Expand All @@ -31,9 +31,9 @@ android.template_release.x86_64 = { }

[libraries]

macos.editor = "libs/libdd3d.macos.editor.universal.dylib"
windows.editor.x86_64 = "libs/libdd3d.windows.editor.x86_64.dll"
linux.editor.x86_64 = "libs/libdd3d.linux.editor.x86_64.so"
# macos.editor = "libs/libdd3d.macos.editor.universal.dylib"
# windows.editor.x86_64 = "libs/libdd3d.windows.editor.x86_64.dll"
# linux.editor.x86_64 = "libs/libdd3d.linux.editor.x86_64.so"

macos = "libs/libdd3d.macos.template_debug.universal.dylib"
windows.x86_64 = "libs/libdd3d.windows.template_debug.x86_64.dll"
Expand All @@ -52,3 +52,12 @@ android.template_release.arm32 = "libs/libdd3d.android.template_release.arm32.so
android.template_release.arm64 = "libs/libdd3d.android.template_release.arm64.so"
android.template_release.x86_32 = "libs/libdd3d.android.template_release.x86_32.so"
android.template_release.x86_64 = "libs/libdd3d.android.template_release.x86_64.so"

macos.template_release.forced_dd3d = "libs/libdd3d.macos.template_release.universal.enabled.dylib"
windows.template_release.x86_64.forced_dd3d = "libs/libdd3d.windows.template_release.x86_64.enabled.dll"
linux.template_release.x86_64.forced_dd3d = "libs/libdd3d.linux.template_release.x86_64.enabled.so"

android.template_release.arm32.forced_dd3d = "libs/libdd3d.android.template_release.arm32.enabled.so"
android.template_release.arm64.forced_dd3d = "libs/libdd3d.android.template_release.arm64.enabled.so"
android.template_release.x86_32.forced_dd3d = "libs/libdd3d.android.template_release.x86_32.enabled.so"
android.template_release.x86_64.forced_dd3d = "libs/libdd3d.android.template_release.x86_64.enabled.so"
9 changes: 3 additions & 6 deletions dev_debug_draw_3d_Library.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "debug_draw_3d_Library", "de
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
editor_dev|x64 = editor_dev|x64
editor|x64 = editor|x64
template_debug|x64 = template_debug|x64
template_dev|x64 = template_dev|x64
template_release|x64 = template_release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.editor_dev|x64.ActiveCfg = editor_dev|x64
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.editor_dev|x64.Build.0 = editor_dev|x64
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.editor|x64.ActiveCfg = editor|x64
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.editor|x64.Build.0 = editor|x64
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.template_debug|x64.ActiveCfg = template_debug|x64
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.template_debug|x64.Build.0 = template_debug|x64
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.template_dev|x64.ActiveCfg = template_dev|x64
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.template_dev|x64.Build.0 = template_dev|x64
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.template_release|x64.ActiveCfg = template_release|x64
{A265372D-FCD7-4FBD-9F8C-0D31F6D0F557}.template_release|x64.Build.0 = template_release|x64
EndGlobalSection
Expand Down
73 changes: 11 additions & 62 deletions dev_debug_draw_3d_Library.vcxproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="editor_dev|x64">
<Configuration>editor_dev</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="editor|x64">
<Configuration>editor</Configuration>
<ProjectConfiguration Include="template_dev|x64">
<Configuration>template_dev</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="template_debug|x64">
Expand Down Expand Up @@ -34,14 +30,7 @@
<CharacterSet>Unicode</CharacterSet>
<EnableUnitySupport>true</EnableUnitySupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='editor|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableUnitySupport>true</EnableUnitySupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='editor_dev|x64'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='template_dev|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
Expand All @@ -64,10 +53,7 @@
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='template_debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='editor|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='editor_dev|x64'" Label="PropertySheets">
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='template_dev|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='template_release|x64'">
Expand All @@ -82,19 +68,11 @@
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='editor|x64'">
<IncludePath>$(ProjectDir)godot-cpp\include;$(ProjectDir)godot-cpp\gdextension;$(ProjectDir)godot-cpp\gen\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)godot-cpp\bin;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)addons\debug_draw_3d\libs\</OutDir>
<TargetName>libdd3d.windows.$(Configuration).$(LlvmPlatformName)</TargetName>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='editor_dev|x64'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='template_dev|x64'">
<IncludePath>$(ProjectDir)godot-cpp\include;$(ProjectDir)godot-cpp\gdextension;$(ProjectDir)godot-cpp\gen\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)godot-cpp\bin;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)addons\debug_draw_3d\libs\</OutDir>
<TargetName>libdd3d.windows.editor.$(LlvmPlatformName)</TargetName>
<TargetName>libdd3d.windows.template_debug.$(LlvmPlatformName)</TargetName>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
Expand All @@ -111,36 +89,7 @@
<WarningLevel>Level3</WarningLevel>
<SDLCheck>false</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>WIN64;NOMINMAX;TYPED_METHOD_BIND;DEBUG_ENABLED;GDEXTENSION_LIBRARY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ExceptionHandling>Sync</ExceptionHandling>
<WholeProgramOptimization>true</WholeProgramOptimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CreateHotpatchableImage>
</CreateHotpatchableImage>
<Optimization>MaxSpeed</Optimization>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>NotSet</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libgodot-cpp.windows.$(Configuration).$(LlvmPlatformName).lib</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<SuppressStartupBanner>true</SuppressStartupBanner>
<IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='editor|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>false</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>WIN64;NOMINMAX;TOOLS_ENABLED;TYPED_METHOD_BIND;DEBUG_ENABLED;GDEXTENSION_LIBRARY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN64;NOMINMAX;TYPED_METHOD_BIND;GDEXTENSION_LIBRARY;DEBUG_ENABLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ExceptionHandling>Sync</ExceptionHandling>
<WholeProgramOptimization>true</WholeProgramOptimization>
Expand All @@ -164,12 +113,12 @@
<IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='editor_dev|x64'">
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='template_dev|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>false</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>WIN64;NOMINMAX;TOOLS_ENABLED;TYPED_METHOD_BIND;DEBUG_ENABLED;GDEXTENSION_LIBRARY;DEV_ENABLED;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN64;NOMINMAX;TYPED_METHOD_BIND;DEBUG_ENABLED;GDEXTENSION_LIBRARY;DEV_ENABLED;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ExceptionHandling>Sync</ExceptionHandling>
<WholeProgramOptimization>
Expand All @@ -184,7 +133,7 @@
<Link>
<SubSystem>NotSet</SubSystem>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<AdditionalDependencies>libgodot-cpp.windows.editor.dev.$(LlvmPlatformName).lib</AdditionalDependencies>
<AdditionalDependencies>libgodot-cpp.windows.template_debug.dev.$(LlvmPlatformName).lib</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<SuppressStartupBanner>true</SuppressStartupBanner>
Expand All @@ -198,7 +147,7 @@
</FunctionLevelLinking>
<IntrinsicFunctions>false</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN64;NOMINMAX;TYPED_METHOD_BIND;GDEXTENSION_LIBRARY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN64;NOMINMAX;TYPED_METHOD_BIND;GDEXTENSION_LIBRARY;DISABLE_DEBUG_RENDERING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ExceptionHandling>Sync</ExceptionHandling>
Expand Down
Binary file added images/export_features.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions lib_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def setup_options(env, arguments, gen_help):
from SCons.Variables import Variables, BoolVariable, EnumVariable, PathVariable
opts = Variables([], arguments)

opts.Add(BoolVariable("force_enabled_dd3d", "Keep the rendering code in the release build", False))
opts.Add(BoolVariable("lto", "Link-time optimization", False))
opts.Add(PathVariable("addon_output_dir", "Path to the output directory",
output_dir, PathVariable.PathIsDirCreate))
Expand All @@ -23,6 +24,9 @@ def setup_options(env, arguments, gen_help):
def gdnative_setup_defines_and_flags(env):
env.Append(CPPDEFINES=["GDEXTENSION_LIBRARY"])

if "release" in env["target"] and not env["force_enabled_dd3d"]:
env.Append(CPPDEFINES=["DISABLE_DEBUG_RENDERING"])

if env["lto"]:
if env.get("is_msvc", False):
env.AppendUnique(CCFLAGS=["/GL"])
Expand Down Expand Up @@ -60,8 +64,12 @@ def gdnative_get_library_object(env, arguments=None, gen_help=None):
# store all obj's in a dedicated folder
env["SHOBJPREFIX"] = "#obj/"

library_full_name = "lib" + lib_name + ".{}.{}.{}{}".format(
env["platform"], env["target"], env["arch"], env["SHLIBSUFFIX"])
additional_tags = ""
if "release" in env["target"] and env["force_enabled_dd3d"]:
additional_tags += ".enabled"

library_full_name = "lib" + lib_name + ".{}.{}.{}{}{}".format(
env["platform"], env["target"], env["arch"], additional_tags,env["SHLIBSUFFIX"])

env.Default(env.SharedLibrary(
target=env.File(Path(env["addon_output_dir"]) / library_full_name),
Expand All @@ -77,5 +85,5 @@ def gdnative_get_library_object(env, arguments=None, gen_help=None):
env.Append(LIBS=[library_full_name.replace(".dll", ".lib")])
else:
env.Append(LIBS=[library_full_name])

return env
4 changes: 3 additions & 1 deletion src/asset_library_update_checker.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "asset_library_update_checker.h"

#ifdef TOOLS_ENABLED
#ifndef DISABLE_DEBUG_RENDERING
#ifdef DEBUG_ENABLED

#include "version.h"

Expand Down Expand Up @@ -69,4 +70,5 @@ AssetLibraryUpdateChecker::AssetLibraryUpdateChecker() {
call_deferred(TEXT(init));
}

#endif
#endif
4 changes: 3 additions & 1 deletion src/asset_library_update_checker.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#ifdef TOOLS_ENABLED
#ifndef DISABLE_DEBUG_RENDERING
#ifdef DEBUG_ENABLED

#include "utils.h"

Expand All @@ -27,4 +28,5 @@ class AssetLibraryUpdateChecker : public RefCounted {
AssetLibraryUpdateChecker();
};

#endif
#endif
Loading

0 comments on commit d7f7933

Please sign in to comment.