Ejemplo n.º 1
0
    def execute(self, script, env, values, inputs):
        if env.config.download_only:
            return step_result(
                True,
                'skipping step_install_requirements because download_only is True'
            )

        package_desc = script.descriptor
        requirements = env.requirement_manager.resolve_deps(
            [package_desc.name], env.config.build_target.system,
            ['BUILD', 'RUN'], False)
        build_blurb.blurb(
            'rebuild', '%s - requirements: %s' %
            (package_desc.name, ' '.join([p.name for p in requirements])))

        if not requirements:
            message = 'No requirements for %s' % (script.descriptor.full_name)
            self.log_d(message)
            return step_result(True, message)

        script.requirements_manager.install_packages(requirements,
                                                     script.build_target,
                                                     ['BUILD', 'RUN'])

        return step_result(True, None)
Ejemplo n.º 2
0
  def call_shell(clazz, command, script, env, shell_env = None, save_logs = None, execution_dir = None):
    command = execute.listify_command(command)
    command = [ part for part in command if part ]
    shell_env = shell_env or key_value_list()
    save_logs = save_logs or []
    check.check_key_value_list(shell_env)
    
    log.log_i('rebuild', 'call_shell(command=%s)' % (command))
    build_blurb.blurb_verbose('rebuild', 'call_shell(cmd=%s, shell_env=%s)' % (command, shell_env))

    env = clazz.create_command_env(script)

    env.update(shell_env)

    #clazz.env_dump(env, script.descriptor.name, 'PRE ENVIRONMENT')

    clazz._env_substitite(env)

    rogue_key = clazz._env_find_roque_dollar_sign(env)
    if rogue_key:
      raise RuntimeError('Rogue dollar sign (\"$\") found in %s: %s' % (rogue_key, env[rogue_key]))

    command = [ variable.substitute(part, env) for part in object_util.listify(command) ]

    # Check that no rogue dollar signs are in the command
    for part in command:
      if variable.has_rogue_dollar_signs(part):
        raise RuntimeError('Rogue dollar sign (\"$\") found in: %s' % (part))
      
    build_blurb.blurb('rebuild', '%s - %s' % (script.descriptor.name, ' '.join(command)))

#    file_util.mkdir(script.build_dir)
    retry_script = clazz._write_retry_script(command, env, script)

    #clazz.env_dump(env, script.descriptor.name, clazz.__name__ + ' : ' + 'POST ENVIRONMENT')

    for k,v in env.items():
      if string_util.is_quoted(v):
        env[k] = string_util.unquote(v)

    if execution_dir:
      cwd = path.join(script.build_dir, execution_dir)
    else:
      cwd = script.build_dir

    rv = execute.execute(command,
                         cwd = cwd,
                         env = env,
                         shell = True,
                         non_blocking = build_blurb.verbose,
                         stderr_to_stdout = build_blurb.verbose,
                         raise_error = False)
    message = rv.stdout
    if rv.stderr:
      message = message + '\n' + rv.stderr
    result = step_result(rv.exit_code == 0, message)
    clazz.save_build_dir_logs(script, save_logs)
    return result
Ejemplo n.º 3
0
 def _update(self):
     if self.no_network:
         build_blurb.blurb(
             'rebuild',
             'Repo source finder update disabled due to no_network: %s' %
             (path.relpath(self.repo.root)))
     else:
         build_blurb.blurb(
             'rebuild',
             'Updating repo sources: %s' % (path.relpath(self.repo.root)))
         self.repo.clone_or_pull()
  def __init__(self, build_target):
    super(_toolchain_android_standalone, self).__init__(build_target)
    self.ndk_root = os.environ.get('REBUILD_ANDROID_NDK_TOOLCHAIN_ARM_ROOT', None)
    if not self.ndk_root:
      build_blurb.blurb('rebuild', '*** ERROR *** Trying to use android NDK but REBUILD_ANDROID_NDK_TOOLCHAIN_ARM_ROOT is not set.')
      return
    self._triplet = 'arm-linux-androideabi'
