예제 #1
0
    def _build(self):
        v_maj, v_min, v_rev = (int(x) for x in self.version.split('.'))
        build_nr = self.buildNumber(v_maj, v_min)

        msg_write('Copy %s %s (%s) Library Headers' %
                  (self.name, self.version, build_nr))
        msg_write('-' * 60)
        self.copyHeaders()

        msg_write('Building %s %s (%s) Library' %
                  (self.name, self.version, build_nr))
        msg_write('-' * 60)

        if not self.compileDirectories(self.src_dirs):
            return

        obj_list = os.listdir(self._dir_obj)
        obj_list = [os.path.join(self._dir_obj, f) for f in obj_list]

        if not os.path.exists(self._dir_lib):
            os.makedirs(self._dir_lib)

        libversion_maj = self.version[:self.version.index('.')]
        lib_ext = 'dylib' if self.platformIsMac() else 'so'
        lib_name = 'lib%s.%s' % (self.name, lib_ext)
        lib_name_maj = 'lib%s.%s.%s' % (self.name, lib_ext, libversion_maj)
        lib_name_full = 'lib%s.%s.%s' % (self.name, lib_ext, self.version)
        lib_path = os.path.join(self._dir_lib, lib_name_full)

        if self.platformIsMac():
            cmd = '%s -dynamiclib -current_version %s -o %s -dylib %s %s' % \
                    (self._options.cc, self.version, lib_path,              \
                     string.join(obj_list, ' '),                            \
                     string.join(self._options.ldlibs, ' '))
        elif self.platformIsLinux():
            cmd = '%s -shared -Wl,-soname,%s -o %s %s %s' %                 \
                    (self._options.cc, lib_name_maj, lib_path,              \
                     string.join(obj_list, ' '),                            \
                     string.join(self._options.ldlibs, ' '))
        else:
            raise RuntimeError("Unsupported Platform %s" %
                               ' '.join(os.uname()))

        msg_write()
        msg_write(' [LD]', lib_name_full)
        exit_code, output = execCommand(cmd)
        if exit_code != 0:
            msg_write(' * Failed with Status %d\n * %s\n%s' %
                      (exit_code, cmd, output))
            sys.exit(1)

        cwd = os.getcwd()
        os.chdir(self._dir_lib)
        for name in (lib_name, lib_name_maj):
            msg_write(' [LN]', name)
            execCommand('ln -s %s %s' % (lib_name_full, name))
        os.chdir(cwd)

        msg_write()
예제 #2
0
    def _build(self):
        v_maj, v_min, v_rev = (int(x) for x in self.version.split('.'))
        build_nr = self.buildNumber(v_maj, v_min)

        msg_write('Copy %s %s (%s) Library Headers' % (self.name, self.version, build_nr))
        msg_write('-' * 60)
        self.copyHeaders()

        msg_write('Building %s %s (%s) Library' % (self.name, self.version, build_nr))
        msg_write('-' * 60)

        if not self.compileDirectories(self.src_dirs):
            return

        obj_list = os.listdir(self._dir_obj)
        obj_list = [os.path.join(self._dir_obj, f) for f in obj_list]

        if not os.path.exists(self._dir_lib):
            os.makedirs(self._dir_lib)

        libversion_maj = self.version[:self.version.index('.')]
        lib_ext = 'dylib' if self.platformIsMac() else 'so'
        lib_name = 'lib%s.%s' % (self.name, lib_ext)
        lib_name_maj = 'lib%s.%s.%s' % (self.name, lib_ext, libversion_maj)
        lib_name_full = 'lib%s.%s.%s' % (self.name, lib_ext, self.version)
        lib_path = os.path.join(self._dir_lib, lib_name_full)

        if self.platformIsMac():
            cmd = '%s -dynamiclib -current_version %s -o %s -dylib %s %s' % \
                    (self._options.cc, self.version, lib_path,              \
                     string.join(obj_list, ' '),                            \
                     string.join(self._options.ldlibs, ' '))
        elif self.platformIsLinux():
            cmd = '%s -shared -Wl,-soname,%s -o %s %s %s' %                 \
                    (self._options.cc, lib_name_maj, lib_path,              \
                     string.join(obj_list, ' '),                            \
                     string.join(self._options.ldlibs, ' '))
        else:
            raise RuntimeError("Unsupported Platform %s" % ' '.join(os.uname()))

        msg_write()
        msg_write(' [LD]', lib_name_full)
        exit_code, output = execCommand(cmd)
        if exit_code != 0:
            msg_write(' * Failed with Status %d\n * %s\n%s' % (exit_code, cmd, output))
            sys.exit(1)

        cwd = os.getcwd()
        os.chdir(self._dir_lib)
        for name in (lib_name, lib_name_maj):
            msg_write(' [LN]', name)
            execCommand('ln -s %s %s' % (lib_name_full, name))
        os.chdir(cwd)

        msg_write()
