-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add picohttpparser #19034
add picohttpparser #19034
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sources: | ||
"cci.20230804": | ||
url: "https://github.com/h2o/picohttpparser/archive/066d2b1e9ab820703db0837a7255d92d30f0c9f5.tar.gz" | ||
sha256: "637ff2ab6f5c7f7e05a5b5dc393d5cf2fea8d4754fcaceaaf935ffff5c1323ee" | ||
patches: | ||
"cci.20230804": | ||
- patch_file: "patches/cci.20230804-0001-add-cmake.patch" | ||
patch_description: "add CMakeLists.txt" | ||
patch_type: "conan" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.files import get, apply_conandata_patches, export_conandata_patches | ||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout | ||
from conan.tools.layout import basic_layout | ||
|
||
required_conan_version = ">=1.51.1" | ||
|
||
|
||
class PicohttpparserConan(ConanFile): | ||
name = "picohttpparser" | ||
description = "tiny HTTP parser written in C (used in HTTP::Parser::XS et al.)" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
license = "MIT" | ||
homepage = "https://github.com/h2o/picohttpparser" | ||
topics = ("http", "parser") | ||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = {"shared": [True, False], "fPIC": [True, False]} | ||
default_options = {"shared": False, "fPIC": True} | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def package(self): | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.generate() | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like the project is abandoned, but still I'll ask you to send this CMake support the upstream first. To use here, please, do not use as a patch, but use export_sources instead. Take a look in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I will try to send this patch to upstream |
||
new file mode 100644 | ||
index 0000000..45a748c | ||
--- /dev/null | ||
+++ b/CMakeLists.txt | ||
@@ -0,0 +1,19 @@ | ||
+cmake_minimum_required(VERSION 3.16) | ||
+project(picohttpparser) | ||
+ | ||
+# Set the C standard | ||
+set(CMAKE_C_STANDARD 99) | ||
+ | ||
+# Build the library from picohttpparser.c | ||
+add_library(picohttpparser STATIC picohttpparser.c) | ||
+ | ||
+# Include the current directory to find picohttpparser.h | ||
+target_include_directories(picohttpparser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||
+ | ||
+# Install the library and headers | ||
+install(TARGETS picohttpparser | ||
+ ARCHIVE DESTINATION lib | ||
+ LIBRARY DESTINATION lib) | ||
+install ( | ||
+ FILES picohttpparser.h | ||
+ DESTINATION include) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
project(test_package LANGUAGES CXX) | ||
|
||
find_package(picohttpparser REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE picohttpparser::picohttpparser) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <picohttpparser.h> | ||
#include <assert.h> | ||
#include <stdio.h> | ||
|
||
#define REQ \ | ||
"GET /wp-content/uploads/2010/03/hello-kitty-darth-vader-pink.jpg " \ | ||
"HTTP/1.1\r\n" \ | ||
"Host: www.kittyhell.com\r\n" \ | ||
"User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; ja-JP-mac; " \ | ||
"rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 " \ | ||
"Pathtraq/0.9\r\n" \ | ||
"Accept: " \ | ||
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" \ | ||
"Accept-Language: ja,en-us;q=0.7,en;q=0.3\r\n" \ | ||
"Accept-Encoding: gzip,deflate\r\n" \ | ||
"Accept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.7\r\n" \ | ||
"Keep-Alive: 115\r\n" \ | ||
"Connection: keep-alive\r\n" \ | ||
"Cookie: wp_ozh_wsa_visits=2; wp_ozh_wsa_visit_lasttime=xxxxxxxxxx; " \ | ||
"__utma=xxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.x; " \ | ||
"__utmz=xxxxxxxxx.xxxxxxxxxx.x.x.utmccn=(referral)|utmcsr=reader." \ | ||
"livedoor.com|utmcct=/reader/|utmcmd=referral\r\n" \ | ||
"\r\n" | ||
|
||
int main(int argc, char **) { | ||
const char *method; | ||
size_t method_len; | ||
const char *path; | ||
size_t path_len; | ||
int minor_version; | ||
struct phr_header headers[32]; | ||
size_t num_headers; | ||
int i, ret; | ||
|
||
num_headers = sizeof(headers) / sizeof(headers[0]); | ||
ret = | ||
phr_parse_request(REQ, sizeof(REQ) - 1, &method, &method_len, &path, | ||
&path_len, &minor_version, headers, &num_headers, 0); | ||
assert(ret == sizeof(REQ) - 1); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from conans import ConanFile, CMake | ||
from conan.tools.build import cross_building | ||
import os | ||
|
||
|
||
class TestPackageV1Conan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"cci.20230804": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package_info is missing.