def build(self, context, variant, build_path, install_path, install=False,<EOL>build_type=BuildType.local):
ret = {}<EOL>if self.write_build_scripts:<EOL><INDENT>build_env_script = os.path.join(build_path, "<STR_LIT>")<EOL>create_forwarding_script(build_env_script,<EOL>module=("<STR_LIT>", "<STR_LIT>"),<EOL>func_name="<STR_LIT>",<EOL>working_dir=self.working_dir,<EOL>build_path=build_path,<EOL>variant_index=variant.index,<EOL>install=install,<EOL>install_path=install_path)<EOL>ret["<STR_LIT:success>"] = True<EOL>ret["<STR_LIT>"] = build_env_script<EOL>return ret<EOL><DEDENT>command = self.package.build_command<EOL>if command is False:<EOL><INDENT>ret["<STR_LIT:success>"] = True<EOL>return ret<EOL><DEDENT>def expand(txt):<EOL><INDENT>root = self.package.root<EOL>install_ = "<STR_LIT>" if install else '<STR_LIT>'<EOL>return txt.format(root=root, install=install_).strip()<EOL><DEDENT>if isinstance(command, str):<EOL><INDENT>if self.build_args:<EOL><INDENT>command = command + '<STR_LIT:U+0020>' + '<STR_LIT:U+0020>'.join(map(quote, self.build_args))<EOL><DEDENT>command = expand(command)<EOL>cmd_str = command<EOL><DEDENT>else:  <EOL><INDENT>command = command + self.build_args<EOL>command = list(map(expand, command))<EOL>cmd_str = '<STR_LIT:U+0020>'.join(map(quote, command))<EOL><DEDENT>if self.verbose:<EOL><INDENT>pr = Printer(sys.stdout)<EOL>pr("<STR_LIT>" % cmd_str, heading)<EOL><DEDENT>def _callback(executor):<EOL><INDENT>self._add_build_actions(executor,<EOL>context=context,<EOL>package=self.package,<EOL>variant=variant,<EOL>build_type=build_type,<EOL>install=install,<EOL>build_path=build_path,<EOL>install_path=install_path)<EOL>if self.opts:<EOL><INDENT>extra_args = getattr(self.opts.parser, "<STR_LIT>", [])<EOL>for key, value in vars(self.opts).items():<EOL><INDENT>if key in extra_args:<EOL><INDENT>varname = "<STR_LIT>" % key.upper()<EOL>if isinstance(value, bool):<EOL><INDENT>value = <NUM_LIT:1> if value else <NUM_LIT:0><EOL><DEDENT>elif isinstance(value, (list, tuple)):<EOL><INDENT>value = list(map(str, value))<EOL>value = list(map(quote, value))<EOL>value = '<STR_LIT:U+0020>'.join(value)<EOL><DEDENT>executor.env[varname] = value<EOL><DEDENT><DEDENT><DEDENT><DEDENT>retcode, _, _ = context.execute_shell(command=command,<EOL>block=True,<EOL>cwd=build_path,<EOL>actions_callback=_callback)<EOL>ret["<STR_LIT:success>"] = (not retcode)<EOL>return ret<EOL>
Perform the build.

        Note that most of the func args aren't used here - that's because this
        info is already passed to the custom build command via environment
        variables.