예제 #1
0
    def compile_sources(self, resources, build_path, inc_dirs=None):
        objects = []
        inc_paths = resources.inc_dirs
        if inc_dirs is not None:
            inc_paths.extend(inc_dirs)

        for source in resources.s_sources:
            _, name, _ = split_path(source)
            object = join(build_path, name + '.o')
            if self.need_update(object, [source]):
                self.progress("assemble", source)
                self.assemble(source, object)
            objects.append(object)

        # The dependency checking for C/C++ is delegated to the specific compiler
        for source in resources.c_sources:
            _, name, _ = split_path(source)
            object = join(build_path, name + '.o')
            if self.COMPILE_C_AS_CPP:
                self.compile_cpp(source, object, inc_paths)
            else:
                self.compile_c(source, object, inc_paths)
            objects.append(object)

        for source in resources.cpp_sources:
            _, name, _ = split_path(source)
            object = join(build_path, name + '.o')
            self.compile_cpp(source, object, inc_paths)
            objects.append(object)

        return objects
예제 #2
0
파일: toolchains.py 프로젝트: alejmrm/mbed
 def compile_sources(self, resources, build_path, inc_dirs=None):
     objects = []
     inc_paths = resources.inc_dirs
     if inc_dirs is not None:
         inc_paths.extend(inc_dirs)
     
     for source in resources.s_sources:
         _, name, _ = split_path(source)
         object = join(build_path, name + '.o')
         if self.need_update(object, [source]):
             self.progress("assemble", source)
             self.assemble(source, object)
         objects.append(object)
     
     # The dependency checking for C/C++ is delegated to the specific compiler
     for source in resources.c_sources:
         _, name, _ = split_path(source)
         object = join(build_path, name + '.o')
         if self.COMPILE_C_AS_CPP:
             self.compile_cpp(source, object, inc_paths)
         else:
             self.compile_c(source, object, inc_paths)
         objects.append(object)
     
     for source in resources.cpp_sources:
         _, name, _ = split_path(source)
         object = join(build_path, name + '.o')
         self.compile_cpp(source, object, inc_paths)
         objects.append(object)
     
     return objects
예제 #3
0
    def compile_sources(self, resources, build_path, inc_dirs=None):
        # Web IDE progress bar for project build
        files_to_compile = resources.s_sources + resources.c_sources + resources.cpp_sources
        self.to_be_compiled = len(files_to_compile)
        self.compiled = 0

        #for i in self.build_params:
        #    self.debug(i)
        #    self.debug("%s" % self.build_params[i])

        inc_paths = resources.inc_dirs
        if inc_dirs is not None:
            inc_paths.extend(inc_dirs)

        objects = []
        queue = []
        prev_dir = None

        # The dependency checking for C/C++ is delegated to the compiler
        base_path = resources.base_path
        files_to_compile.sort()
        for source in files_to_compile:
            _, name, _ = split_path(source)
            object = self.relative_object_path(build_path, base_path, source)

            # Avoid multiple mkdir() calls on same work directory
            work_dir = dirname(object)
            if work_dir is not prev_dir:
                prev_dir = work_dir
                mkdir(work_dir)

            # Queue mode (multiprocessing)
            commands = self.compile_command(source, object, inc_paths)
            if commands is not None:
                queue.append({
                    'source': source,
                    'object': object,
                    'commands': commands,
                    'work_dir': work_dir,
                    'chroot': self.CHROOT
                })
            else:
                objects.append(object)

        # Use queues/multiprocessing if cpu count is higher than setting
        jobs = self.jobs if self.jobs else cpu_count()
        if jobs > CPU_COUNT_MIN and len(queue) > jobs:
            return self.compile_queue(queue, objects)
        else:
            return self.compile_seq(queue, objects)
예제 #4
0
파일: __init__.py 프로젝트: Shirlies/mbed
    def compile_sources(self, resources, build_path, inc_dirs=None):
        # Web IDE progress bar for project build
        files_to_compile = resources.s_sources + resources.c_sources + resources.cpp_sources
        self.to_be_compiled = len(files_to_compile)
        self.compiled = 0

        #for i in self.build_params:
        #    self.debug(i)
        #    self.debug("%s" % self.build_params[i])

        inc_paths = resources.inc_dirs
        if inc_dirs is not None:
            inc_paths.extend(inc_dirs)

        objects = []
        queue = []
        prev_dir = None

        # The dependency checking for C/C++ is delegated to the compiler
        base_path = resources.base_path
        files_to_compile.sort()
        for source in files_to_compile:
            _, name, _ = split_path(source)
            object = self.relative_object_path(build_path, base_path, source)

            # Avoid multiple mkdir() calls on same work directory
            work_dir = dirname(object)
            if work_dir is not prev_dir:
                prev_dir = work_dir
                mkdir(work_dir)

            # Queue mode (multiprocessing)
            commands = self.compile_command(source, object, inc_paths)
            if commands is not None:
                queue.append({
                    'source': source,
                    'object': object,
                    'commands': commands,
                    'work_dir': work_dir,
                    'chroot': self.CHROOT
                })
            else:
                objects.append(object)

        # Use queues/multiprocessing if cpu count is higher than setting
        jobs = self.jobs if self.jobs else cpu_count()
        if jobs > CPU_COUNT_MIN and len(queue) > jobs:
            return self.compile_queue(queue, objects)
        else:
            return self.compile_seq(queue, objects)
예제 #5
0
 def relative_object_path(self, build_path, base_dir, source):
     source_dir, name, _ = split_path(source)
     obj_dir = join(build_path, relpath(source_dir, base_dir))
     mkdir(obj_dir)
     return join(obj_dir, name + '.o')
예제 #6
0
파일: __init__.py 프로젝트: Shirlies/mbed
 def relative_object_path(self, build_path, base_dir, source):
     source_dir, name, _ = split_path(source)
     obj_dir = join(build_path, relpath(source_dir, base_dir))
     mkdir(obj_dir)
     return join(obj_dir, name + '.o')