-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hide symbols for shared libraries
- Loading branch information
1 parent
ba97f7b
commit 3671f9d
Showing
7 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
project(test_hide_symbols) | ||
|
||
include(../../rocbuild.cmake) | ||
|
||
add_library(bar SHARED | ||
../src/bar.h | ||
../src/bar.c | ||
../src/bar_internal.h | ||
../src/bar_internal.c | ||
) | ||
target_include_directories(bar PRIVATE ../src) | ||
target_compile_definitions(bar PRIVATE BAR_EXPORTS) | ||
|
||
if(HIDDEN) | ||
rocbuild_hide_symbols(bar) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include "bar.h" | ||
#include "bar_internal.h" | ||
|
||
int bar() { return 1 + bar_internal(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#ifdef BAR_EXPORTS | ||
# if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) | ||
# define BAR_API __declspec(dllexport) | ||
# elif defined(__GNUC__) && __GNUC__ >= 4 | ||
# define BAR_API __attribute__ ((visibility ("default"))) | ||
# endif | ||
#else | ||
# if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) | ||
# define BAR_API __declspec(dllimport) | ||
# else | ||
# define BAR_API | ||
# endif | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
BAR_API int bar(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "bar_internal.h" | ||
|
||
int bar_internal() | ||
{ | ||
return 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
int bar_internal(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |