Skip to content

Commit 24ac9e0

Browse files
committed
deprecation: ensure we GIT_EXTERN deprecated funcs
Although the error functions were deprecated, we did not properly mark them as deprecated. We need to include the `deprecated.h` file in order to ensure that the functions get their export attributes. Similarly, do not define `GIT_DEPRECATE_HARD` within the library, or those functions will also not get their export attributes. Define that only on the tests and examples.
1 parent e191637 commit 24ac9e0

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${
105105
FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION [0-9]+$")
106106
STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}")
107107

108-
# Ensure that we do not use deprecated functions internally
109-
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
110-
111108
# Platform specific compilation flags
112109
IF (MSVC)
113110
IF (STDCALL)

examples/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ FILE(GLOB_RECURSE SRC_EXAMPLE_GIT2 network/*.c network/*.h common.?)
55
ADD_EXECUTABLE(cgit2 ${SRC_EXAMPLE_GIT2})
66
SET_TARGET_PROPERTIES(cgit2 PROPERTIES C_STANDARD 90)
77

8+
# Ensure that we do not use deprecated functions internally
9+
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
10+
811
IF(WIN32 OR ANDROID)
912
TARGET_LINK_LIBRARIES(cgit2 git2)
1013
ELSE()

src/common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
#include "thread-utils.h"
8080
#include "integer.h"
8181

82+
/*
83+
* Include the declarations for deprecated functions; this ensures
84+
* that they're decorated with the proper extern/visibility attributes.
85+
*/
86+
#include "git2/deprecated.h"
87+
8288
#include <regex.h>
8389

8490
#define DEFAULT_BUFSIZE 65536

tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ ADD_DEFINITIONS(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
1111
ADD_DEFINITIONS(-DCLAR_TMPDIR=\"libgit2_tests\")
1212
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
1313

14+
# Ensure that we do not use deprecated functions internally
15+
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
16+
1417
INCLUDE_DIRECTORIES(${CLAR_PATH} ${libgit2_BINARY_DIR}/src)
1518
FILE(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h)
1619
SET(SRC_CLAR "main.c" "clar_libgit2.c" "clar_libgit2_trace.c" "clar_libgit2_timer.c" "clar.c")

0 commit comments

Comments
 (0)