Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
22 changes: 22 additions & 0 deletions ports/b64/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.20)
project(b64)

set(SOURCE_FILES src/cdecode.c src/cencode.c)
set(HEADER_FILES include/b64/cdecode.h include/b64/cencode.h include/b64/decode.h include/b64/encode.h)

set(LIBB64_EXPORTS 1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LIBB64_EXPORTS seems unused?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used in window-fix.patch, line 18.
I use it to handle dllimport dllexport stuff for dlls on Windows.
If you have some suggestion how to handle that in an different way, it's welcome.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that constant used in the patch but I'm missing how this set is attached to that. Did I miss a configure_file or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably need add_definitions here, not set 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even better, add_compile_definitions

add_library(b64 ${SOURCE_FILES} ${HEADER_FILES})
target_include_directories(b64 PRIVATE include)

set_target_properties(b64 PROPERTIES PUBLIC_HEADER "include/b64/cdecode.h;include/b64/cencode.h;include/b64/decode.h;include/b64/encode.h")

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)

26 changes: 26 additions & 0 deletions ports/b64/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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 ports/b64/CMakeLists.txt DESTINATION ${SOURCE_PATH}/)
Comment thread
9cvele3 marked this conversation as resolved.
Outdated

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
Comment thread
9cvele3 marked this conversation as resolved.
Outdated
)

vcpkg_install_cmake()
Comment thread
9cvele3 marked this conversation as resolved.
Outdated

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/${PORT})
Comment thread
9cvele3 marked this conversation as resolved.
Outdated

vcpkg_copy_pdbs()


# handle copyright
file(INSTALL ${SOURCE_PATH}/LICENSE.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
Comment thread
9cvele3 marked this conversation as resolved.
Outdated
5 changes: 5 additions & 0 deletions ports/b64/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
"name": "b64",
"version": "2.0.0.1"
Comment thread
9cvele3 marked this conversation as resolved.
Outdated
}
139 changes: 139 additions & 0 deletions ports/b64/windows-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
diff --git a/include/b64/ccommon.h b/include/b64/ccommon.h
index 2b614df..6c5b52a 100644
--- a/include/b64/ccommon.h
+++ b/include/b64/ccommon.h
@@ -14,11 +14,21 @@ For details, see http://sourceforge.net/projects/libb64
#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;
#endif
#endif

+#ifdef _WIN32

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this will do the wrong thing for static triplets.

+ #ifdef LIBB64_EXPORTS
+ #define LIBB64 __declspec(dllexport)
+ #else
+ #define LIBB64 __declspec(dllimport)
+ #endif
+#else
+#define LIBB64
+#endif
+
#endif /* BASE64_CCOMMON_H */
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 changes: 9 additions & 0 deletions versions/b-/b64.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "e88dbb8ac8a4186b3d7ae49825ef8c4afe120dd6",
"version": "2.0.0.1",
"port-version": 0
}
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down