Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use upstream repo for libudfread #23

Open
wants to merge 1 commit into
base: externalProject
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,10 @@ ExternalProject_Add(libdvdnav
add_dependency_project_package(libdvdnav 6.0.1)

ExternalProject_Add(libudfread
GIT_REPOSITORY https://github.com/Paxxi/libudfread
GIT_TAG 29fcdb5280e5d1778786795b594ec9fc60bf75da
GIT_REPOSITORY https://code.videolan.org/videolan/libudfread.git
GIT_TAG a35513813819efadca82c4b90edbe1407b1b9e05
GIT_SHALLOW ON
PATCH_COMMAND ${PATCH} -p1 -i ${CMAKE_SOURCE_DIR}/patches/$(TargetName).diff
CMAKE_ARGS
${ADDITIONAL_ARGS}
-DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PREFIX}
Expand Down
222 changes: 222 additions & 0 deletions patches/libudfread.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
diff --git a/.gitignore b/.gitignore
index c3c4ef6..fe10f0d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,10 +23,10 @@
/m4/lt~obsolete.m4
/Makefile
/Makefile.in
-/src/udfread-version.h
/stamp-h1
.dirstamp
.deps
.libs
udfcat
udfls
+build*/
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..1e0d182
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,99 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(libudfread VERSION 1.1.2 LANGUAGES C)
+
+if(MSVC)
+ set(CMAKE_DEBUG_POSTFIX "d")
+endif()
+
+add_library(libudfread STATIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/blockinput.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/default_blockinput.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/default_blockinput.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/ecma167.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/ecma167.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/udfread.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/udfread.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/udfread-version.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/udfread-version.h
+)
+
+set_target_properties(libudfread
+ PROPERTIES
+ COMPILE_PDB_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
+ PDB_NAME libudfread
+ PDB_NAME_DEBUG libudfreadd
+ COMPILE_PDB_NAME libudfread
+ COMPILE_PDB_NAME_DEBUG libudfreadd
+)
+
+target_compile_definitions(libudfread
+ PRIVATE
+ _CRT_SECURE_NO_WARNINGS
+ HAVE_FCNTL_H
+)
+target_link_options(libudfread
+ PRIVATE
+ /INCREMENTAL:NO
+ /debug:full
+)
+if(WINDOWS_STORE)
+ target_compile_definitions(libudfread
+ PRIVATE
+ MS_APP
+ )
+endif()
+target_include_directories(libudfread
+ PRIVATE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
+ INTERFACE
+ $<INSTALL_INTERFACE:include/udfread>
+)
+
+install(FILES
+ ${PROJECT_BINARY_DIR}/RelWithDebInfo/libudfread.pdb
+ DESTINATION lib
+ CONFIGURATIONS RelWithDebInfo
+)
+install(FILES
+ ${PROJECT_BINARY_DIR}/Debug/libudfreadd.pdb
+ DESTINATION lib
+ CONFIGURATIONS Debug
+)
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ ${CMAKE_CURRENT_BINARY_DIR}/libudfread-config-version.cmake
+ VERSION ${libudfread_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
+install(TARGETS libudfread EXPORT libudfread
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+)
+
+
+install(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/udfread-version.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/udfread.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/blockinput.h
+ DESTINATION include/udfread
+)
+
+install(EXPORT libudfread
+ FILE
+ libudfread.cmake
+ NAMESPACE
+ libudfread::
+ DESTINATION
+ lib/cmake/libudfread
+)
+install(
+ FILES
+ cmake/libudfread-config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/libudfread-config-version.cmake
+ DESTINATION
+ lib/cmake/libudfread
+)
diff --git a/cmake/libudfread-config.cmake b/cmake/libudfread-config.cmake
new file mode 100644
index 0000000..f61e7e5
--- /dev/null
+++ b/cmake/libudfread-config.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/libudfread.cmake)
diff --git a/src/default_blockinput.c b/src/default_blockinput.c
index 3926e65..056b5a5 100644
--- a/src/default_blockinput.c
+++ b/src/default_blockinput.c
@@ -54,6 +54,13 @@
# define off_t off64_t
#endif

+#include <stdint.h>
+#if !defined(_SSIZE_T_DEFINED) && !defined(HAVE_SSIZE_T)
+typedef intptr_t ssize_t;
+#define _SSIZE_T_DEFINED
+#endif
+
+
#ifdef _WIN32
static ssize_t pread(int fd, void *buf, size_t count, off_t offset)
{
@@ -113,7 +120,7 @@ static int _def_close(udfread_block_input *p_gen)

if (p) {
if (p->fd >= 0) {
- result = close(p->fd);
+ result = _close(p->fd);
}
free(p);
}
diff --git a/src/udfread-version.h b/src/udfread-version.h
new file mode 100644
index 0000000..3f8ea3a
--- /dev/null
+++ b/src/udfread-version.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of libudfread
+ * Copyright (C) 2014 VLC authors and VideoLAN
+ *
+ * Authors: Petri Hintukainen <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef UDFREAD_VERSION_H_
+#define UDFREAD_VERSION_H_
+
+#define UDFREAD_VERSION_CODE(major, minor, micro) \
+ (((major) * 10000) + \
+ ((minor) * 100) + \
+ ((micro) * 1))
+
+#define UDFREAD_VERSION_MAJOR 1
+#define UDFREAD_VERSION_MINOR 0
+#define UDFREAD_VERSION_MICRO 0
+
+#define UDFREAD_VERSION_STRING "1.0.0"
+
+#define UDFREAD_VERSION \
+ UDFREAD_VERSION_CODE(UDFREAD_VERSION_MAJOR, UDFREAD_VERSION_MINOR, UDFREAD_VERSION_MICRO)
+
+/**
+ * Get library version
+ *
+ */
+void udfread_get_version(int *major, int *minor, int *micro);
+
+#endif /* UDFREAD_VERSION_H_ */
diff --git a/src/udfread.h b/src/udfread.h
index dcce516..a6bac80 100644
--- a/src/udfread.h
+++ b/src/udfread.h
@@ -52,6 +52,10 @@ extern "C" {
typedef struct udfread udfread;

struct udfread_block_input;
+#if !defined(_SSIZE_T_DEFINED) && !defined(HAVE_SSIZE_T)
+typedef intptr_t ssize_t;
+#define _SSIZE_T_DEFINED
+#endif

/**
* Initialize UDF reader