This repository has been archived by the owner on Aug 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py-ios-2.7.5.patch
72 lines (66 loc) · 3 KB
/
setup.py-ios-2.7.5.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--- setup.py 2013-05-12 11:32:54.000000000 +0800
+++ setup.py.static 2013-07-22 18:50:59.000000000 +0800
@@ -33,14 +33,21 @@
COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
# This global variable is used to hold the list of modules to be disabled.
-disabled_module_list = []
+disabled_module_list = ["_ctypes", ]
+enabled_module_list = []
def add_dir_to_list(dirlist, dir):
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
1) 'dir' is not already in 'dirlist'
2) 'dir' actually exists, and is a directory."""
if dir is not None and os.path.isdir(dir) and dir not in dirlist:
- dirlist.insert(0, dir)
+ # hack: will not add default include dir or other dir
+ # building for iOS will cause add some suffix like $UNIX2003
+ # or $INODE64 into symbols
+ # details reference Readme for Python4iOS
+ #dirlist.insert(0, dir)
+ #dirlist.append(dir)
+ pass
def macosx_sdk_root():
"""
@@ -166,8 +173,13 @@
missing = self.detect_modules()
# Remove modules that are present on the disabled list
- extensions = [ext for ext in self.extensions
- if ext.name not in disabled_module_list]
+ if 0 == len(enabled_module_list):
+ extensions = [ext for ext in self.extensions
+ if ext.name not in disabled_module_list]
+ else:
+ extensions = [ext for ext in self.extensions
+ if ext.name in enabled_module_list]
+
# move ctypes to the end, it depends on other modules
ext_map = dict((ext.name, i) for i, ext in enumerate(extensions))
if "_ctypes" in ext_map:
@@ -245,10 +257,27 @@
# compilers
if compiler is not None:
(ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
- args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
+ args['compiler'] = compiler + ' ' + ccshared + ' ' + cflags
+
self.compiler.set_executables(**args)
- build_ext.build_extensions(self)
+ objs = set()
+ for ext in self.extensions[:]:
+ o = self.compiler.compile(ext.sources, self.build_lib, ext.define_macros, ext.include_dirs)
+ # there are duplicated symbols, use set() to elimate them
+ objs.update(o)
+
+ # different lib requires different lib, such as OpenSSL, sqlite, etc.
+ # Normally, Python load module dynamically, but I want Python built
+ # as stati lib, with static module, so I separate all module into
+ # separate lib.
+ # On the other hand, some module all include math.o or timemodule.o,
+ # so I must ensure each object is archived in to one .a
+
+ for o in objs:
+ self.compiler.create_static_lib([o], os.path.basename(o)[:-2], self.build_lib)
+
+ #build_ext.build_extensions(self)
longest = max([len(e.name) for e in self.extensions])
if self.failed: