Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 28 additions & 15 deletions src/Makefile.win32
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,66 @@
# packaging script.
-include version.mk

ifeq ($(OS),Windows_NT)
RM = del /Q /F
CP = copy /Y
ifdef ComSpec
SHELL := $(ComSpec)
endif
ifdef COMSPEC
SHELL := $(COMSPEC)
endif
else
RM = rm -rf
CP = cp -f
endif

LIB_VER=1
CFLAGS=-g -DXP_WIN -DWINVER=0x0501 -DVERSION=$(VERSION) -Ispidermonkey/js/src -Wall
CC=gcc
PYTHON:=python

.PHONY: clean pymod install-pymod

all: pacparser.dll pacparser.lib pactester
all: pacparser.dll pactester

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

js.lib:
$(MAKE) -C spidermonkey -f Makefile.win32
cp spidermonkey/js.lib .

pacparser.dll: pacparser.o js.lib
pacparser.dll: pacparser.o spidermonkey/js.lib
$(CC) -shared -o pacparser.dll \
-Wl,--output-def,pacparser.def \
-Wl,--out-implib,libpacparser.a \
-Wl,--export-all-symbols \
pacparser.o -ljs -L. -lws2_32
pacparser.o -ljs -Lspidermonkey -lws2_32

pacparser.lib: pacparser.dll pacparser.def
lib /machine:i386 /def:pacparser.def

pactester: pactester.c pacparser.h pacparser.dll
$(CC) pactester.c -o pactester -lpacparser -L. -I.

dist: pacparser.dll pactester
dist: pacparser.dll pactester pacparser.lib
if exist dist rmdir /s /q dist
mkdir dist
copy pacparser.dll dist
copy pacparser.h dist
copy pactester.exe dist
if exist pacparser.lib copy pacparser.lib dist
copy ..\README.md dist\README.txt
copy ..\COPYING dist\COPYING.txt
copy ..\INSTALL dist\INSTALL.txt
$(CP) pacparser.lib dist
$(CP) ..\README.md dist\README.txt
$(CP) ..\COPYING dist\COPYING.txt
$(CP) ..\INSTALL dist\INSTALL.txt
mkdir dist\docs
copy ..\README.win32 dist\docs
$(CP) ..\README.win32 dist\docs
if exist ..\docs\html xcopy ..\docs\html dist\docs

# Targets to build python module
pymod: pacparser.h pacparser.dll pacparser.o js.lib
cp pacparser.o js.lib pymod/
cd pymod && $(PYTHON) setup.py build
cd .. && $(PYTHON) tests\runtests.py
cd .. && $(PYTHON) tests/runtests.py

pymod2: pacparser.h pacparser.dll
cd pymod && py -2.7-32 setup.py dist
Expand All @@ -79,7 +92,7 @@ pymod3: pacparser.h pacparser.dll
cd .. && py -3.6-32 tests\runtests.py

clean:
del /F pacparser.dll *.lib pacparser.def pacparser.exp pacparser.o pactester.exe libpacparser.a
$(RM) pacparser.dll *.lib pacparser.def pacparser.exp pacparser.o pactester.exe libpacparser.a
$(MAKE) -C spidermonkey -f Makefile.win32 clean
cd pymod && setup.py clean
if exist dist rmdir /s /q dist
cd pymod && $(PYTHON) setup.py clean --all
$(RM) dist
76 changes: 0 additions & 76 deletions src/pymod/Makefile.win32

This file was deleted.

2 changes: 1 addition & 1 deletion src/pymod/pacparser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def find_proxy(url, host=None):
m = _URL_REGEX.match(url)
if not m:
raise URLError(url)
if len(m.groups()) is 1:
if len(m.groups()) == 1:
host = m.groups()[0]
else:
raise URLError(url)
Expand Down
5 changes: 2 additions & 3 deletions src/pymod/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2007 Manu Garg.
# Copyright (C) 2007-2022 Manu Garg.
# Author: Manu Garg <manugarg@gmail.com>
#
# pacparser is a library that provides methods to parse proxy auto-config
Expand Down Expand Up @@ -28,7 +28,6 @@
import sys
import os