#    self._api = '26'
#    self._api_dir = 'android-%s' % (self._api)
#    self._arch_dir = self._REBUILD_ARCH_TO_PLATFORM_ARCH[self.build_target.arch[0]]
#    self._platforms_dir = path.join(self.ndk_root, 'platforms')
    self._sysroot_dir = path.join(self.ndk_root, 'sysroot')
    self._bin_dir = path.join(self.ndk_root, 'bin')
Ejemplo n.º 5
0
 def __init__(self, build_target):
     super(_toolchain_android, self).__init__(build_target)
     self.ndk_root = os.environ.get('REBUILD_ANDROID_NDK_ROOT', None)
     if not self.ndk_root:
         build_blurb.blurb(
             'rebuild',
             '*** ERROR *** Trying to use android NDK but REBUILD_ANDROID_NDK_ROOT is not set.'
         )
         return
     self._triplet = self._REBUILD_ARCH_TO_TRIPLET[
         self.build_target.arch[0]]
     self._api = '26'
     self._api_dir = 'android-%s' % (self._api)
     self._arch_dir = self._REBUILD_ARCH_TO_PLATFORM_ARCH[
         self.build_target.arch[0]]
     self._platforms_dir = path.join(self.ndk_root, 'platforms')
     self._sysroot_platform_dir = path.join(self._platforms_dir,
                                            self._api_dir, self._arch_dir)
    def execute(self, script, env, values, inputs):
        if env.config.download_only:
            return step_result(
                True,
                'skipping step_setup_install_tool_requirements because download_only is True'
            )

        package_desc = script.descriptor
        tools = script.resolve_deps(['TOOL'], False)
        build_blurb.blurb(
            'rebuild', '%s - tool requirements: %s' %
            (package_desc.name, ' '.join([t.name for t in tools])))
        if not tools:
            message = 'No tools for %s' % (script.descriptor.full_name)
            self.log_d(message)
            return step_result(True, message)

        env.tools_manager.ensure_tools(tools)
        env.tools_manager.expose_env(tools)

        return step_result(True, None)
Ejemplo n.º 7
0
    def _command_test(self, bt, package_tarball, test, artifacts_dir,
                      tools_dir, tmp_dir, opts, verbose):
        parsed_opts = key_value_parser.parse_to_dict(opts)
        opts = parsed_opts

        if 'build_level' in opts and bt == build_target.DEFAULT:
            bt == opts['build_level']

        bt = build_level.parse_level(bt)

        opts['build_level'] = bt

        build_blurb.set_process_name('package_tester')
        build_blurb.set_verbose(bool(verbose))

        if not path.isfile(test):
            raise RuntimeError('Test not found: %s' % (test))

        tmp_dir = None
        if tmp_dir:
            tmp_dir = tmp_dir
        else:
            tmp_dir = temp_file.make_temp_dir(delete=False)
        file_util.mkdir(tmp_dir)

        if not path.isdir(artifacts_dir):
            raise RuntimeError('Not an artifacts directory: %s' %
                               (artifacts_dir))

        if not path.isdir(tools_dir):
            raise RuntimeError('Not an tools directory: %s' % (tools_dir))

        am = artifact_manager_local(artifacts_dir)
        tm = tools_manager(tools_dir, self.build_target, am)

        build_blurb.blurb('tester',
                          ' build_target: %s' % (str(self.build_target)))
        build_blurb.blurb('tester', '      tmp_dir: %s' % (tmp_dir))
        build_blurb.blurb('tester', 'artifacts_dir: %s' % (artifacts_dir))

        if not package.is_package(package_tarball):
            raise RuntimeError('Not a valid package: %s' % (package_tarball))

        test_dir = path.join(tmp_dir, 'test')
        source_dir = path.dirname(test)
        #test_config = namedtuple('test_config', 'script,package_tarball,artifact_manager,tools_manager,extra_env')
        test_config = package_tester.test_config(
            None, package_tarball, am, tm,
            [])  #     source_dir, test_dir, am, tm, target)
        tester = package_tester(test_config, test)

        result = tester.run()

        if not result.success:
            print("result: ", result)
            return 1

        return 0
