|
| 1 | +import os |
| 2 | +import sys |
| 3 | +import struct |
| 4 | +import platform |
| 5 | +from setuptools import setup |
| 6 | + |
| 7 | +COMPILE_FLAGS = ['-flto', '-std=gnu++11', '-g', '-Wall', |
| 8 | + '-fPIC', '-Werror'] |
| 9 | + |
| 10 | +LINK_FLAGS = ['-flto', '-Wl,-rpath,.'] |
| 11 | + |
| 12 | +if len(sys.argv) > 1 and "--fast" in sys.argv: |
| 13 | + sys.argv.remove("--fast") |
| 14 | + # Fast mode disables optimization flags |
| 15 | + FAST = True |
| 16 | + print("FAST mode On") |
| 17 | +else: |
| 18 | + FAST = False |
| 19 | + # Fix "ImportError ... undefined symbol ..." caused by CEF's include/base/ |
| 20 | + # headers by adding the -flto flag (Issue #230). Unfortunately -flto |
| 21 | + # prolongs compilation time significantly. |
| 22 | + # More on the other flags: https://stackoverflow.com/questions/6687630/ |
| 23 | + COMPILE_FLAGS += ['-fdata-sections', '-ffunction-sections'] |
| 24 | + LINK_FLAGS += ['-Wl,--gc-sections'] |
| 25 | + |
| 26 | + |
| 27 | +# Architecture and OS postfixes |
| 28 | +ARCH32 = (8 * struct.calcsize('P') == 32) |
| 29 | +ARCH64 = (8 * struct.calcsize('P') == 64) |
| 30 | +OS_POSTFIX = ("win" if platform.system() == "Windows" else |
| 31 | + "linux" if platform.system() == "Linux" else |
| 32 | + "mac" if platform.system() == "Darwin" else "unknown") |
| 33 | +OS_POSTFIX2 = "unknown" |
| 34 | +if OS_POSTFIX == "win": |
| 35 | + OS_POSTFIX2 = "win32" if ARCH32 else "win64" |
| 36 | +elif OS_POSTFIX == "mac": |
| 37 | + OS_POSTFIX2 = "mac32" if ARCH32 else "mac64" |
| 38 | +elif OS_POSTFIX == "linux": |
| 39 | + OS_POSTFIX2 = "linux32" if ARCH32 else "linux64" |
| 40 | + |
| 41 | +# Directories |
| 42 | +CLIENT_HANDLER_DIR = os.path.abspath(os.path.dirname(__file__)) |
| 43 | +SRC_DIR = os.path.abspath(os.path.join(CLIENT_HANDLER_DIR, "..")) |
| 44 | + |
| 45 | +# Python version string: "27" or "32". |
| 46 | +PYTHON_VERSION = str(sys.version_info.major) + str(sys.version_info.minor) |
| 47 | + |
| 48 | + |
| 49 | +client_handler_src = [ |
| 50 | + 'client_handler.cpp', 'cookie_visitor.cpp', 'resource_handler.cpp', |
| 51 | + 'web_request_client.cpp', 'string_visitor.cpp', 'request_context_handler.cpp', |
| 52 | + 'task.cpp', 'x11.cpp', 'context_menu_handler.cpp', 'display_handler.cpp', |
| 53 | + 'download_handler.cpp', 'focus_handler.cpp', 'js_dialog_handler.cpp', |
| 54 | + 'keyboard_handler.cpp', 'lifespan_handler.cpp', 'load_handler.cpp', |
| 55 | + 'render_handler.cpp', 'request_handler.cpp' |
| 56 | +] |
| 57 | + |
| 58 | +if OS_POSTFIX.startswith('mac'): |
| 59 | + client_handler_src.append('util_mac.mm') |
| 60 | + |
| 61 | + |
| 62 | +setup( |
| 63 | + name='client_handler', |
| 64 | + libraries=[('client_handler', dict( |
| 65 | + sources=[os.path.join(CLIENT_HANDLER_DIR, src) for src in client_handler_src], |
| 66 | + include_dirs=[ |
| 67 | + r'./../', |
| 68 | + r'./../common/', |
| 69 | + r'/usr/include/python2.7', |
| 70 | + r'/usr/include/gtk-2.0', |
| 71 | + r'/usr/include/gtk-unix-print-2.0', |
| 72 | + r'/usr/include/glib-2.0', |
| 73 | + r'/usr/include/cairo', |
| 74 | + r'/usr/include/pango-1.0', |
| 75 | + r'/usr/include/gdk-pixbuf-2.0', |
| 76 | + r'/usr/include/atk-1.0', |
| 77 | + r'/usr/lib/x86_64-linux-gnu/gtk-2.0/include', |
| 78 | + r'/usr/lib/x86_64-linux-gnu/gtk-unix-print-2.0', |
| 79 | + r'/usr/lib/x86_64-linux-gnu/glib-2.0/include', |
| 80 | + r'/usr/lib/i386-linux-gnu/gtk-2.0/include', |
| 81 | + r'/usr/lib/i386-linux-gnu/gtk-unix-print-2.0', |
| 82 | + r'/usr/lib/i386-linux-gnu/glib-2.0/include', |
| 83 | + r'/usr/lib64/gtk-2.0/include', |
| 84 | + r'/usr/lib64/gtk-unix-print-2.0', |
| 85 | + r'/usr/lib64/glib-2.0/include', |
| 86 | + r'/usr/lib/gtk-2.0/include', |
| 87 | + r'/usr/lib/gtk-2.0/gtk-unix-print-2.0', |
| 88 | + r'/usr/lib/glib-2.0/include', |
| 89 | + ], |
| 90 | + |
| 91 | + # library_dirs=library_dirs, |
| 92 | + |
| 93 | + # Static libraries only. Order is important, if library A depends on B, |
| 94 | + # then B must be included before A. |
| 95 | + # libraries=libs, |
| 96 | + |
| 97 | + extra_compile_args=COMPILE_FLAGS, |
| 98 | + extra_link_args=LINK_FLAGS, |
| 99 | + ))], |
| 100 | +) |
0 commit comments