from distutils import sysconfig
from setuptools import setup
from distutils.core import Extension

Expand All @@ -39,7 +38,7 @@ def main():
libraries = []
extra_link_args = []
if sys.platform == 'win32':
extra_objects = ['pacparser.o', 'js.lib']
extra_objects = ['../pacparser.o', '../spidermonkey/js.lib']
libraries = ['ws2_32']
if 'mingw32' in sys.argv or '--compiler=mingw32' in sys.argv:
extra_link_args = ['-static-libgcc']
Expand Down
30 changes: 23 additions & 7 deletions src/spidermonkey/Makefile.win32
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
# Project: fdlibm

ifeq ($(OS),Windows_NT)
RM = del /Q /F
CP = copy /Y
ifdef ComSpec
SHELL := $(ComSpec)
endif
ifdef COMSPEC
SHELL := $(COMSPEC)
endif
else
RM = rm -rf
CP = cp -f
endif

CC = gcc.exe

JS_SRCDIR = js/src

JS_OBJECTS = \
$(JS_SRCDIR)/jsapi.o \
$(JS_SRCDIR)/jsarena.o \
Expand Down Expand Up @@ -44,21 +59,22 @@ CFLAGS = -D_IEEE_LIBM -DEXPORT_JS_API -DWIN32 -D_MINGW -D_WINDOWS -DXP_WIN -s

all: js.lib

.c.o: $(CC) -c $(CFLAGS) -o $@ $(JS_SRCDIR)/$*.c
%.o: %.c js/src/jsautokw.h
$(CC) -c $(CFLAGS) -o $@ $<

js\src\jsautokw.h:
js/src/jsautokw.h:
ifeq ($(wildcard js),)
$(error JS source directory not found. Extract $(wildcard js-*.tar.gz) tarball using tool of your choice. Possible options are 7z, WinRAR, WinZip.)
endif
$(CC) -o jskwgen js/src/jskwgen.c
jskwgen > js/src/jsautokw.h
rm jskwgen.exe
$(RM) jskwgen.exe

js.lib: js\src\jsautokw.h $(JS_OBJECTS)
js.lib: $(JS_OBJECTS)
ar r js.lib $(JS_OBJECTS)
ranlib js.lib

clean:
rm js\src\*.o
rm js\src\jsautokw.h
rm *.lib
$(RM) js\src\*.o
$(RM) js\src\jsautokw.h
$(RM) *.lib
19 changes: 5 additions & 14 deletions tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,14 @@
import glob
import os
import sys
from distutils import sysconfig


def runtests(pacfile, testdata, tests_dir):
py_ver = '.'.join([str(x) for x in sys.version_info[0:2]])
if sys.platform == 'win32':
pacparser_module_path = os.path.join(
tests_dir, '..', 'src', 'pymod',
'pacparser-python%s' % sysconfig.get_config_vars('VERSION')[0])
if os.path.exists(os.path.join(pacparser_module_path, '_pacparser.pyd')):
raise Exception('Tests failed. Could not determine pacparser path.')
else:
try:
pacparser_module_path = glob.glob(os.path.join(
tests_dir, '..', 'src', 'pymod', 'build', 'lib*%s' % py_ver))[0]
except Exception:
raise Exception('Tests failed. Could not determine pacparser path.')
try:
pacparser_module_path = glob.glob(os.path.join(
tests_dir, '..', 'src', 'pymod', 'build', 'lib*%s' % py_ver))[0]
except Exception:
raise Exception('Tests failed. Could not determine pacparser path.')
if 'DEBUG' in os.environ: print('Pacparser module path: %s' %
pacparser_module_path)
sys.path.insert(0, pacparser_module_path)
Expand Down