~ubuntu-branches/ubuntu/trusty/jcc/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/avoid-ftbfs-unknown-archs.patch/setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Ludovico Cavedon
  • Date: 2010-07-18 11:16:04 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100718111604-pmncb3js701dk0qp
Tags: 2.6-1
* New upstream release.
* Fix typo in README.Debian.
* Refresh avoid-ftbfs-unknown-archs.patch.
* Update Standards-Version to 3.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
import os, sys, platform, subprocess
14
14
 
15
 
jcc_ver = '2.5.1'
 
15
jcc_ver = '2.6'
16
16
machine = platform.machine()
17
17
 
18
18
if machine.startswith("iPod") or machine.startswith("iPhone"):
19
19
    platform = 'ipod'
 
20
elif sys.platform == "win32" and "--compiler=mingw32" in sys.argv:
 
21
    platform = 'mingw32'
20
22
else:
21
23
    platform = sys.platform
22
24
 
33
35
# JCC_LFLAGS and JCC_JAVAC environment variables using os.pathsep as value
34
36
# separator.
35
37
 
 
38
if platform in ("win32", "mingw32"):
 
39
    try:
 
40
        from helpers.windows import JAVAHOME
 
41
    except ImportError:
 
42
        JAVAHOME = None
 
43
else:
 
44
    JAVAHOME = None
 
45
 
36
46
JDK = {
37
47
    'darwin': '/System/Library/Frameworks/JavaVM.framework/Versions/Current',
38
48
    'ipod': '/usr/include/gcc',
39
49
    'linux2': '/usr/lib/jvm/java-6-openjdk',
40
50
    'sunos5': '/usr/jdk/instances/jdk1.6.0',
41
 
    'win32': 'o:/Java/jdk1.6.0_02',
42
 
    'freebsd7': '/usr/local/diablo-jdk1.6.0',
 
51
    'win32': JAVAHOME,
 
52
    'mingw32': JAVAHOME,
 
53
    'freebsd7': '/usr/local/diablo-jdk1.6.0'
43
54
}
44
55
if 'JCC_JDK' in os.environ:
45
56
    JDK[platform] = os.environ['JCC_JDK']
46
57
 
 
58
 
 
59
if not JDK[platform]:
 
60
    raise RuntimeError('''
 
61
                       
 
62
Can't determine where the Java JDK has been installed on this machine.
 
63
 
 
64
Please set the environment variable JCC_JDK to that location before
 
65
running setup.py.
 
66
''')
 
67
 
 
68
elif not os.path.isdir(JDK[platform]):
 
69
    raise RuntimeError('''
 
70
                       
 
71
Java JDK directory '%s' does not exist.
 
72
 
 
73
Please set the environment variable JCC_JDK to the correct location before
 
74
running setup.py.
 
75
''' %(JDK[platform]))
 
76
 
 
77
 
47
78
INCLUDES = {
48
79
    'darwin': ['%(darwin)s/Headers' %(JDK)],
49
80
    'ipod': ['%(ipod)s/darwin/default' %(JDK)],
53
84
               '%(sunos5)s/include/solaris' %(JDK)],
54
85
    'win32': ['%(win32)s/include' %(JDK),
55
86
              '%(win32)s/include/win32' %(JDK)],
 
87
    'mingw32': ['%(mingw32)s/include' %(JDK),
 
88
                '%(mingw32)s/include/win32' %(JDK)],
56
89
    'freebsd7': ['%(freebsd7)s/include' %(JDK),
57
90
                 '%(freebsd7)s/include/freebsd' %(JDK)],
58
91
}
64
97
    'sunos5': ['-features=iddollar',
65
98
               '-erroff=badargtypel2w,wbadinitl,wvarhidemem'],
66
99
    'win32': [],
 
100
    'mingw32': ['-fno-strict-aliasing', '-Wno-write-strings'],
67
101
    'freebsd7': ['-fno-strict-aliasing', '-Wno-write-strings'],
68
102
}
69
103
 
74
108
    'linux2': ['-O0', '-g', '-DDEBUG'],
75
109
    'sunos5': ['-DDEBUG'],
76
110
    'win32': ['/Od', '/DDEBUG'],
 
111
    'mingw32': ['-O0', '-g', '-DDEBUG'],
