Пример #1
0
 def run(self):
     log.log(log.INFO, "running `ant clean dist` to compile sfntly...")
     subprocess.call('ant', shell=True, cwd=java_src_dir)
     if os.path.exists(sfnttool_jar):
         shutil.copy(sfnttool_jar, sfnttool_dest)
     else:
         log.log(log.ERROR, "no such file: %s" % sfnttool_jar)
Пример #2
0
 def run(self):
     log.log(log.INFO, "running `ant clean dist` to compile sfntly...")
     subprocess.call('ant', shell=True, cwd=java_src_dir)
     if os.path.exists(sfnttool_jar):
         shutil.copy(sfnttool_jar, sfnttool_dest)
     else:
         log.log(log.ERROR, "no such file: %s" % sfnttool_jar)
Пример #3
0
def fail():
    log.log(
        "===================================================================\n"
        "  Build FAILED: check build/build.log for full details\n"
        "===================================================================",
        log.FAIL
    )
    sys.exit()
Пример #4
0
def set_permissions_for_host_executables(outputs):
    for file in outputs:
        if os.path.basename(file) in host_executables:
            current_mode = os.stat(file).st_mode
            new_mode = current_mode | stat.S_IEXEC
            os.chmod(file, new_mode)
            log.log(
                log.INFO, "Changed file mode of %s from %s to %s" %
                (file, oct(current_mode), oct(new_mode)))
Пример #5
0
    def run(self):
        clean.run(self)
        if self.jar or self.all:
            log.log(log.INFO, "running `ant clean` under 'vendor/sfntly/java'...")
            subprocess.call('ant clean', shell=True, cwd=java_src_dir)

            log.log(log.INFO, "removing *.jar files under 'Lib/sfntly/sfntly-java-dist'")
            for root, dirs, files in os.walk(sfnttool_dest, topdown=False):
                for name in files:
                    if os.path.splitext(name)[1].lower() == ".jar":
                        os.remove(os.path.join(root, name))
Пример #6
0
def _ensure_list(value, fieldname):
    if isinstance(value, str):
        # a string containing comma separated values is okay.  It will
        # be converted to a list by Distribution.finalize_options().
        pass
    elif not isinstance(value, list):
        # passing a tuple or an iterator perhaps, warn and convert
        typename = type(value).__name__
        msg = f"Warning: '{fieldname}' should be a list, got type '{typename}'"
        log.log(log.WARN, msg)
        value = list(value)
    return value
Пример #7
0
def _ensure_list(value, fieldname):
    if isinstance(value, str):
        # a string containing comma separated values is okay.  It will
        # be converted to a list by Distribution.finalize_options().
        pass
    elif not isinstance(value, list):
        # passing a tuple or an iterator perhaps, warn and convert
        typename = type(value).__name__
        msg = f"Warning: '{fieldname}' should be a list, got type '{typename}'"
        log.log(log.WARN, msg)
        value = list(value)
    return value
Пример #8
0
    def run(self):
        clean.run(self)
        if self.jar or self.all:
            log.log(log.INFO,
                    "running `ant clean` under 'vendor/sfntly/java'...")
            subprocess.call('ant clean', shell=True, cwd=java_src_dir)

            log.log(
                log.INFO,
                "removing *.jar files under 'Lib/sfntly/sfntly-java-dist'")
            for root, dirs, files in os.walk(sfnttool_dest, topdown=False):
                for name in files:
                    if os.path.splitext(name)[1].lower() == ".jar":
                        os.remove(os.path.join(root, name))
Пример #9
0
 def build(self):
     # set log verbosity to print everything
     distutils.log.set_verbosity(3)
     cwd = os.getcwd()
     os.chdir(str(self.path))
     t = time.time()
     log.log("Cythoning " + str(self.path) + "\n", log.GREEN)
     self.cmd.ensure_finalized()
     self.cmd.run()
     log.log("Finished Compiling " + str(self.path) + "\n", log.GREEN)
     log.log(
         "Time spent Compiling %s: %s Seconds\n" %
         (self.path, time.time() - t),
         log.BLUE
     )
     os.chdir(cwd)
Пример #10
0
 def announce(self, msg, level=log.INFO):
     log.log(level, msg)
Пример #11
0
 def announce(self, msg, level=log.INFO):
     log.log(level, msg)
Пример #12
0
 def announce(self, msg, level = 1):
     log.log(level, msg)
Пример #13
0
    def build(self):

        ncpus = num_cpus()

        log.log("Building useing " + str(ncpus) + " threads\n", log.BLUE)

        t = time.time()

        if ncpus > 1:

            import multiprocessing
            import multiprocessing.pool

            pool = multiprocessing.Pool(
                ncpus, initializer=_init_multiprocessing_helper)

            try:
                result = pool.map_async(builder, self.packages, chunksize=1)
                pool.close()
                while not result.ready():
                    try:
                        result.get(1)  # seconds
                    except multiprocessing.TimeoutError:
                        pass
            except KeyboardInterrupt:
                pool.terminate()
                raise

            pool.terminate()
            pool.join()

            results = result.get(1)

            # fix keyboard interupt
            # from multiprocessing.pool import IMapIterator

            # def wrapper(func):
            #     def wrap(self, timeout=None):
            # Note: the timeout of 1 googol seconds introduces a rather subtle
            # bug for Python scripts intended to run many times the age of the universe.
            #         return func(self, timeout=timeout if timeout is not None else 1e100)
            #     return wrap
            # IMapIterator.next = wrapper(IMapIterator.next)

            # with multiprocessing.pool.Pool(ncpus) as pool:
            #     results = pool.map(builder, self.packages)
        else:
            results = []
            for path in self.packages:
                results.append(builder(path))

        log.log(
            "TOTAL Time spent Compiling: %s Seconds\n" %
            (time.time() - t),
            log.BLUE)
        errors = [r for r in results if r]
        if errors:
            return ''.join(errors)
        else:
            log.log("There were no errors", log.GREEN)
        return False
