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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# This file contains the default configuration to compile for Windows
# platforms. It contains sensitive enviroment configuration that
# shouldn't be modified unless you now what you are doing.
# PLEASE, DO NOT EDIT THIS FILE
import os
from cerbero.config import Architecture, Platform
# We don't want anything from mingw or msys detected in configure and
# used later.
allow_system_libs=False
if platform == Platform.WINDOWS:
separator = ';'
if target_arch == Architecture.X86:
build = 'i686-w64-mingw32'
if target_arch == Architecture.X86_64:
build = 'x86_64-w64-mingw32'
else:
separator = ':'
if target_arch == Architecture.X86:
buildname='windows_x86'
host = 'i686-w64-mingw32'
_path = 'w32'
else:
buildname='windows_x86_64'
host = 'x86_64-w64-mingw32'
_path = 'w64'
target = host
if not toolchain_prefix:
toolchain_prefix = os.path.join(home_dir, 'mingw', _path)
if not mingw_perl_prefix:
mingw_perl_prefix = os.path.join(home_dir, 'mingw', 'perl')
def cmd(command):
return '%s-%s' % (host, command)
export_msvc = ('CERBERO_EXPORT_MSVC' in os.environ) and (platform == Platform.WINDOWS)
# Default GCC compiler flags
if not export_msvc:
os.environ['CFLAGS'] = '-Wall -g -O2 '
os.environ['CXXFLAGS'] = '-Wall -g -O2 '
os.environ['OBJCFLAGS'] = '-Wall -g -O2 '
else:
os.environ['CFLAGS'] = ''
ccache = use_ccache and 'ccache ' or ''
# Toolchain environment
os.environ['CFLAGS'] += " -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 "
os.environ['CXXFLAGS']=os.environ['CFLAGS']
os.environ['PERL'] = 'perl'
os.environ['NM']= cmd('nm')
os.environ['DLLTOOL']= cmd('dlltool')
if not export_msvc:
os.environ['LIBRARY_PATH'] = "{0}/lib{1}".format(prefix, lib_suffix)
os.environ['CC']= '%s%s' % (ccache, cmd('gcc'))
os.environ['CXX']= '%s%s' % (ccache, cmd('g++'))
os.environ['LD']= cmd('ld')
os.environ['CPP']= cmd('cpp')
os.environ['RANLIB']= cmd('ranlib')
os.environ['AR']= cmd('ar')
os.environ['AS']= cmd('as')
os.environ['STRIP']= cmd('strip')
os.environ['WINDRES']= cmd('windres')
os.environ['RC']= cmd('windres')
# PATH
toolchainbin = os.path.join(toolchain_prefix, 'bin')
if os.path.isdir(toolchainbin) and not toolchainbin in os.environ['PATH']:
os.environ['PATH'] = '%s%s%s' % (toolchainbin, separator, os.environ['PATH'])
os.environ['ne_cv_libsfor_socket'] = '-lws2_32'
os.environ['ne_cv_libsfor_gethostbyname'] = '-lws2_32'
os.environ['ac_cv_func_malloc_0_nonnull'] ='yes'
os.environ['ac_cv_func_realloc_0_nonnull'] ='yes'
os.environ['lt_cv_deplibs_check_method'] = 'pass_all'
os.environ['ac_cv_lib_bz2_BZ2_bzlibVersion'] = 'yes'
os.environ['ac_cv_c_attribute_aligned'] = '64'
# With MinGW, DirectX headers are inside a subdir, and we don't want to
# accidentally use these when building with MSVC, so we don't unconditionally
# add them to CFLAGS.
mingw_toolchain_env = {'CPPFLAGS': ('-I%s/%s/include/directx' % (toolchain_prefix, host), ' ')}
if platform == Platform.WINDOWS:
os.environ['ACLOCAL'] = 'aclocal-1.11'
# We use Visual Studio by default on Windows
if 'novisualstudio' not in variants:
variants.append('visualstudio')
from cerbero.ide.vs.env import vcvarsall, get_msvc_env, append_path
# Contains only the env vars that MSVC needs, including any existing vars
# that were appended/prepended and have new values
# FIXME: Use EnvVarOp class from cerbero/build/build.py
msvc_toolchain_env = {}
for key, value in get_msvc_env(vcvarsall, arch, target_arch).items():
if key in ('PATH', 'PATHEXT', 'INCLUDE', 'LIB'):
sep = separator
else:
sep = ' '
msvc_toolchain_env.update({key: [value, sep]})
# We want the MSVC compiler and linker to find the headers and libraries
# provided by recipes built by us, so append to INCLUDE and LIB.
# NOTE: We do not want to add the MinGW toolchain paths here
msvc_toolchain_env['INCLUDE'][0] = append_path(msvc_toolchain_env['INCLUDE'][0],
os.path.join(prefix, 'include'))
msvc_toolchain_env['LIB'][0] = append_path(msvc_toolchain_env['LIB'][0],
os.path.join(prefix, 'lib' + lib_suffix))
if export_msvc:
for var, (val, sep) in msvc_toolchain_env.items():
if var not in os.environ or not os.environ[var]:
os.environ[var] = val
else:
os.environ[var] = '{}{}{}'.format(val, sep, os.environ[var])
# Don't set this twice
del os.environ['CERBERO_EXPORT_MSVC']
|