77
112
    'freebsd7': ['-O0', '-g', '-DDEBUG'],
78
113
}
79
114
 
94
129
               '-L%(sunos5)s/jre/lib/i386/client' %(JDK), '-ljvm',
95
130
               '-R%(sunos5)s/jre/lib/i386:%(sunos5)s/jre/lib/i386/client' %(JDK)],
96
131
    'win32': ['/LIBPATH:%(win32)s/lib' %(JDK), 'jvm.lib'],
 
132
    'mingw32': ['-L%(mingw32)s/lib' %(JDK), '-ljvm'],
97
133
    'freebsd7': ['-L%(freebsd7)s/jre/lib/i386' %(JDK), '-ljava', '-lverify',
98
134
                 '-L%(freebsd7)s/jre/lib/i386/client' %(JDK), '-ljvm',
99
135
                 '-Wl,-rpath=%(freebsd7)s/jre/lib/i386:%(freebsd7)s/jre/lib/i386/client' %(JDK)],
100
136
}
101
137
 
 
138
IMPLIB_LFLAGS = {
 
139
    'win32': ["/IMPLIB:%s"],
 
140
    'mingw32': ["-Wl,--out-implib,%s"]
 
141
}
 
142
 
102
143
if platform == 'linux2':
103
144
    LFLAGS['linux2'] = LFLAGS['linux2/%s' %(machine)]
104
145
 
107
148
    'ipod': ['jikes', '-cp', '/usr/share/classpath/glibj.zip'],
108
149
    'linux2': ['javac'],
109
150
    'sunos5': ['javac'],
110
 
    'win32': ['javac.exe'],
 
151
    'win32': ['%(win32)s/bin/javac.exe' %(JDK)],
 
152
    'mingw32': ['%(mingw32)s/bin/javac.exe' %(JDK)],
111
153
    'freebsd7': ['javac'],
112
154
}
113
155
        
121
163
    
122
164
    enable_shared = False
123
165
    with_setuptools_c7 = ('00000000', '00000006', '*c', '00000007', '*final')
124
 
    with_setuptools_c11 = ('00000000', '00000006', '*c', '00000011', '*final')
 
166
 
125
167
    if with_setuptools >= with_setuptools_c7 and 'NO_SHARED' not in os.environ:
126
168
        if platform in ('darwin', 'ipod', 'win32'):
127
169
            enable_shared = True
128
170
        elif platform == 'linux2':
129
 
            try:
130
 
                from setuptools.command.build_ext import sh_link_shared_object
131
 
                enable_shared = True  # jcc/patches/patch.43 was applied
132
 
            except ImportError:
133
 
                import setuptools
134
 
                jccdir = os.path.dirname(os.path.abspath(__file__))
135
 
                st_egg = os.path.dirname(setuptools.__path__[0])
136
 
                if with_setuptools < with_setuptools_c11:
137
 
                    patch_version = '0.6c7'
138
 
                else:
139
 
                    patch_version = '0.6c11'
140
 
 
141
 
                def patch_st_dir():
142
 
                    return '''
143
 
 
144
 
Shared mode is disabled, setuptools patch.43.%s must be applied to enable it
145
 
or the NO_SHARED environment variable must be set to turn off this error.
146
 
 
147
 
    sudo patch -d %s -Nup0 < %s/jcc/patches/patch.43.%s
148
 
 
149
 
See %s/INSTALL for more information about shared mode.
150
 
''' %(patch_version, st_egg, jccdir, patch_version, jccdir)
151
 
 
152
 
                def patch_st_zip():
153
 
                    return '''
154
 
 
155
 
Shared mode is disabled, setuptools patch.43.%s must be applied to enable it
156
 
or the NO_SHARED environment variable must be set to turn off this error.
157
 
 
158
 
    mkdir tmp
159
 
    cd tmp
160
 
    unzip -q %s
161
 
    patch -Nup0 < %s/jcc/patches/patch.43.%s
162
 
    sudo zip %s -f
163
 
    cd ..
164
 
    rm -rf tmp
165
 
 
166
 
See %s/INSTALL for more information about shared mode.
167
 
''' %(patch_version, st_egg, jccdir, patch_version, st_egg, jccdir)
168
 
 
169
 
                if os.path.isdir(st_egg):
