Use CMake buildsystem
It is very tiny project with 3 source files. We don't want to have gyp as build-time dependency as it is huge. Writing plain makefile is painful. Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
This commit is contained in:
parent
394fa448b8
commit
0cb0b0d3e3
|
@ -5,3 +5,4 @@
|
||||||
/joyent-http-parser-v2.0-7-gcd01361.tar.gz
|
/joyent-http-parser-v2.0-7-gcd01361.tar.gz
|
||||||
/v2.6.0.tar.gz
|
/v2.6.0.tar.gz
|
||||||
/v2.7.1.tar.gz
|
/v2.7.1.tar.gz
|
||||||
|
/http-parser-2.7.1.tar.gz
|
||||||
|
|
|
@ -96,3 +96,6 @@ index ea26394..45c72a0 100644
|
||||||
/* Request Methods */
|
/* Request Methods */
|
||||||
#define HTTP_METHOD_MAP(XX) \
|
#define HTTP_METHOD_MAP(XX) \
|
||||||
XX(0, DELETE, DELETE) \
|
XX(0, DELETE, DELETE) \
|
||||||
|
--
|
||||||
|
2.10.2
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
--- http_parser.gyp~ 2012-11-27 15:40:11.721398004 -0700
|
|
||||||
+++ http_parser.gyp 2012-11-27 15:40:11.721398004 -0700
|
|
||||||
@@ -12,7 +12,7 @@
|
|
||||||
# RuntimeLibrary MUST MATCH across the entire project
|
|
||||||
'Debug': {
|
|
||||||
'defines': [ 'DEBUG', '_DEBUG' ],
|
|
||||||
- 'cflags': [ '-Wall', '-Wextra', '-O0', '-g', '-ftrapv' ],
|
|
||||||
+ 'cflags': [ '-Wall', '-Wextra', '-g', '-ftrapv' ],
|
|
||||||
'msvs_settings': {
|
|
||||||
'VCCLCompilerTool': {
|
|
||||||
'RuntimeLibrary': 1, # static debug
|
|
||||||
@@ -21,7 +21,7 @@
|
|
||||||
},
|
|
||||||
'Release': {
|
|
||||||
'defines': [ 'NDEBUG' ],
|
|
||||||
- 'cflags': [ '-Wall', '-Wextra', '-O3' ],
|
|
||||||
+ 'cflags': [ '-Wall', '-Wextra' ],
|
|
||||||
'msvs_settings': {
|
|
||||||
'VCCLCompilerTool': {
|
|
||||||
'RuntimeLibrary': 0, # static release
|
|
||||||
@@ -50,7 +50,8 @@
|
|
||||||
'targets': [
|
|
||||||
{
|
|
||||||
'target_name': 'http_parser',
|
|
||||||
- 'type': 'static_library',
|
|
||||||
+ 'type': 'shared_library',
|
|
||||||
+ 'product_extension': 'so.2',
|
|
||||||
'include_dirs': [ '.' ],
|
|
||||||
'direct_dependent_settings': {
|
|
||||||
'defines': [ 'HTTP_PARSER_STRICT=0' ],
|
|
||||||
@@ -73,7 +74,8 @@
|
|
||||||
|
|
||||||
{
|
|
||||||
'target_name': 'http_parser_strict',
|
|
||||||
- 'type': 'static_library',
|
|
||||||
+ 'type': 'shared_library',
|
|
||||||
+ 'product_extension': 'so.2',
|
|
||||||
'include_dirs': [ '.' ],
|
|
||||||
'direct_dependent_settings': {
|
|
||||||
'defines': [ 'HTTP_PARSER_STRICT=1' ],
|
|
109
http-parser.spec
109
http-parser.spec
|
@ -5,23 +5,18 @@
|
||||||
|
|
||||||
Name: http-parser
|
Name: http-parser
|
||||||
Version: %{somajor}.%{sominor}.%{sopoint}
|
Version: %{somajor}.%{sominor}.%{sopoint}
|
||||||
Release: 3%{?dist}
|
Release: 4%{?dist}
|
||||||
Summary: HTTP request/response parser for C
|
Summary: HTTP request/response parser for C
|
||||||
|
|
||||||
Group: System Environment/Libraries
|
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: http://github.com/joyent/http-parser
|
URL: https://github.com/nodejs/http-parser
|
||||||
|
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||||
|
|
||||||
Source0: https://github.com/nodejs/http-parser/archive/v%{version}.tar.gz
|
# https://github.com/nodejs/http-parser/commit/335850f6b868d3411968cbf5a4d59fe619dee36f
|
||||||
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
Patch0001: %{name}-0001-parser-HTTP_STATUS_MAP-XX-and-enum-http_status.patch
|
||||||
|
|
||||||
# Build shared library with SONAME using gyp and remove -O flags so optflags take over
|
BuildRequires: gcc
|
||||||
# TODO: do this nicely upstream
|
BuildRequires: cmake
|
||||||
Patch1: http-parser-gyp-sharedlib.patch
|
|
||||||
Patch2: http-parser-status.patch
|
|
||||||
|
|
||||||
BuildRequires: gyp
|
|
||||||
BuildRequires: util-linux
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This is a parser for HTTP messages written in C. It parses both requests and
|
This is a parser for HTTP messages written in C. It parses both requests and
|
||||||
|
@ -31,76 +26,84 @@ be interrupted at anytime. Depending on your architecture, it only requires
|
||||||
about 40 bytes of data per message stream (in a web server that is per
|
about 40 bytes of data per message stream (in a web server that is per
|
||||||
connection).
|
connection).
|
||||||
|
|
||||||
|
|
||||||
%package devel
|
%package devel
|
||||||
Group: Development/Libraries
|
|
||||||
Summary: Development headers and libraries for http-parser
|
Summary: Development headers and libraries for http-parser
|
||||||
Requires: %{name} = %{version}-%{release}
|
Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
|
||||||
|
|
||||||
%description devel
|
%description devel
|
||||||
Development headers and libraries for http-parser.
|
Development headers and libraries for http-parser.
|
||||||
|
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n http-parser-%{version}
|
%autosetup -p1
|
||||||
|
# TODO: try to send upstream?
|
||||||
|
cat > CMakeLists.txt << EOF
|
||||||
|
cmake_minimum_required (VERSION 2.8.5)
|
||||||
|
project (http-parser C)
|
||||||
|
include (GNUInstallDirs)
|
||||||
|
|
||||||
|
set (SRCS http_parser.c)
|
||||||
|
set (HDRS http_parser.h)
|
||||||
|
set (TEST_SRCS test.c)
|
||||||
|
|
||||||
|
# Non-Strict version
|
||||||
|
add_library (http_parser \${SRCS})
|
||||||
|
target_compile_definitions (http_parser
|
||||||
|
PUBLIC -DHTTP_PARSER_STRICT=0)
|
||||||
|
add_executable (test-nonstrict \${TEST_SRCS})
|
||||||
|
target_link_libraries (test-nonstrict http_parser)
|
||||||
|
# Strict version
|
||||||
|
add_library (http_parser_strict \${SRCS})
|
||||||
|
target_compile_definitions (http_parser_strict
|
||||||
|
PUBLIC -DHTTP_PARSER_STRICT=1)
|
||||||
|
add_executable (test-strict \${TEST_SRCS})
|
||||||
|
target_link_libraries (test-strict http_parser_strict)
|
||||||
|
|
||||||
|
set_target_properties (http_parser http_parser_strict
|
||||||
|
PROPERTIES
|
||||||
|
SOVERSION %{somajor}
|
||||||
|
VERSION %{version})
|
||||||
|
|
||||||
|
install (TARGETS http_parser http_parser_strict
|
||||||
|
LIBRARY DESTINATION \${CMAKE_INSTALL_LIBDIR})
|
||||||
|
install (FILES \${HDRS}
|
||||||
|
DESTINATION \${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
|
|
||||||
|
enable_testing ()
|
||||||
|
add_test (NAME test-nonstrict COMMAND test-nonstrict)
|
||||||
|
add_test (NAME test-strict COMMAND test-strict)
|
||||||
|
EOF
|
||||||
|
|
||||||
%build
|
%build
|
||||||
# TODO: fix -fPIC upstream
|
mkdir %{_target_platform}
|
||||||
export CFLAGS='%{optflags} -fPIC'
|
pushd %{_target_platform}
|
||||||
gyp -f make --depth=`pwd` http_parser.gyp
|
%cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
make %{?_smp_mflags} BUILDTYPE=Release
|
popd
|
||||||
|
%make_build -C %{_target_platform}
|
||||||
|
|
||||||
%install
|
%install
|
||||||
rm -rf %{buildroot}
|
%make_install -C %{_target_platform}
|
||||||
|
|
||||||
install -d %{buildroot}%{_includedir}
|
|
||||||
install -d %{buildroot}%{_libdir}
|
|
||||||
|
|
||||||
install -pm644 http_parser.h %{buildroot}%{_includedir}
|
|
||||||
|
|
||||||
#install regular variant
|
|
||||||
install out/Release/lib.target/libhttp_parser.so.%{somajor} %{buildroot}%{_libdir}/libhttp_parser.so.%{somajor}.%{sominor}
|
|
||||||
ln -sf libhttp_parser.so.%{somajor}.%{sominor} %{buildroot}%{_libdir}/libhttp_parser.so.%{somajor}
|
|
||||||
ln -sf libhttp_parser.so.%{somajor}.%{sominor} %{buildroot}%{_libdir}/libhttp_parser.so
|
|
||||||
|
|
||||||
#install strict variant
|
|
||||||
install out/Release/lib.target/libhttp_parser_strict.so.%{somajor} %{buildroot}%{_libdir}/libhttp_parser_strict.so.%{somajor}.%{sominor}
|
|
||||||
ln -sf libhttp_parser_strict.so.%{somajor}.%{sominor} %{buildroot}%{_libdir}/libhttp_parser_strict.so.%{somajor}
|
|
||||||
ln -sf libhttp_parser_strict.so.%{somajor}.%{sominor} %{buildroot}%{_libdir}/libhttp_parser_strict.so
|
|
||||||
|
|
||||||
|
|
||||||
%check
|
%check
|
||||||
export LD_LIBRARY_PATH='./out/Release/lib.target'
|
make test -C %{_target_platform}
|
||||||
./out/Release/test-nonstrict
|
|
||||||
./out/Release/test-strict
|
|
||||||
|
|
||||||
|
|
||||||
%clean
|
|
||||||
rm -rf %{buildroot}
|
|
||||||
|
|
||||||
|
|
||||||
%post -p /sbin/ldconfig
|
%post -p /sbin/ldconfig
|
||||||
%postun -p /sbin/ldconfig
|
%postun -p /sbin/ldconfig
|
||||||
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root,-)
|
|
||||||
%{_libdir}/libhttp_parser.so.*
|
%{_libdir}/libhttp_parser.so.*
|
||||||
%{_libdir}/libhttp_parser_strict.so.*
|
%{_libdir}/libhttp_parser_strict.so.*
|
||||||
%doc AUTHORS README.md
|
%doc AUTHORS README.md
|
||||||
%license LICENSE-MIT
|
%license LICENSE-MIT
|
||||||
|
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
%defattr(-,root,root,-)
|
%{_includedir}/http_parser.h
|
||||||
%{_includedir}/*
|
|
||||||
%{_libdir}/libhttp_parser.so
|
%{_libdir}/libhttp_parser.so
|
||||||
%{_libdir}/libhttp_parser_strict.so
|
%{_libdir}/libhttp_parser_strict.so
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Nov 21 2016 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 2.7.1-4
|
||||||
|
- Use CMake buildsystem
|
||||||
|
|
||||||
* Tue Oct 25 2016 Nathaniel McCallum <npmccallum@redhat.com> - 2.7.1-3
|
* Tue Oct 25 2016 Nathaniel McCallum <npmccallum@redhat.com> - 2.7.1-3
|
||||||
- Add (upstreamed) status code patch
|
- Add (upstreamed) status code patch
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue