SConstruct (10878:0e466ba12a99) | SConstruct (10881:133d8bb2024f) |
---|---|
1# -*- mode:python -*- 2 3# Copyright (c) 2013, 2015 ARM Limited 4# All rights reserved. 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating --- 805 unchanged lines hidden (view full) --- 814# add the new swig scanner that we like better 815from SCons.Scanner import ClassicCPP as CPPScanner 816swig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 817scanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 818 819# replace the scanners list that has what we want 820main['SCANNERS'] = scanners 821 | 1# -*- mode:python -*- 2 3# Copyright (c) 2013, 2015 ARM Limited 4# All rights reserved. 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating --- 805 unchanged lines hidden (view full) --- 814# add the new swig scanner that we like better 815from SCons.Scanner import ClassicCPP as CPPScanner 816swig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 817scanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 818 819# replace the scanners list that has what we want 820main['SCANNERS'] = scanners 821 |
822# Add a custom Check function to the Configure context so that we can 823# figure out if the compiler adds leading underscores to global 824# variables. This is needed for the autogenerated asm files that we 825# use for embedding the python code. 826def CheckLeading(context): 827 context.Message("Checking for leading underscore in global variables...") 828 # 1) Define a global variable called x from asm so the C compiler 829 # won't change the symbol at all. 830 # 2) Declare that variable. 831 # 3) Use the variable 832 # 833 # If the compiler prepends an underscore, this will successfully 834 # link because the external symbol 'x' will be called '_x' which 835 # was defined by the asm statement. If the compiler does not 836 # prepend an underscore, this will not successfully link because 837 # '_x' will have been defined by assembly, while the C portion of 838 # the code will be trying to use 'x' 839 ret = context.TryLink(''' 840 asm(".globl _x; _x: .byte 0"); 841 extern int x; 842 int main() { return x; } 843 ''', extension=".c") 844 context.env.Append(LEADING_UNDERSCORE=ret) 845 context.Result(ret) 846 return ret 847 | |
848# Add a custom Check function to test for structure members. 849def CheckMember(context, include, decl, member, include_quotes="<>"): 850 context.Message("Checking for member %s in %s..." % 851 (member, decl)) 852 text = """ 853#include %(header)s 854int main(){ 855 %(decl)s test; --- 10 unchanged lines hidden (view full) --- 866 return ret 867 868# Platform-specific configuration. Note again that we assume that all 869# builds under a given build root run on the same host platform. 870conf = Configure(main, 871 conf_dir = joinpath(build_root, '.scons_config'), 872 log_file = joinpath(build_root, 'scons_config.log'), 873 custom_tests = { | 822# Add a custom Check function to test for structure members. 823def CheckMember(context, include, decl, member, include_quotes="<>"): 824 context.Message("Checking for member %s in %s..." % 825 (member, decl)) 826 text = """ 827#include %(header)s 828int main(){ 829 %(decl)s test; --- 10 unchanged lines hidden (view full) --- 840 return ret 841 842# Platform-specific configuration. Note again that we assume that all 843# builds under a given build root run on the same host platform. 844conf = Configure(main, 845 conf_dir = joinpath(build_root, '.scons_config'), 846 log_file = joinpath(build_root, 'scons_config.log'), 847 custom_tests = { |
874 'CheckLeading' : CheckLeading, | |
875 'CheckMember' : CheckMember, 876 }) 877 | 848 'CheckMember' : CheckMember, 849 }) 850 |
878# Check for leading underscores. Don't really need to worry either 879# way so don't need to check the return code. 880conf.CheckLeading() 881 | |
882# Check if we should compile a 64 bit binary on Mac OS X/Darwin 883try: 884 import platform 885 uname = platform.uname() 886 if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0: 887 if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]): 888 main.Append(CCFLAGS=['-arch', 'x86_64']) 889 main.Append(CFLAGS=['-arch', 'x86_64']) --- 545 unchanged lines hidden --- | 851# Check if we should compile a 64 bit binary on Mac OS X/Darwin 852try: 853 import platform 854 uname = platform.uname() 855 if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0: 856 if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]): 857 main.Append(CCFLAGS=['-arch', 'x86_64']) 858 main.Append(CFLAGS=['-arch', 'x86_64']) --- 545 unchanged lines hidden --- |