Skip to content

Commit 90446fe

Browse files
committed
SCons: Move platform logo/run icon to export folder
Follow-up to godotengine#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.
1 parent dbe8712 commit 90446fe

29 files changed

+48
-78
lines changed

SConstruct

+6-11
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import methods
5656
import glsl_builders
5757
import gles3_builders
5858
import scu_builders
59-
from platform_methods import architectures, architecture_aliases
59+
from platform_methods import architectures, architecture_aliases, generate_export_icons
6060

6161
if ARGUMENTS.get("target", "editor") == "editor":
6262
_helper_module("editor.editor_builders", "editor/editor_builders.py")
@@ -68,9 +68,6 @@ platform_list = [] # list of platforms
6868
platform_opts = {} # options for each platform
6969
platform_flags = {} # flags for each platform
7070
platform_doc_class_path = {}
71-
72-
active_platforms = []
73-
active_platform_ids = []
7471
platform_exporters = []
7572
platform_apis = []
7673

@@ -93,13 +90,13 @@ for x in sorted(glob.glob("platform/*")):
9390
except Exception:
9491
pass
9592

93+
platform_name = x[9:]
94+
9695
if os.path.exists(x + "/export/export.cpp"):
97-
platform_exporters.append(x[9:])
96+
platform_exporters.append(platform_name)
97+
generate_export_icons(x, platform_name)
9898
if os.path.exists(x + "/api/api.cpp"):
99-
platform_apis.append(x[9:])
100-
if detect.is_active():
101-
active_platforms.append(detect.get_name())
102-
active_platform_ids.append(x)
99+
platform_apis.append(platform_name)
103100
if detect.can_build():
104101
x = x.replace("platform/", "") # rest of world
105102
x = x.replace("platform\\", "") # win32
@@ -109,8 +106,6 @@ for x in sorted(glob.glob("platform/*")):
109106
sys.path.remove(tmppath)
110107
sys.modules.pop("detect")
111108

112-
methods.save_active_platforms(active_platforms, active_platform_ids)
113-
114109
custom_tools = ["default"]
115110

116111
platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False))

methods.py

-27
Original file line numberDiff line numberDiff line change
@@ -559,33 +559,6 @@ def mySpawn(sh, escape, cmd, args, env):
559559
self["SPAWN"] = mySpawn
560560

561561

562-
def save_active_platforms(apnames, ap):
563-
for x in ap:
564-
svg_names = []
565-
if os.path.isfile(x + "/logo.svg"):
566-
svg_names.append("logo")
567-
if os.path.isfile(x + "/run_icon.svg"):
568-
svg_names.append("run_icon")
569-
570-
for name in svg_names:
571-
svgf = open(x + "/" + name + ".svg", "rb")
572-
b = svgf.read(1)
573-
svg_str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n"
574-
svg_str += " static const char *_" + x[9:] + "_" + name + '_svg = "'
575-
while len(b) == 1:
576-
svg_str += "\\" + hex(ord(b))[1:]
577-
b = svgf.read(1)
578-
579-
svg_str += '";\n'
580-
581-
svgf.close()
582-
583-
# NOTE: It is safe to generate this file here, since this is still executed serially
584-
wf = x + "/" + name + "_svg.gen.h"
585-
with open(wf, "w") as svgw:
586-
svgw.write(svg_str)
587-
588-
589562
def no_verbose(sys, env):
590563
colors = {}
591564

platform/android/detect.py

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
from SCons import Environment
1010

1111

12-
def is_active():
13-
return True
14-
15-
1612
def get_name():
1713
return "Android"
1814

platform/android/export/export_plugin.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030

3131
#include "export_plugin.h"
3232

33-
#include "../logo_svg.gen.h"
34-
#include "../run_icon_svg.gen.h"
3533
#include "gradle_export_util.h"
34+
#include "logo_svg.gen.h"
35+
#include "run_icon_svg.gen.h"
3636

3737
#include "core/config/project_settings.h"
3838
#include "core/io/dir_access.h"
File renamed without changes.
File renamed without changes.

platform/ios/detect.py

-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
from SCons import Environment
99

1010

11-
def is_active():
12-
return True
13-
14-
1511
def get_name():
1612
return "iOS"
1713

platform/ios/export/export_plugin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "export_plugin.h"
3232

33-
#include "../logo_svg.gen.h"
33+
#include "logo_svg.gen.h"
3434

