[libdwarf] New port (#34382)

* Try to add libdwarf

* Has

* fix

* hash

* fixes

* hash

* Fixes

* bump hash

* zlib fix

* bump hash

* fix

* bump hash

* fixes

* Bump hash

* fix

* bump

* x

* bump

* fix

* bump

* fix

* bump

* fix

* bump

* fix

* bump

* fix

* bump

* Try this

* bump

* cleanup

* bump

* Update patches

* bump hash

* fix whitespace

* bump

* Update usage

* Bump

* Update portfile and patches (#1)

* Re-introduce off_t patch

* Bump

* Fix patch

* Bump

* Usage is now correct

* Bump

* Revert "Usage is now correct"

This reverts commit 54b32d172de8abd916589f781065c87d3afaaaf2.

* Bump

---------

Co-authored-by: Kai Pastor <dg0yt@darc.de>
This commit is contained in:
Jeremy Rifkin 2023-10-31 15:31:57 -04:00 committed by GitHub
parent edd68d8a94
commit 809e93f524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 172 additions and 0 deletions

View File

@ -0,0 +1,46 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e9b75f..fd5fbe3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -195,6 +195,20 @@ check_c_source_compiles([=[
}]=] HAVE_STDAFX_H)
#message(STATUS "Checking have windows stdafx.h... ${HAVE_STDAFX_H}")
+find_package(ZLIB REQUIRED)
+add_library(z ALIAS ZLIB::ZLIB)
+set(HAVE_ZLIB 1)
+set(HAVE_ZLIB_H 1)
+
+find_package(zstd CONFIG REQUIRED)
+if(TARGET zstd::libzstd_shared)
+ add_library(zstd ALIAS zstd::libzstd_shared)
+else()
+ add_library(zstd ALIAS zstd::libzstd_static)
+endif()
+set(HAVE_ZSTD 1)
+set(HAVE_ZSTD_H 1)
+
set(CMAKE_REQUIRED_LIBRARIES z)
check_c_source_compiles( [=[
#include "zlib.h"
diff --git a/src/lib/libdwarf/cmake/libdwarf-config.cmake b/src/lib/libdwarf/cmake/libdwarf-config.cmake
index 604c563..5362360 100644
--- a/src/lib/libdwarf/cmake/libdwarf-config.cmake
+++ b/src/lib/libdwarf/cmake/libdwarf-config.cmake
@@ -1,3 +1,6 @@
+include(CMakeFindDependencyMacro)
+find_dependency(ZLIB)
+find_dependency(zstd CONFIG)
if (NOT TARGET libdwarf::libdwarf)
include(${CMAKE_CURRENT_LIST_DIR}/libdwarf-targets.cmake)
endif()
diff --git a/src/lib/libdwarf/libdwarf.pc.cmake b/src/lib/libdwarf/libdwarf.pc.cmake
index 6b18c77..5c97ce9 100644
--- a/src/lib/libdwarf/libdwarf.pc.cmake
+++ b/src/lib/libdwarf/libdwarf.pc.cmake
@@ -9,4 +9,5 @@ Description: DWARF debug symbols library
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -ldwarf
Cflags: -I${includedir}
+Requires.private: zlib libzstd

View File

@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28076ee..f9795dd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,6 +19,8 @@ endmacro()
set(LIBDWARF_CRT "MD" CACHE STRING "Either MT or MD, specifies whether to use the static or dynamic MSVCRT.")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+ set(LIBDWARF_CRT ignore)
+elseif(0)
# Use CMAKE_MSVC_RUNTIME in versions 3.15 and up
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15")
cmake_policy(SET CMP0091 NEW)

View File

@ -0,0 +1,24 @@
diff --git a/src/bin/dwarfdump/CMakeLists.txt b/src/bin/dwarfdump/CMakeLists.txt
index 1b8aa3a..c77d2f0 100644
--- a/src/bin/dwarfdump/CMakeLists.txt
+++ b/src/bin/dwarfdump/CMakeLists.txt
@@ -66,7 +66,6 @@ target_compile_options(dwarfdump PRIVATE ${DW_FWALL})
target_link_libraries(dwarfdump PRIVATE ${dwarf-target} ${DW_FZLIB} ${DW_FZSTD} )
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
- set(SUFFIX 64)
endif()
set(LIBDIR lib${SUFFIX})
set(BINDIR bin${SUFFIX})
diff --git a/src/lib/libdwarf/CMakeLists.txt b/src/lib/libdwarf/CMakeLists.txt
index 09908bb..91a1447 100644
--- a/src/lib/libdwarf/CMakeLists.txt
+++ b/src/lib/libdwarf/CMakeLists.txt
@@ -109,7 +109,6 @@ foreach(i RANGE ${targetCount})
set_target_properties(${target} PROPERTIES OUTPUT_NAME dwarf)
- set(SUFFIX $<$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>:64>)
set(LIBDIR lib${SUFFIX})
set(BINDIR bin${SUFFIX})

16
ports/libdwarf/off_t.diff Normal file
View File

@ -0,0 +1,16 @@
diff --git a/src/lib/libdwarf/libdwarf_private.h b/src/lib/libdwarf/libdwarf_private.h
index b37ae994..7fa89256 100644
--- a/src/lib/libdwarf/libdwarf_private.h
+++ b/src/lib/libdwarf/libdwarf_private.h
@@ -26,11 +26,7 @@
#ifdef _MSC_VER /* Macro to select VS compiler */
#include <windows.h>
typedef SSIZE_T ssize_t;
-#ifdef _WIN64
-typedef long long off_t;
-#else
typedef long off_t;
-#endif
#endif /* _MSC_VER */
#ifndef TRUE

View File

@ -0,0 +1,37 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO davea42/libdwarf-code
REF "v${VERSION}"
SHA512 3117c69cc77d5a1189aeb1ea7e74d917dedfb84e9e9e98e3df7fec930f8183d12f55bb12e4871ed3746cdb19a29aba924bc73d6334b23bbb6413a1f4be67d499
HEAD_REF main
PATCHES
dependencies.diff
msvc-runtime.diff
no-suffix.diff
off_t.diff
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_NON_SHARED)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_NON_SHARED=${BUILD_NON_SHARED}
-DBUILD_SHARED=${BUILD_SHARED}
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/libdwarf")
vcpkg_fixup_pkgconfig()
vcpkg_copy_tools(TOOL_NAMES dwarfdump AUTO_CLEAN)
if(BUILD_SHARED)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libdwarf/libdwarf.h" "ifndef LIBDWARF_STATIC" "if 1")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")

4
ports/libdwarf/usage Normal file
View File

@ -0,0 +1,4 @@
libdwarf provides CMake targets:
find_package(libdwarf CONFIG REQUIRED)
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:libdwarf::dwarf-static>,libdwarf::dwarf-static,libdwarf::dwarf-shared>)

19
ports/libdwarf/vcpkg.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "libdwarf",
"version": "0.8.0",
"description": "A library for reading DWARF2 and later DWARF.",
"homepage": "https://github.com/davea42/libdwarf-code",
"license": "LGPL-2.1-only",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib",
"zstd"
]
}

View File

@ -4148,6 +4148,10 @@
"baseline": "0.6.0",
"port-version": 3
},
"libdwarf": {
"baseline": "0.8.0",
"port-version": 0
},
"libe57": {
"baseline": "1.1.332",
"port-version": 4

View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "8aa61f875f55fe903c05d51dc9ce4d0301e4ddbf",
"version": "0.8.0",
"port-version": 0
}
]
}