mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 13:48:02 +08:00
[Libb64] Add new port (#19447)
This commit is contained in:
parent
772d435ba1
commit
a82c62d5c8
35
ports/b64/CMakeLists.txt
Normal file
35
ports/b64/CMakeLists.txt
Normal file
@ -0,0 +1,35 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(b64)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/b64_dynamic_config.h ${CMAKE_CURRENT_BINARY_DIR}/b64_config.h)
|
||||
else()
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/b64_static_config.h ${CMAKE_CURRENT_BINARY_DIR}/b64_config.h)
|
||||
endif()
|
||||
|
||||
set(SRC_DIR src)
|
||||
set(INC_DIR include/b64)
|
||||
set(SOURCE_FILES ${SRC_DIR}/cdecode.c ${SRC_DIR}/cencode.c)
|
||||
set(HEADER_FILES ${INC_DIR}/cdecode.h ${INC_DIR}/cencode.h ${INC_DIR}/decode.h ${INC_DIR}/encode.h ${INC_DIR}/ccommon.h ${CMAKE_CURRENT_BINARY_DIR}/b64_config.h)
|
||||
|
||||
add_library(b64 ${SOURCE_FILES} ${HEADER_FILES})
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(b64 PRIVATE LIBB64_EXPORTS=1)
|
||||
endif()
|
||||
|
||||
target_include_directories(b64 PRIVATE include ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set_property(TARGET b64
|
||||
PROPERTY PUBLIC_HEADER ${HEADER_FILES})
|
||||
|
||||
install(TARGETS b64
|
||||
EXPORT b64-targets
|
||||
LIBRARY DESTINATION lib
|
||||
PUBLIC_HEADER DESTINATION include/b64
|
||||
)
|
||||
|
||||
install(EXPORT b64-targets
|
||||
FILE b64-targets.cmake
|
||||
DESTINATION lib/cmake/b64)
|
||||
|
14
ports/b64/b64_dynamic_config.h
Normal file
14
ports/b64/b64_dynamic_config.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef B64_CONFIG_H
|
||||
#define B64_CONFIG_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef LIBB64_EXPORTS
|
||||
#define LIBB64 __declspec(dllexport)
|
||||
#else
|
||||
#define LIBB64 __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define LIBB64
|
||||
#endif
|
||||
|
||||
#endif
|
6
ports/b64/b64_static_config.h
Normal file
6
ports/b64/b64_static_config.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef B64_CONFIG_H
|
||||
#define B64_CONFIG_H
|
||||
|
||||
#define LIBB64
|
||||
|
||||
#endif
|
28
ports/b64/portfile.cmake
Normal file
28
ports/b64/portfile.cmake
Normal file
@ -0,0 +1,28 @@
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO libb64/libb64
|
||||
REF v2.0.0.1
|
||||
SHA512 72c2fd4c81575b505f4851cd3820b6a2d8e78cd031a1ed138ffe5667ca711558f43b515428971966f7a73ace7c9951f1f0b39c362a59fe4691958875775cce23
|
||||
HEAD_REF master
|
||||
PATCHES "windows-fix.patch"
|
||||
)
|
||||
|
||||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/b64_dynamic_config.h" DESTINATION "${SOURCE_PATH}")
|
||||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/b64_static_config.h" DESTINATION "${SOURCE_PATH}")
|
||||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
)
|
||||
|
||||
vcpkg_cmake_install()
|
||||
|
||||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
|
||||
|
||||
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT})
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
|
||||
# handle copyright
|
||||
file(INSTALL "${SOURCE_PATH}/LICENSE.md" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|
16
ports/b64/vcpkg.json
Normal file
16
ports/b64/vcpkg.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
|
||||
"name": "b64",
|
||||
"version": "2.0.0.1",
|
||||
"description": "libb64 is a library of ANSI C routines for fast encoding/decoding data into and from a base64-encoded format",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
}
|
||||
]
|
||||
}
|
130
ports/b64/windows-fix.patch
Normal file
130
ports/b64/windows-fix.patch
Normal file
@ -0,0 +1,130 @@
|
||||
diff --git a/include/b64/ccommon.h b/include/b64/ccommon.h
|
||||
index 2b614df..0e46141 100644
|
||||
--- a/include/b64/ccommon.h
|
||||
+++ b/include/b64/ccommon.h
|
||||
@@ -10,11 +10,12 @@ For details, see http://sourceforge.net/projects/libb64
|
||||
|
||||
#define BASE64_VER_MAJOR 2
|
||||
#define BASE64_VER_MINOR 0
|
||||
+#include "b64_config.h"
|
||||
|
||||
#ifndef HAVE_SIZE_T
|
||||
#ifdef _WIN32
|
||||
#include <crtdefs.h>
|
||||
- #elseif defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
|
||||
+ #elif defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
typedef unsigned long size_t;
|
||||
diff --git a/include/b64/cdecode.h b/include/b64/cdecode.h
|
||||
index d6ff24c..4553efc 100644
|
||||
--- a/include/b64/cdecode.h
|
||||
+++ b/include/b64/cdecode.h
|
||||
@@ -24,11 +24,11 @@ typedef struct
|
||||
char plainchar;
|
||||
} base64_decodestate;
|
||||
|
||||
-extern void base64_init_decodestate(base64_decodestate* state_in);
|
||||
+extern LIBB64 void base64_init_decodestate(base64_decodestate* state_in);
|
||||
|
||||
-extern size_t base64_decode_maxlength(size_t encode_len);
|
||||
+extern LIBB64 size_t base64_decode_maxlength(size_t encode_len);
|
||||
|
||||
-extern int base64_decode_value(signed char value_in);
|
||||
-extern size_t base64_decode_block(const char* code_in, const size_t length_in, void* plaintext_out, base64_decodestate* state_in);
|
||||
+extern LIBB64 int base64_decode_value(signed char value_in);
|
||||
+extern LIBB64 size_t base64_decode_block(const char* code_in, const size_t length_in, void* plaintext_out, base64_decodestate* state_in);
|
||||
|
||||
#endif /* BASE64_CDECODE_H */
|
||||
diff --git a/include/b64/cencode.h b/include/b64/cencode.h
|
||||
index 96b0cdb..1feb695 100644
|
||||
--- a/include/b64/cencode.h
|
||||
+++ b/include/b64/cencode.h
|
||||
@@ -31,12 +31,12 @@ typedef struct
|
||||
char result;
|
||||
} base64_encodestate;
|
||||
|
||||
-extern void base64_init_encodestate(base64_encodestate* state_in);
|
||||
+extern LIBB64 void base64_init_encodestate(base64_encodestate* state_in);
|
||||
|
||||
-extern size_t base64_encode_length(size_t plain_len, base64_encodestate* state_in);
|
||||
+extern LIBB64 size_t base64_encode_length(size_t plain_len, base64_encodestate* state_in);
|
||||
|
||||
-extern char base64_encode_value(signed char value_in);
|
||||
-extern size_t base64_encode_block(const void* plaintext_in, const size_t length_in, char* code_out, base64_encodestate* state_in);
|
||||
-extern size_t base64_encode_blockend(char* code_out, base64_encodestate* state_in);
|
||||
+extern LIBB64 char base64_encode_value(signed char value_in);
|
||||
+extern LIBB64 size_t base64_encode_block(const void* plaintext_in, const size_t length_in, char* code_out, base64_encodestate* state_in);
|
||||
+extern LIBB64 size_t base64_encode_blockend(char* code_out, base64_encodestate* state_in);
|
||||
|
||||
#endif /* BASE64_CENCODE_H */
|
||||
diff --git a/include/b64/decode.h b/include/b64/decode.h
|
||||
index b2362e5..dd772d4 100644
|
||||
--- a/include/b64/decode.h
|
||||
+++ b/include/b64/decode.h
|
||||
@@ -22,23 +22,23 @@ namespace base64
|
||||
base64_decodestate _state;
|
||||
int _buffersize;
|
||||
|
||||
- decoder(int buffersize_in = BUFFERSIZE)
|
||||
+ LIBB64 decoder(int buffersize_in = BUFFERSIZE)
|
||||
: _buffersize(buffersize_in)
|
||||
{
|
||||
base64_init_decodestate(&_state);
|
||||
}
|
||||
|
||||
- int decode(char value_in)
|
||||
+ LIBB64 int decode(char value_in)
|
||||
{
|
||||
return base64_decode_value(value_in);
|
||||
}
|
||||
|
||||
- std::streamsize decode(const char* code_in, const std::streamsize length_in, char* plaintext_out)
|
||||
+ LIBB64 std::streamsize decode(const char* code_in, const std::streamsize length_in, char* plaintext_out)
|
||||
{
|
||||
return base64_decode_block(code_in, static_cast<int>(length_in), plaintext_out, &_state);
|
||||
}
|
||||
|
||||
- void decode(std::istream& istream_in, std::ostream& ostream_in)
|
||||
+ LIBB64 void decode(std::istream& istream_in, std::ostream& ostream_in)
|
||||
{
|
||||
base64_init_decodestate(&_state);
|
||||
//
|
||||
diff --git a/include/b64/encode.h b/include/b64/encode.h
|
||||
index c1a5f88..ff2c9b4 100644
|
||||
--- a/include/b64/encode.h
|
||||
+++ b/include/b64/encode.h
|
||||
@@ -22,28 +22,28 @@ namespace base64
|
||||
base64_encodestate _state;
|
||||
int _buffersize;
|
||||
|
||||
- encoder(int buffersize_in = BUFFERSIZE)
|
||||
+ LIBB64 encoder(int buffersize_in = BUFFERSIZE)
|
||||
: _buffersize(buffersize_in)
|
||||
{
|
||||
base64_init_encodestate(&_state);
|
||||
}
|
||||
|
||||
- int encode(char value_in)
|
||||
+ LIBB64 int encode(char value_in)
|
||||
{
|
||||
return base64_encode_value(value_in);
|
||||
}
|
||||
|
||||
- std::streamsize encode(const char* code_in, const std::streamsize length_in, char* plaintext_out)
|
||||
+ LIBB64 std::streamsize encode(const char* code_in, const std::streamsize length_in, char* plaintext_out)
|
||||
{
|
||||
return base64_encode_block(code_in, static_cast<int>(length_in), plaintext_out, &_state);
|
||||
}
|
||||
|
||||
- int encode_end(char* plaintext_out)
|
||||
+ LIBB64 int encode_end(char* plaintext_out)
|
||||
{
|
||||
return base64_encode_blockend(plaintext_out, &_state);
|
||||
}
|
||||
|
||||
- void encode(std::istream& istream_in, std::ostream& ostream_in)
|
||||
+ LIBB64 void encode(std::istream& istream_in, std::ostream& ostream_in)
|
||||
{
|
||||
base64_init_encodestate(&_state);
|
||||
//
|
9
versions/b-/b64.json
Normal file
9
versions/b-/b64.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "9f1b6b36747fb6349483bf78531123d4b1ec5d7d",
|
||||
"version": "2.0.0.1",
|
||||
"port-version": 0
|
||||
}
|
||||
]
|
||||
}
|
@ -332,6 +332,10 @@
|
||||
"baseline": "2020-12-09",
|
||||
"port-version": 0
|
||||
},
|
||||
"b64": {
|
||||
"baseline": "2.0.0.1",
|
||||
"port-version": 0
|
||||
},
|
||||
"basisu": {
|
||||
"baseline": "1.11-4",
|
||||
"port-version": 0
|
||||
|
Loading…
Reference in New Issue
Block a user