Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCons: Move platform logo/run icon to export folder #78435

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 = []

Expand All @@ -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
Expand All @@ -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))
Expand Down
27 changes: 0 additions & 27 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,33 +559,6 @@ def mySpawn(sh, escape, cmd, args, env):
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 = {}

Expand Down
4 changes: 0 additions & 4 deletions platform/android/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
from SCons import Environment


def is_active():
return True


def get_name():
return "Android"

Expand Down
4 changes: 2 additions & 2 deletions platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes
File renamed without changes
4 changes: 0 additions & 4 deletions platform/ios/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
from SCons import Environment


def is_active():
return True


def get_name():
return "iOS"

Expand Down
2 changes: 1 addition & 1 deletion platform/ios/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes
4 changes: 0 additions & 4 deletions platform/linuxbsd/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
from SCons import Environment


def is_active():
return True


def get_name():
return "LinuxBSD"

Expand Down
4 changes: 2 additions & 2 deletions platform/linuxbsd/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes
4 changes: 0 additions & 4 deletions platform/macos/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
from SCons import Environment


def is_active():
return True


def get_name():
return "macOS"

Expand Down
4 changes: 2 additions & 2 deletions platform/macos/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines +35 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if there is an argument to be made about putting generated files separately from other includes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be, but I feel the current logic already has a lot of rules and the more we add, the harder it will be to keep consistent.


#include "core/io/image_loader.h"
#include "core/string/translation.h"
Expand Down
File renamed without changes
File renamed without changes
4 changes: 0 additions & 4 deletions platform/uwp/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
from SCons import Environment


def is_active():
return True


def get_name():
return "UWP"

Expand Down
2 changes: 1 addition & 1 deletion platform/uwp/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes
4 changes: 0 additions & 4 deletions platform/web/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
from SCons import Environment


def is_active():
return True


def get_name():
return "Web"

Expand Down
4 changes: 2 additions & 2 deletions platform/web/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes
File renamed without changes
4 changes: 0 additions & 4 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
STACK_SIZE = 8388608


def is_active():
return True


def get_name():
return "Windows"

Expand Down
4 changes: 2 additions & 2 deletions platform/windows/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes
File renamed without changes
30 changes: 30 additions & 0 deletions platform_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)