def check_dependency(conf, dependency): print "\nChecking {0} dependencies..".format(dependency.name) for header in Split(dependency.check_headers): if not conf.CheckCXXHeader(header): print('!! Cannot locate header {0} ...'.format(header)) Exit(0) # check libs for lib in Split(dependency.libs): if not conf.CheckLib(lib): print('!! Cannot locate library {0}'.format(lib)) Exit(0)
def generate(env, gcc_cross_prefix=None, gcc_strict=True, gcc_stop_on_warning=True, gcc_extra_options=[]): if gcc_stop_on_warning == None: gcc_stop_on_warning = env['stop_on_warning'] ### compiler flags gcc_extra_options = Split(gcc_extra_options) # normalize if gcc_strict: env.AppendUnique(CCFLAGS = ['-pedantic', '-Wall', '-W', '-Wundef', '-Wno-long-long']) env.AppendUnique(CFLAGS = ['-Wmissing-prototypes', '-Wmissing-declarations']) else: env.AppendUnique(CCFLAGS = ['-Wall']) compiler_defines = ['-D_REENTRANT'] env.AppendUnique(CCFLAGS = compiler_defines) env.AppendUnique(CPPFLAGS = compiler_defines) if env['build_config'] == 'Debug': env.AppendUnique(CCFLAGS = '-g') else: env.AppendUnique(CCFLAGS = '-O3') if gcc_stop_on_warning: env.AppendUnique(CCFLAGS = ['-Werror']) if gcc_cross_prefix: env['ENV']['PATH'] += os.environ['PATH'] env['AR'] = gcc_cross_prefix+'-ar' env['RANLIB'] = gcc_cross_prefix+'-ranlib' env['CC'] = gcc_cross_prefix+'-gcc' env['CXX'] = gcc_cross_prefix+'-g++' env['LINK'] = gcc_cross_prefix+'-g++' env.Append(CCFLAGS = gcc_extra_options)
def update_and_check_env(conf, dependencies): ''' Update the build environment with the dependencies ''' for dep in dependencies.values(): if dep.header_path: conf.env.Append(CPPPATH=[dep.header_path]) if dep.flags: conf.env.Append(CFLAGS=[dep.flags]) if dep.libs: conf.env.Append(LIBS=Split(dep.libs)) if dep.lib_path: conf.env.Append(LIBPATH=[dep.lib_path]) conf.env.Append(RPATH=[dep.lib_path]) if conf.env["SYSTEM"] == "Darwin": conf.env.Append(LINKFLAGS="-rpath {0}".format(dep.lib_path)) check_dependency(conf, dep)
def CleanEmptyDirs(env, targets, dir_list): """ Recursively remove directories from specified directory list. Only removes directories which would become empty after cleanup was done for specified target list. """ targets = env.arg2nodes(targets, Entry) state.log.debug("CleanEmptyDirs() : targets: %r" % map(str, targets)) state.log.debug("CleanEmptyDirs() : dir_list: %r" % dir_list) nodes = all_children(targets) dir2nodes = collections.defaultdict(lambda: set()) for node in nodes: try: path = node.abspath except AttributeError: # likely an Alias continue state.log.debug("CleanEmptyDirs() : node abspath: %s" % path) if not os.path.isdir(path): dirname, basename = os.path.split(path) dir2nodes[dirname].add(basename) empty_dirs = set() for dir in Split(dir_list): state.log.debug("CleanEmptyDirs() : checking dir: %s" % dir) for dirpath, dirnames, filenames in os.walk(Dir(dir).abspath, topdown=False): filenames = set(filenames) - dir2nodes[dirpath] dirnames = set(os.path.join(dirpath, d) for d in dirnames) dirnames = dirnames - empty_dirs if not filenames and not dirnames: state.log.debug("CleanEmptyDirs() : empty dir: %s" % dirpath) empty_dirs.add(dirpath) else: state.log.debug( "CleanEmptyDirs() : dir: %s files: %s subdirs: %s" % (dirpath, filenames, dirnames)) env.Clean(targets, list(empty_dirs))
def androidx64(env): # Sets up the environment for Google Android def setup(pre, x): return '%s%s' % (pre, x) platform = 'android-9' arch = 'x86_64' path = '/opt/android/android-x64-toolchain' # bin_path = setup(path, '/arm-linux-androideabi-4.4.3/bin') bin_path = setup(path, '/bin') prefix = 'x86_64-linux-android-' def set_prefix(x): return '%s%s' % (prefix, x) env['CC'] = set_prefix('gcc') env['LD'] = set_prefix('ld') env['CXX'] = set_prefix('g++') env['AS'] = set_prefix('as') env['AR'] = set_prefix('ar') env['OBJCOPY'] = set_prefix('objcopy') base = setup(path, '/user/%(arch)s' % {'arch': arch}) env.PrependENVPath('PKG_CONFIG_PATH', base + '/lib/pkgconfig') env.Append(CPPPATH=[ '%s/include' % base, # '%s/include/allegro5' % base ]) #env.Append(CPPPATH = [setup(path, '/arm-linux-androideabi-4.4.3/include'), # setup(path, '/platforms/%s/arch-arm/usr/include' % platform), # setup(path, '/platforms/%s/arch-arm/usr/include/SDL' % platform), # setup(path, '/platforms/%s/arch-arm/usr/include/freetype' % platform), # setup(path, '/sources/cxx-stl/gnu-libstdc++/include') # ]) env.Append(CPPDEFINES=Split("""ANDROID""")) # flags = ['-fpic', '-fexceptions', '-ffunction-sections', '-funwind-tables', '-fstack-protector', '-Wno-psabi', '-march=armv5te', '-mtune=xscale', '-msoft-float', '-mthumb', '-Os', '-fomit-frame-pointer', '-fno-strict-aliasing', '-finline-limit=64',] flags = [ '-shared', '-fpic', '-fexceptions', '-ffunction-sections', '-funwind-tables', '-Wno-psabi', '-O2', '-fno-strict-aliasing' ] # linkflags = flags + ['-Wl,--allow-shlib-undefined'] linkflags = flags + ['-Wl,--no-undefined'] # libs = ['freetype', 'png', 'SDL', 'm', 'log', 'jnigraphics', 'c', 'm', 'supc++',] # Copy the static stdc++ from gnu-libstdc++ # gnustdlib = env.InstallAs('misc/libgnustdc++.a', '/opt/android/sources/cxx-stl/gnu-libstdc++/libs/armeabi/libstdc++.a') # libs = Split("""freetype2-static png SDL m log c jnigraphics supc++ EGL GLESv2 GLESv1_CM z gnustdc++""") libs = Split( """freetype2-static png m log c jnigraphics EGL GLESv2 GLESv1_CM z gnustl_static""" ) env.Append(CCFLAGS=flags) env.Append(CXXFLAGS=flags) env.Append(LINKFLAGS=linkflags) env.Append(CPPPATH=['#src/android']) env['LINKCOM'] = '$CXX $LINKFLAGS -Wl,--start-group $SOURCES $ARCHIVES $_LIBDIRFLAGS $_LIBFLAGS -Wl,--end-group -o $TARGET' # Hack to put libstdc++ at the end # env['LINKCOM'] = '$CXX $LINKFLAGS $SOURCES $_LIBDIRFLAGS $_LIBFLAGS /opt/android/sources/cxx-stl/gnu-libstdc++/libs/armeabi/libstdc++.a -o $TARGET' # env['LINKCOM'] = '$CXX $LINKFLAGS $SOURCES $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET' env.Append(LIBS=libs) env.Append(LIBPATH=[ '%s/lib' % base, #setup(path, '/platforms/%s/arch-arm/usr/lib' % platform), ]) env.PrependENVPath('PATH', bin_path) return env