SCons: Move platform logo/run icon to `export` folder

Follow-up to #75932.
Since these icons are only used by the export plugin, it makes sense to
move them and generate the headers there.

The whole `detect.is_active()` logic seems to be a leftover from before
times, as far back as 1.0-stable it already wasn't used for anything.

So I'm removing it and moving the export icon generation to
`platform_methods`, where it makes more sense.
This commit is contained in:
Rémi Verschelde 2023-06-19 11:28:22 +02:00
parent dbe8712d4e
commit 90446fe9f3
No known key found for this signature in database
GPG Key ID: C3336907360768E1
29 changed files with 48 additions and 78 deletions

View File

@ -56,7 +56,7 @@ import methods
import glsl_builders
import gles3_builders
import scu_builders
from platform_methods import architectures, architecture_aliases
from platform_methods import architectures, architecture_aliases, generate_export_icons
if ARGUMENTS.get("target", "editor") == "editor":
_helper_module("editor.editor_builders", "editor/editor_builders.py")
@ -68,9 +68,6 @@ platform_list = [] # list of platforms
platform_opts = {} # options for each platform
platform_flags = {} # flags for each platform
platform_doc_class_path = {}
active_platforms = []
active_platform_ids = []
platform_exporters = []
platform_apis = []
@ -93,13 +90,13 @@ for x in sorted(glob.glob("platform/*")):
except Exception:
pass
platform_name = x[9:]
if os.path.exists(x + "/export/export.cpp"):
platform_exporters.append(x[9:])
platform_exporters.append(platform_name)
generate_export_icons(x, platform_name)
if os.path.exists(x + "/api/api.cpp"):
platform_apis.append(x[9:])
if detect.is_active():
active_platforms.append(detect.get_name())
active_platform_ids.append(x)
platform_apis.append(platform_name)
if detect.can_build():
x = x.replace("platform/", "") # rest of world
x = x.replace("platform\\", "") # win32
@ -109,8 +106,6 @@ for x in sorted(glob.glob("platform/*")):
sys.path.remove(tmppath)
sys.modules.pop("detect")
methods.save_active_platforms(active_platforms, active_platform_ids)
custom_tools = ["default"]
platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False))

View File

@ -559,33 +559,6 @@ def use_windows_spawn_fix(self, platform=None):
self["SPAWN"] = mySpawn
def save_active_platforms(apnames, ap):
for x in ap:
svg_names = []
if os.path.isfile(x + "/logo.svg"):
svg_names.append("logo")
if os.path.isfile(x + "/run_icon.svg"):
svg_names.append("run_icon")
for name in svg_names:
svgf = open(x + "/" + name + ".svg", "rb")
b = svgf.read(1)
svg_str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n"
svg_str += " static const char *_" + x[9:] + "_" + name + '_svg = "'
while len(b) == 1:
svg_str += "\\" + hex(ord(b))[1:]
b = svgf.read(1)
svg_str += '";\n'
svgf.close()
# NOTE: It is safe to generate this file here, since this is still executed serially
wf = x + "/" + name + "_svg.gen.h"
with open(wf, "w") as svgw:
svgw.write(svg_str)
def no_verbose(sys, env):
colors = {}

View File

@ -9,10 +9,6 @@ if TYPE_CHECKING:
from SCons import Environment
def is_active():
return True
def get_name():
return "Android"

View File

@ -30,9 +30,9 @@
#include "export_plugin.h"
#include "../logo_svg.gen.h"
#include "../run_icon_svg.gen.h"
#include "gradle_export_util.h"
#include "logo_svg.gen.h"
#include "run_icon_svg.gen.h"
#include "core/config/project_settings.h"
#include "core/io/dir_access.h"

View File

Before

Width:  |  Height:  |  Size: 422 B

After

Width:  |  Height:  |  Size: 422 B

View File

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 468 B

View File

@ -8,10 +8,6 @@ if TYPE_CHECKING:
from SCons import Environment
def is_active():
return True
def get_name():
return "iOS"

View File

