• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2011 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17COMMON_CFLAGS = ['-Wall', '-Werror', '-D__HOST__']
18COMMON_CXXFLAGS = ['-Wall', '-Werror', '-fno-exceptions', '-D__HOST__']
19
20configs = {
21    'debug': {
22        'CFLAGS': COMMON_CFLAGS + ['-g'],
23        'CXXFLAGS': COMMON_CXXFLAGS + ['-g']
24    },
25
26    'release': {
27        'CFLAGS': COMMON_CFLAGS + ['-O2'],
28        'CXXFLAGS': COMMON_CXXFLAGS + ['-O2']
29    },
30}
31
32toolsets = {
33    'gcc': {
34        'CC': 'gcc',
35        'CXX': 'g++',
36    },
37
38    'mips-gcc': {
39        'CC': 'mips-linux-gnu-gcc',
40        'CXX': 'mips-linux-gnu-g++',
41    },
42
43    'clang': {
44        'CC': 'clang',
45        'CXX': 'clang++',
46    },
47}
48
49toolset_configs = {
50    'gcc': { 'CFLAGS': [], 'CXXFLAGS': [], 'LDFLAGS': [] },
51    'clang': { 'CFLAGS': [], 'CXXFLAGS': [], 'LDFLAGS': [] },
52    'mips-gcc': { 'CFLAGS': ['-EL', '-mips32r2'],
53                  'CXXFLAGS': ['-EL', '-mips32r2'],
54                  'LDFLAGS': ['-EL', '-mips32r2'] }
55}
56
57mode = ARGUMENTS.get('mode', 'release')
58toolset = ARGUMENTS.get('toolset', 'gcc')
59
60if not mode in configs:
61    print 'ERROR: Unknown building mode:', mode
62    Exit(1)
63
64if not toolset in toolsets:
65    print 'ERROR: Unknown toolset:', toolset
66    Exit(1)
67
68build_config = configs[mode]
69build_toolset = toolsets[toolset]
70build_toolset_config = toolset_configs[toolset]
71
72print '===> BUILDING IN', mode.upper(), 'MODE ...'
73
74import os
75
76cflags = build_config['CFLAGS'] + build_toolset_config['CFLAGS']
77cxxflags = build_config['CXXFLAGS'] + build_toolset_config['CXXFLAGS']
78linkflags = build_toolset_config['LDFLAGS']
79
80env = Environment(CC=build_toolset['CC'],
81                  CXX=build_toolset['CXX'],
82                  CFLAGS=cflags,
83                  CXXFLAGS=cxxflags,
84                  LINKFLAGS=linkflags,
85                  CPPPATH=['.', 'include'],
86                  ENV={'PATH': os.environ['PATH']})
87
88env.ParseConfig('llvm-config --cxxflags --ldflags --libs support')
89
90env.Program('rsloader',
91            source=['lib/ELFHeader.cpp',
92                    'lib/ELFSectionHeader.cpp',
93                    'lib/ELFSymbol.cpp',
94                    'lib/ELFTypes.cpp',
95                    'lib/MemChunk.cpp',
96                    'lib/StubLayout.cpp',
97                    'lib/GOT.cpp',
98                    'utils/helper.cpp',
99                    'utils/raw_ostream.cpp',
100                    'utils/rsl_assert.cpp',
101                    'main.cpp'])
102