Skip to content

Commit 026083d

Browse files
committed
Merge branch 'android-build' into 'master'
Add config info functions used in Android build investigation See merge request nublar/pdal-c!4
2 parents b2d07a2 + 82830f9 commit 026083d

File tree

7 files changed

+367
-3
lines changed

7 files changed

+367
-3
lines changed

source/pdal/capi/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ find_package(PDAL REQUIRED CONFIG)
44
message(STATUS "Found PDAL ${PDAL_VERSION}")
55

66
set(SOURCES
7+
Config.cpp
78
DimType.cpp
89
Pipeline.cpp
910
PointLayout.cpp
@@ -12,6 +13,7 @@ set(SOURCES
1213
)
1314

1415
set(HEADERS
16+
Config.h
1517
Defines.h
1618
DimType.h
1719
Forward.h

source/pdal/capi/Config.cpp

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Copyright (c) Simverge Software LLC - All Rights Reserved
3+
*/
4+
5+
#include "Config.h"
6+
7+
#include <pdal/pdal_config.hpp>
8+
9+
#include <cstring>
10+
#include <string>
11+
12+
namespace pdal
13+
{
14+
namespace capi
15+
{
16+
size_t PDALFullVersionString(char *version, size_t size)
17+
{
18+
size_t length = 0;
19+
20+
if (version && size > 0)
21+
{
22+
version[0] = '\0';
23+
version[size-1] = '\0';
24+
25+
std::string s = pdal::Config::fullVersionString();
26+
std::strncpy(version, s.c_str(), size - 1);
27+
length = std::min(s.length(), size - 1);
28+
}
29+
30+
return length;
31+
}
32+
33+
size_t PDALVersionString(char *version, size_t size)
34+
{
35+
size_t length = 0;
36+
37+
if (version && size > 0)
38+
{
39+
version[0] = '\0';
40+
version[size-1] = '\0';
41+
42+
std::string s = pdal::Config::versionString();
43+
std::strncpy(version, s.c_str(), size - 1);
44+
length = std::min(s.length(), size - 1);
45+
}
46+
47+
return length;
48+
}
49+
50+
int PDALVersionInteger()
51+
{
52+
return pdal::Config::versionInteger();
53+
}
54+
55+
size_t PDALSha1(char *sha1, size_t size)
56+
{
57+
size_t length = 0;
58+
59+
if (sha1 && size > 0)
60+
{
61+
sha1[0] = '\0';
62+
sha1[size-1] = '\0';
63+
64+
std::string s = pdal::Config::sha1();
65+
std::strncpy(sha1, s.c_str(), size - 1);
66+
length = std::min(s.length(), size - 1);
67+
}
68+
69+
return length;
70+
}
71+
72+
int PDALVersionMajor()
73+
{
74+
return pdal::Config::versionMajor();
75+
}
76+
77+
int PDALVersionMinor()
78+
{
79+
return pdal::Config::versionMinor();
80+
}
81+
82+
int PDALVersionPatch()
83+
{
84+
return pdal::Config::versionPatch();
85+
}
86+
87+
size_t PDALDebugInformation(char *info, size_t size)
88+
{
89+
size_t length = 0;
90+
91+
if (info && size > 0)
92+
{
93+
info[0] = '\0';
94+
info[size-1] = '\0';
95+
96+
std::string s = pdal::Config::debugInformation();
97+
std::strncpy(info, s.c_str(), size - 1);
98+
length = std::min(s.length(), size - 1);
99+
}
100+
101+
return length;
102+
}
103+
104+
size_t PDALPluginInstallPath(char *path, size_t size)
105+
{
106+
size_t length = 0;
107+
108+
if (path && size > 0)
109+
{
110+
path[0] = '\0';
111+
path[size-1] = '\0';
112+
113+
std::string s = pdal::Config::pluginInstallPath();
114+
std::strncpy(path, s.c_str(), size - 1);
115+
length = std::min(s.length(), size - 1);
116+
}
117+
118+
return length;
119+
}
120+
}
121+
}
122+

source/pdal/capi/Config.h

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
* Copyright (c) Simverge Software LLC - All Rights Reserved
3+
*/
4+
5+
#ifndef PDAL_CAPI_CONFIG_H
6+
#define PDAL_CAPI_CONFIG_H
7+
8+
#include "Forward.h"
9+
10+
/**
11+
* @file Config.h
12+
* Functions to PDAL version and configuration information.
13+
*/
14+
15+
#ifdef __cplusplus
16+
17+
namespace pdal
18+
{
19+
namespace capi
20+
{
21+
extern "C"
22+
{
23+
#else
24+
#include <stdbool.h>
25+
#endif
26+
/**
27+
* Retrieves the full PDAL version string.
28+
* The full version string includes the major version number, the minor version
29+
* number, the patch version number, and the shortened Git commit SHA1.
30+
*
31+
* @see pdal::config::fullVersionString
32+
*
33+
* @param[out] version The buffer used to retrieve the version string
34+
* @param size The size of the provided buffer
35+
* @return The size of the retrieved version string
36+
*/
37+
PDAL_C_API size_t PDALFullVersionString(char *version, size_t size);
38+
39+
/**
40+
* Retrieves the PDAL version string.
41+
* The version string includes the major version number, the minor version
42+
* number, and the patch version number.
43+
*
44+
* @see pdal::config::versionString
45+
*
46+
* @param[out] version The buffer used to retrieve the version string
47+
* @param size The size of the provided buffer
48+
* @return The size of the retrieved version string
49+
*/
50+
PDAL_C_API size_t PDALVersionString(char *version, size_t size);
51+
52+
/**
53+
* Returns an integer representation of the PDAL version.
54+
* The returned value is the sum of ther major version number multiplied
55+
* by 10,000, the minor version number multiplied by 100, and the patch version
56+
* number. For example, this method returns `10702` for version 1.7.2.
57+
*
58+
* @see pdal::config::versionInteger
59+
*
60+
* @return An integer representation of the PDAL version
61+
*/
62+
PDAL_C_API int PDALVersionInteger();
63+
64+
/**
65+
* Retrieves PDAL's Git commit SHA1 as a string.
66+
*
67+
* @see pdal::config::sha1
68+
*
69+
* @param[out] version The buffer used to retrieve the SHA1 string
70+
* @param size The size of the provided buffer
71+
* @return The size of the retrieved SHA1 string
72+
*/
73+
PDAL_C_API size_t PDALSha1(char *sha1, size_t size);
74+
75+
/**
76+
* Returns the PDAL major version number.
77+
*
78+
* @see pdal::config::versionMajor
79+
*
80+
* @return The major version
81+
*/
82+
PDAL_C_API int PDALVersionMajor();
83+
84+
/**
85+
* Returns the PDAL minor version number.
86+
*
87+
* @see pdal::config::versionMinor
88+
*
89+
* @return The minor version
90+
*/
91+
PDAL_C_API int PDALVersionMinor();
92+
93+
/**
94+
* Returns the PDAL patch version number.
95+
*
96+
* @see pdal::config::versionPatch
97+
*
98+
* @return The patch version
99+
*/
100+
PDAL_C_API int PDALVersionPatch();
101+
102+
/**
103+
* Retrieves PDAL debugging information.
104+
*
105+
* @see pdal::config::debugInformation
106+
*
107+
* @param[out] version The buffer used to retrieve the debugging information
108+
* @param size The size of the provided buffer
109+
* @return The size of the retrieved debugging information
110+
*/
111+
PDAL_C_API size_t PDALDebugInformation(char *info, size_t size);
112+
113+
/**
114+
* Retrieves the path to the PDAL installation.
115+
*
116+
* @see pdal::config::pluginInstallPath
117+
*
118+
* @param[out] version The buffer used to retrieve the installation path
119+
* @param size The size of the provided buffer
120+
* @return The size of the retrieved installation path
121+
*/
122+
PDAL_C_API size_t PDALPluginInstallPath(char *path, size_t size);
123+
124+
#ifdef __cplusplus
125+
}
126+
}
127+
}
128+
#endif
129+
130+
#endif

tests/pdal/capi/CMakeLists.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
set(TARGET test_pdal_c)
22

3+
find_package(PDAL REQUIRED CONFIG)
4+
35
set(CONFIGS )
46
set(SOURCES main.c)
57
set(HEADERS )
6-
set(DEPENDENCIES pdal_c)
8+
set(DEPENDENCIES
9+
${PDAL_LIBRARIES}
10+
pdal_c
11+
)
712

813
set(TESTS
14+
ConfigTest
915
PipelineTest
1016
PointLayoutTest
1117
PointViewIteratorTest
@@ -20,7 +26,17 @@ foreach(TEST ${TESTS})
2026
endforeach()
2127

2228
source_group("Config Files" FILES ${CONFIGS})
23-
include_directories(${CMAKE_SOURCE_DIR}/source)
29+
30+
include_directories(
31+
${CMAKE_SOURCE_DIR}/source
32+
${PDAL_INCLUDE_DIRS}
33+
)
34+
35+
# Add definition if building debug with vcpkg - PDAL_PLUGIN_INSTALL_PATH points to release binaries
36+
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_UPPERCASE)
37+
if (BUILD_TYPE_UPPERCASE STREQUAL "DEBUG" AND VCPKG_TARGET_TRIPLET)
38+
add_definitions(-DUSING_VCPKG_DEBUG)
39+
endif()
2440

2541
add_executable(${TARGET} ${SOURCES} ${HEADERS} ${CONFIG})
2642
set_target_properties(${TARGET} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})

0 commit comments

Comments
 (0)