Skip to content

Commit 033b171

Browse files
committed
ENH: itkexpat: restore local edits after fresh import
Manufacture a merge commit with the second parent pointing at the commit before the old import was removed so that `git blame` can follow the edited lines back through their original history.
2 parents b5ed6af + b12ac06 commit 033b171

File tree

3 files changed

+233
-2
lines changed

3 files changed

+233
-2
lines changed

Modules/ThirdParty/Expat/src/itkexpat/CMakeLists.txt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,21 @@
3737

3838
cmake_minimum_required(VERSION 3.15.0)
3939

40+
if (0) # ITK --start
4041
project(expat
4142
VERSION
4243
2.7.2
4344
LANGUAGES
4445
C
4546
)
47+
else()
48+
project(ITK3P_EXPAT
49+
VERSION
50+
2.7.2
51+
LANGUAGES
52+
C
53+
)
54+
endif() # ITK --stop
4655
set(CMAKE_C_STANDARD 99)
4756
set(CMAKE_C_STANDARD_REQUIRED ON)
4857
set(CMAKE_C_EXTENSIONS OFF) # i.e. -std=c99 rather than default -std=gnu99
@@ -79,11 +88,21 @@ if(MSVC)
7988
else()
8089
set(_EXPAT_BUILD_PKGCONFIG_DEFAULT ON)
8190
endif()
91+
#[[ # ITK --replace
8292
if(DEFINED BUILD_SHARED_LIBS)
8393
set(_EXPAT_SHARED_LIBS_DEFAULT ${BUILD_SHARED_LIBS})
8494
else()
8595
set(_EXPAT_SHARED_LIBS_DEFAULT ON)
8696
endif()
97+
#]]
98+
# ITK --start
99+
# To match previous behavior prior to synchronizing with expat 2.7.2,
100+
# only static builds of expat internal to ITK are supported.
101+
set(_EXPAT_SHARED_LIBS_DEFAULT OFF)
102+
set(EXPAT_SHARED_LIBS OFF CACHE BOOL "build a shared expat library" FORCE )
103+
# set(_EXPAT_SHARED_LIBS_DEFAULT ${ITK_BUILD_SHARED_LIBS})
104+
# set(EXPAT_SHARED_LIBS ${_EXPAT_SHARED_LIBS_DEFAULT} CACHE BOOL "build a shared expat library" FORCE )
105+
# ITK --end
87106
if(NOT CMAKE_BUILD_TYPE)
88107
set(CMAKE_BUILD_TYPE NoConfig) # so that accessing EXPAT_*_POSTFIX will be waterproof
89108
endif()
@@ -162,7 +181,12 @@ mark_as_advanced(EXPAT_LARGE_SIZE)
162181
expat_shy_set(EXPAT_MIN_SIZE OFF CACHE BOOL "Get a smaller (but slower) parser (in particular avoid multiple copies of the tokenizer)")
163182
mark_as_advanced(EXPAT_MIN_SIZE)
164183
if(MSVC OR _EXPAT_HELP)
184+
#[[ ITK --replace
165185
expat_shy_set(EXPAT_MSVC_STATIC_CRT OFF CACHE BOOL "Use /MT flag (static CRT) when compiling in MSVC")
186+
#]]
187+
# ITK --start
188+
expat_shy_set(EXPAT_MSVC_STATIC_CRT ${ITK_MSVC_STATIC_RUNTIME_LIBRARY} CACHE INTERNAL "Use /MT flag (static CRT) when compiling in MSVC")
189+
# ITK --stop
166190
endif()
167191
if(NOT _EXPAT_HELP)
168192
expat_shy_set(_EXPAT_M32 OFF CACHE BOOL "(Unofficial!) Produce 32bit code with -m32")
@@ -310,9 +334,18 @@ macro(expat_install)
310334
endif()
311335
endmacro()
312336

337+
#[[
313338
configure_file(expat_config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h")
314339
expat_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
340+
#]]
341+
#ITK --start
342+
configure_file(expat_config.h.cmake "${ITK3P_EXPAT_BINARY_DIR}/expat_config.h")
315343

344+
set(MANGLE_PREFIX itk_expat)
345+
configure_file(itk_expat_mangle.h.in
346+
"${ITK3P_EXPAT_BINARY_DIR}/itk_expat_mangle.h"
347+
@ONLY)
348+
# ITK --stop
316349

317350
set(EXTRA_COMPILE_FLAGS)
318351
if(FLAG_NO_STRICT_ALIASING)
@@ -373,7 +406,14 @@ if(_EXPAT_M32 AND NOT MSVC)
373406
endforeach()
374407
endif()
375408

409+
if(0) # ITK --start
376410
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib)
411+
else()
412+
include_regular_expression("^(expat|xml|ascii|utf|name|iascii|latin|itk).*$")
413+
414+
include_directories(BEFORE ${ITK3P_EXPAT_SOURCE_DIR})
415+
include_directories(BEFORE ${ITK3P_EXPAT_BINARY_DIR})
416+
endif() # ITK --stop
377417
if(MSVC)
378418
add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4996)
379419
endif()
@@ -392,6 +432,7 @@ set(_EXPAT_C_SOURCES
392432

393433
if(EXPAT_SHARED_LIBS)
394434
set(_SHARED SHARED)
435+
#[[ ITK --start ITK does not use the .def file for MSVC
395436
if(WIN32)
396437
macro(_expat_def_file_toggle source_var target_var)
397438
if(${source_var})
@@ -418,10 +459,12 @@ if(EXPAT_SHARED_LIBS)
418459
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/win32/version.rc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/win32/version.rc")
419460
set(_EXPAT_EXTRA_SOURCES ${_EXPAT_EXTRA_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/win32/version.rc")
420461
endif()
462+
#]] # ITK --stop
421463
else()
422464
set(_SHARED STATIC)
423465
endif()
424466

467+
#[[ ITK --replace
425468
add_library(expat ${_SHARED} ${_EXPAT_C_SOURCES} ${_EXPAT_EXTRA_SOURCES})
426469
add_library(expat::expat ALIAS expat)
427470
if(_EXPAT_LIBM_FOUND)
@@ -431,6 +474,42 @@ if(EXPAT_WITH_LIBBSD)
431474
target_link_libraries(expat ${LIB_BSD})
432475
endif()
433476
477+
#]]
478+
# ITK -start
479+
add_library(ITKEXPAT ${_SHARED} ${_EXPAT_C_SOURCES})
480+
if(_EXPAT_LIBM_FOUND)
481+
target_link_libraries(ITKEXPAT m)
482+
endif()
483+
if(EXPAT_WITH_LIBBSD)
484+
target_link_libraries(ITKEXPAT ${LIB_BSD})
485+
endif()
486+
#ITK --stop
487+
# ITK --start
488+
# Apply user-defined properties to the library target.
489+
if(ITK_LIBRARY_PROPERTIES)
490+
set_target_properties(ITKEXPAT PROPERTIES ${ITK_LIBRARY_PROPERTIES})
491+
endif()
492+
if(NOT EXPAT_SHARED_LIBS)
493+
target_compile_definitions(ITKEXPAT PUBLIC -DXML_STATIC)
494+
endif()
495+
496+
install(TARGETS ITKEXPAT
497+
EXPORT ${ITK3P_INSTALL_EXPORT_NAME}
498+
RUNTIME DESTINATION ${ITK3P_INSTALL_RUNTIME_DIR} COMPONENT RuntimeLibraries
499+
LIBRARY DESTINATION ${ITK3P_INSTALL_LIBRARY_DIR} COMPONENT RuntimeLibraries
500+
ARCHIVE DESTINATION ${ITK3P_INSTALL_ARCHIVE_DIR} COMPONENT Development
501+
)
502+
503+
install(FILES
504+
${ITK3P_EXPAT_BINARY_DIR}/itk_expat_mangle.h
505+
${ITK3P_EXPAT_BINARY_DIR}/expat_config.h
506+
${ITK3P_EXPAT_SOURCE_DIR}/lib/expat.h
507+
${ITK3P_EXPAT_SOURCE_DIR}/lib/expat_external.h
508+
DESTINATION ${ITK3P_INSTALL_INCLUDE_DIR} # TODO: itk_expat.h #include "itkexpat/expat.h"
509+
COMPONENT Development)
510+
# ITK --stop
511+
512+
#[[ ITK --start the rest of configuation is not used in ITK, but here to minimize diff with upstream
434513
#
435514
# Library filename postfix
436515
#
@@ -1028,3 +1107,4 @@ if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
10281107
message(STATUS "")
10291108
endif()
10301109
message(STATUS "===========================================================================")
1110+
#]]
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*=========================================================================
2+
*
3+
* Copyright NumFOCUS
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*=========================================================================*/
18+
#ifndef itk_expat_mangle_h
19+
#define itk_expat_mangle_h
20+
21+
/*
22+
23+
This header file mangles all symbols exported from the expat library.
24+
It is included in all files while building the expat library. Due to
25+
namespace pollution, no expat headers should be included in .h files in
26+
ITK.
27+
28+
The following command was used to obtain the symbol list:
29+
30+
nm libITKEXPAT-5.3.a | grep " [TRD] " | awk '{ print $3 }' | sort -df | awk '{ print "#define "$1" @MANGLE_PREFIX@_ "$1 }'
31+
32+
*/
33+
34+
#define g_reparseDeferralEnabledDefault @MANGLE_PREFIX@_g_reparseDeferralEnabledDefault
35+
#define _INTERNAL_trim_to_complete_utf8_characters @MANGLE_PREFIX@__INTERNAL_trim_to_complete_utf8_characters
36+
#define testingAccountingGetCountBytesDirect @MANGLE_PREFIX@_testingAccountingGetCountBytesDirect
37+
#define testingAccountingGetCountBytesIndirect @MANGLE_PREFIX@_testingAccountingGetCountBytesIndirect
38+
#define unsignedCharToPrintable @MANGLE_PREFIX@_unsignedCharToPrintable
39+
#define XML_DefaultCurrent @MANGLE_PREFIX@_XML_DefaultCurrent
40+
#define XML_ErrorString @MANGLE_PREFIX@_XML_ErrorString
41+
#define XML_ExpatVersionInfo @MANGLE_PREFIX@_XML_ExpatVersionInfo
42+
#define XML_ExpatVersion @MANGLE_PREFIX@_XML_ExpatVersion
43+
#define XML_ExpatVersionInfo @MANGLE_PREFIX@_XML_ExpatVersionInfo
44+
#define XML_ExternalEntityParserCreate @MANGLE_PREFIX@_XML_ExternalEntityParserCreate
45+
#define XML_FreeContentModel @MANGLE_PREFIX@_XML_FreeContentModel
46+
#define XML_GetBase @MANGLE_PREFIX@_XML_GetBase
47+
#define XML_GetBuffer @MANGLE_PREFIX@_XML_GetBuffer
48+
#define XML_GetCurrentByteCount @MANGLE_PREFIX@_XML_GetCurrentByteCount
49+
#define XML_GetCurrentByteIndex @MANGLE_PREFIX@_XML_GetCurrentByteIndex
50+
#define XML_GetCurrentColumnNumber @MANGLE_PREFIX@_XML_GetCurrentColumnNumber
51+
#define XML_GetCurrentLineNumber @MANGLE_PREFIX@_XML_GetCurrentLineNumber
52+
#define XML_GetErrorCode @MANGLE_PREFIX@_XML_GetErrorCode
53+
#define XML_GetFeatureList @MANGLE_PREFIX@_XML_GetFeatureList
54+
#define XML_GetIdAttributeIndex @MANGLE_PREFIX@_XML_GetIdAttributeIndex
55+
#define XML_GetInputContext @MANGLE_PREFIX@_XML_GetInputContext
56+
#define XML_GetParsingStatus @MANGLE_PREFIX@_XML_GetParsingStatus
57+
#define XML_GetSpecifiedAttributeCount @MANGLE_PREFIX@_XML_GetSpecifiedAttributeCount
58+
#define XmlGetUtf16InternalEncoding @MANGLE_PREFIX@_XmlGetUtf16InternalEncoding
59+
#define XmlGetUtf16InternalEncodingNS @MANGLE_PREFIX@_XmlGetUtf16InternalEncodingNS
60+
#define XmlGetUtf8InternalEncoding @MANGLE_PREFIX@_XmlGetUtf8InternalEncoding
61+
#define XmlGetUtf8InternalEncodingNS @MANGLE_PREFIX@_XmlGetUtf8InternalEncodingNS
62+
#define XmlInitEncoding @MANGLE_PREFIX@_XmlInitEncoding
63+
#define XmlInitEncodingNS @MANGLE_PREFIX@_XmlInitEncodingNS
64+
#define XmlInitUnknownEncoding @MANGLE_PREFIX@_XmlInitUnknownEncoding
65+
#define XmlInitUnknownEncodingNS @MANGLE_PREFIX@_XmlInitUnknownEncodingNS
66+
#define XML_MemFree @MANGLE_PREFIX@_XML_MemFree
67+
#define XML_MemMalloc @MANGLE_PREFIX@_XML_MemMalloc
68+
#define XML_MemRealloc @MANGLE_PREFIX@_XML_MemRealloc
69+
#define XML_ParseBuffer @MANGLE_PREFIX@_XML_ParseBuffer
70+
#define XML_Parse @MANGLE_PREFIX@_XML_Parse
71+
#define XML_ParseBuffer @MANGLE_PREFIX@_XML_ParseBuffer
72+
#define XML_ParserCreate @MANGLE_PREFIX@_XML_ParserCreate
73+
#define XML_ParserCreate_MM @MANGLE_PREFIX@_XML_ParserCreate_MM
74+
#define XML_ParserCreateNS @MANGLE_PREFIX@_XML_ParserCreateNS
75+
#define XML_ParserFree @MANGLE_PREFIX@_XML_ParserFree
76+
#define XML_ParserReset @MANGLE_PREFIX@_XML_ParserReset
77+
#define XmlParseXmlDecl @MANGLE_PREFIX@_XmlParseXmlDecl
78+
#define XmlParseXmlDeclNS @MANGLE_PREFIX@_XmlParseXmlDeclNS
79+
#define XmlPrologStateInitExternalEntity @MANGLE_PREFIX@_XmlPrologStateInitExternalEntity
80+
#define XmlPrologStateInit @MANGLE_PREFIX@_XmlPrologStateInit
81+
#define XmlPrologStateInitExternalEntity @MANGLE_PREFIX@_XmlPrologStateInitExternalEntity
82+
#define XML_ResumeParser @MANGLE_PREFIX@_XML_ResumeParser
83+
#define XML_SetAllocTrackerActivationThreshold @MANGLE_PREFIX@_XML_SetAllocTrackerActivationThreshold
84+
#define XML_SetAllocTrackerMaximumAmplification @MANGLE_PREFIX@_XML_SetAllocTrackerMaximumAmplification
85+
#define XML_SetAttlistDeclHandler @MANGLE_PREFIX@_XML_SetAttlistDeclHandler
86+
#define XML_SetBase @MANGLE_PREFIX@_XML_SetBase
87+
#define XML_SetBillionLaughsAttackProtectionActivationThreshold @MANGLE_PREFIX@_XML_SetBillionLaughsAttackProtectionActivationThreshold
88+
#define XML_SetBillionLaughsAttackProtectionMaximumAmplification @MANGLE_PREFIX@_XML_SetBillionLaughsAttackProtectionMaximumAmplification
89+
#define XML_SetCdataSectionHandler @MANGLE_PREFIX@_XML_SetCdataSectionHandler
90+
#define XML_SetCharacterDataHandler @MANGLE_PREFIX@_XML_SetCharacterDataHandler
91+
#define XML_SetCommentHandler @MANGLE_PREFIX@_XML_SetCommentHandler
92+
#define XML_SetDefaultHandlerExpand @MANGLE_PREFIX@_XML_SetDefaultHandlerExpand
93+
#define XML_SetDefaultHandler @MANGLE_PREFIX@_XML_SetDefaultHandler
94+
#define XML_SetDefaultHandlerExpand @MANGLE_PREFIX@_XML_SetDefaultHandlerExpand
95+
#define XML_SetDoctypeDeclHandler @MANGLE_PREFIX@_XML_SetDoctypeDeclHandler
96+
#define XML_SetElementDeclHandler @MANGLE_PREFIX@_XML_SetElementDeclHandler
97+
#define XML_SetElementHandler @MANGLE_PREFIX@_XML_SetElementHandler
98+
#define XML_SetEncoding @MANGLE_PREFIX@_XML_SetEncoding
99+
#define XML_SetEndCdataSectionHandler @MANGLE_PREFIX@_XML_SetEndCdataSectionHandler
100+
#define XML_SetEndDoctypeDeclHandler @MANGLE_PREFIX@_XML_SetEndDoctypeDeclHandler
101+
#define XML_SetEndElementHandler @MANGLE_PREFIX@_XML_SetEndElementHandler
102+
#define XML_SetEndNamespaceDeclHandler @MANGLE_PREFIX@_XML_SetEndNamespaceDeclHandler
103+
#define XML_SetEntityDeclHandler @MANGLE_PREFIX@_XML_SetEntityDeclHandler
104+
#define XML_SetExternalEntityRefHandlerArg @MANGLE_PREFIX@_XML_SetExternalEntityRefHandlerArg
105+
#define XML_SetExternalEntityRefHandler @MANGLE_PREFIX@_XML_SetExternalEntityRefHandler
106+
#define XML_SetExternalEntityRefHandlerArg @MANGLE_PREFIX@_XML_SetExternalEntityRefHandlerArg
107+
#define XML_SetHashSalt @MANGLE_PREFIX@_XML_SetHashSalt
108+
#define XML_SetNamespaceDeclHandler @MANGLE_PREFIX@_XML_SetNamespaceDeclHandler
109+
#define XML_SetNotationDeclHandler @MANGLE_PREFIX@_XML_SetNotationDeclHandler
110+
#define XML_SetNotStandaloneHandler @MANGLE_PREFIX@_XML_SetNotStandaloneHandler
111+
#define XML_SetParamEntityParsing @MANGLE_PREFIX@_XML_SetParamEntityParsing
112+
#define XML_SetProcessingInstructionHandler @MANGLE_PREFIX@_XML_SetProcessingInstructionHandler
113+
#define XML_SetReparseDeferralEnabled @MANGLE_PREFIX@_XML_SetReparseDeferralEnabled
114+
#define XML_SetReturnNSTriplet @MANGLE_PREFIX@_XML_SetReturnNSTriplet
115+
#define XML_SetSkippedEntityHandler @MANGLE_PREFIX@_XML_SetSkippedEntityHandler
116+
#define XML_SetStartCdataSectionHandler @MANGLE_PREFIX@_XML_SetStartCdataSectionHandler
117+
#define XML_SetStartDoctypeDeclHandler @MANGLE_PREFIX@_XML_SetStartDoctypeDeclHandler
118+
#define XML_SetStartElementHandler @MANGLE_PREFIX@_XML_SetStartElementHandler
119+
#define XML_SetStartNamespaceDeclHandler @MANGLE_PREFIX@_XML_SetStartNamespaceDeclHandler
120+
#define XML_SetUnknownEncodingHandler @MANGLE_PREFIX@_XML_SetUnknownEncodingHandler
121+
#define XML_SetUnparsedEntityDeclHandler @MANGLE_PREFIX@_XML_SetUnparsedEntityDeclHandler
122+
#define XML_SetUserData @MANGLE_PREFIX@_XML_SetUserData
123+
#define XML_SetXmlDeclHandler @MANGLE_PREFIX@_XML_SetXmlDeclHandler
124+
#define XmlSizeOfUnknownEncoding @MANGLE_PREFIX@_XmlSizeOfUnknownEncoding
125+
#define XML_StopParser @MANGLE_PREFIX@_XML_StopParser
126+
#define XML_UseForeignDTD @MANGLE_PREFIX@_XML_UseForeignDTD
127+
#define XML_UseParserAsHandlerArg @MANGLE_PREFIX@_XML_UseParserAsHandlerArg
128+
#define XmlUtf16Encode @MANGLE_PREFIX@_XmlUtf16Encode
129+
#define XmlUtf8Encode @MANGLE_PREFIX@_XmlUtf8Encode
130+
#endif /* itk_expat_mangle_h */

Modules/ThirdParty/Expat/src/itkexpat/lib/expat_external.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
#ifndef Expat_External_INCLUDED
4141
# define Expat_External_INCLUDED 1
4242

43+
// ITK --start override with ITK import/export conventions
44+
// Inserted code for ITK support
45+
// upstream expat uses a .def file for visual studio to define exported
46+
// symbols. ITK uses a paradigm that is used throughout ITK codebase
47+
// to accomplish exporting symbols.
48+
# include "itk_expat_mangle.h"
49+
// ITK --stop
50+
4351
/* External API definitions */
4452

4553
/* Expat tries very hard to make the API boundary very specifically
@@ -92,7 +100,6 @@
92100
&& ! defined(__CYGWIN__)
93101
# define XMLIMPORT __declspec(dllimport)
94102
# endif
95-
96103
# endif
97104
# endif /* not defined XML_STATIC */
98105

@@ -101,7 +108,20 @@
101108
# endif
102109

103110
# if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
111+
// ITK --start
112+
# if ! defined(XML_STATIC) && defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) \
113+
&& ! defined(__CYGWIN__) && defined(ITKEXPAT_EXPORTS)
114+
# define XMLIMPORT __declspec( dllexport )
115+
# else
116+
# if defined(XML_STATIC)
117+
# define XMLIMPORT
118+
# else
119+
// ITK --stop
104120
# define XMLIMPORT __attribute__((visibility("default")))
121+
//ITK --start
122+
# endif
123+
# endif
124+
// ITK --stop
105125
# endif
106126

107127
/* If we didn't define it above, define it away: */
@@ -116,7 +136,8 @@
116136
# define XML_ATTR_MALLOC
117137
# endif
118138

119-
# if defined(__GNUC__) \
139+
140+
# if defined(__GNUC__) \
120141
&& ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
121142
# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
122143
# else

0 commit comments

Comments
 (0)