@ -30,7 +30,7 @@
#include "export_plugin.h"
#include "../logo_svg.gen.h"
#include "logo_svg.gen.h"
#include "core/string/translation.h"
#include "editor/editor_node.h"

View File

Before

Width:  |  Height:  |  Size: 929 B

After

Width:  |  Height:  |  Size: 929 B

View File

@ -10,10 +10,6 @@ if TYPE_CHECKING:
from SCons import Environment
def is_active():
return True
def get_name():
return "LinuxBSD"

View File

@ -30,8 +30,8 @@
#include "export_plugin.h"
#include "../logo_svg.gen.h"
#include "../run_icon_svg.gen.h"
#include "logo_svg.gen.h"
#include "run_icon_svg.gen.h"
#include "core/config/project_settings.h"
#include "editor/editor_node.h"

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -9,10 +9,6 @@ if TYPE_CHECKING:
from SCons import Environment
def is_active():
return True
def get_name():
return "macOS"

View File

@ -30,11 +30,11 @@
#include "export_plugin.h"
#include "../logo_svg.gen.h"
#include "../run_icon_svg.gen.h"
#include "codesign.h"
#include "lipo.h"
#include "logo_svg.gen.h"
#include "macho.h"
#include "run_icon_svg.gen.h"
#include "core/io/image_loader.h"
#include "core/string/translation.h"

View File

Before

Width:  |  Height:  |  Size: 838 B

After

Width:  |  Height:  |  Size: 838 B

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -9,10 +9,6 @@ if TYPE_CHECKING:
from SCons import Environment
def is_active():
return True
def get_name():
return "UWP"

View File

@ -30,7 +30,7 @@
#include "export_plugin.h"
#include "../logo_svg.gen.h"
#include "logo_svg.gen.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"

View File

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 438 B

View File

@ -17,10 +17,6 @@ if TYPE_CHECKING:
from SCons import Environment
def is_active():
return True
def get_name():
return "Web"

View File

@ -30,8 +30,8 @@
#include "export_plugin.h"
#include "../logo_svg.gen.h"
#include "../run_icon_svg.gen.h"
#include "logo_svg.gen.h"
#include "run_icon_svg.gen.h"
#include "core/config/project_settings.h"
#include "editor/editor_scale.h"

View File

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 351 B

View File

Before

Width:  |  Height:  |  Size: 418 B

After

Width:  |  Height:  |  Size: 418 B

View File

@ -13,10 +13,6 @@ if TYPE_CHECKING:
STACK_SIZE = 8388608
def is_active():
return True
def get_name():
return "Windows"

View File

@ -30,8 +30,8 @@
#include "export_plugin.h"
#include "../logo_svg.gen.h"
#include "../run_icon_svg.gen.h"
#include "logo_svg.gen.h"
#include "run_icon_svg.gen.h"
#include "core/config/project_settings.h"
#include "core/io/image_loader.h"

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 300 B

After

Width:  |  Height:  |  Size: 300 B

View File

@ -110,3 +110,33 @@ def detect_arch():
print("Unsupported CPU architecture: " + host_machine)
print("Falling back to x86_64.")
return "x86_64"
def generate_export_icons(platform_path, platform_name):
"""
Generate headers for logo and run icon for the export plugin.
"""
export_path = platform_path + "/export"
svg_names = []
if os.path.isfile(export_path + "/logo.svg"):
svg_names.append("logo")
if os.path.isfile(export_path + "/run_icon.svg"):
svg_names.append("run_icon")
for name in svg_names:
svgf = open(export_path + "/" + name + ".svg", "rb")
b = svgf.read(1)
svg_str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n"
svg_str += " static const char *_" + platform_name + "_" + name + '_svg = "'
while len(b) == 1:
svg_str += "\\" + hex(ord(b))[1:]
b = svgf.read(1)
svg_str += '";\n'
svgf.close()
# NOTE: It is safe to generate this file here, since this is still executed serially.
wf = export_path + "/" + name + "_svg.gen.h"
with open(wf, "w") as svgw:
svgw.write(svg_str)