Skip to content

Commit f5e4f95

Browse files
[Scons] Added the ability to change the visibility of symbols
1 parent 6fd4e15 commit f5e4f95

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tools/godotcpp.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ def options(opts, env):
189189
)
190190
)
191191

192+
opts.Add(
193+
EnumVariable(
194+
key="symbols_visibility",
195+
help="Symbols visibility on GNU platforms. Use 'auto' to apply the default value.",
196+
default=env.get("symbols_visibility", "hidden"),
197+
allowed_values=["auto", "visible", "hidden"],
198+
)
199+
)
200+
192201
# Add platform options
193202
for pl in platforms:
194203
tool = Tool(pl, toolpath=["tools"])
@@ -269,6 +278,14 @@ def generate(env):
269278
elif env.get("is_msvc", False):
270279
env.Append(CXXFLAGS=["/EHsc"])
271280

281+
if not env.get("is_msvc", False):
282+
if env["symbols_visibility"] == "visible":
283+
env.Append(CCFLAGS=["-fvisibility=default"])
284+
env.Append(LINKFLAGS=["-fvisibility=default"])
285+
elif env["symbols_visibility"] == "hidden":
286+
env.Append(CCFLAGS=["-fvisibility=hidden"])
287+
env.Append(LINKFLAGS=["-fvisibility=hidden"])
288+
272289
# Require C++17
273290
if env.get("is_msvc", False):
274291
env.Append(CXXFLAGS=["/std:c++17"])

0 commit comments

Comments
 (0)