Exemplo n.º 1
0
    def setDefault(self):

        if self.getHostArch() == 'x64':
            self.X86_PROGRAMFILES = os.environ['ProgramFiles(x86)']
        else:
            self.X86_PROGRAMFILES = os.environ['ProgramFiles']

        cs_search_path = [
            os.path.join(
                self.X86_PROGRAMFILES,
                'Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin/Roslyn'
            ),
            os.path.join(
                self.X86_PROGRAMFILES,
                'Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/Roslyn'
            ),
            os.path.join(self.X86_PROGRAMFILES, 'MSBuild/14.0/Bin'),
            os.path.join(self.X86_PROGRAMFILES, 'MSBuild/12.0/Bin'),
            'C:/Windows/Microsoft.NET/Framework64/v4.0.30319',
            'C:/Windows/Microsoft.NET/Framework64/v3.5',
            'C:/Windows/Microsoft.NET/Framework64/v3.0',
            'C:/Windows/Microsoft.NET/Framework/v4.0.30319',
            'C:/Windows/Microsoft.NET/Framework/v3.5',
            'C:/Windows/Microsoft.NET/Framework/v3.0',
        ]

        csc_path = self.findPath(cs_search_path)
        if csc_path is None:
            return

        Log.d('Found csc.exe [%s]' % cs_search_path)

        self.CMD_CC = os.path.join(csc_path, 'csc.exe')
        self.refresh()
Exemplo n.º 2
0
 def signal(self):
     count = self.dec()
     Log.d(('signal %d ' + self.target) % count)
     if count == 0:
         Log.d('signal zero run preBuild ' + self.target)
         self.state_wait = False
         return self.preBuild()
     return 0
Exemplo n.º 3
0
 def addThread(self):
     if len(self.thread_list) < self.max_thread:
         index = 0
         with self.lock:
             index = len(self.thread_list)
             thread = WorkerThread(index, self.job_queue)
             self.thread_list.append(thread)
         Log.d('Start thread %d' % index)
         thread.start()
Exemplo n.º 4
0
 def completeTask(self, result_code):
     self.setCompleted(True)
     if result_code != 0:
         return result_code
     for task in self.callback_task:
         Log.d(' completeTask callback = ' + task.target)
         result_code = task.run()
         if result_code != 0:
             return result_code
     return 0
Exemplo n.º 5
0
    def preBuild(self):
        Log.d('Task prebuild= ' + self.target)
        if not os.path.exists(self.target):
            return self.build('not exists "%s"' % self.target)

        dest_time = self.tool.timestamp_cache.getTimeStamp(self.target)
        #print( 'TargetTime =' + str(dest_time) )
        result = self.isBuild({}, dest_time)
        if result != None:
            return self.build(result)
        return self.completeTask(0)
Exemplo n.º 6
0
    def __init__(self, tool, parent=None):
        super().__init__(tool, parent)

        self.MSVC_DIR = None
        self.WINDOWS_SDK_DIR = None
        self.WINDOWS_SDK_VERSION = None

        self.CMD_CC = None
        self.CMD_LINK = None
        self.CMD_LIB = None

        if self.getHostPlatform() != 'Windows':
            return

        self.findVSPath()
        if self.MSVC_DIR is None:
            return

        self.SAVE_PATH = os.environ['PATH']

        self.setDefault()

        self.ARCH_LIST = ['x64', 'x86']
        if self.getUserOption('ARM', '0') == '1':
            if os.path.exists(
                    os.path.join(self.MSVC_VC_DIR, 'bin/HostX64/arm64')):
                self.ARCH_LIST.append('arm64')
            if os.path.exists(os.path.join(self.MSVC_VC_DIR,
                                           'bin/HostX64/arm')):
                self.ARCH_LIST.append('arm7')

        Log.d('MSVC = %d' % self.MSVC_VERSION)
        Log.d('SDK = ', self.WINDOWS_SDK_DIR)
        Log.d('SDK Version = ', self.WINDOWS_SDK_VERSION)
        Log.d('CPU Arch    = ', ','.join(self.ARCH_LIST))
Exemplo n.º 7
0
 def dependTask(self):
     if len(self.task_list) != 0:
         for task in self.task_list:
             if not task.isCompleted():
                 self.inc()
         if self.task_count != 0:
             self.state_wait = True
             for task in self.task_list:
                 if not task.isCompleted():
                     Log.d(' depend -> ' + task.target)
                     task.onCompleteTask(self)
                     self.tool.thread_pool.addJob(task)
             return 0
     return self.preBuild()