3535
#include "core/string/translation.h"
3636
#include "editor/editor_node.h"
File renamed without changes.

platform/linuxbsd/detect.py

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
from SCons import Environment
1111

1212

13-
def is_active():
14-
return True
15-
16-
1713
def get_name():
1814
return "LinuxBSD"
1915

platform/linuxbsd/export/export_plugin.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
#include "export_plugin.h"
3232

33-
#include "../logo_svg.gen.h"
34-
#include "../run_icon_svg.gen.h"
33+
#include "logo_svg.gen.h"
34+
#include "run_icon_svg.gen.h"
3535

3636
#include "core/config/project_settings.h"
3737
#include "editor/editor_node.h"
File renamed without changes.
File renamed without changes.

platform/macos/detect.py

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
from SCons import Environment
1010

1111

12-
def is_active():
13-
return True
14-
15-
1612
def get_name():
1713
return "macOS"
1814

platform/macos/export/export_plugin.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030

3131
#include "export_plugin.h"
3232

33-
#include "../logo_svg.gen.h"
34-
#include "../run_icon_svg.gen.h"
3533
#include "codesign.h"
3634
#include "lipo.h"
35+
#include "logo_svg.gen.h"
3736
#include "macho.h"
37+
#include "run_icon_svg.gen.h"
3838

3939
#include "core/io/image_loader.h"
4040
#include "core/string/translation.h"
File renamed without changes.
File renamed without changes.

platform/uwp/detect.py

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
from SCons import Environment
1010

1111

12-
def is_active():
13-
return True
14-
15-
1612
def get_name():
1713
return "UWP"
1814

platform/uwp/export/export_plugin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "export_plugin.h"
3232

33-
#include "../logo_svg.gen.h"
33+
#include "logo_svg.gen.h"
3434

3535
#include "editor/editor_scale.h"
3636
#include "editor/editor_settings.h"
File renamed without changes.

platform/web/detect.py

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
from SCons import Environment
1818

1919

20-
def is_active():
21-
return True
22-
23-
2420
def get_name():
2521
return "Web"
2622

platform/web/export/export_plugin.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
#include "export_plugin.h"
3232

33-
#include "../logo_svg.gen.h"
34-
#include "../run_icon_svg.gen.h"
33+
#include "logo_svg.gen.h"
34+
#include "run_icon_svg.gen.h"
3535

3636
#include "core/config/project_settings.h"
3737
#include "editor/editor_scale.h"
File renamed without changes.
File renamed without changes.

platform/windows/detect.py

-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
STACK_SIZE = 8388608
1414

1515

16-
def is_active():
17-
return True
18-
19-
2016
def get_name():
2117
return "Windows"
2218

platform/windows/export/export_plugin.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
#include "export_plugin.h"
3232

33-
#include "../logo_svg.gen.h"
34-
#include "../run_icon_svg.gen.h"
33+
#include "logo_svg.gen.h"
34+
#include "run_icon_svg.gen.h"
3535

3636
#include "core/config/project_settings.h"
3737
#include "core/io/image_loader.h"
File renamed without changes.
File renamed without changes.

platform_methods.py

+30
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,33 @@ def detect_arch():
110110
print("Unsupported CPU architecture: " + host_machine)
111111
print("Falling back to x86_64.")
112112
return "x86_64"
113+
114+
115+
def generate_export_icons(platform_path, platform_name):
116+
"""
117+
Generate headers for logo and run icon for the export plugin.
118+
"""
119+
export_path = platform_path + "/export"
120+
svg_names = []
121+
if os.path.isfile(export_path + "/logo.svg"):
122+
svg_names.append("logo")
123+
if os.path.isfile(export_path + "/run_icon.svg"):
124+
svg_names.append("run_icon")
125+
126+
for name in svg_names:
127+
svgf = open(export_path + "/" + name + ".svg", "rb")
128+
b = svgf.read(1)
129+
svg_str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n"
130+
svg_str += " static const char *_" + platform_name + "_" + name + '_svg = "'
131+
while len(b) == 1:
132+
svg_str += "\\" + hex(ord(b))[1:]
133+
b = svgf.read(1)
134+
135+
svg_str += '";\n'
136+
137+
svgf.close()
138+
139+
# NOTE: It is safe to generate this file here, since this is still executed serially.
140+
wf = export_path + "/" + name + "_svg.gen.h"
141+
with open(wf, "w") as svgw:
142+
svgw.write(svg_str)

0 commit comments

Comments
 (0)