Skip to content

Commit 65e5ccf

Browse files
Export C++ symbols part 2 (#1953)
* Export C++ symbols part 2 Signed-off-by: Darby Johnston <[email protected]>
1 parent 19d12b8 commit 65e5ccf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+261
-144
lines changed

CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@ if(OTIO_SHARED_LIBS)
109109
else()
110110
message(STATUS "Building static libs")
111111
set(OTIO_SHARED_OR_STATIC_LIB "STATIC")
112-
if (OTIO_PYTHON_INSTALL)
113-
# If we're compiling for pybind, we can hide all our symbols, they'll only be called from pybind
114-
# Note that this has no effect on Windows.
115-
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
116-
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
117-
endif()
118112
endif()
119113

120114
# Set the SO version. The SO version must be incremented every time a change

src/opentime/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
set(OPENTIME_HEADER_FILES
55
errorStatus.h
6+
export.h
67
rationalTime.h
78
stringPrintf.h
89
timeRange.h
@@ -25,13 +26,21 @@ target_include_directories(
2526
set_target_properties(opentime PROPERTIES
2627
DEBUG_POSTFIX "${OTIO_DEBUG_POSTFIX}"
2728
LIBRARY_OUTPUT_NAME "opentime"
28-
POSITION_INDEPENDENT_CODE TRUE
29-
WINDOWS_EXPORT_ALL_SYMBOLS true)
29+
POSITION_INDEPENDENT_CODE TRUE)
3030

3131
if(BUILD_SHARED_LIBS)
3232
set_target_properties(opentime PROPERTIES
3333
SOVERSION ${OTIO_SOVERSION}
3434
VERSION ${OTIO_VERSION})
35+
target_compile_definitions(
36+
opentime
37+
PUBLIC
38+
OPENTIME_EXPORTS)
39+
else()
40+
target_compile_definitions(
41+
opentime
42+
PUBLIC
43+
OPENTIME_STATIC)
3544
endif()
3645

3746
if(APPLE)

src/opentime/errorStatus.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
#pragma once
55

6+
#include "opentime/export.h"
67
#include "opentime/version.h"
78
#include <string>
89

910
namespace opentime { namespace OPENTIME_VERSION {
1011

1112
/// @brief This struct represents the return status of a function.
12-
struct ErrorStatus
13+
struct OPENTIME_API_TYPE ErrorStatus
1314
{
1415
/// @brief This enumeration represents the possible outcomes.
1516
enum Outcome
@@ -47,7 +48,7 @@ struct ErrorStatus
4748
std::string details;
4849

4950
///! @brief Return a human readable string for the given outcome.
50-
static std::string outcome_to_string(Outcome);
51+
static OPENTIME_API std::string outcome_to_string(Outcome);
5152
};
5253

5354
///! @brief Check whether the given ErrorStatus is an error.

src/opentime/export.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright Contributors to the OpenTimelineIO project
3+
4+
#pragma once
5+
6+
// For an explanation of how these export defines work, see:
7+
// https://github.com/PixarAnimationStudios/OpenUSD/blob/dev/pxr/base/arch/export.h
8+
#if defined(_WINDOWS)
9+
# if defined(__GNUC__) && __GNUC__ >= 4 || defined(__clang__)
10+
# define OPENTIMELINIO_EXPORT __attribute__((dllexport))
11+
# define OPENTIMELINIO_IMPORT __attribute__((dllimport))
12+
# define OPENTIMELINIO_HIDDEN
13+
# define OPENTIMELINIO_EXPORT_TYPE
14+
# else
15+
# define OPENTIMELINIO_EXPORT __declspec(dllexport)
16+
# define OPENTIMELINIO_IMPORT __declspec(dllimport)
17+
# define OPENTIMELINIO_HIDDEN
18+
# define OPENTIMELINIO_EXPORT_TYPE
19+
# endif
20+
#elif defined(__GNUC__) && __GNUC__ >= 4 || defined(__clang__)
21+
# define OPENTIMELINIO_EXPORT __attribute__((visibility("default")))
22+
# define OPENTIMELINIO_IMPORT
23+
# define OPENTIMELINIO_HIDDEN __attribute__((visibility("hidden")))
24+
# if defined(__clang__)
25+
# define OPENTIMELINIO_EXPORT_TYPE __attribute__((type_visibility("default")))
26+
# else
27+
# define OPENTIMELINIO_EXPORT_TYPE __attribute__((visibility("default")))
28+
# endif
29+
#else
30+
# define OPENTIMELINIO_EXPORT
31+
# define OPENTIMELINIO_IMPORT
32+
# define OPENTIMELINIO_HIDDEN
33+
# define OPENTIMELINIO_EXPORT_TYPE
34+
#endif
35+
#define OPENTIMELINIO_EXPORT_TEMPLATE(type, ...)
36+
#define OPENTIMELINIO_IMPORT_TEMPLATE(type, ...) \
37+
extern template type OPENTIMELINIO_IMPORT __VA_ARGS__
38+
39+
#if defined(OPENTIME_STATIC)
40+
# define OPENTIME_API
41+
# define OPENTIME_API_TYPE
42+
# define OPENTIME_API_TEMPLATE_CLASS(...)
43+
# define OPENTIME_API_TEMPLATE_STRUCT(...)
44+
# define OPENTIME_LOCAL
45+
#else
46+
# if defined(OPENTIME_EXPORTS)
47+
# define OPENTIME_API OPENTIMELINIO_EXPORT
48+
# define OPENTIME_API_TYPE OPENTIMELINIO_EXPORT_TYPE
49+
# define OPENTIME_API_TEMPLATE_CLASS(...) \
50+
OPENTIMELINIO_EXPORT_TEMPLATE(class, __VA_ARGS__)
51+
# define OPENTIME_API_TEMPLATE_STRUCT(...) \
52+
OPENTIMELINIO_EXPORT_TEMPLATE(struct, __VA_ARGS__)
53+
# else
54+
# define OPENTIME_API OPENTIMELINIO_IMPORT
55+
# define OPENTIME_API_TYPE OPENTIMELINIO_IMPORT_TYPE
56+
# define OPENTIME_API_TEMPLATE_CLASS(...) \
57+
OPENTIMELINIO_IMPORT_TEMPLATE(class, __VA_ARGS__)
58+
# define OPENTIME_API_TEMPLATE_STRUCT(...) \
59+
OPENTIMELINIO_IMPORT_TEMPLATE(struct, __VA_ARGS__)
60+
# endif
61+
# define OPENTIME_LOCAL OPENTIMELINIO_HIDDEN
62+
#endif

src/opentime/rationalTime.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
namespace opentime { namespace OPENTIME_VERSION {
1414

1515
/// @brief This enumeration provides options for drop frame timecode.
16-
enum IsDropFrameRate : int
16+
enum OPENTIME_API_TYPE IsDropFrameRate : int
1717
{
1818
InferFromRate = -1,
1919
ForceNo = 0,
2020
ForceYes = 1,
2121
};
2222

2323
/// @brief This class represents a measure of time defined by a value and rate.
24-
class RationalTime
24+
class OPENTIME_API_TYPE RationalTime
2525
{
2626
public:
2727
/// @brief Construct a new time with an optional value and rate.
@@ -167,17 +167,17 @@ class RationalTime
167167

168168
/// @brief Returns true is the rate is supported by SMPTE timecode.
169169
[[deprecated("Use is_smpte_timecode_rate() instead")]]
170-
static bool is_valid_timecode_rate(double rate);
170+
static OPENTIME_API bool is_valid_timecode_rate(double rate);
171171

172172
/// @brief Returns true is the rate is supported by SMPTE timecode.
173-
static bool is_smpte_timecode_rate(double rate);
173+
static OPENTIME_API bool is_smpte_timecode_rate(double rate);
174174

175175
/// @brief Returns the SMPTE timecode rate nearest to the given rate.
176176
[[deprecated("Use nearest_smpte_timecode_rate() instead")]]
177-
static double nearest_valid_timecode_rate(double rate);
177+
static OPENTIME_API double nearest_valid_timecode_rate(double rate);
178178

179179
/// @brief Returns the SMPTE timecode rate nearest to the given rate.
180-
static double nearest_smpte_timecode_rate(double rate);
180+
static OPENTIME_API double nearest_smpte_timecode_rate(double rate);
181181

182182
/// @brief Convert a frame number and rate into a time.
183183
static constexpr RationalTime
@@ -204,7 +204,7 @@ class RationalTime
204204
/// @param timecode The timecode string.
205205
/// @param rate The timecode rate.
206206
/// @param error_status Optional error status.
207-
static RationalTime from_timecode(
207+
static OPENTIME_API RationalTime from_timecode(
208208
std::string const& timecode,
209209
double rate,
210210
ErrorStatus* error_status = nullptr);
@@ -218,7 +218,7 @@ class RationalTime
218218
/// @param time_string The time string.
219219
/// @param rate The time rate.
220220
/// @param error_status Optional error status.
221-
static RationalTime from_time_string(
221+
static OPENTIME_API RationalTime from_time_string(
222222
std::string const& time_string,
223223
double rate,
224224
ErrorStatus* error_status = nullptr);
@@ -243,7 +243,7 @@ class RationalTime
243243
/// @param rate The timecode rate.
244244
/// @param drop_frame Whether to use drop frame timecode.
245245
/// @param error_status Optional error status.
246-
std::string to_timecode(
246+
OPENTIME_API std::string to_timecode(
247247
double rate,
248248
IsDropFrameRate drop_frame,
249249
ErrorStatus* error_status = nullptr) const;
@@ -259,7 +259,7 @@ class RationalTime
259259
/// @param rate The timecode rate.
260260
/// @param drop_frame Whether to use drop frame timecode.
261261
/// @param error_status Optional error status.
262-
std::string to_nearest_timecode(
262+
OPENTIME_API std::string to_nearest_timecode(
263263
double rate,
264264
IsDropFrameRate drop_frame,
265265
ErrorStatus* error_status = nullptr) const;
@@ -278,7 +278,7 @@ class RationalTime
278278
/// Seconds may have up to microsecond precision.
279279
///
280280
/// @return The time string, which may have a leading negative sign.
281-
std::string to_time_string() const;
281+
OPENTIME_API std::string to_time_string() const;
282282

283283
/// @brief Add a time to this time.
284284
constexpr RationalTime const& operator+=(RationalTime other) noexcept

src/opentime/timeRange.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace opentime { namespace OPENTIME_VERSION {
1616
/// a resolution of half a frame at 192kHz. The value can be changed in the future if
1717
/// necessary, due to higher sampling rates or some other kind of numeric tolerance
1818
/// detected in the library.
19-
constexpr double DEFAULT_EPSILON_s = 1.0 / (2 * 192000.0);
19+
OPENTIME_API constexpr double DEFAULT_EPSILON_s = 1.0 / (2 * 192000.0);
2020

2121
/// @brief This class represents a time range defined by a start time and duration.
2222
///
@@ -27,7 +27,7 @@ constexpr double DEFAULT_EPSILON_s = 1.0 / (2 * 192000.0);
2727
/// The duration on a TimeRange indicates a time range that is inclusive of the
2828
/// start time, and exclusive of the end time. All of the predicates are
2929
/// computed accordingly.
30-
class TimeRange
30+
class OPENTIME_API_TYPE TimeRange
3131
{
3232
public:
3333
/// @brief Construct a new time range with a zero start time and duration.

src/opentime/timeTransform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace opentime { namespace OPENTIME_VERSION {
1212

1313
/// @brief One-dimensional time transform.
14-
class TimeTransform
14+
class OPENTIME_API_TYPE TimeTransform
1515
{
1616
public:
1717
/// @brief Construct a new transform with an optional offset, scale, and rate.

src/opentimelineio/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(OPENTIMELINEIO_HEADER_FILES
1212
algo/editAlgorithm.h
1313
effect.h
1414
errorStatus.h
15+
export.h
1516
externalReference.h
1617
freezeFrame.h
1718
gap.h
@@ -100,13 +101,21 @@ target_link_libraries(opentimelineio
100101
set_target_properties(opentimelineio PROPERTIES
101102
DEBUG_POSTFIX "${OTIO_DEBUG_POSTFIX}"
102103
LIBRARY_OUTPUT_NAME "opentimelineio"
103-
POSITION_INDEPENDENT_CODE TRUE
104-
WINDOWS_EXPORT_ALL_SYMBOLS true)
104+
POSITION_INDEPENDENT_CODE TRUE)
105105

106106
if(BUILD_SHARED_LIBS)
107107
set_target_properties(opentimelineio PROPERTIES
108108
SOVERSION ${OTIO_SOVERSION}
109109
VERSION ${OTIO_VERSION})
110+
target_compile_definitions(
111+
opentimelineio
112+
PUBLIC
113+
OTIO_EXPORTS)
114+
else()
115+
target_compile_definitions(
116+
opentimelineio
117+
PUBLIC
118+
OTIO_STATIC)
110119
endif()
111120

112121
if(APPLE)

src/opentimelineio/algo/editAlgorithm.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ enum class ReferencePoint
3838
//
3939
// If overwrite range starts and ends before A, a gap hole is filled with
4040
// fill_template.
41-
void overwrite(
41+
OTIO_API void overwrite(
4242
Item* item,
4343
Composition* composition,
4444
TimeRange const& range,
@@ -62,7 +62,7 @@ void overwrite(
6262
// If A and B's length is L1 and C's length is L2, the end result is L1 + L2.
6363
// A is split.
6464
//
65-
void insert(
65+
OTIO_API void insert(
6666
Item* const item,
6767
Composition* composition,
6868
RationalTime const& time,
@@ -88,7 +88,7 @@ void insert(
8888
// Fill now-"empty" time with gap or template
8989
// Unless item is meeting a Gap, then, existing Gap's duration will be augmented
9090
//
91-
void trim(
91+
OTIO_API void trim(
9292
Item* item,
9393
RationalTime const& delta_in,
9494
RationalTime const& delta_out,
@@ -101,7 +101,7 @@ void trim(
101101
// ^
102102
// composition = usually a track item.
103103
// time = time to slice at.
104-
void slice(
104+
OTIO_API void slice(
105105
Composition* composition,
106106
RationalTime const& time,
107107
bool const remove_transitions = true,
@@ -119,7 +119,7 @@ void slice(
119119
// Do not affect item duration.
120120
// Do not affect surrounding items.
121121
// Clamp to available_range of media (if available)
122-
void slip(Item* item, RationalTime const& delta);
122+
OTIO_API void slip(Item* item, RationalTime const& delta);
123123

124124
//
125125
// Slide an item start_time by + or -, adjusting the previous item's duration.
@@ -133,7 +133,7 @@ void slip(Item* item, RationalTime const& delta);
133133
//
134134
// If item is the first clip, it does nothing.
135135
//
136-
void slide(Item* item, RationalTime const& delta);
136+
OTIO_API void slide(Item* item, RationalTime const& delta);
137137

138138
//
139139
// Adjust a source_range without affecting any other items.
@@ -146,7 +146,7 @@ void slide(Item* item, RationalTime const& delta);
146146
// will be adjusted by
147147
// delta_out = RationalTime that the item's
148148
// source_range().end_time_exclusive() will be adjusted by
149-
void ripple(
149+
OTIO_API void ripple(
150150
Item* item,
151151
RationalTime const& delta_in,
152152
RationalTime const& delta_out,
@@ -168,7 +168,7 @@ void ripple(
168168
// will be adjusted by
169169
// delta_out = RationalTime that the item's
170170
// source_range().end_time_exclusive() will be adjusted by
171-
void roll(
171+
OTIO_API void roll(
172172
Item* item,
173173
RationalTime const& delta_in,
174174
RationalTime const& delta_out,
@@ -186,7 +186,7 @@ void roll(
186186
// reference_point = For 4 point editing, the reference point dictates what
187187
// transform to use when running the fill.
188188
//
189-
void fill(
189+
OTIO_API void fill(
190190
Item* item,
191191
Composition* track,
192192
RationalTime const& track_time,
@@ -207,7 +207,7 @@ void fill(
207207
//
208208
// if fill is not set, A and B become concatenated, with no fill.
209209
//
210-
void remove(
210+
OTIO_API void remove(
211211
Composition* composition,
212212
RationalTime const& time,
213213
bool const fill = true,

src/opentimelineio/anyDictionary.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#pragma once
55

6+
#include "opentimelineio/export.h"
67
#include "opentimelineio/version.h"
78

89
#include <any>
@@ -24,7 +25,7 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
2425
/// This allows us to hand out iterators that can be aware of mutation and moves
2526
/// and take steps to safe-guard themselves from causing a crash. (Yes, I'm
2627
/// talking to you, Python...)
27-
class AnyDictionary : private std::map<std::string, std::any>
28+
class OTIO_API_TYPE AnyDictionary : private std::map<std::string, std::any>
2829
{
2930
public:
3031
using map::map;

0 commit comments

Comments
 (0)