[rply]new port

This commit is contained in:
Chao Jia 2019-11-19 12:03:20 +01:00
parent 29def6aa63
commit 93c3bb1baf
5 changed files with 412 additions and 0 deletions

63
ports/rply/CMakeLists.txt Normal file
View File

@ -0,0 +1,63 @@
cmake_minimum_required (VERSION 3.14)
project ("rply")
set (target_name ${CMAKE_PROJECT_NAME})
set (target_include_prefix "rply")
option (BUILD_SHARED_LIBS "Create ${target_name} as a shared library" ON)
set (CMAKE_DEBUG_POSTFIX "d" CACHE STRING "postfix for debug lib")
include (GNUInstallDirs)
file (GLOB target_headers "*.h")
file (GLOB target_srcs "*.c" )
add_library (${target_name} ${target_srcs} ${target_headers})
target_include_directories (${target_name}
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if (MSVC)
target_compile_definitions (${target_name} PRIVATE RPLY_BUILD_LIB)
endif ()
if (BUILD_SHARED_LIBS)
target_compile_definitions (${target_name} PUBLIC RPLY_SHARED_LIB)
endif ()
set_target_properties(${target_name} PROPERTIES
C_STANDARD 11
)
if (MSVC)
set_target_properties(${target_name} PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:${target_name}>
)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${target_name})
endif()
message (STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
install (TARGETS ${target_name} EXPORT ${target_name}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install (FILES ${target_headers}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${target_name}"
CONFIGURATIONS Release
)
install (EXPORT ${target_name}-targets
FILE ${target_name}-targets.cmake
NAMESPACE ${target_name}::
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${target_name}"
)
configure_file(${target_name}-config.cmake.in "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${target_name}-config.cmake" @ONLY)
install(FILES
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${target_name}-config.cmake"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${target_name}"
)

3
ports/rply/CONTROL Normal file
View File

@ -0,0 +1,3 @@
Source: rply
Version: 1.1.4
Description: ANSI C Library for PLY file format input and output

View File

@ -0,0 +1,305 @@
diff --git a/rply.h b/rply.h
index 9fa6da9..2e2a0c5 100644
--- a/rply.h
+++ b/rply.h
@@ -1,5 +1,5 @@
-#ifndef RPLY_H
-#define RPLY_H
+#pragma once
+
/* ----------------------------------------------------------------------
* RPly library, read/write PLY files
* Diego Nehab, IMPA
@@ -9,6 +9,19 @@
* at the end of this file.
* ---------------------------------------------------------------------- */
+#ifdef RPLY_SHARED_LIB
+
+#ifdef RPLY_BUILD_LIB
+#define RPLY_DLL_DEF __declspec(dllexport)
+#else
+#define RPLY_DLL_DEF __declspec(dllimport)
+#endif // RPLY_BUILD_LIB
+
+#else
+#define RPLY_DLL_DEF
+#endif // RPLY_SHARED_LIB
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -57,6 +70,8 @@ typedef void (*p_ply_error_cb)(p_ply ply, const char *message);
* ply: handle returned by ply_open or ply_create
* idata,pdata: contextual information set in ply_open or ply_create
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_get_ply_user_data(p_ply ply, void **pdata, long *idata);
/* ----------------------------------------------------------------------
@@ -68,6 +83,8 @@ int ply_get_ply_user_data(p_ply ply, void **pdata, long *idata);
*
* Returns 1 if successful, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
p_ply ply_open(const char *name, p_ply_error_cb error_cb, long idata,
void *pdata);
@@ -78,6 +95,8 @@ p_ply ply_open(const char *name, p_ply_error_cb error_cb, long idata,
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_read_header(p_ply ply);
/* ----------------------------------------------------------------------
@@ -101,6 +120,8 @@ typedef int (*p_ply_read_cb)(p_ply_argument argument);
* Returns 0 if no element or no property in element, returns the
* number of element instances otherwise.
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
long ply_set_read_cb(p_ply ply, const char *element_name,
const char *property_name, p_ply_read_cb read_cb,
void *pdata, long idata);
@@ -115,6 +136,8 @@ long ply_set_read_cb(p_ply ply, const char *element_name,
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_get_argument_element(p_ply_argument argument,
p_ply_element *element, long *instance_index);
@@ -128,6 +151,8 @@ int ply_get_argument_element(p_ply_argument argument,
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_get_argument_property(p_ply_argument argument,
p_ply_property *property, long *length, long *value_index);
@@ -139,6 +164,8 @@ int ply_get_argument_property(p_ply_argument argument,
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_get_argument_user_data(p_ply_argument argument, void **pdata,
long *idata);
@@ -149,6 +176,8 @@ int ply_get_argument_user_data(p_ply_argument argument, void **pdata,
*
* Returns the current data item
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
double ply_get_argument_value(p_ply_argument argument);
/* ----------------------------------------------------------------------
@@ -159,6 +188,8 @@ double ply_get_argument_value(p_ply_argument argument);
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_read(p_ply ply);
/* ----------------------------------------------------------------------
@@ -170,6 +201,8 @@ int ply_read(p_ply ply);
*
* Returns element if successfull or NULL if no more elements
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
p_ply_element ply_get_next_element(p_ply ply, p_ply_element last);
/* ----------------------------------------------------------------------
@@ -181,6 +214,8 @@ p_ply_element ply_get_next_element(p_ply ply, p_ply_element last);
*
* Returns comment if successfull or NULL if no more comments
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
const char *ply_get_next_comment(p_ply ply, const char *last);
/* ----------------------------------------------------------------------
@@ -192,6 +227,8 @@ const char *ply_get_next_comment(p_ply ply, const char *last);
*
* Returns obj_info if successfull or NULL if no more obj_infos
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
const char *ply_get_next_obj_info(p_ply ply, const char *last);
/* ----------------------------------------------------------------------
@@ -203,6 +240,8 @@ const char *ply_get_next_obj_info(p_ply ply, const char *last);
*
* Returns 1 if successfull or 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_get_element_info(p_ply_element element, const char** name,
long *ninstances);
@@ -215,6 +254,8 @@ int ply_get_element_info(p_ply_element element, const char** name,
*
* Returns element if successfull or NULL if no more properties
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
p_ply_property ply_get_next_property(p_ply_element element,
p_ply_property last);
@@ -231,6 +272,8 @@ p_ply_property ply_get_next_property(p_ply_element element,
*
* Returns 1 if successfull or 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_get_property_info(p_ply_property property, const char** name,
e_ply_type *type, e_ply_type *length_type, e_ply_type *value_type);
@@ -244,6 +287,8 @@ int ply_get_property_info(p_ply_property property, const char** name,
*
* Returns handle to PLY file if successfull, NULL otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
p_ply ply_create(const char *name, e_ply_storage_mode storage_mode,
p_ply_error_cb error_cb, long idata, void *pdata);
@@ -256,6 +301,8 @@ p_ply ply_create(const char *name, e_ply_storage_mode storage_mode,
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_add_element(p_ply ply, const char *name, long ninstances);
/* ----------------------------------------------------------------------
@@ -269,6 +316,8 @@ int ply_add_element(p_ply ply, const char *name, long ninstances);
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_add_property(p_ply ply, const char *name, e_ply_type type,
e_ply_type length_type, e_ply_type value_type);
@@ -282,6 +331,8 @@ int ply_add_property(p_ply ply, const char *name, e_ply_type type,
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_add_list_property(p_ply ply, const char *name,
e_ply_type length_type, e_ply_type value_type);
@@ -294,6 +345,8 @@ int ply_add_list_property(p_ply ply, const char *name,
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_add_scalar_property(p_ply ply, const char *name, e_ply_type type);
/* ----------------------------------------------------------------------
@@ -304,6 +357,8 @@ int ply_add_scalar_property(p_ply ply, const char *name, e_ply_type type);
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_add_comment(p_ply ply, const char *comment);
/* ----------------------------------------------------------------------
@@ -314,6 +369,8 @@ int ply_add_comment(p_ply ply, const char *comment);
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_add_obj_info(p_ply ply, const char *obj_info);
/* ----------------------------------------------------------------------
@@ -324,6 +381,8 @@ int ply_add_obj_info(p_ply ply, const char *obj_info);
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_write_header(p_ply ply);
/* ----------------------------------------------------------------------
@@ -337,6 +396,8 @@ int ply_write_header(p_ply ply);
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_write(p_ply ply, double value);
/* ----------------------------------------------------------------------
@@ -346,13 +407,14 @@ int ply_write(p_ply ply, double value);
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
+
+RPLY_DLL_DEF
int ply_close(p_ply ply);
#ifdef __cplusplus
-}
+} // extern 'C'
#endif
-#endif /* RPLY_H */
/* ----------------------------------------------------------------------
* Copyright (C) 2003-2015 Diego Nehab. All rights reserved.
diff --git a/rplyfile.h b/rplyfile.h
index 206e716..1b5a40e 100644
--- a/rplyfile.h
+++ b/rplyfile.h
@@ -9,6 +9,19 @@
* at the end of this file.
* ---------------------------------------------------------------------- */
+#ifdef RPLY_SHARED_LIB
+
+#ifdef RPLY_BUILD_LIB
+#define RPLY_DLL_DEF __declspec(dllexport)
+#else
+#define RPLY_DLL_DEF __declspec(dllimport)
+#endif // RPLY_BUILD_LIB
+
+#else
+#define RPLY_DLL_DEF
+#endif // RPLY_SHARED_LIB
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -22,6 +35,7 @@ extern "C" {
*
* Returns 1 if successful, 0 otherwise
* ---------------------------------------------------------------------- */
+RPLY_DLL_DEF
p_ply ply_open_from_file(FILE *file_pointer, p_ply_error_cb error_cb,
long idata, void *pdata);
@@ -35,6 +49,7 @@ p_ply ply_open_from_file(FILE *file_pointer, p_ply_error_cb error_cb,
*
* Returns handle to PLY file if successfull, NULL otherwise
* ---------------------------------------------------------------------- */
+RPLY_DLL_DEF
p_ply ply_create_to_file(FILE *file_pointer, e_ply_storage_mode storage_mode,
p_ply_error_cb error_cb, long idata, void *pdata);

33
ports/rply/portfile.cmake Normal file
View File

@ -0,0 +1,33 @@
include(vcpkg_common_functions)
set(VERSION 1.1.4)
vcpkg_download_distfile(ARCHIVE
URLS "http://w3.impa.br/~diego/software/rply/rply-${VERSION}.tar.gz"
FILENAME "rply-${VERSION}.tar.gz"
SHA512 be389780b8ca74658433f271682d91e89709ced588c4012c152ccf4014557692a1afd37b1bd5e567cedf9c412d42721eb0412ff3331f38717e527bd5d29c27a7
)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
REF ${VERSION}
PATCHES
export_functions.patch
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/rply-config.cmake.in DESTINATION ${SOURCE_PATH})
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
vcpkg_fixup_cmake_targets()
# Handle copyright
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/rply RENAME copyright)

View File

@ -0,0 +1,8 @@
get_filename_component(_RPLY_PREFIX_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
set (_TARGET_NAME "rply")
# IMPORTED targets
include("${_RPLY_PREFIX_DIR}/${_TARGET_NAME}-targets.cmake")
set(_RPLY_PREFIX_DIR)
set(_TARGET_NAME)