Exemplo n.º 8
0
 def run(self):
     while True:
         if self.queue.isBreak():
             Log.d('Quit thread %d' % self.index)
             break
         job = self.queue.popJob()
         if job == None:
             Log.d('End thread %d' % self.index)
             break
         #print( ' Run %d' % self.index )
         try:
             code = job.run()
         except BuildUtility.FLB_Error as err:
             Log.e(err)
             code = 100
         except:
             Log.e('Exception! in thread %d' % self.index)
             raise
         if code != 0:
             self.queue.setBreak(code)
             break
Exemplo n.º 9
0
 def setupHostPlatform(self):
     Log.d('system= ' + platform.system())
     Log.d('machine= ' + platform.machine())
     Log.d('processor= ' + platform.processor())
     machine = platform.machine()
     table_arch = {
         'x64': 'x64',
         'AMD64': 'x64',
         'x86_64': 'x64',
         'x86': 'x86',
         'i686': 'x86',
         'i386': 'x86',
         'armv8l': 'arm64',
         'armv7l': 'arm7',
         'armv6l': 'arm6',
         'aarch64': 'arm64',
         'arm64': 'arm64',
     }
     if machine in table_arch:
         self.HOST_ARCH = table_arch[machine]
     table_platform = {
         'Windows': 'Windows',
         'Linux': 'Linux',
         'Unix': 'Linux',
         'Darwin': 'macOS',
     }
     system = platform.system()
     if system in table_platform:
         self.HOST_PLATFORM = table_platform[system]
Exemplo n.º 10
0
def main(argv):
    makefile = 'FLB_Makefile.py'
    default_task = 'build'
    debug_flag = False
    dump_flag = False
    func_command = None
    env_dump = False
    job_count = 0
    action_list = []
    opt_dict = load_config()
    acount = len(argv)
    ai = 1
    while ai < acount:
        arg = argv[ai]
        if arg[0] == '-':
            if arg == '-f':
                ai += 1
                if ai < acount:
                    makefile = argv[ai]
            elif arg == '--env':
                ai += 1
                if ai < acount:
                    platform = argv[ai]
                env_dump = True
            elif arg == '--opt':
                ai += 1
                if ai < acount:
                    opts = argv[ai].split('=')
                    opt_dict[opts[0]] = opts[1]
            elif arg == '--job':
                ai += 1
                if ai < acount:
                    job_count = int(argv[ai])
            elif arg == '--debug':
                debug_flag = True
                Log.DebugLevel = 2
            elif arg == '-v' or arg == '--verbose':
                debug_flag = True
                Log.DebugLevel = 1
            elif arg == '--dump':
                dump_flag = True
            elif arg == '--list':
                func_command = 'f_list'
            elif arg == '--platforms':
                func_command = 'f_platforms'
            else:
                usage()
        else:
            default_task = None
            action_list.append(arg)
        ai += 1

    if default_task:
        action_list.append(default_task)
    if makefile != None:
        start_time_real = time.perf_counter()
        try:
            tool = BuildTool(job_count, opt_dict)
            tool.execScript(makefile)
            if func_command:
                getattr(tool, func_command)()
            else:
                for task_name in action_list:
                    actions = task_name.split(',')
                    tool.runSequentialTask(tool.nameToTaskList(actions))
            tool.wait()
            if dump_flag:
                tool.dump()
            if tool.result_code:
                return tool.result_code
        except Exception as e:
            if not debug_flag:
                print(e)
            else:
                raise
        finally:
            Log.p('time %f' % (time.perf_counter() - start_time_real))
    else:
        usage()

    Log.d('OK')
    return 0
Exemplo n.º 11
0
 def addPlatform(self, platform_name, platform_env):
     Log.d('Load platform : ' + platform_name)
     self.platform_table[platform_name] = platform_env
Exemplo n.º 12
0
 def preBuild(self):
     Log.d('Sequential task "%s" completed' % self.target)
     return self.completeTask(0)
Exemplo n.º 13
0
 def preBuild(self):
     if self.script:
         self.script(self)
     Log.d('Script task "%s" completed' % self.target)
     return self.completeTask(0)
Exemplo n.º 14
0
 def preBuild(self):
     Log.d('Group task "%s" completed' % self.target)
     return self.completeTask(0)
Exemplo n.º 15
0
 def run(self):
     Log.d('RunTask: ' + self.target)
     if self.state_wait:
         return self.signal()
     return self.dependTask()