170
 
                    raise NotImplementedError, patch_st_dir()
171
 
                else:
172
 
                    raise NotImplementedError, patch_st_zip()
 
171
            from helpers.linux import patch_setuptools
 
172
            enable_shared = patch_setuptools(with_setuptools)
 
173
        elif platform == 'mingw32':
 
174
            enable_shared = True
 
175
            # need to monkeypatch the CygwinCCompiler class to generate
 
176
            # jcc.lib in the correct place
 
177
            from helpers.mingw32 import JCCMinGW32CCompiler
 
178
            import distutils.cygwinccompiler
 
179
            distutils.cygwinccompiler.Mingw32CCompiler = JCCMinGW32CCompiler
173
180
 
174
181
except ImportError:
175
182
    if sys.version_info < (2, 4):
204
211
    else:
205
212
        _lflags = LFLAGS[platform]
206
213
 
 
214
    if 'JCC_IMPLIB_LFLAGS' in os.environ:
 
215
        _implib_lflags = os.environ['JCC_IMPLIB_LFLAGS'].split(_jcc_argsep)
 
216
    else:
 
217
        _implib_lflags = IMPLIB_LFLAGS.get(platform, [])
 
218
 
207
219
    if 'JCC_JAVAC' in os.environ:
208
220
        _javac = os.environ['JCC_JAVAC'].split(_jcc_argsep)
209
221
    else:
210
222
        _javac = JAVAC[platform]
211
223
 
212
 
    config = file(os.path.join(os.path.dirname(os.path.abspath(__file__)),
213
 
                               'jcc', 'config.py'), 'w')
214
 
    print >>config
215
 
    print >>config, 'INCLUDES=%s' %(_includes)
216
 
    print >>config, 'CFLAGS=%s' %(_cflags)
217
 
    print >>config, 'DEBUG_CFLAGS=%s' %(_debug_cflags)
218
 
    print >>config, 'LFLAGS=%s' %(_lflags)
219
 
    print >>config, 'SHARED=%s' %(enable_shared)
220
 
    print >>config
221
 
    config.close()
 
224
    from helpers.build import jcc_build_py
 
225
 
 
226
    jcc_build_py.config_file = \
 
227
        os.path.join(os.path.dirname(os.path.abspath(__file__)),
 
228
                     'jcc', 'config.py')
 
229
    jcc_build_py.config_text = \
 
230
        '\n'.join(['',
 
231
                   'INCLUDES=%s' %(_includes),
 
232
                   'CFLAGS=%s' %(_cflags),
 
233
                   'DEBUG_CFLAGS=%s' %(_debug_cflags),
 
234
                   'LFLAGS=%s' %(_lflags),
 
235
                   'IMPLIB_LFLAGS=%s' %(_implib_lflags),
 
236
                   'SHARED=%s' %(enable_shared),
 
237
                   'VERSION="%s"' %(jcc_ver),
 
238
                   ''])
222
239
 
223
240
    extensions = []
224
241
 
255
272
 
256
273
        kwds = { "extra_compile_args": cflags,
257
274
                 "include_dirs": includes,
258
 
                 "define_macros": [('_jcc_lib', None)],
 
275
                 "define_macros": [('_jcc_lib', None),
 
276
                                   ('JCC_VER', '"%s"' %(jcc_ver))],
259
277
                 "sources": sources[0:2] }
260
278
 
261
279
        if platform in ('darwin', 'ipod'):
297
315
                                extra_compile_args=cflags,
298
316
                                extra_link_args=lflags,
299
317
                                include_dirs=includes,
300
 
                                define_macros=[('_java_generics', None)],
 
318
                                define_macros=[('_java_generics', None),
 
319
                                               ('JCC_VER', '"%s"' %(jcc_ver))],
301
320
                                sources=sources))
302
321
 
303
322
    args = {
320
339
        'packages': ['jcc'],
321
340
        'package_dir': {'jcc': 'jcc'},
322
341
        'package_data': {'jcc': package_data},
323
 
        'ext_modules': extensions
 
342
        'ext_modules': extensions,
 
343
        "cmdclass": {"build_py": jcc_build_py},
324
344
    }
325
345
    if with_setuptools:
326
346
        args['zip_safe'] = False