Пример #14
0
 def announce(self, msg, level=1):
     log.log(level, msg)
Пример #15
0
 def announce(self, msg, level=1):
     """If the current verbosity level is of greater than or equal to
     'level' print 'msg' to stdout.
     """
     log.log(level, msg)
Пример #16
0
def build(folder, out_dir, debug=False, force=False):

    # set log verbosity to print everything
    distutils.log.set_verbosity(3)

    sources = []
    include_dirs = []
    lib_dirs = []

    cc = distutils.ccompiler.new_compiler(verbose=1)
    distutils.sysconfig.customize_compiler(cc)

    out_temp_path = os.path.abspath(os.path.join(out_dir, "temp"))
    out_path = os.path.abspath(out_dir)
    target = "welder"
    target_exe = cc.executable_filename(target)
    target_path = os.path.abspath(os.path.join(out_path, target_exe))

    # for welder
    sources.append(os.path.abspath(os.path.join(folder, "welder.c")))
    if sys.platform == "win32":
        sources.append(os.path.abspath(os.path.join(folder, "welder.rc")))

    include_dirs.append(os.path.abspath(os.path.join(folder, "include")))

    lib_dirs.append(os.path.abspath(os.path.join(folder, "libs")))

    # for python
    py_include = distutils.sysconfig.get_python_inc()
    plat_py_include = distutils.sysconfig.get_python_inc(plat_specific=1)
    include_dirs.append(os.path.abspath(sysconfig.get_path('include')))
    include_dirs.append(os.path.abspath(py_include))
    if plat_py_include != py_include:
        include_dirs.append(os.path.abspath(plat_py_include))

    lib_dirs.append(os.path.abspath(os.path.join(sys.exec_prefix, 'libs')))
    lib_dirs.append(os.path.abspath(os.path.join(sys.base_exec_prefix,
                                                 'libs')))

    # define Macros
    if sys.platform == "win32":
        cc.define_macro("_CONSOLE")
        cc.define_macro("_MBCS")
    else:
        pass

    # collect link libs
    if sys.platform == "win32":
        extralibs = [
            "kernel32",
            "user32",
            "gdi32",
            "winspool",
            "comdlg32",
            "advapi32",
            "shell32",
            "ole32",
            "oleaut32",
            "uuid",
            "odbc32",
            "odbccp32",
            "shlwapi"
        ]
    else:
        extralibs = []

    libraries = get_libraries(extralibs, debug)

    # extra compile arguments?
    extra_cc_args = []
    if sys.platform == "win32":
        extra_link_args = [
            "/MANIFEST",
            "/MANIFESTUAC:level='asInvoker' uiAccess='false'",
            "/SUBSYSTEM:CONSOLE"
        ]
    else:
        extra_link_args = [
            "-Wl,-R,'$ORIGIN'"
        ]

    language = cc.detect_language(sources)

    # no need to compile if we are up-to-date
    if not (force or
            distutils.dep_util.newer_group(sources, target_path, 'newer')):
        log.log(
            "Skipping Launcher build, " + str(target_path)
            + " is up-to-date\n",
            log.GREEN
        )
        # there was no error
        return False
    else:
        log.log(
            "Starting Launcher build: " + str(target_path) + "\n",
            log.BLUE
        )
    # ensure paths exist
    if not os.path.isdir(out_path):
        os.makedirs(out_path)

    if not os.path.isdir(out_temp_path):
        os.makedirs(out_temp_path)

    try:
        # compile sources to objects
        objects = cc.compile(
            sources,
            output_dir=out_temp_path,
            macros=[],
            include_dirs=include_dirs,
            debug=debug,
            extra_postargs=extra_cc_args,
            depends=[]
        )

        # link objects and libraries into an exacutable
        cc.link_executable(
            objects,
            target,
            output_dir=out_path,
            libraries=libraries,
            library_dirs=lib_dirs,
            extra_postargs=extra_link_args,
            debug=debug,
            target_lang=language
        )
    except Exception:
        return traceback.format_exc()

    log.log("Build of launcher compleated\n", log.GREEN)
    # there was no error
    return False
Пример #17
0
 def announce(self, msg, level=1):
     """If the current verbosity level is of greater than or equal to
     'level' print 'msg' to stdout.
     """
     log.log(level, msg)
Пример #18
0
    logpath = os.path.join(destpath, "build.log")

    # init loging
    log.init_log_file(logpath)

    log.replace_distutils_Log_log()
    # set log verbosity to print everything
    distutils.log.set_verbosity(3)

    # ==========================================================================
    # Icon Conversion
    # ==========================================================================
    log.log(
        "===================================================================\n"
        "  Converting Icons\n"
        "===================================================================",
        log.HEAD
    )
    iconpath = os.path.join(dirName, "EditorIcons")

    error = convertimages2py.convert(iconpath)

    if error:
        log.log("There was an error converting images", log.FAIL)
        log.log(error)
        fail()

    # move the images.py into place
    filepath = os.path.join(dirName, "EditorIcons", "GenImages.py")
    topath = os.path.join(
        dirName, "Editor", "Core", "Editor", "Icons", "GenImages.py")