Commit d10228cd authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Merge branch 'mindw-lib_msvc_fix'

parents 3973d9ce 1dd3564d
...@@ -31,3 +31,10 @@ test-driver ...@@ -31,3 +31,10 @@ test-driver
# test logs generated by `make check` # test logs generated by `make check`
*.log *.log
*.trs *.trs
lib/MSVC_obj/
_VC_ROOT/
.depend.MSVC
*.pyd
*.egg-info/
python/nghttp2.c
...@@ -10,50 +10,68 @@ ...@@ -10,50 +10,68 @@
# Choose your weapons: # Choose your weapons:
# Set 'USE_CYTHON=1' to build and install the 'nghttp2.pyd' Python extension. # Set 'USE_CYTHON=1' to build and install the 'nghttp2.pyd' Python extension.
# #
USE_CYTHON = 1 THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
_VERSION := $(shell grep AC_INIT ../configure.ac | cut -d'[' -f3 | sed -e 's/-DEV], //g') USE_CYTHON := 1
_VERSION := $(subst ., ,$(_VERSION)) #USE_CYTHON := 0
VER_MAJOR = $(word 1,$(_VERSION))
VER_MINOR = $(word 2,$(_VERSION))
VER_MICRO = $(word 3,$(_VERSION))
VERSION = $(VER_MAJOR).$(VER_MINOR).$(VER_MICRO)
VERSION_NUM = ($(VER_MAJOR) << 16) + ($(VER_MINOR) << 8) + $(VER_MICRO)
GENERATED = 'Generated by $(realpath Makefile.MSVC)' _VERSION := $(shell grep AC_INIT ../configure.ac | cut -d'[' -f3 | sed -e 's/-DEV], //g')
_VERSION := $(subst ., ,$(_VERSION))
VER_MAJOR := $(word 1,$(_VERSION))
VER_MINOR := $(word 2,$(_VERSION))
VER_MICRO := $(word 3,$(_VERSION))
VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_MICRO)
VERSION_NUM := ($(VER_MAJOR) << 16) + ($(VER_MINOR) << 8) + $(VER_MICRO)
GENERATED := 'Generated by $(realpath Makefile.MSVC)'
OBJ_DIR := MSVC_obj
#SUFFIX :=-vc90-mt-x86
# #
# Where to copy nghttp2.dll + lib + headers to. # Where to copy nghttp2.dll + lib + headers to.
# Note: 'make install' is not in default targets. Do it explicitly. # Note: 'make install' is not in default targets. Do it explicitly.
# #
VC_ROOT = $(realpath $(VCINSTALLDIR)) TARGET_DIR ?= ../_VC_ROOT
INSTALL_BIN = $(VC_ROOT)/bin VC_ROOT := $(abspath $(TARGET_DIR))
INSTALL_LIB = $(VC_ROOT)/lib INSTALL_BIN := $(VC_ROOT)/bin
INSTALL_HDR = $(VC_ROOT)/include INSTALL_LIB := $(VC_ROOT)/lib
INSTALL_HDR := $(VC_ROOT)/include
DLL_R := $(OBJ_DIR)/nghttp2$(SUFFIX).dll
DLL_D := $(OBJ_DIR)/nghttp2d$(SUFFIX).dll
LIB_R := $(OBJ_DIR)/nghttp2-static.lib
LIB_D := $(OBJ_DIR)/nghttp2d-static.lib
IMP_R := $(OBJ_DIR)/nghttp2.lib
IMP_D := $(OBJ_DIR)/nghttp2d.lib
# #
# Build for DEBUG-model and RELEASE at the same time. # Build for DEBUG-model and RELEASE at the same time.
# #
TARGETS = nghttp2.lib nghttp2.dll nghttp2_imp.lib \ TARGETS := $(LIB_R) $(DLL_R) $(IMP_R) \
nghttp2d.lib nghttp2d.dll nghttp2d_imp.lib $(LIB_D) $(DLL_D) $(IMP_D)
EXT_LIBS = EXT_LIBS =
OBJ_DIR = MSVC_obj NGHTTP2_PDB_R := $(OBJ_DIR)/nghttp2.pdb
NGHTTP2_PDB_D := $(OBJ_DIR)/nghttp2d.pdb
NGHTTP2_PDB_R = $(OBJ_DIR)/nghttp2.pdb
NGHTTP2_PDB_D = $(OBJ_DIR)/nghttp2d.pdb
CC = cl CC = cl
CFLAGS = -I./includes -Dssize_t=long -D_U_="" LD := link
AR := lib
CFLAGS_R = -nologo -MD -W3 -Zi -Fd./$(NGHTTP2_PDB_R) #CC := icl
CFLAGS_D = -nologo -MDd -W3 -Zi -Fd./$(NGHTTP2_PDB_D) \ #LD := xilink
#AR := xilib
RC := rc
CFLAGS := -I./includes -Dssize_t=long -D_U_=""
CFLAGS_R := -nologo -MD -W3 -Z7 -DBUILDING_NGHTTP2
CFLAGS_D := -nologo -MDd -W3 -Z7 -DBUILDING_NGHTTP2 \
-Ot -D_DEBUG -GF -RTCs -RTCu # -RTCc -GS -Ot -D_DEBUG -GF -RTCs -RTCu # -RTCc -GS
LDFLAGS = -nologo -machine:x64 -map -debug -incremental:no # -verbose LDFLAGS := -nologo -MAP -debug -incremental:no -opt:ref,icf -MANIFEST # -verbose
NGHTTP2_SRC = nghttp2_pq.c \ NGHTTP2_SRC := nghttp2_pq.c \
nghttp2_map.c \ nghttp2_map.c \
nghttp2_queue.c \ nghttp2_queue.c \
nghttp2_frame.c \ nghttp2_frame.c \
...@@ -74,10 +92,16 @@ NGHTTP2_SRC = nghttp2_pq.c \ ...@@ -74,10 +92,16 @@ NGHTTP2_SRC = nghttp2_pq.c \
nghttp2_mem.c \ nghttp2_mem.c \
nghttp2_http.c nghttp2_http.c
NGHTTP2_OBJ_R = $(addprefix $(OBJ_DIR)/r_, $(notdir $(NGHTTP2_SRC:.c=.obj))) NGHTTP2_OBJ_R := $(addprefix $(OBJ_DIR)/r_, $(notdir $(NGHTTP2_SRC:.c=.obj)))
NGHTTP2_OBJ_D = $(addprefix $(OBJ_DIR)/d_, $(notdir $(NGHTTP2_SRC:.c=.obj))) NGHTTP2_OBJ_D := $(addprefix $(OBJ_DIR)/d_, $(notdir $(NGHTTP2_SRC:.c=.obj)))
all: intro $(OBJ_DIR) $(TARGETS) .PHONY: all intro test_ver install copy_headers_and_libs \
install_nghttp2_pyd_0 install_nghttp2_pyd_1 \
build_nghttp2_pyd_0 build_nghttp2_pyd_1 \
clean_nghttp2_pyd_0 clean_nghttp2_pyd_1
all: intro $(OBJ_DIR) $(TARGETS) build_nghttp2_pyd_$(USE_CYTHON)
@echo 'Welcome to NgHTTP2 (release + debug).' @echo 'Welcome to NgHTTP2 (release + debug).'
@echo 'Do a "make -f Makefile.MSVC install" at own risk!' @echo 'Do a "make -f Makefile.MSVC install" at own risk!'
...@@ -95,73 +119,88 @@ $(OBJ_DIR): ...@@ -95,73 +119,88 @@ $(OBJ_DIR):
- mkdir $(OBJ_DIR) - mkdir $(OBJ_DIR)
install: includes/nghttp2/nghttp2.h includes/nghttp2/nghttp2ver.h \ install: includes/nghttp2/nghttp2.h includes/nghttp2/nghttp2ver.h \
nghttp2.dll nghttp2.lib nghttp2_imp.lib \ $(TARGETS) \
nghttp2d.dll nghttp2d.lib nghttp2d_imp.lib \ copy_headers_and_libs install_nghttp2_pyd_$(USE_CYTHON)
copy_headers_and_libs install_nghttp2_pyd_$(USE_CYTHON)
# #
# This MUST be done before using the 'install_nghttp2_pyd_1' rule. # This MUST be done before using the 'install_nghttp2_pyd_1' rule.
# #
copy_headers_and_libs: copy_headers_and_libs:
- mkdir $(INSTALL_HDR)/nghttp2 - mkdir -p $(INSTALL_HDR)/nghttp2 $(INSTALL_BIN) $(INSTALL_LIB)
cp --update $(addprefix includes/nghttp2/, nghttp2.h nghttp2ver.h) $(INSTALL_HDR)/nghttp2 cp --update $(addprefix includes/nghttp2/, nghttp2.h nghttp2ver.h) $(INSTALL_HDR)/nghttp2
cp --update nghttp2.dll nghttp2d.dll $(NGHTTP2_PDB_R) $(NGHTTP2_PDB_D) $(INSTALL_BIN) cp --update $(DLL_R) $(DLL_D) $(NGHTTP2_PDB_R) $(NGHTTP2_PDB_D) $(INSTALL_BIN)
cp --update nghttp2.lib nghttp2d.lib nghttp2_imp.lib nghttp2d_imp.lib $(INSTALL_LIB) cp --update $(IMP_R) $(IMP_D) $(LIB_R) $(LIB_D) $(INSTALL_LIB)
@echo @echo
nghttp2.lib: $(NGHTTP2_OBJ_R) $(LIB_R): $(NGHTTP2_OBJ_R)
lib -nologo -out:$@ $^ $(AR) -nologo -out:$@ $^
@echo @echo
nghttp2d.lib: $(NGHTTP2_OBJ_D) $(LIB_D): $(NGHTTP2_OBJ_D)
lib -nologo -out:$@ $^ $(AR) -nologo -out:$@ $^
@echo @echo
nghttp2.dll nghttp2_imp.lib: $(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res
link $(LDFLAGS) -dll -out:nghttp2.dll -implib:nghttp2_imp.lib \ $(IMP_R): $(DLL_R)
$(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res $(EXT_LIBS)
$(DLL_R): $(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res
$(LD) $(LDFLAGS) -dll -out:$@ -implib:$(IMP_R) $(NGHTTP2_OBJ_R) -PDB:$(NGHTTP2_PDB_R) $(OBJ_DIR)/r_nghttp2.res $(EXT_LIBS)
mt -nologo -manifest $@.manifest -outputresource:$@\;2
@echo @echo
nghttp2d.dll nghttp2d_imp.lib: $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res $(IMP_D): $(DLL_D)
link $(LDFLAGS) -dll -out:nghttp2d.dll -implib:nghttp2d_imp.lib \
$(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res $(EXT_LIBS) $(DLL_D): $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res
$(LD) $(LDFLAGS) -dll -out:$@ -implib:$(IMP_D) $(NGHTTP2_OBJ_D) -PDB:$(NGHTTP2_PDB_D) $(OBJ_DIR)/d_nghttp2.res $(EXT_LIBS)
mt -nologo -manifest $@.manifest -outputresource:$@\;2
@echo @echo
install_nghttp2_pyd_0: ;
install_nghttp2_pyd_1: $(addprefix ../python/, setup.py.in nghttp2.pyx) WIN_OBJDIR:=$(shell cygpath -w $(abspath $(OBJ_DIR)))
WIN_OBJDIR:=$(subst \,/,$(WIN_OBJDIR))
../python/setup.py: ../python/setup.py.in $(THIS_MAKEFILE)
cd ../python ; \ cd ../python ; \
echo '# $(GENERATED). DO NOT EDIT.' > setup.py ; \ echo '# $(GENERATED). DO NOT EDIT.' > setup.py ; \
sed -e 's/@top_srcdir@/../' \ sed -e 's/@top_srcdir@/../' \
-e 's/@top_builddir@/../' \ -e 's%@top_builddir@%$(WIN_OBJDIR)%' \
-e 's/@PACKAGE_VERSION@/$(VERSION)/' setup.py.in >> setup.py ; \ -e 's/@PACKAGE_VERSION@/$(VERSION)/' setup.py.in >> setup.py ;
cython -v nghttp2.pyx ; \
python setup.py install build_nghttp2_pyd_0: ;
build_nghttp2_pyd_1: $(addprefix ../python/, setup.py nghttp2.pyx)
cd ../python ; \
python setup.py build_ext -i -f bdist_wininst
install_nghttp2_pyd_0: ;
install_nghttp2_pyd_1: $(addprefix ../python/, setup.py nghttp2.pyx)
cd ../python ; \
pip install .
clean_nghttp2_pyd_0: ; clean_nghttp2_pyd_0: ;
clean_nghttp2_pyd_1: clean_nghttp2_pyd_1:
cd ../python ; \ cd ../python ; \
rm -f setup.py nghttp2.c ; \ rm -fR build dist
rm -fR build/*
$(OBJ_DIR)/r_%.obj: %.c $(OBJ_DIR)/r_%.obj: %.c $(THIS_MAKEFILE)
$(CC) $(CFLAGS_R) $(CFLAGS) -Fo$@ -c $< $(CC) $(CFLAGS_R) $(CFLAGS) -Fo$@ -c $<
@echo @echo
$(OBJ_DIR)/d_%.obj: %.c $(OBJ_DIR)/d_%.obj: %.c $(THIS_MAKEFILE)
$(CC) $(CFLAGS_D) $(CFLAGS) -Fo$@ -c $< $(CC) $(CFLAGS_D) $(CFLAGS) -Fo$@ -c $<
@echo @echo
$(OBJ_DIR)/r_nghttp2.res: nghttp2.rc $(OBJ_DIR)/r_nghttp2.res: $(OBJ_DIR)/nghttp2.rc $(THIS_MAKEFILE)
rc -nologo -D_RELEASE -Fo $@ $< $(RC) -nologo -D_RELEASE -Fo $@ $<
@echo @echo
$(OBJ_DIR)/d_nghttp2.res: nghttp2.rc $(OBJ_DIR)/d_nghttp2.res: $(OBJ_DIR)/nghttp2.rc $(THIS_MAKEFILE)
rc -nologo -D_DEBUG -Fo $@ $< $(RC) -nologo -D_DEBUG -Fo $@ $<
@echo @echo
includes/nghttp2/nghttp2ver.h: includes/nghttp2/nghttp2ver.h.in includes/nghttp2/nghttp2ver.h: includes/nghttp2/nghttp2ver.h.in $(THIS_MAKEFILE)
sed < includes/nghttp2/nghttp2ver.h.in \ sed < includes/nghttp2/nghttp2ver.h.in \
-e 's/@PACKAGE_VERSION@/$(VERSION)/g' \ -e 's/@PACKAGE_VERSION@/$(VERSION)/g' \
-e 's/@PACKAGE_VERSION_NUM@/($(VERSION_NUM))/g' > $@ -e 's/@PACKAGE_VERSION_NUM@/($(VERSION_NUM))/g' > $@
...@@ -201,8 +240,6 @@ define RES_FILE ...@@ -201,8 +240,6 @@ define RES_FILE
VALUE "OriginalFilename", "nghttp2" DBG ".dll" VALUE "OriginalFilename", "nghttp2" DBG ".dll"
VALUE "ProductName", "NGHTTP2." VALUE "ProductName", "NGHTTP2."
VALUE "ProductVersion", VER_STR VALUE "ProductVersion", VER_STR
VALUE "PrivateBuild", "The privat build of <gvanem@yahoo.no>."
VALUE "SpecialBuild", ""
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
...@@ -214,20 +251,19 @@ endef ...@@ -214,20 +251,19 @@ endef
export RES_FILE export RES_FILE
nghttp2.rc: Makefile.MSVC $(OBJ_DIR)/nghttp2.rc: Makefile.MSVC
@echo 'Generating $@...' @echo 'Generating $@...'
@echo ' /* $(GENERATED). DO NOT EDIT.' > $@ @echo ' /* $(GENERATED). DO NOT EDIT.' > $@
@echo ' */' >> $@ @echo ' */' >> $@
@echo "$$RES_FILE" >> $@ @echo "$$RES_FILE" >> $@
clean: clean:
rm -f $(OBJ_DIR)/* nghttp2_imp.exp nghttp2_imp.exp \ rm -f $(OBJ_DIR)/* includes/nghttp2/nghttp2ver.h
nghttp2.map nghttp2d.map nghttp2.rc includes/nghttp2/nghttp2ver.h
@echo @echo
vclean realclean: clean clean_nghttp2_pyd_$(USE_CYTHON) vclean realclean: clean clean_nghttp2_pyd_$(USE_CYTHON)
rm -f $(TARGETS) nghttp2.pdb nghttp2d.pdb nghttp2_imp.exp nghttp2d_imp.exp .depend.MSVC - rm -rf $(OBJ_DIR)
- rmdir $(OBJ_DIR) - rm -f .depend.MSVC
# #
# Use gcc to generated the dependencies. No MSVC specific args please! # Use gcc to generated the dependencies. No MSVC specific args please!
......
...@@ -356,7 +356,7 @@ int nghttp2_hd_emit_newname_block(nghttp2_bufs *bufs, nghttp2_nv *nv, ...@@ -356,7 +356,7 @@ int nghttp2_hd_emit_newname_block(nghttp2_bufs *bufs, nghttp2_nv *nv,
int nghttp2_hd_emit_table_size(nghttp2_bufs *bufs, size_t table_size); int nghttp2_hd_emit_table_size(nghttp2_bufs *bufs, size_t table_size);
/* For unittesting purpose */ /* For unittesting purpose */
nghttp2_hd_entry *nghttp2_hd_table_get(nghttp2_hd_context *context, NGHTTP2_EXTERN nghttp2_hd_entry *nghttp2_hd_table_get(nghttp2_hd_context *context,
size_t index); size_t index);
/* For unittesting purpose */ /* For unittesting purpose */
......
...@@ -21,14 +21,10 @@ ...@@ -21,14 +21,10 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import sys from setuptools import setup, Extension
from distutils.core import setup from Cython.Build import cythonize
from distutils.extension import Extension
LIBS = ['nghttp2']
if sys.platform == "win32":
LIBS = ['nghttp2_imp', 'ws2_32']
else:
LIBS = ['nghttp2']
setup( setup(
name = 'python-nghttp2', name = 'python-nghttp2',
...@@ -38,12 +34,13 @@ setup( ...@@ -38,12 +34,13 @@ setup(
author_email = 'tatsuhiro.t@gmail.com', author_email = 'tatsuhiro.t@gmail.com',
url = 'https://nghttp2.org/', url = 'https://nghttp2.org/',
keywords = [], keywords = [],
ext_modules = [Extension("nghttp2", ext_modules = cythonize([Extension("nghttp2",
["nghttp2.c"], ["nghttp2.pyx"],
include_dirs=['@top_srcdir@/lib', include_dirs=['@top_srcdir@/lib',
'@top_srcdir@/lib/includes', '@top_srcdir@/lib/includes',
'@top_builddir@/lib/includes'], '@top_builddir@/lib/includes'],
library_dirs=['@top_builddir@/lib/.libs'], library_dirs=['@top_builddir@/lib/.libs',
libraries=LIBS)], '@top_builddir@'],
libraries=LIBS)]),
long_description='TBD' long_description='TBD'
) )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment