Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 45f4c1d

Browse filesBrowse files
Version the native library (#127)
Use LibZipSharp MAJOR.MINOR version in the native library name. This is to avoid issues when two or more versions of the LibZipSharp nuget are found and their native libraries have the same name but different ABI, which can result in runtime problems when a function expected by the managed code is not found in the native library. From this point on, whenever any function is added or removed in the native library, at least the MINOR version number must be bumped. More serious ABI changes will require also MAJOR version number bump. Co-authored-by: Dean Ellis <dellis1972@googlemail.com>
1 parent d5499c2 commit 45f4c1d
Copy full SHA for 45f4c1d

File tree

Expand file treeCollapse file tree

12 files changed

+284
-102
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

12 files changed

+284
-102
lines changed
Open diff view settings
Collapse file

‎CMakeLists.txt‎

Copy file name to clipboardExpand all lines: CMakeLists.txt
+37-6Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ endif()
7373
#
7474
# Read product version
7575
#
76-
file(STRINGS "LibZipSharp.props" LZS_PRODUCT_VERSION_XML REGEX "^[ \t]*<_LibZipSharpAssemblyVersion>(.*)</_LibZipSharpAssemblyVersion>")
77-
string(REGEX REPLACE "^[ \t]*<_LibZipSharpAssemblyVersion>([0-9.]+).*</_LibZipSharpAssemblyVersion>" "\\1" LZS_VERSION "${LZS_PRODUCT_VERSION_XML}")
76+
file(STRINGS "LibZipSharp.props" LZS_PRODUCT_VERSION_XML_MAJOR REGEX "^[ \t]*<_LibZipSharpAssemblyVersionMajor>(.*)</_LibZipSharpAssemblyVersionMajor>")
77+
file(STRINGS "LibZipSharp.props" LZS_PRODUCT_VERSION_XML_MINOR REGEX "^[ \t]*<_LibZipSharpAssemblyVersionMinor>(.*)</_LibZipSharpAssemblyVersionMinor>")
78+
file(STRINGS "LibZipSharp.props" LZS_PRODUCT_VERSION_XML_PATCH REGEX "^[ \t]*<_LibZipSharpAssemblyVersionPatch>(.*)</_LibZipSharpAssemblyVersionPatch>")
79+
80+
string(REGEX REPLACE "^[ \t]*<_LibZipSharpAssemblyVersionMajor>([0-9.]+).*</_LibZipSharpAssemblyVersionMajor>" "\\1" LZS_VERSION_MAJOR "${LZS_PRODUCT_VERSION_XML_MAJOR}")
81+
string(REGEX REPLACE "^[ \t]*<_LibZipSharpAssemblyVersionMinor>([0-9.]+).*</_LibZipSharpAssemblyVersionMinor>" "\\1" LZS_VERSION_MINOR "${LZS_PRODUCT_VERSION_XML_MINOR}")
82+
string(REGEX REPLACE "^[ \t]*<_LibZipSharpAssemblyVersionPatch>([0-9.]+).*</_LibZipSharpAssemblyVersionPatch>" "\\1" LZS_VERSION_PATCH "${LZS_PRODUCT_VERSION_XML_PATCH}")
83+
84+
set(LZS_VERSION "${LZS_VERSION_MAJOR}.${LZS_VERSION_MINOR}.${LZS_VERSION_PATCH}")
7885

7986
if(WIN32)
8087
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "Statically link MSVC runtime library")
@@ -516,17 +523,31 @@ else()
516523
${LZS_CXX_FLAGS}
517524
)
518525

526+
set(LT_VERSION "${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}")
527+
set(LT_VERSION_SHORT "${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}")
528+
set(LT_RELEASE "${CMAKE_PROJECT_VERSION_MAJOR}-${CMAKE_PROJECT_VERSION_MINOR}")
529+
set(NATIVE_LIB_OUTPUT_NAME "${PROJECT_NAME}-${LT_RELEASE}")
530+
519531
if(APPLE)
520532
set_target_properties(
521533
${PROJECT_NAME}
522534
PROPERTIES
523535
OSX_ARCHITECTURES "${LZS_OSX_ARCHITECTURES}"
524-
)
536+
OUTPUT_NAME "${NATIVE_LIB_OUTPUT_NAME}"
537+
)
538+
elseif(UNIX)
539+
set_target_properties(
540+
${PROJECT_NAME}
541+
PROPERTIES
542+
VERSION ${LT_VERSION}
543+
SOVERSION ${LT_RELEASE}
544+
OUTPUT_NAME "${NATIVE_LIB_OUTPUT_NAME}"
545+
)
525546
elseif(WIN32)
526547
set_target_properties(
527548
${PROJECT_NAME}
528549
PROPERTIES
529-
OUTPUT_NAME "lib${PROJECT_NAME}"
550+
OUTPUT_NAME "lib${NATIVE_LIB_OUTPUT_NAME}"
530551
)
531552
endif()
532553

