Skip to content
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

Google backporting #75

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
476a754
Update to spidermonkey to version 1.8.0-rc1
slattarini Feb 15, 2016
b435c52
Extend shell-based tests for pactester; not yet passing
slattarini Feb 15, 2016
b4afa5a
Add C utility library for future uses.
slattarini Feb 15, 2016
cad6c8c
preparatory refactorings in resolve_host(), step 1
slattarini Feb 15, 2016
bc2f253
myIpAddressEx(): return 127.0.0.1 if unable to determine the local IP.
slattarini Feb 15, 2016
c85c114
dnsResolveEx(): on failure, return null, not ""
slattarini Feb 15, 2016
6f5007d
preparatory refactoring in resolve_host(), step 2
slattarini Feb 15, 2016
2e84edc
Less duplication in C functions dealing with DNS in JavaScript context
slattarini Feb 15, 2016
db61851
Allow users to disable Microsoft *Ex() functions
slattarini Feb 15, 2016
887fa1c
pactester: better IPv6 addresses support, backport of Google modifica…
slattarini Feb 15, 2016
f6ef520
Make sure that dnsResolveEx() returns IPv6 addrs before IPv4 addrs
slattarini Feb 16, 2016
72f7f7c
make code for resolve_host() somewhat saner
slattarini Feb 16, 2016
3e2dd53
pactester.c: pacparser_set_dns_{server,domains} might return error
slattarini Feb 16, 2016
239d398
Fix formatting in pacparser.h, remove duplicated comments
slattarini Feb 16, 2016
62f6ef8
Allow user to select which DNS resolver to use
slattarini Feb 16, 2016
20eb9e5
Move DNS resolutions internal details in its own file (pacarser_dns.c)
slattarini Feb 16, 2016
06b394d
Remove few unneeded #include directives
slattarini Feb 16, 2016
3b02377
Prepare the stage for upcoming c-ares integration
slattarini Feb 16, 2016
d3f718e
cosmetics and stylistic changes
slattarini Feb 16, 2016
7d8e996
Add c-ares integration, still quite rough around the edges
slattarini Feb 16, 2016
00b8b66
pac_utils.h: couple of cosmetic changes to enhance readability (sligh…
slattarini Apr 4, 2016
f98d713
pymod: update license, few stylistic changes
slattarini Apr 4, 2016
921eaa0
pymod: integrate all new features added to the C library
slattarini Apr 4, 2016
5e39d26
pacparser.hL trivial typofix in comments
slattarini Apr 4, 2016
6e37da6
Get rid of dns_resolver_t, using strings is simpler & clearer
slattarini Apr 4, 2016
a9f256d
pymod: implement the set_dns_resolver_variant() function
slattarini Apr 4, 2016
0aa79d7
pac_utils.h -> pac_builtins.h
slattarini Apr 4, 2016
9513618
Rename: ares_wait_for_all_queries_to_complete() -> ares_wait_for_all_…
slattarini Apr 4, 2016
51aa9df
Get rid of a couple of C utility functions
slattarini Apr 4, 2016
c5142d3
Simplify pacparser_resolve_host_getaddrinfo() implementation
slattarini Apr 5, 2016
beef022
Remove unused utility functions
slattarini Apr 5, 2016
455be51
pacparser_dns: reduce doe duplication and indirection
slattarini Apr 5, 2016
ac9a233
DNS domains: allow them to be specified as a comma-separated string
slattarini Apr 5, 2016
1666bdf
Get rid of few more unused utility functions
slattarini Apr 5, 2016
5ddbe1e
Get rid of util.c, inline the two remaining function in the file usin…
slattarini Apr 5, 2016
82fd83b
adjust pymod to recent changes
slattarini Apr 5, 2016
4a379bb
fix a memory misalignment (thanks tmalloc for catching it)
slattarini Apr 5, 2016
65fe22d
pymod: update slightly obsolete comment
slattarini Apr 5, 2016
9c48efc
Fix some style issues and uncheck mallocs
slattarini Apr 6, 2016
620e8d8
Merge pacparser_dns.c into pacparser.c
slattarini Apr 8, 2016
18263d2
Slightly better error messages, with less code duplication
slattarini Apr 8, 2016
d0c0c89
pactester.c: refactor for clarity and less shady memory management
slattarini Apr 8, 2016
c45838f
read_file_into_str(): do not return NULL upon reading empty files
slattarini Apr 8, 2016
9e524b2
Fix docs generation, and update docs.
slattarini Apr 8, 2016
c46245c
make directory structure more flat, switch to setuptools (from distut…
slattarini Apr 8, 2016
c29750d
Rework error-printing macro to only call user-defined error printing …
slattarini Apr 8, 2016
274bd3a
simplify concat_strings()
slattarini Apr 8, 2016
2664d47
Simplify str_replace() slightly, fix a memory leak in the process
slattarini Apr 8, 2016
a9870c6
fix another memory leak: we were never calling freeaddrinfo()
slattarini Apr 8, 2016
d6f80fd
give a warning on getnameinfo() failures
slattarini Apr 8, 2016
55db2cd
"foo = realloc(foo, ...)" is a classic anti-pattern which can cause m…
slattarini Apr 10, 2016
a0e759b
test_pacparser.py: add short top-level description
slattarini Apr 10, 2016
ac14db3
More tests (for the python module, and for the isInNetEx() function)
slattarini Apr 10, 2016
e428ce1
pacparser.c: fix a double-free issue revealed by our new python tests
slattarini Apr 10, 2016
d85a9e1
pacparser_ares_init(): try harder not to leave things half-initialize…
slattarini Apr 10, 2016
74fbc5b
isInNetEx4(); handle a prefix_len of 0 correctly
slattarini Apr 10, 2016
ef71ab9
pacparser.h: fix minor typo in comments
slattarini Apr 11, 2016
ee13301
pactester.c: use __FILE__ rather than hardcoding the filename
slattarini Apr 12, 2016
99860ab
pactester: report usage error if -u and -f options are both used
slattarini Apr 12, 2016
f4d0432
use gai_strerror(err) rather than strerror(errno) to report getnamein…
slattarini Apr 12, 2016
ef3fda7
concat_strings(): have a saner interface with clearer emory ownership
slattarini Apr 12, 2016
9137816
collect_mallocd_address(): give diagnostics on memory errors
slattarini Apr 12, 2016
5585317
pactester: on malformed URLs, report the original one rather than a p…
slattarini Apr 12, 2016
4178d2a
try even harder not to leave c-ares half-initialized in case of error…
slattarini Apr 12, 2016
697bce3
getnameinfo doesn't guarantee that error values will be negative, onl…
slattarini Apr 12, 2016
e0a3917
Always return null when resolving an empty hostname
slattarini Apr 14, 2016
d9c6ef3
Fix unconsistent indentation
slattarini Apr 14, 2016
e7d82ef
Fix one occurrence of inconsistent shell variable expansion
slattarini Apr 14, 2016
ef0f7b9
pymod: make pacparser exception avilable to clients
slattarini Aug 2, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Object files
*.o

# Python bytecode
*.pyc
*.pyo

# Libraries
*.lib
*.a
Expand All @@ -22,9 +26,16 @@ tools/packages
*.pkg

# Other build files
pymod/build
pymod/pacparser.egg-info
*buildstamp
src/spidermonkey/js
src/pactester
spidermonkey/js
pactester

# Temporary files resulting from tests.
stderr.tmp
stdout.tmp
pac.js.tmp

# OS specific files
.DS_Store
119 changes: 85 additions & 34 deletions src/Makefile → Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,46 @@
# packaging script.
-include version.mk

VERSION ?= $(shell git describe --always --tags --candidate=100)

BASH ?= bash
PREFIX ?= /usr
VERSION ?= $(shell git describe --always --tags --candidate=100)
OS_ARCH := $(subst /,_,$(shell uname -s | sed /\ /s//_/))

LIBRARY_NAME = libpacparser
LIB_VER = 1

PYTHON ?= python

LDFLAGS =
CFLAGS = -g -DXP_UNIX -Wall -DVERSION=$(VERSION)

# NOTICE(slattarini): in an ideal world, we would autonconfiscate the
# pacparser build system and turn these definition into automatically
# populated ones (via ./configure); however, given the current status of
# the build system, compounded by the fact that we use a bundled package
# (SpiderMonkey) which is not autoconfiscated and mostly incompatible with
# several autotools conventions, we take the easier albeit suboptimal
# solution.
ENABLE_C_ARES ?= auto
ifeq "$(ENABLE_C_ARES)" "auto"
ENABLE_C_ARES := $(shell pkg-config --exists libcares && echo yes || echo no)
$(info ENABLE_C_ARES was undefined; autodetected to "$(ENABLE_C_ARES)")
ifeq "$(ENABLE_C_ARES)" "yes"
C_ARES_CFLAGS := $(shell pkg-config --cflags libcares)
C_ARES_LDFLAGS := $(shell pkg-config --libs libcares)
C_ARES_LDFLAGS += -Wl,-rpath
C_ARES_LDFLAGS += -Wl,$(shell pkg-config --variable=libdir libcares)
endif
endif
ifeq "$(ENABLE_C_ARES)" "yes"
C_ARES_CFLAGS += -DHAVE_C_ARES
else
$(warning c-ares (http://c-ares.haxx.se) library not found or disabled)
$(warning Some DNS-related features will be unavailable)
endif
CFLAGS += $(C_ARES_CFLAGS)
LDFLAGS += $(C_ARES_LDFLAGS)

# This Makefile should at least work on Linux and Mac OS X. It should work on
# most other types of Unix systems too, but I have not put any conscious effort
# for that.
Expand All @@ -55,12 +87,6 @@ ifeq ($(OS_ARCH),Darwin)
endif
endif

CFLAGS = -g -DXP_UNIX -Wall -DVERSION=$(VERSION)

ifndef PYTHON
PYTHON = python
endif

# Spidermonkey library.
CFLAGS += -Ispidermonkey/js/src

Expand All @@ -70,12 +96,13 @@ LIB_PREFIX = $(PREFIX)/lib
INC_PREFIX = $(PREFIX)/include
BIN_PREFIX = $(PREFIX)/bin
MAN_PREFIX = $(PREFIX)/share/man
DOC_PREFIX = $(PREFIX)/share/doc

.PHONY: clean pymod install-pymod
all: testpactester
.PHONY: all docs pymod install-pymod install test pymod-test clean pymod-clean
all: pactester

spidermonkey/js/src: spidermonkey/js-?.?.?.tar.gz
tar xzvf spidermonkey/js-?.?.?.tar.gz -C spidermonkey
spidermonkey/js/src: spidermonkey/js.tar.gz
tar xzvf $< -C spidermonkey
sed -i -e 's:\(shell uname -s | sed /\\ /s//_/\):\1 | sed s,GNU.*,Linux,:g' spidermonkey/js/src/config.mk

jsapi_buildstamp: spidermonkey/js/src
Expand All @@ -85,25 +112,42 @@ jsapi_buildstamp: spidermonkey/js/src
libjs.a: spidermonkey/js/src
cd spidermonkey && SMCFLAGS="$(SHFLAGS) $(SMCFLAGS)" "$(MAKE)" jslib

pacparser.o: pacparser.c pac_utils.h pacparser.h jsapi_buildstamp
$(CC) $(CFLAGS) $(SHFLAGS) -c pacparser.c -o pacparser.o
touch pymod/pacparser_o_buildstamp
%.o: %.c
$(CC) $(CFLAGS) $(SHFLAGS) -c $< -o $@

pacparser.o: pac_builtins.h pacparser_utils.h pacparser.h jsapi_buildstamp
pactester.o: pacparser.h pacparser_utils.h

$(LIBRARY): pacparser.o libjs.a
$(MKSHLIB) $(CFLAGS) $(LDFLAGS) $(LIB_OPTS) -o $(LIBRARY) pacparser.o libjs.a -lm
# Also used for the python module, below.
LIBRARY_DEPS = pacparser.o libjs.a

$(LIBRARY): $(LIBRARY_DEPS)
$(MKSHLIB) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lm

$(LIBRARY_LINK): $(LIBRARY)
ln -sf $(LIBRARY) $(LIBRARY_LINK)

pactester: pactester.c pacparser.h $(LIBRARY_LINK)
$(CC) $(CFLAGS) $(LDFLAGS) pactester.c -o pactester -lpacparser -L. -I.

testpactester: pactester
echo "Running tests for pactester."
NO_INTERNET=$(NO_INTERNET) ../tests/runtests.sh
pactester: pactester.o $(LIBRARY_LINK) $(LIBRARY_DEPS)
$(CC) $(CFLAGS) $< -o $@ -lpacparser $(LDFLAGS) -L. -I.

test: pactester
@set -u -e; st=0; \
export PACTESTER="$$(pwd)/$<"; \
(set -x && $(BASH) pactester_nointernet_test.sh) || st=1; \
tst=pactester_dns_test.sh; \
if [ -n '$(NO_INTERNET)' ]; then \
echo "Skipping test $${tst}"; \
exit $${st}; \
fi; \
args=$$(test -z '$(NO_IPV6)' && printf '%s\n' '--ipv6'); \
(set -x && $(BASH) $${tst} $${args}) || st=1; \
if [ '$(ENABLE_C_ARES)' = 'yes' ]; then \
(set -x && $(BASH) $${tst} $${args} --c-ares) || st=1; \
fi; \
exit $${st}

docs:
../tools/generatedocs.sh
tools/generatedocs.sh

install: all
install -d $(LIB_PREFIX) $(INC_PREFIX) $(BIN_PREFIX)
Expand All @@ -113,26 +157,33 @@ install: all
install -m 644 pacparser.h $(INC_PREFIX)/pacparser.h
# install pactester manpages
install -d $(MAN_PREFIX)/man1/
(test -d ../docs && install -m 644 ../docs/man/man1/*.1 $(MAN_PREFIX)/man1/) || true
(test -d docs && install -m 644 docs/man/man1/*.1 $(MAN_PREFIX)/man1/) || true
# install pacparser manpages
install -d $(MAN_PREFIX)/man3/
(test -d ../docs && install -m 644 ../docs/man/man3/*.3 $(MAN_PREFIX)/man3/) || true
(test -d docs && install -m 644 docs/man/man3/*.3 $(MAN_PREFIX)/man3/) || true
# install html docs
install -d $(PREFIX)/share/doc/pacparser/html/
(test -d ../docs/html && install -m 644 ../docs/html/* $(PREFIX)/share/doc/pacparser/html/) || true
(test -d docs/html && install -m 644 docs/html/* $(PREFIX)/share/doc/pacparser/html/) || true
# install examples
install -d $(PREFIX)/share/doc/pacparser/examples/
(test -d ../examples && install -m 644 ../examples/* $(PREFIX)/share/doc//pacparser/examples/) || true
(test -d examples && install -m 644 examples/* $(PREFIX)/share/doc/pacparser/examples/) || true

# Targets to build python module
pymod: pacparser.o pacparser.h libjs.a
cd pymod && ARCHFLAGS="" $(PYTHON) setup.py build
$(PYTHON) ../tests/runtests.py
pymod: all
cd pymod && python setup.py clean --all
cd pymod && C_ARES_LDFLAGS='$(C_ARES_LDFLAGS)' ARCHFLAGS="" $(PYTHON) setup.py build

pymod-test: pymod
cd pymod && ENABLE_C_ARES='$(ENABLE_C_ARES)' $(PYTHON) setup.py test

install-pymod: pymod
cd pymod && ARCHFLAGS="" $(PYTHON) setup.py install --root="$(DESTDIR)/" $(EXTRA_ARGS)

clean:
rm -f $(LIBRARY_LINK) $(LIBRARY) libjs.a pacparser.o pactester pymod/pacparser_o_buildstamp jsapi_buildstamp
pymod-clean:
cd pymod && python setup.py clean --all
cd pymod && rm -rf pacparser.egg-info
cd pymod && rm -f $$(find -name '*.py[co]')

clean: pymod-clean
rm -f $(LIBRARY_LINK) $(LIBRARY) libjs.a *.o pactester jsapi_buildstamp
rm -f pac.js.tmp stdout.tmp stderr.tmp
cd spidermonkey && "$(MAKE)" clean
4 changes: 2 additions & 2 deletions src/Makefile.win32 → Makefile.win32
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ CC=gcc

all: pacparser.dll pacparser.lib pactester

pacparser.o: pacparser.c pac_utils.h js.lib
pacparser.o: pacparser.c pac_builtins.h js.lib
$(CC) $(CFLAGS) -c pacparser.c -o pacparser.o

fdlibm.lib js.lib:
$(MAKE) -C spidermonkey -f Makefile.win32
copy spidermonkey\fdlibm.lib .
Expand Down
Loading