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'] 18COMMON_CXXFLAGS = ['-Wall', '-Werror', '-fno-exceptions'] 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 'clang': { 39 'CC': 'clang', 40 'CXX': 'clang++', 41 }, 42} 43 44mode = ARGUMENTS.get('mode', 'release') 45toolset = ARGUMENTS.get('toolset', 'gcc') 46 47if not mode in configs: 48 print 'ERROR: Unknown building mode:', mode 49 Exit(1) 50 51if not toolset in toolsets: 52 print 'ERROR: Unknown toolset:', toolset 53 Exit(1) 54 55build_config = configs[mode] 56build_toolset = toolsets[toolset] 57 58print '===> BUILDING IN', mode.upper(), 'MODE ...' 59 60import os 61 62env = Environment(CC=build_toolset['CC'], 63 CXX=build_toolset['CXX'], 64 CFLAGS=build_config['CFLAGS'], 65 CXXFLAGS=build_config['CXXFLAGS'], 66 CPPPATH=['.', 'include'], 67 ENV={'PATH': os.environ['PATH']}) 68 69env.ParseConfig('llvm-config --cxxflags --ldflags --libs support') 70 71env.Program('rsloader', 72 source=['lib/ELFHeader.cpp', 73 'lib/ELFSectionHeader.cpp', 74 'lib/ELFSymbol.cpp', 75 'lib/ELFTypes.cpp', 76 'lib/MemChunk.cpp', 77 'lib/StubLayout.cpp', 78 'utils/helper.cpp', 79 'utils/raw_ostream.cpp', 80 'utils/rsl_assert.cpp', 81 'main.cpp']) 82