Skip to content

Commit

Permalink
Merge pull request #6713 from sgallagher/llhttp
Browse files Browse the repository at this point in the history
  • Loading branch information
ethomson committed Apr 23, 2024
2 parents 93c9444 + fb1797d commit b739aca
Show file tree
Hide file tree
Showing 23 changed files with 12,212 additions and 2,579 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-containers.yml
Expand Up @@ -40,6 +40,7 @@ jobs:
qemu: true
- name: centos7
- name: centos8
- name: fedora
runs-on: ubuntu-latest
name: "Create container: ${{ matrix.container.name }}"
steps:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/nightly.yml
Expand Up @@ -213,7 +213,15 @@ jobs:
SKIP_NEGOTIATE_TESTS: true
SKIP_SSH_TESTS: true
ARCH: x86

- name: "Linux (Fedora, llhttp)"
id: fedora
os: ubuntu-latest
container:
name: fedora
env:
CC: gcc
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=pcre2 -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=libssh2 -DUSE_HTTP_PARSER=llhttp
- name: "Linux (Bionic, GCC, dynamically-loaded OpenSSL)"
id: bionic-gcc-dynamicopenssl
container:
Expand Down
25 changes: 25 additions & 0 deletions COPYING
Expand Up @@ -1383,3 +1383,28 @@ without express or implied warranty of any kind.

These notices must be retained in any copies of any part of this
documentation and/or software.

----------------------------------------------------------------------

The bundled llhttp dependency is licensed under the MIT license:

Copyright Fedor Indutny, 2018.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
52 changes: 52 additions & 0 deletions ci/docker/fedora
@@ -0,0 +1,52 @@
ARG BASE=fedora:rawhide

FROM ${BASE} AS stream
RUN dnf -y distro-sync

FROM stream AS yum
RUN yum install -y \
which \
bzip2 \
git \
libarchive \
cmake \
gcc \
make \
openssl-devel \
openssh-server \
git-daemon \
java-1.8.0-openjdk-headless \
sudo \
python3 \
valgrind \
krb5-workstation \
krb5-libs \
krb5-devel \
pcre2-devel \
zlib-devel \
ninja-build \
llhttp-devel

FROM yum AS libssh2
RUN cd /tmp && \
curl --location --silent --show-error https://www.libssh2.org/download/libssh2-1.11.0.tar.gz | tar -xz && \
cd libssh2-1.11.0 && \
./configure && \
make && \
make install && \
cd .. && \
rm -rf libssh2-1.11.0

FROM libssh2 AS adduser
ARG UID=""
ARG GID=""
RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \
if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \
groupadd ${GROUP_ARG} libgit2 && \
useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2

FROM adduser AS configure
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
RUN mkdir /var/run/sshd
RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local && \
ldconfig
39 changes: 39 additions & 0 deletions cmake/FindLLHTTP.cmake
@@ -0,0 +1,39 @@
# - Try to find llhttp
#
# Defines the following variables:
#
# LLHTTP_FOUND - system has llhttp
# LLHTTP_INCLUDE_DIR - the llhttp include directory
# LLHTTP_LIBRARIES - Link these to use llhttp
# LLHTTP_VERSION_MAJOR - major version
# LLHTTP_VERSION_MINOR - minor version
# LLHTTP_VERSION_STRING - the version of llhttp found

# Find the header and library
find_path(LLHTTP_INCLUDE_DIR NAMES llhttp.h)
find_library(LLHTTP_LIBRARY NAMES llhttp libllhttp)

# Found the header, read version
if(LLHTTP_INCLUDE_DIR AND EXISTS "${LLHTTP_INCLUDE_DIR}/llhttp.h")
file(READ "${LLHTTP_INCLUDE_DIR}/llhttp.h" LLHTTP_H)
if(LLHTTP_H)
string(REGEX REPLACE ".*#define[\t ]+LLHTTP_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" LLHTTP_VERSION_MAJOR "${LLHTTP_H}")
string(REGEX REPLACE ".*#define[\t ]+LLHTTP_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" LLHTTP_VERSION_MINOR "${LLHTTP_H}")
set(LLHTTP_VERSION_STRING "${LLHTTP_VERSION_MAJOR}.${LLHTTP_VERSION_MINOR}")
endif()
unset(LLHTTP_H)
endif()

# Handle the QUIETLY and REQUIRED arguments and set LLHTTP_FOUND
# to TRUE if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LLHTTP REQUIRED_VARS LLHTTP_INCLUDE_DIR LLHTTP_LIBRARY)

# Hide advanced variables
mark_as_advanced(LLHTTP_INCLUDE_DIR LLHTTP_LIBRARY)

# Set standard variables
if(LLHTTP_FOUND)
set(LLHTTP_LIBRARIES ${LLHTTP_LIBRARY})
set(LLHTTP_INCLUDE_DIRS ${LLHTTP_INCLUDE_DIR})
endif()
27 changes: 20 additions & 7 deletions cmake/SelectHTTPParser.cmake
@@ -1,19 +1,32 @@
# Optional external dependency: http-parser
if(USE_HTTP_PARSER STREQUAL "system")
if(USE_HTTP_PARSER STREQUAL "http-parser")
find_package(HTTPParser)

if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
list(APPEND LIBGIT2_SYSTEM_LIBS ${HTTP_PARSER_LIBRARIES})
list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
add_feature_info(http-parser ON "http-parser support (system)")
set(GIT_HTTPPARSER_HTTPPARSER 1)
add_feature_info(http-parser ON "using http-parser (system)")
else()
message(FATAL_ERROR "http-parser support was requested but not found")
endif()
elseif(USE_HTTP_PARSER STREQUAL "llhttp")
find_package(LLHTTP)

if(LLHTTP_FOUND AND LLHTTP_VERSION_MAJOR EQUAL 9)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LLHTTP_INCLUDE_DIRS})
list(APPEND LIBGIT2_SYSTEM_LIBS ${LLHTTP_LIBRARIES})
list(APPEND LIBGIT2_PC_LIBS "-lllhttp")
set(GIT_HTTPPARSER_LLHTTP 1)
add_feature_info(http-parser ON "using llhttp (system)")
else()
message(FATAL_ERROR "llhttp support was requested but not found")
endif()
else()
message(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/http-parser" "${PROJECT_BINARY_DIR}/deps/http-parser")
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/http-parser")
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:http-parser>")
add_feature_info(http-parser ON "http-parser support (bundled)")
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/llhttp" "${PROJECT_BINARY_DIR}/deps/llhttp")
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/llhttp")
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:llhttp>")
set(GIT_HTTPPARSER_BUILTIN 1)
add_feature_info(http-parser ON "using bundled parser")
endif()
6 changes: 0 additions & 6 deletions deps/http-parser/CMakeLists.txt

This file was deleted.

23 changes: 0 additions & 23 deletions deps/http-parser/COPYING

This file was deleted.

0 comments on commit b739aca

Please sign in to comment.