@@ -629,7 +650,7 @@ else()
629650
)
630651

631652
#
632-
# Place debug info in separate files, if possible
653+
# Place debug info in separate files, if possible, and get rid of symlinks
633654
#
634655
if(IS_LINUX OR IS_ANDROID)
635656
if(IS_LINUX)
@@ -647,6 +668,16 @@ else()
647668
COMMAND ${OBJCOPY} --only-keep-debug "$<TARGET_FILE_NAME:${PROJECT_NAME}>" "$<TARGET_FILE_NAME:${PROJECT_NAME}>.debug"
648669
COMMAND ${STRIP} --strip-debug --strip-unneeded "$<TARGET_FILE_NAME:${PROJECT_NAME}>"
649670
COMMAND ${OBJCOPY} --add-gnu-debuglink="$<TARGET_FILE_NAME:${PROJECT_NAME}>.debug" "$<TARGET_FILE_NAME:${PROJECT_NAME}>"
650-
)
671+
)
672+
673+
add_custom_command(
674+
TARGET ${PROJECT_NAME}
675+
POST_BUILD
676+
WORKING_DIRECTORY "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
677+
COMMAND rm lib${PROJECT_NAME}-${LT_RELEASE}.so
678+
COMMAND rm lib${PROJECT_NAME}-${LT_RELEASE}.so.${LT_RELEASE}
679+
COMMAND ln lib${PROJECT_NAME}-${LT_RELEASE}.so.${LT_VERSION} lib${PROJECT_NAME}-${LT_RELEASE}.so.${LT_VERSION_SHORT}
680+
COMMAND ln lib${PROJECT_NAME}-${LT_RELEASE}.so.${LT_VERSION} lib${PROJECT_NAME}-${LT_RELEASE}.so
681+
)
651682
endif()
652683
endif()
Collapse file

‎LibZipSharp.UnitTest/LibZipSharp.UnitTest.csproj‎

Copy file name to clipboardExpand all lines: LibZipSharp.UnitTest/LibZipSharp.UnitTest.csproj
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323

2424
<ItemGroup>
2525
<ProjectReference Include="..\LibZipSharp\libZipSharp.csproj" Condition="'$(ReferenceNuget)' != 'True'" />
26-
<None Include="$(_NativeBuildDir)\lib\Darwin\libZipSharpNative.dylib" Condition="'$(ReferenceNuget)' != 'True' And Exists ('$(_NativeBuildDir)\lzsbuild\lib\Darwin\libZipSharpNative.dylib')">
27-
<Link>libZipSharpNative.dylib</Link>
26+
<None Include="$(_NativeBuildDir)\lib\Darwin\$(_NativeLibraryBaseName).dylib" Condition="'$(ReferenceNuget)' != 'True' And Exists ('$(_NativeBuildDir)\lzsbuild\lib\Darwin\$(_NativeLibraryBaseName).dylib')">
27+
<Link>$(_NativeLibraryBaseName).dylib</Link>
2828
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2929
</None>
30-
<None Include="$(_NativeBuildDir)\lib\win64\RelWithDebInfo\libZipSharpNative.dll" Condition="'$(ReferenceNuget)' != 'True' And Exists ('$(_NativeBuildDir)\lib\win64\RelWithDebInfo\libZipSharpNative.dll')">
31-
<Link>libZipSharpNative.dll</Link>
30+
<None Include="$(_NativeBuildDir)\lib\win64\RelWithDebInfo\$(_NativeLibraryBaseName).dll" Condition="'$(ReferenceNuget)' != 'True' And Exists ('$(_NativeBuildDir)\lib\win64\RelWithDebInfo\$(_NativeLibraryBaseName).dll')">
31+
<Link>$(_NativeLibraryBaseName).dll</Link>
3232
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3333
</None>
34-
<None Include="$(_NativeBuildDir)\lib\Linux\libZipSharpNative.so" Condition="'$(ReferenceNuget)' != 'True' And Exists ('$(_NativeBuildDir)\lib\Linux\libZipSharpNative.so')">
35-
<Link>libZipSharpNative.so</Link>
34+
<None Include="$(_NativeBuildDir)\lib\Linux\$(_NativeLibraryBaseName).so" Condition="'$(ReferenceNuget)' != 'True' And Exists ('$(_NativeBuildDir)\lib\Linux\$(_NativeLibraryBaseName).so')">
35+
<Link>$(_NativeLibraryBaseName).so</Link>
3636
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3737
</None>
38-
<None Include="$(_NativeBuildDir)\lib\Linux\libZipSharpNative.so.debug" Condition="'$(ReferenceNuget)' != 'True' And Exists ('$(_NativeBuildDir)\lib\Linux\libZipSharpNative.so.debug')">
39-
<Link>libZipSharpNative.so.debug</Link>
38+
<None Include="$(_NativeBuildDir)\lib\Linux\$(_NativeLibraryBaseName).so.$(_LibZipSharpAssemblyVersionMajor).$(_LibZipSharpAssemblyVersionMinor).$(_LibZipSharpAssemblyVersionPatch).debug" Condition="'$(ReferenceNuget)' != 'True' And Exists ('$(_NativeBuildDir)\lib\Linux\$(_NativeLibraryBaseName).so.$(_LibZipSharpAssemblyVersionMajor).$(_LibZipSharpAssemblyVersionMinor).$(_LibZipSharpAssemblyVersionPatch).debug')">
39+
<Link>$(_NativeLibraryBaseName).so.$(_LibZipSharpAssemblyVersionMajor).$(_LibZipSharpAssemblyVersionMinor).$(_LibZipSharpAssemblyVersionPatch).debug</Link>
4040
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4141
</None>
4242
<None Include="packaged_resources">
Collapse file

‎LibZipSharp.props‎

Copy file name to clipboardExpand all lines: LibZipSharp.props
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<_LibZipSharpAssemblyVersion>3.0.0</_LibZipSharpAssemblyVersion>
3+
<_LibZipSharpAssemblyVersionMajor>3</_LibZipSharpAssemblyVersionMajor>
4+
<_LibZipSharpAssemblyVersionMinor>0</_LibZipSharpAssemblyVersionMinor>
5+
<_LibZipSharpAssemblyVersionPatch>0</_LibZipSharpAssemblyVersionPatch>
6+
<_LibZipSharpAssemblyVersion>$(_LibZipSharpAssemblyVersionMajor).$(_LibZipSharpAssemblyVersionMinor).$(_LibZipSharpAssemblyVersionPatch)</_LibZipSharpAssemblyVersion>
7+
<_NativeLibraryVersionForName>$(_LibZipSharpAssemblyVersionMajor)-$(_LibZipSharpAssemblyVersionMinor)</_NativeLibraryVersionForName>
8+
<_NativeLibraryBaseName>libZipSharpNative-$(_NativeLibraryVersionForName)</_NativeLibraryBaseName>
9+
410
<!--
511
Nuget Version. You can append things like -alpha-1 etc to this value.
612
But always leave the $(_LibZipSharpAssemblyVersion) value at the start.
Collapse file

‎LibZipSharp/Xamarin.LibZipSharp.targets‎ renamed to ‎LibZipSharp/Xamarin.LibZipSharp.targets.in‎

Copy file name to clipboardExpand all lines: LibZipSharp/Xamarin.LibZipSharp.targets.in
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
<LibZipSharpBundleAllNativeLibraries Condition=" '$(LibZipSharpBundleAllNativeLibraries)' == '' ">false</LibZipSharpBundleAllNativeLibraries>
44
</PropertyGroup>
55
<ItemGroup>
6-
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\libZipSharpNative.*">
6+
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\@LibraryBaseFileName@.*">
77
<Link>x64\%(FileName)%(Extension)</Link>
88
</_LibZipNativeLibs>
9-
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-arm64\native\libZipSharpNative.*">
9+
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-arm64\native\@LibraryBaseFileName@.*">
1010
<Link>arm64\%(FileName)%(Extension)</Link>
1111
</_LibZipNativeLibs>
12-
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-x86\native\libZipSharpNative.*">
12+
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-x86\native\@LibraryBaseFileName@.*">
1313
<Link>x86\%(FileName)%(Extension)</Link>
1414
</_LibZipNativeLibs>
15-
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\osx\native\libZipSharpNative.dylib">
15+
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\osx\native\@LibraryBaseFileName@.dylib">
1616
<Link>%(FileName)%(Extension)</Link>
1717
</_LibZipNativeLibs>
18-
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\linux-x64\native\libZipSharpNative.*">
18+
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\linux-x64\native\@LibraryBaseFileName@.so">
19+
<Link>%(FileName)%(Extension)</Link>
20+
</_LibZipNativeLibs>
21+
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\linux-x64\native\@LibraryBaseFileName@.so.@LibraryVersionMajor@.@LibraryVersionMinor@.@LibraryVersionPatch@.debug">
1922
<Link>%(FileName)%(Extension)</Link>
2023
</_LibZipNativeLibs>
2124
<None Include="@(_LibZipNativeLibs)" Condition="'$(LibZipSharpBundleAllNativeLibraries)' == 'True'">
Collapse file
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Xamarin.Tools.Zip
2+
{
3+
static class Constants
4+
{
5+
public const string ZIP_LIBNAME = "@LibraryBaseFileName@";
6+
}
7+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.