예제 #3
0
    def runTool(self, tool, verbose=True):
        ldLibraryPathUpdate([self._dir_lib])
        exit_code, output = execCommand(tool)

        tool_output = []
        if verbose:
            tool_output.append(output)

        if exit_code != 0:
            tool_output.append(' [FAIL] %s exit code %d' % (tool, exit_code))
        else:
            tool_output.append(' [ OK ] %s' % tool)

        msg_write('\n'.join(tool_output))
예제 #4
0
    def runTool(self, tool, verbose=True):
        ldLibraryPathUpdate([self._dir_lib])
        exit_code, output = execCommand(tool)

        tool_output = []
        if verbose:
            tool_output.append(output)

        if exit_code != 0:
            tool_output.append(' [FAIL] %s exit code %d' % (tool, exit_code))
        else:
            tool_output.append(' [ OK ] %s' % tool)

        msg_write('\n'.join(tool_output))
예제 #5
0
    def linkFile(self, filename, dump_error=True):
        _, obj_path = self._objFilePath(filename)
        app_name, app_path = self._appFilePathFromObj(obj_path)

        cmd = '%s -o %s %s %s' %                            \
                (self._options.cc, app_path, obj_path,      \
                 string.join(self._options.ldlibs, ' '))
        msg_write(' [LD]', app_name)
        exit_code, output = execCommand(cmd)
        if exit_code != 0:
            if dump_error:
                msg_write(' * Failed with Status %d\n * %s\n%s' % (exit_code, cmd, output))
            raise RuntimeError("Linking Failure!")

        return app_path
예제 #6
0
    def linkFile(self, filename, dump_error=True):
        _, obj_path = self._objFilePath(filename)
        app_name, app_path = self._appFilePathFromObj(obj_path)

        cmd = '%s -o %s %s %s' %                            \
                (self._options.cc, app_path, obj_path,      \
                 string.join(self._options.ldlibs, ' '))
        msg_write(' [LD]', app_name)
        exit_code, output = execCommand(cmd)
        if exit_code != 0:
            if dump_error:
                msg_write(' * Failed with Status %d\n * %s\n%s' %
                          (exit_code, cmd, output))
            raise RuntimeError("Linking Failure!")

        return app_path
예제 #7
0
    def _testApp(self, filename, dump_error):
        try:
            self.compileFile(filename, dump_error=dump_error)
            self.linkFile(filename, dump_error=dump_error)
        except:
            msg_write(' [!!]', filename)
            raise Exception('Config Test %s failed' % filename)

        obj_name, obj_path = self._objFilePath(filename)
        app_name, app_path = self._appFilePathFromObj(obj_path)

        ldLibraryPathUpdate([self._dir_lib])
        exit_code, output = execCommand(app_path)
        if exit_code != 0:
            msg_write(' [!!]', filename)
            raise Exception('Config Test %s failed' % app_name)

        return app_name
예제 #8
0
    def _testApp(self, filename, dump_error):
        try:
            self.compileFile(filename, dump_error=dump_error)
            self.linkFile(filename, dump_error=dump_error)
        except:
            msg_write(' [!!]', filename)
            raise Exception('Config Test %s failed' % filename)

        obj_name, obj_path = self._objFilePath(filename)
        app_name, app_path = self._appFilePathFromObj(obj_path)

        ldLibraryPathUpdate([self._dir_lib])
        exit_code, output = execCommand(app_path)
        if exit_code != 0:
            msg_write(' [!!]', filename)
            raise Exception('Config Test %s failed' % app_name)

        return app_name
예제 #9
0
    def compileFile(self, filename, dump_error=True):
        obj_name, obj_path = self._objFilePath(filename)

        cmd = '%s -c %s %s %s %s %s -o %s' %                \
               (self._options.cc,                           \
                string.join(self._options.cflags, ' '),     \
                string.join(self._options.defines, ' '),    \
                string.join(self._options.includes, ' '),   \
                '-I%s' % self._dir_inc,                     \
                filename,                                   \
                obj_path)

        msg_write(' [CC]', filename)
        exit_code, output = execCommand(cmd)
        if exit_code != 0:
            if dump_error:
                msg_write(' * Failed with Status %d\n * %s\n%s' % (exit_code, cmd, output))
            raise RuntimeError("Compilation Failure!")

        if self._options.pedantic and len(output) > 0:
            msg_write(output)
예제 #10
0
    def _build(self):
        msg_write('Building', self.name)
        msg_write('-' * 60)

        if not self.compileDirectories(self.src_dirs):
            return

        obj_list = os.listdir(self._dir_obj)
        obj_list = [os.path.join(self._dir_obj, f) for f in obj_list]
        app_path = os.path.join(self._dir_out, self.name)

        cmd = '%s -o %s %s %s' %                            \
                (self._options.cc, app_path,                \
                 string.join(obj_list, ' '),                \
                 string.join(self._options.ldlibs, ' '))

        msg_write(' [LD]', self.name)
        exit_code, output = execCommand(cmd)
        if exit_code != 0:
            msg_write(' * Failed with Status %d\n * %s\n%s' % (exit_code, cmd, output))
            sys.exit(1)
        msg_write()
예제 #11
0
    def compileFile(self, filename, dump_error=True):
        obj_name, obj_path = self._objFilePath(filename)

        cmd = '%s -c %s %s %s %s %s -o %s' %                \
               (self._options.cc,                           \
                string.join(self._options.cflags, ' '),     \
                string.join(self._options.defines, ' '),    \
                string.join(self._options.includes, ' '),   \
                '-I%s' % self._dir_inc,                     \
                filename,                                   \
                obj_path)

        msg_write(' [CC]', filename)
        exit_code, output = execCommand(cmd)
        if exit_code != 0:
            if dump_error:
                msg_write(' * Failed with Status %d\n * %s\n%s' %
                          (exit_code, cmd, output))
            raise RuntimeError("Compilation Failure!")

        if self._options.pedantic and len(output) > 0:
            msg_write(output)
예제 #12
0
    def _build(self):
        msg_write('Building', self.name)
        msg_write('-' * 60)

        if not self.compileDirectories(self.src_dirs):
            return

        obj_list = os.listdir(self._dir_obj)
        obj_list = [os.path.join(self._dir_obj, f) for f in obj_list]
        app_path = os.path.join(self._dir_out, self.name)

        cmd = '%s -o %s %s %s' %                            \
                (self._options.cc, app_path,                \
                 string.join(obj_list, ' '),                \
                 string.join(self._options.ldlibs, ' '))

        msg_write(' [LD]', self.name)
        exit_code, output = execCommand(cmd)
        if exit_code != 0:
            msg_write(' * Failed with Status %d\n * %s\n%s' %
                      (exit_code, cmd, output))
            sys.exit(1)
        msg_write()
예제 #13
0
    hadoop_env = (
        'HADOOP_COMMON_HOME',
        'HADOOP_HDFS_HOME',
        'HADOOP_MAPRED_HOME',
        'HBASE_HOME',
    )

    return ':'.join(_findJars(
        os.getenv(henv) for henv in reversed(hadoop_env)))


if __name__ == '__main__':
    if len(sys.argv) < 1:
        print 'usage:'
        print '     jhadoop FileName.java'
        print '     jhadoop FileName.class'
        sys.exit(1)

    mime, _ = mimetypes.guess_type(sys.argv[1])
    if mime == 'text/x-java':
        sources = ' '.join(sys.argv[1:])
        cmd = 'javac -classpath %s %s' % (hadoopClassPath(), sources)
    elif mime == 'application/java-vm':
        cmd = 'java -classpath %s %s' % (hadoopClassPath(), sys.argv[1][:-6])
    else:
        raise TypeError(mime)

    exit_code, output = execCommand(cmd)
    print output
예제 #14
0
파일: jhadoop.py 프로젝트: JetBanana/Hadoop
            for root, dirs, files in os.walk(path, topdown=False):
                for name in files:
                    if name.endswith(".jar"):
                        jars[name] = os.path.join(root, name)
        return jars.values()

    hadoop_env = ("HADOOP_COMMON_HOME", "HADOOP_HDFS_HOME", "HADOOP_MAPRED_HOME", "HBASE_HOME")

    return ":".join(_findJars(os.getenv(henv) for henv in reversed(hadoop_env)))


if __name__ == "__main__":
    if len(sys.argv) < 1:
        print "usage:"
        print "     jhadoop FileName.java"
        print "     jhadoop FileName.class"
        sys.exit(1)

    mime, _ = mimetypes.guess_type(sys.argv[1])
    if mime == "text/x-java":
        sources = " ".join(sys.argv[1:])
        cmd = "javac -classpath %s %s" % (hadoopClassPath(), sources)
    elif mime == "application/java-vm":
        cmd = "java -classpath %s %s" % (hadoopClassPath(), sys.argv[1][:-6])
    else:
        raise TypeError(mime)

    exit_code, output = execCommand(cmd)
    print output