Beispiel #1
0
def GetCppInclude(obj):
    result = ['.', Path.GetOutputDir(), Path.GetBaseDir()]
    result.append(Path.AddBaseDir('third_part/boost/include'))
    if obj.has_thrift_dep:
        result.append(Path.GetThriftOutPath())
        result.append(Path.AddBaseDir('third_part/libevent/include'))
        result.append(Path.AddBaseDir('third_part/thrift/include'))
    if obj.has_proto_dep:
        result.append(Path.GetProtoOutPath())
        result.append(Path.AddBaseDir('third_part/protobuf/include'))
    return result
Beispiel #2
0
    def _GetFlags(self, obj, env):
        source = []
        path = []
        always_link_libs = ''
        libs = ['dl', 'rt', 'crypt']  # crypt is the lib of linux sys

        if 'libs' in obj.option_:
            libs += obj.option_['libs']

        if 'path' in obj.option_:
            path += obj.option_['path']

        if obj.has_thrift_dep:
            libs += ['thriftnb', 'thriftz', 'thrift', 'event']
            path.append(Path.AddBaseDir('third_part/thrift/lib'))
            path.append(Path.AddBaseDir('third_part/libevent/lib'))

        if obj.has_proto_dep:
            libs += ['protobuf']
            path.append(Path.AddBaseDir('third_part/protobuf/lib'))

        # check dependent obj's special attributes
        for d in obj.depends_:
            dep_obj = BuildingObject.BuildingObject()
            if Path.IsStaticLib(d):
                dep_obj.name_ = d
            else:
                dep_obj = self.build_manager_.GetObjByName(d)
            d_lib = self._GetLibPathForObj(dep_obj)
            if self._HasCopt(dep_obj, 'always_link'):
                always_link_libs += ' %s' % d_lib
                # add explicit dependency since Scons could not figure out such dep
                # relationship for always link lib
                obj_name = Path.GetAbsRelativePath(obj.name_)
                env.Depends(obj_name, d_lib)
            else:
                source.append(d_lib)

        link_flags = env['LINKFLAGS']
        if len(always_link_libs) > 0:
            link_flags += (' -Wl,--whole-archive%s -Wl,--no-whole-archive' %
                           always_link_libs)
        if 'link_flags' in obj.option_:
            link_flags += ' '
            link_flags += ' '.join(obj.option_['link_flags'])
        return source, libs, path, link_flags
Beispiel #3
0
    def BuildObject(self, env, obj):
        if (not obj.option_['gen_cpp'] and not obj.option_['gen_php']
                and not obj.option_['gen_py']):
            print Util.BuildMessage(
                '%s: at least specify one generated '
                'language(gen_cpp,gen_php, gen_py)' % obj.name_, 'WARNING')
        source = [Path.GetAbsPath(x) for x in obj.sources_]
        if obj.option_['gen_cpp']:
            cpp_outdir = self._GetOutputDir(obj)
            cpp_sources = env.ThriftCppLibrary([],
                                               source,
                                               THRIFTOUTDIR=cpp_outdir)
            cpp_path = ['.']
            cpp_path.append(Path.GetOutputDir())
            cpp_path.append(Path.GetThriftOutPath())
            cpp_path.append(Path.AddBaseDir('third_part/boost/include'))
            cpp_path.append(Path.AddBaseDir('third_part/libevent'))
            cpp_path.append(Path.AddBaseDir('third_part/thrift/include'))

            target = Path.GetAbsRelativePath(obj.name_)
            cc_flags = env['CCFLAGS']
            cc_flags += " -Wno-return-type -DHAVE_NETINET_IN_H"
            print Util.BuildMessage(target)
            env.StaticLibrary(target=target,
                              source=cpp_sources,
                              CPPPATH=cpp_path,
                              CCFLAGS=cc_flags)

        if obj.option_['gen_php']:
            php_outdir = self._GetOutputDir(obj)
            php_sources = env.ThriftPhpLibrary([],
                                               source,
                                               THRIFTOUTDIR=php_outdir)

        if obj.option_['gen_py']:
            py_outdir = self._GetOutputDir(obj)
            target = []
            py_sources = env.ThriftPyLibrary(target,
                                             source,
                                             THRIFTOUTDIR=py_outdir)
Beispiel #4
0
 def GenerateEnv(self, env):
     assert len(_proto_bin) > 0
     env['PROTO'] = _proto_bin
     env['PROTOINCLUDE'] = ('-I%s -I%s' % (
         Path.GetBaseDir(), Path.AddBaseDir('third_part/protobuf/include')))
     env['PROTOCOUTDIR'] = Path.GetProtoOutPath()
     env['PROTOCCOM'] = (
         '$PROTO $PROTOCFLAGS ${SOURCE.abspath} '
         '--cpp_out=$PROTOCCPPOUTFLAGS$PROTOCOUTDIR $PROTOINCLUDE')
     # python
     env['PROTOPYCCOM'] = (
         '$PROTO $PROTOCFLAGS ${SOURCE.abspath} '
         '--python_out=$PROTOCCPPOUTFLAGS$PROTOCOUTDIR $PROTOINCLUDE')
     pass
Beispiel #5
0
 def _GenerateBuildingInfo(self, env):
     content = open(Path.AddBaseDir(Flags.BUILDING_INFO_IN)).read()
     content = content.replace('BD_TIME',
                               'Local Time:%s' % Util.LocalTime())
     content = content.replace('BD_HOST', socket.gethostname())
     cxx = env['CXX'].split('/')
     cxx.reverse()
     content = content.replace('BD_COM', '-'.join(
         (cxx[0], env['CXXVERSION'])))
     content = content.replace('BD_MODE', self._build_mode)
     (sys, d1, release, d2, machine) = os.uname()
     content = content.replace('BD_PLATFORM', '-'.join(
         (sys, release, machine)))
     # build binary map
     targets = ''
     for b in GetBuildManager().build_targets_:
         if len(targets) > 0: targets += ','
         targets += '%s' % b
     content = content.replace('BD_TARGET', targets)
     path = os.path.join(Path.GetOutputDir(), Flags.BUILDING_INFO_OUT)
     Util.Log(path)
     Util.MkDir(os.path.dirname(path))
     Util.Log(content)
     open(path, 'w').write(content)