Skip to content

Commit 9c46cf7

Browse files
Merge pull request #16 from lucaromagnoli/fix/windows-build
Fix Windows build: Add SSL support configuration and conditional comp…
2 parents 0ad0a9d + 3bf4d2d commit 9c46cf7

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ jobs:
9999
run: |
100100
brew install openssl
101101
102-
- name: Configure CMake
102+
- name: Configure CMake (Windows)
103+
if: runner.os == 'Windows'
104+
run: |
105+
cmake -B build ${{ matrix.cmake_args }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake"
106+
107+
- name: Configure CMake (Non-Windows)
108+
if: runner.os != 'Windows'
103109
run: |
104110
cmake -B build ${{ matrix.cmake_args }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
105111

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.22)
22

3-
project(llmcpp VERSION 1.0.1 LANGUAGES CXX)
3+
project(llmcpp VERSION 1.0.2 LANGUAGES CXX)
44

55
# Set version variables for easier access
66
set(LLMCPP_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
@@ -50,6 +50,9 @@ FetchContent_Declare(
5050
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
5151
GIT_TAG v0.15.3
5252
)
53+
54+
# Configure httplib to use OpenSSL
55+
set(HTTPLIB_USE_OPENSSL ON)
5356
FetchContent_MakeAvailable(httplib)
5457

5558
# Source files

scripts/release.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ main() {
164164
echo " 1. Update version in CMakeLists.txt and vcpkg.json"
165165
echo " 2. Create a git commit with the version changes"
166166
echo " 3. Create and push a git tag v$new_version"
167-
echo " 4. Trigger GitHub Actions to create a release"
167+
echo " 4. Push the current branch to origin"
168+
echo " 5. Trigger GitHub Actions to create a release (if on main branch)"
168169
echo ""
169170
read -p "Continue? (y/N): " -n 1 -r
170171
echo ""
@@ -185,7 +186,12 @@ main() {
185186
# Create and push tag
186187
print_info "Creating and pushing tag v$new_version..."
187188
git tag "v$new_version"
188-
git push origin main
189+
190+
# Get current branch name
191+
local current_branch
192+
current_branch=$(git branch --show-current)
193+
print_info "Pushing current branch: $current_branch"
194+
git push origin "$current_branch"
189195
git push origin "v$new_version"
190196

191197
print_success "Release v$new_version created!"

src/openai/OpenAIHttpClient.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class OpenAIHttpClient::HttpClientImpl {
3232
basePath_ = "/v1";
3333
}
3434

35+
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
3536
client_ = std::make_unique<httplib::SSLClient>(hostname_);
3637

3738
// Configure client
@@ -41,40 +42,66 @@ class OpenAIHttpClient::HttpClientImpl {
4142

4243
// Enable SSL verification
4344
client_->enable_server_certificate_verification(true);
45+
#else
46+
throw std::runtime_error(
47+
"SSL support not available. Please ensure OpenSSL is properly linked.");
48+
#endif
4449
}
4550

4651
OpenAIHttpClient::HttpResponse post(const std::string& endpoint, const json& requestBody) {
52+
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
4753
auto headers = buildHeaders();
4854
auto url = buildUrl(endpoint);
4955
auto bodyStr = requestBody.dump();
5056

5157
auto result = client_->Post(url, headers, bodyStr, "application/json");
5258

5359
return processResponse(result);
60+
#else
61+
OpenAIHttpClient::HttpResponse response;
62+
response.success = false;
63+
response.statusCode = 0;
64+
response.errorMessage = "SSL support not available";
65+
return response;
66+
#endif
5467
}
5568

5669
OpenAIHttpClient::HttpResponse get(const std::string& endpoint) {
70+
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
5771
auto headers = buildHeaders();
5872
auto url = buildUrl(endpoint);
5973

6074
auto result = client_->Get(url, headers);
6175

6276
return processResponse(result);
77+
#else
78+
OpenAIHttpClient::HttpResponse response;
79+
response.success = false;
80+
response.statusCode = 0;
81+
response.errorMessage = "SSL support not available";
82+
return response;
83+
#endif
6384
}
6485

6586
void setConfig(const OpenAI::OpenAIConfig& config) {
6687
config_ = config;
88+
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
6789
// Update client timeouts
6890
client_->set_connection_timeout(config_.timeoutSeconds);
6991
client_->set_read_timeout(config_.timeoutSeconds);
7092
client_->set_write_timeout(config_.timeoutSeconds);
93+
#endif
7194
}
7295

7396
OpenAI::OpenAIConfig getConfig() const { return config_; }
7497

7598
private:
7699
OpenAI::OpenAIConfig config_;
100+
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
77101
std::unique_ptr<httplib::SSLClient> client_;
102+
#else
103+
std::unique_ptr<void> client_; // Placeholder when SSL not available
104+
#endif
78105
std::string hostname_;
79106
std::string basePath_;
80107

vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "llmcpp",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"dependencies": [
55
"openssl"
66
],

0 commit comments

Comments
 (0)