Merge pull request #1044 from tdesveauxPKFX/visibility-hidden

Add Visibility API for gcc/clang toolsets
This commit is contained in:
J. Perkins 2018-04-17 12:44:36 -04:00 committed by GitHub
commit 2dfa956d2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 1 deletions

View File

@ -1366,6 +1366,18 @@
}
}
api.register {
name = "visibility",
scope = "config",
kind = "string",
allowed = {
"Default",
"Hidden",
"Internal",
"Protected"
}
}
-----------------------------------------------------------------------------
--
-- Field name aliases for backward compatibility

View File

@ -171,6 +171,12 @@
},
rtti = {
Off = "-fno-rtti"
},
visibility = {
Default = "-fvisibility=default",
Hidden = "-fvisibility=hidden",
Internal = "-fvisibility=internal",
Protected = "-fvisibility=protected",
}
}

View File

@ -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