diff --git a/src/_premake_init.lua b/src/_premake_init.lua index b1a77829..12f7e203 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -1366,6 +1366,18 @@ } } + api.register { + name = "visibility", + scope = "config", + kind = "string", + allowed = { + "Default", + "Hidden", + "Internal", + "Protected" + } + } + ----------------------------------------------------------------------------- -- -- Field name aliases for backward compatibility diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index c131f09b..446b1b45 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -171,6 +171,12 @@ }, rtti = { Off = "-fno-rtti" + }, + visibility = { + Default = "-fvisibility=default", + Hidden = "-fvisibility=hidden", + Internal = "-fvisibility=internal", + Protected = "-fvisibility=protected", } } diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index df6ba573..3e495f00 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -320,7 +320,6 @@ test.contains({ "-fno-stack-protector" }, gcc.getcxxflags(cfg)) end - -- -- Check the basic translation of LDFLAGS for a Posix system. -- @@ -836,3 +835,35 @@ test.contains({ "-fno-omit-frame-pointer" }, gcc.getcxxflags(cfg)) test.contains({ "-fno-omit-frame-pointer" }, gcc.getcflags(cfg)) end + +-- +-- Test visibility. +-- + + function suite.cxxflags_onVisibilityDefault() + visibility "Default" + prepare() + test.excludes({ "-fvisibility=default" }, gcc.getcflags(cfg)) + test.contains({ "-fvisibility=default" }, gcc.getcxxflags(cfg)) + end + + function suite.cxxflags_onVisibilityHidden() + visibility "Hidden" + prepare() + test.excludes({ "-fvisibility=hidden" }, gcc.getcflags(cfg)) + test.contains({ "-fvisibility=hidden" }, gcc.getcxxflags(cfg)) + end + + function suite.cxxflags_onVisibilityInternal() + visibility "Internal" + prepare() + test.excludes({ "-fvisibility=internal" }, gcc.getcflags(cfg)) + test.contains({ "-fvisibility=internal" }, gcc.getcxxflags(cfg)) + end + + function suite.cxxflags_onVisibilityProtected() + visibility "Protected" + prepare() + test.excludes({ "-fvisibility=protected" }, gcc.getcflags(cfg)) + test.contains({ "-fvisibility=protected" }, gcc.getcxxflags(cfg)) + end