Esempio n. 1
0
def main(argv=sys.argv):
    try:
        build_cfg = BuildConfig()
        build_cfg._args = argv[1:]
        log.logging_monitoring_enable(build_cfg)
        
        v = inst.get_technical_xmake_version()
        if v is not None:
            log.info('technical xmake version is '+v)

        phases = [('PRELUDE',        execute_prelude),
                  ('MODULES',        execute_modules),
                  ('IMPORT',         execute_imports),
                  ('BUILD',          execute_build),
                  ('EXPORT',         execute_exports),
                  ('FORWARD',        execute_forward),
                  ('CREATE_STAGING', execute_create_staging),
                  ('DEPLOY',         execute_deployment),
                  ('CLOSE_STAGING',  execute_close_staging),
                  ('PROMOTE',        execute_promote)]

        def exec_phase(name, method):
            if name == 'PRELUDE':
                log.info('='*100)
            log.info('= {0:96} ='.format('entering xmake ' + name + ' phase'))
            log.info('='*100)

            try:
                method(build_cfg)
                notify_phase_ended(name, build_cfg)
                utils.flush()
            except SystemExit:
                raise
            except BaseException:
                raise
            log.info('end of xmake ' + name + ' phase')
            log.info('='*100)

        [exec_phase(name, method) for (name, method) in phases]
        log.info('')
        log.info('*'*100)
        log.info('*{0:98}*'.format(''))
        log.info('* {0:96} *'.format('XMake Build Successfully Done (^_^)'))
        log.info('*{0:98}*'.format(''))
        log.info('*'*100)
        return 0
    except SystemExit as se:
        log.exception(se)
        log.info('')
        log.error('*'*100)
        log.error('*{0:98}*'.format(''))
        log.error('* {0:96} *'.format('XMake Build failed (-_-\')'))
        log.error('*{0:98}*'.format(''))
        log.error('* {0:96} *'.format('Exit code '+str(se)))
        if build_cfg.genroot_dir():
            log.error('* {0:96} *'.format(os.path.join(build_cfg.genroot_dir(), 'boot.log')))
            log.error('* {0:96} *'.format(os.path.join(build_cfg.genroot_dir(), 'build.log')))
        log.error('*{0:98}*'.format(''))
        log.error('*'*100)
        raise
    except BaseException as ex:
        log.exception(ex)
        log.info('')
        log.error('*'*100)
        log.error('*{0:98}*'.format(''))
        log.error('* {0:96} *'.format('XMake Build failed (-_-\')'))
        log.error('*{0:98}*'.format(''))
        log.error('* {0:96} *'.format('aborting build because of error in last phase'))
        if build_cfg.genroot_dir():
            log.error('* {0:96} *'.format(os.path.join(build_cfg.genroot_dir(), 'boot.log')))
            log.error('* {0:96} *'.format(os.path.join(build_cfg.genroot_dir(), 'build.log')))
        log.error('*{0:98}*'.format(''))
        log.error('*'*100)
        sys.exit(1)
Esempio n. 2
0
def bootstrap2(argv):
    global xmake_status, build_cfg
    prepare_bootstrap()
    xmake_inst_dir = inst.get_installation_dir()
    if len(argv)>1 and argv[1]=='--bootstrap':
        xmake_status='bootstrap'
        sys.argv=argv=argv[0:1]+argv[2:]
    else:
        if isfile(join(xmake_inst_dir,'.loaded')):
            log.warning( 'directly using loaded sub level version of xmake')
            xmake_status='loaded'

    if xmake_status=='loaded':
        run(argv)
    else:
        log.info( 'bootstrapping xmake...')
        build_cfg = BuildConfig()
        (args,_,_) = setup_config(build_cfg, True)
        log.info("component root is "+build_cfg.component_dir())
        log.info( 'build runtime is ' + build_cfg.runtime())
        create_gendir(build_cfg)
        log.start_logfile(join(build_cfg.genroot_dir(),"boot.log"))
        determine_version_suffix(build_cfg, args.version) # required by xmake version check below

        if args.use_current_xmake_version:
            log.warning( 'using actually installed version as requested by option --use-current-xmake-version')
            run(argv)
        else:
            v=determine_xmake_version(build_cfg)
            if v==None:
                log.warning( 'no xmake version specified (please maintain file '+XMAKE_VERSION+" or xmake.cfg in project's cfg folder")
                log.info("default version is "+str(args.default_xmake_version))
                if args.default_xmake_version==None:
                    if build_cfg.is_release() or build_cfg.is_milestone():
                        raise XmakeException('no version specified for xmake for a productive build')
                    else:
                        log.warning( 'using actually installed version')
                        run(argv)
                else:
                    v=args.default_xmake_version
                    log.warning( 'using explicit default version '+v)
            if v==None:
                log.error("do not know any xmake version to use -> exit")
                sys.exit(2)
            else:
                v=find_latest(v)
                log.info( 'required xmake version is '+v)
                if v.endswith("-SNAPSHOT"):
                    if build_cfg.is_release() or build_cfg.is_milestone():
                        log.info("version suffix is "+str(build_cfg.version_suffix()))
                        log.error( 'this is a snapshot version, it cannot be used for release or milestone builds')
                        raise XmakeException('snapshot version specified for xmake for a realease or milestone build')
                    else:
                        log.warning( 'this is a snapshot version, it cannot be used for release builds')
                l=get_xmake_version(v, build_cfg)
                if is_existing_file(xmake_loaded): os.remove(xmake_loaded)
                log.info( 'required xmake version found at '+l)
                if test_mode:
                    cmd=[sys.executable, join(l,'xmake','bootstrap.py'), '--use-current-xmake-version']
                else:
                    cmd=[sys.executable, join(l,'xmake','xmake.py')]
                log.info( 'starting xmake...')
                cmd.extend(prepare_args(build_cfg, l,argv[1:]))
                if build_cfg.component_dir()!=None: os.chdir(build_cfg.component_dir())
                flush()
                log.stop_logfile()
                rc=subprocess.call(cmd)
                sys.exit(rc)