Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

header: treat Wine like MinGW #259

Closed
wants to merge 10 commits into from
Closed

header: treat Wine like MinGW #259

wants to merge 10 commits into from

Conversation

Tatsh
Copy link
Contributor

@Tatsh Tatsh commented Jul 12, 2015

This makes the project work with winegcc.

@@ -144,7 +144,7 @@ enum flags


/* Map for errno-related constants
*

This comment was marked as off-topic.

@indutny
Copy link
Member

indutny commented Jul 16, 2015

Change looks good! The only question is how could one test it?

@Tatsh
Copy link
Contributor Author

Tatsh commented Jul 16, 2015

For testing, not sure the best way to keep this clean, but this works (also I do not know why my conditional with ifeq(wine,$(PLATFORM)) did not work with make PLATFORM=wine, but that is the idea):

$ make CC=winegcc HELPER=wine BINEXT=.exe.so
winegcc  -I. -DHTTP_PARSER_STRICT=1  -Wall -Wextra -Werror -O0 -g  -c http_parser.c -o http_parser_g.o
winegcc  -I. -DHTTP_PARSER_STRICT=1  -Wall -Wextra -Werror -O0 -g  -c test.c -o test_g.o
winegcc -Wall -Wextra -Werror -O0 -g   http_parser_g.o test_g.o -o test_g
winegcc  -I. -DHTTP_PARSER_STRICT=0  -Wall -Wextra -Werror -O3  -c http_parser.c
winegcc  -I. -DHTTP_PARSER_STRICT=0  -Wall -Wextra -Werror -O3  -c test.c -o test.o
winegcc -Wall -Wextra -Werror -O3   http_parser.o test.o -o test_fast
wine test_g.exe.so
wine: cannot find L"C:\\windows\\system32\\winemenubuilder.exe"
err:wineboot:ProcessRunKeys Error running cmd L"C:\\windows\\system32\\winemenubuilder.exe -a -r" (2)
http_parser v2.5.0 (0x020500)
sizeof(http_parser) = 32
response scan 1/2  100%
response scan 2/2  100%
responses okay
request scan 1/4  100%
request scan 2/4  100%
request scan 3/4  100%
request scan 4/4  100%
requests okay
wine test_fast.exe.so
http_parser v2.5.0 (0x020500)
sizeof(http_parser) = 32
response scan 1/2  100%
response scan 2/2  100%
responses okay
request scan 1/4  100%
request scan 2/4  100%
request scan 3/4  100%
request scan 4/4  100%
requests okay
diff --git a/Makefile b/Makefile
index 62009ff..5624be1 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,8 @@
 # IN THE SOFTWARE.

 PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
+HELPER ?=
+BINEXT ?=
 ifeq (darwin,$(PLATFORM))
 SONAME ?= libhttp_parser.2.5.0.dylib
 SOEXT ?= dylib
@@ -26,7 +28,14 @@ else
 SONAME ?= libhttp_parser.so.2.5.0
 SOEXT ?= so
 endif
-CC?=gcc
+
+CC ?= winegcc
+SONAME ?= libhttp_parser.2.5.0.dll
+SOEXT ?= dll
+BINEXT ?= .exe.so
+HELPER ?= wine
+
+# CC?=gcc
 AR?=ar

 CPPFLAGS ?=
@@ -58,8 +67,8 @@ LDFLAGS_LIB += -Wl,-soname=$(SONAME)
 endif

 test: test_g test_fast
-       ./test_g
-       ./test_fast
+       $(HELPER) test_g$(BINEXT)
+       $(HELPER) test_fast$(BINEXT)

 test_g: http_parser_g.o test_g.o
        $(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@
@@ -86,7 +95,7 @@ http_parser.o: http_parser.c http_parser.h Makefile
        $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c

 test-run-timed: test_fast
-       while(true) do time ./test_fast > /dev/null; done
+       while(true) do time $(HELPER) ./test_fast$(BINEXT) > /dev/null; done

 test-valgrind: test_g
        valgrind ./test_g
@@ -107,10 +116,10 @@ url_parser_g: http_parser_g.o contrib/url_parser.c
        $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $@

 parsertrace: http_parser.o contrib/parsertrace.c
-       $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace
+       $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace$(BINEXT)

 parsertrace_g: http_parser_g.o contrib/parsertrace.c
-       $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g
+       $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g$(BINEXT)

 tags: http_parser.c http_parser.h test.c
        ctags $^
@@ -133,7 +142,8 @@ uninstall:
 clean:
        rm -f *.o *.a tags test test_fast test_g \
                http_parser.tar libhttp_parser.so.* \
-               url_parser url_parser_g parsertrace parsertrace_g
+               url_parser url_parser_g parsertrace parsertrace_g \
+               *.exe *.exe.so

 contrib/url_parser.c:  http_parser.h
 contrib/parsertrace.c: http_parser.h

@Tatsh
Copy link
Contributor Author

Tatsh commented Jul 17, 2015

I made this work with Travis, but I do not know if this is wanted. Reasoning is because it takes much longer to install Wine. It would be better to make a matrix more proper where a separate box only installs Wine, runs make PLATFORM=wine and that is it. So what I have committed for .travis.yml is definitely not the best way.

According to Travis documentation, only compiler and env set up a build matrix, but I do not think you can put anything other than gcc or clang for compiler value. script does not add to the multiplier for build matrix. I guess you could do something like this?

compiler:
  - clang
  - gcc
env:
  - nothing=1
  - PLATFORM=wine
matrix:
  exclude:
    - compiler: clang
      env: PLATFORM=wine
script: "make -e"

This way you create (2x2)-1 build matrix. And use make -e to inherit environment variables instead of using them on the make command line (i.e. make PLATFORM=wine).

@indutny
Copy link
Member

indutny commented Jul 19, 2015

@Tatsh I'd rather remove it from travis.

@Tatsh
Copy link
Contributor Author

Tatsh commented Jul 19, 2015

As long as you have Wine installed (winegcc in PATH), make PLATFORM=wine is the way to test that build. Even if you are not in a terminal with DISPLAY defined (or other requirements to use Wine with X), this will work.

As requested, the style change was removed, and the #if was split into two lines with 2 space indents.

indutny pushed a commit that referenced this pull request Jul 23, 2015
PR-URL: #259
Reviewed-By: Fedor Indutny <fedor@indutny.com>
@indutny
Copy link
Member

indutny commented Jul 23, 2015

Landed in b36c2a9, thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants