diff --git a/ports/libdwarf/dependencies.diff b/ports/libdwarf/dependencies.diff new file mode 100644 index 0000000000..b172105530 --- /dev/null +++ b/ports/libdwarf/dependencies.diff @@ -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 + diff --git a/ports/libdwarf/msvc-runtime.diff b/ports/libdwarf/msvc-runtime.diff new file mode 100644 index 0000000000..3232921a88 --- /dev/null +++ b/ports/libdwarf/msvc-runtime.diff @@ -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) diff --git a/ports/libdwarf/no-suffix.diff b/ports/libdwarf/no-suffix.diff new file mode 100644 index 0000000000..a9200e2c20 --- /dev/null +++ b/ports/libdwarf/no-suffix.diff @@ -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 $<$:64>) + set(LIBDIR lib${SUFFIX}) + set(BINDIR bin${SUFFIX}) + diff --git a/ports/libdwarf/off_t.diff b/ports/libdwarf/off_t.diff new file mode 100644 index 0000000000..f7338a8316 --- /dev/null +++ b/ports/libdwarf/off_t.diff @@ -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 + typedef SSIZE_T ssize_t; +-#ifdef _WIN64 +-typedef long long off_t; +-#else + typedef long off_t; +-#endif + #endif /* _MSC_VER */ + + #ifndef TRUE diff --git a/ports/libdwarf/portfile.cmake b/ports/libdwarf/portfile.cmake new file mode 100644 index 0000000000..670b957315 --- /dev/null +++ b/ports/libdwarf/portfile.cmake @@ -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") diff --git a/ports/libdwarf/usage b/ports/libdwarf/usage new file mode 100644 index 0000000000..e3dbb4f6fc --- /dev/null +++ b/ports/libdwarf/usage @@ -0,0 +1,4 @@ +libdwarf provides CMake targets: + + find_package(libdwarf CONFIG REQUIRED) + target_link_libraries(main PRIVATE $,libdwarf::dwarf-static,libdwarf::dwarf-shared>) diff --git a/ports/libdwarf/vcpkg.json b/ports/libdwarf/vcpkg.json new file mode 100644 index 0000000000..81b93e5047 --- /dev/null +++ b/ports/libdwarf/vcpkg.json @@ -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" + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index 0d364f91fa..aacb281185 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -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 diff --git a/versions/l-/libdwarf.json b/versions/l-/libdwarf.json new file mode 100644 index 0000000000..8ace935f69 --- /dev/null +++ b/versions/l-/libdwarf.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "8aa61f875f55fe903c05d51dc9ce4d0301e4ddbf", + "version": "0.8.0", + "port-version": 0 + } + ] +}