Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 23 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
clang-format --version
cd test && make style_check

ubuntu:
build-error-check-on-32bit:
runs-on: ubuntu-latest
if: >
(github.event_name == 'push') ||
Expand All @@ -53,10 +53,28 @@ jobs:
- arch_flags: -m32
arch_suffix: :i386
name: (32-bit)
- arch_flags:
arch_suffix:
name: (64-bit)
name: ubuntu ${{ matrix.config.name }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: install libraries
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y libc6-dev${{ matrix.config.arch_suffix }} libstdc++-13-dev${{ matrix.config.arch_suffix }} \
libssl-dev${{ matrix.config.arch_suffix }} libcurl4-openssl-dev${{ matrix.config.arch_suffix }} \
zlib1g-dev${{ matrix.config.arch_suffix }} libbrotli-dev${{ matrix.config.arch_suffix }} \
libzstd-dev${{ matrix.config.arch_suffix }}
- name: build and run tests (expect failure)
run: cd test && make test EXTRA_CXXFLAGS="${{ matrix.config.arch_flags }}"
continue-on-error: true

ubuntu:
runs-on: ubuntu-latest
if: >
(github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true')
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down
19 changes: 15 additions & 4 deletions httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@

#define CPPHTTPLIB_VERSION "0.22.0"

/*
* Platform compatibility check
*/

#if defined(_WIN32) && !defined(_WIN64)
#error \
"cpp-httplib doesn't support 32-bit Windows. Please use a 64-bit compiler."
#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ < 8
#error \
"cpp-httplib doesn't support 32-bit platforms. Please use a 64-bit compiler."
#elif defined(__SIZEOF_SIZE_T__) && __SIZEOF_SIZE_T__ < 8
#error \
"cpp-httplib doesn't support platforms where size_t is less than 64 bits."
#endif

/*
* Configuration
*/
Expand Down Expand Up @@ -177,11 +192,7 @@

#pragma comment(lib, "ws2_32.lib")

#ifdef _WIN64
using ssize_t = __int64;
#else
using ssize_t = long;
#endif
#endif // _MSC_VER

#ifndef S_ISREG
Expand Down
18 changes: 17 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ project(
meson_version: '>=0.62.0'
)

cxx = meson.get_compiler('cpp')

# Check just in case downstream decides to edit the source
# and add a project version
version = meson.project_version()
if version == 'undefined'
cxx = meson.get_compiler('cpp')
version = cxx.get_define('CPPHTTPLIB_VERSION',
prefix: '#include <httplib.h>',
include_directories: include_directories('.')).strip('"')
Expand Down Expand Up @@ -65,6 +66,21 @@ if brotli_found_all
args += '-DCPPHTTPLIB_BROTLI_SUPPORT'
endif

async_ns_opt = get_option('cpp-httplib_non_blocking_getaddrinfo')

if host_machine.system() == 'windows'
async_ns_dep = cxx.find_library('ws2_32', required: async_ns_opt)
elif host_machine.system() == 'darwin'
async_ns_dep = dependency('appleframeworks', modules: ['CFNetwork'], required: async_ns_opt)
else
async_ns_dep = cxx.find_library('anl', required: async_ns_opt)
endif

if async_ns_dep.found()
deps += async_ns_dep
args += '-DCPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO'
endif

cpp_httplib_dep = dependency('', required: false)

if get_option('cpp-httplib_compile')
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ option('cpp-httplib_openssl', type: 'feature', value: 'auto', description: 'Enab
option('cpp-httplib_zlib', type: 'feature', value: 'auto', description: 'Enable zlib support')
option('cpp-httplib_brotli', type: 'feature', value: 'auto', description: 'Enable Brotli support')
option('cpp-httplib_macosx_keychain', type: 'feature', value: 'auto', description: 'Enable loading certs from the Keychain on Apple devices')
option('cpp-httplib_non_blocking_getaddrinfo', type: 'feature', value: 'auto', description: 'Enable asynchronous name lookup')
option('cpp-httplib_compile', type: 'boolean', value: false, description: 'Split the header into a compilable header & source file (requires python3)')
option('cpp-httplib_test', type: 'boolean', value: false, description: 'Build tests')
Loading