Ejemplo n.º 8
0
 def _run_test(clazz, config, test):
     build_blurb.blurb(
         'tester', 'Testing %s with %s' %
         (path.relpath(config.package_tarball), path.relpath(test)))
     assert path.isfile(test)
     tc = toolchain.get_toolchain(config.script.build_target)
     ce = tc.compiler_environment()
     compiler_flags = tc.compiler_flags()
     if test.endswith('.cpp'):
         return clazz._run_c_test(config, test, ce['CXX'],
                                  compiler_flags['CXXFLAGS'])
     if test.endswith('.c'):
         return clazz._run_c_test(config, test, ce['CC'],
                                  compiler_flags['CFLAGS'])
     elif test.endswith('.py'):
         return clazz._run_python_test(config, test)
     elif test.endswith('.pl'):
         return clazz._run_perl_test(config, test)
     elif test.endswith('.sh'):
         return clazz._run_shell_test(config, test)
     else:
         raise RuntimeError(
             'Uknown test type for %s: %s - %s' %
             (config.script.descriptor.full_name, str(test), type(test)))
Ejemplo n.º 9
0
    def main(self):
        args = self.parser.parse_args()
        bt = self.build_target_resolve(args)
        args.verbose = bool(args.verbose)

        if args.change_dir:
            os.chdir(args.change_dir)

        target_packages = args.target_packages[0]

        available_packages = self.load_project_file(args.project_file)

        if args.filter:
            if path.isfile(args.filter[0]):
                target_packages_filter = file_util.read(
                    args.filter[0]).split('\n')
            else:
                target_packages_filter = args.filter[0].split(',')
            target_packages_filter = [p for p in target_packages_filter if p]
            available_packages = self._filter_target_packages(
                available_packages, target_packages_filter)

        args.system = build_system.parse_system(args.system)
        args.level = build_level.parse_level(args.level)
        args.arch = build_arch.parse_arch(args.arch, args.system, args.distro)

        build_blurb.set_process_name('rebuild')
        build_blurb.set_verbose(args.verbose)

        # Tests only run on desktop
        if not bt.is_desktop():
            args.skip_tests = True

        if args.download_only and args.no_network:
            build_blurb.blurb(
                'rebuild',
                'Only one of --download-only and --no-net can be given.')
            return 1

        config = builder_config()
        config.build_root = path.abspath(path.abspath(args.root))
        config.build_target = bt
        config.deps_only = args.deps_only
        config.recipes_only = args.recipes_only
        config.disabled = args.disabled
        config.keep_going = args.keep_going
        config.no_checksums = args.no_checksums
        config.no_network = args.no_network
        config.skip_tests = args.skip_tests
        config.skip_to_step = args.skip_to_step
        config.source_dir = args.source_dir
        config.source_pcloud = args.source_pcloud
        config.tools_only = args.tools_only
        config.source_git = args.source_git
        config.users = args.users
        config.verbose = args.verbose
        config.wipe = args.wipe
        config.scratch = args.scratch
        config.third_party_prefix = args.third_party_prefix
        if args.timestamp:
            config.timestamp = args.timestamp
        config.performance = args.performance
        config.download_only = args.download_only
        config.artifacts_dir = args.artifacts
        env = builder_env(config, available_packages)

        bldr = builder(env)

        resolved_args = bldr.check_and_resolve_cmd_line_args(target_packages)

        if args.targets:
            build_blurb.blurb('rebuild',
                              ' '.join(bldr.package_names()),
                              fit=True)
            return 1

        build_blurb.blurb(
            'rebuild',
            'target=%s; host=%s' % (config.build_target.build_path,
                                    config.host_build_target.build_path))
        build_blurb.blurb_verbose('rebuild',
                                  'command line: %s' % (' '.join(sys.argv)))

        if resolved_args.invalid_args:
            build_blurb.blurb(
                'rebuild',
                'Invalid targets: %s' % (' '.join(resolved_args.invalid_args)))
            build_blurb.blurb('rebuild', 'possible targets:')
            build_blurb.blurb('rebuild',
                              ' '.join(bldr.package_names()),
                              fit=True)
            return 1

        if config.recipes_only:
            return bldr.EXIT_CODE_SUCCESS

        return bldr.build_many_scripts(resolved_args.package_names)
Ejemplo n.º 10
0
 def main(clazz):
   exit_code, message = clazz.__main()
   if exit_code != 0:
     build_blurb.blurb('rebuild', message)
   raise SystemExit(exit_code)