forked from estkme-group/lpac
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move drivers into
libeuicc-drivers.so
(estkme-group#59)
* Move drivers back to their own (optionally dynamic) This allows for reuse from projects dynamically linked to libeuicc. Note that we don't reintroduce dlopen() based drivers here. All backends except stdio have been made optional using CMake options. C-side macros in driver.c have been adjusted to always mean enabling the corresponding backend when defined. Note that the GBinder backend does not need to distinguish between the current HIDL version and a future AIDL implementation. Both will have the same dependencies and will probably fall back on to each other automatically. * Set up installed headers and pkg-config for libeuicc-drivers.so Also separate lpac_driver struct from the installed version * Namespace all exposed symbols in libeuicc-drivers.so * Add back output directory config This is needed by github actions * curl is dlopen()'d on Windows
- Loading branch information
Showing
25 changed files
with
196 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,5 @@ endif() | |
|
||
add_subdirectory(cjson) | ||
add_subdirectory(euicc) | ||
add_subdirectory(driver) | ||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
enum lpac_driver_type | ||
{ | ||
DRIVER_APDU, | ||
DRIVER_HTTP, | ||
}; | ||
|
||
struct lpac_driver | ||
{ | ||
enum lpac_driver_type type; | ||
const char *name; | ||
int (*init)(void *interface); | ||
int (*main)(int argc, char **argv); | ||
void (*fini)(void); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
include(CMakeDependentOption) | ||
cmake_dependent_option(LPAC_DYNAMIC_DRIVERS "Build lpac/libeuicc driver backends as a dynamic library" OFF "LPAC_DYNAMIC_LIBEUICC" OFF) | ||
|
||
option(LPAC_WITH_APDU_PCSC "Build APDU PCSC Backend (requires PCSC libraries)" ON) | ||
option(LPAC_WITH_APDU_AT "Build APDU AT Backend" ON) | ||
option(LPAC_WITH_APDU_GBINDER "Build APDU Gbinder backend for libhybris devices (requires gbinder headers)" OFF) | ||
|
||
option(LPAC_WITH_HTTP_CURL "Build HTTP Curl interface" ON) | ||
|
||
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} DIR_INTERFACE_SRCS) | ||
if(LPAC_DYNAMIC_DRIVERS) | ||
add_library(euicc-drivers SHARED ${DIR_INTERFACE_SRCS}) | ||
else() | ||
add_library(euicc-drivers STATIC ${DIR_INTERFACE_SRCS}) | ||
endif() | ||
target_link_libraries(euicc-drivers euicc cjson-static) | ||
target_include_directories(euicc-drivers PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/apdu/stdio.c) | ||
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/http/stdio.c) | ||
|
||
if(LPAC_WITH_APDU_PCSC) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_PCSC") | ||
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/apdu/pcsc.c) | ||
if(WIN32) | ||
target_link_libraries(euicc-drivers winscard) | ||
elseif(APPLE) | ||
target_link_libraries(euicc-drivers "-framework PCSC") | ||
else() | ||
find_package(PCSCLite) | ||
target_link_libraries(euicc-drivers PCSCLite::PCSCLite) | ||
endif() | ||
endif() | ||
|
||
if(LPAC_WITH_APDU_AT) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_AT") | ||
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/apdu/at.c) | ||
endif() | ||
|
||
if(LPAC_WITH_APDU_GBINDER) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_GBINDER") | ||
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/apdu/gbinder_hidl.c) | ||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(GBINDER REQUIRED IMPORTED_TARGET libgbinder) | ||
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) | ||
target_link_libraries(euicc-drivers PkgConfig::GBINDER PkgConfig::GLIB) | ||
endif() | ||
|
||
if(LPAC_WITH_HTTP_CURL) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_HTTP_CURL") | ||
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/http/curl.c) | ||
if(WIN32) | ||
target_link_libraries(euicc-drivers ${DL_LIBRARY}) | ||
else() | ||
find_package(curl) | ||
target_link_libraries(euicc-drivers curl) | ||
endif() | ||
endif() | ||
|
||
if(LPAC_DYNAMIC_DRIVERS) | ||
# Install headers | ||
file(GLOB ALL_HEADERS "*.h") | ||
foreach(header ${ALL_HEADERS}) | ||
if(${header} MATCHES "^.*\.private\.h$") | ||
list(REMOVE_ITEM ALL_HEADERS ${header}) | ||
endif() | ||
endforeach() | ||
set_target_properties(euicc-drivers PROPERTIES PUBLIC_HEADER "${ALL_HEADERS}") | ||
# Install a pkg-config file | ||
configure_file(libeuicc-drivers.pc.in libeuicc-drivers.pc @ONLY) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libeuicc-drivers.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) | ||
set_target_properties(euicc-drivers PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}) | ||
install(TARGETS euicc-drivers LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/euicc) | ||
endif() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#pragma once | ||
#include <driver.h> | ||
#include <driver.private.h> | ||
|
||
extern const struct lpac_driver driver_apdu_at; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#pragma once | ||
#include <driver.h> | ||
#include <driver.private.h> | ||
|
||
extern const struct lpac_driver driver_apdu_gbinder_hidl; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#pragma once | ||
#include <driver.h> | ||
#include <driver.private.h> | ||
|
||
extern const struct lpac_driver driver_apdu_pcsc; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#pragma once | ||
#include <driver.h> | ||
#include <driver.private.h> | ||
|
||
extern const struct lpac_driver driver_apdu_stdio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
#include <stddef.h> | ||
#include <inttypes.h> | ||
#include <euicc/interface.h> | ||
|
||
extern struct euicc_apdu_interface euicc_driver_interface_apdu; | ||
extern struct euicc_http_interface euicc_driver_interface_http; | ||
extern int (*euicc_driver_main_apdu)(int argc, char **argv); | ||
extern int (*euicc_driver_main_http)(int argc, char **argv); | ||
|
||
int euicc_driver_init(void); | ||
void euicc_driver_fini(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
enum lpac_driver_type | ||
{ | ||
DRIVER_APDU, | ||
DRIVER_HTTP, | ||
}; | ||
|
||
struct lpac_driver | ||
{ | ||
enum lpac_driver_type type; | ||
const char *name; | ||
int (*init)(void *interface); | ||
int (*main)(int argc, char **argv); | ||
void (*fini)(void); | ||
}; | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#pragma once | ||
#include <driver.h> | ||
#include <driver.private.h> | ||
|
||
extern const struct lpac_driver driver_http_curl; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#pragma once | ||
#include <driver.h> | ||
#include <driver.private.h> | ||
|
||
extern const struct lpac_driver driver_http_stdio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
prefix="@CMAKE_INSTALL_PREFIX@" | ||
exec_prefix="${prefix}" | ||
libdir="${prefix}/lib" | ||
includedir="${prefix}/include" | ||
|
||
Name: libeuicc-drivers | ||
Description: An "official" collection of drivers (backends) and their loader for use with libeuicc | ||
Version: @PROJECT_VERSION@ | ||
Requires: libeuicc = @PROJECT_VERSION@ | ||
Cflags: -I${includedir} | ||
Libs: -L${libdir} -leuicc-drivers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.