2020-01-29 21:58:43 +02:00
|
|
|
[BuildSteps::] Build Steps.
|
|
|
|
|
2020-02-24 01:49:56 +02:00
|
|
|
A build step is a task which exercises one of the build skills.
|
2020-01-29 21:58:43 +02:00
|
|
|
|
2020-02-24 01:49:56 +02:00
|
|
|
@h Build skills.
|
|
|
|
|
|
|
|
=
|
|
|
|
typedef struct build_skill {
|
|
|
|
struct text_stream *name;
|
|
|
|
METHOD_CALLS
|
|
|
|
MEMORY_MANAGEMENT
|
|
|
|
} build_skill;
|
|
|
|
|
|
|
|
build_skill *BuildSteps::new_skill(text_stream *name) {
|
|
|
|
build_skill *S = CREATE(build_skill);
|
|
|
|
S->name = Str::duplicate(name);
|
|
|
|
ENABLE_METHOD_CALLS(S);
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
@
|
2020-01-29 21:58:43 +02:00
|
|
|
|
2020-02-24 01:49:56 +02:00
|
|
|
@e BUILD_SKILL_COMMAND_MTID
|
|
|
|
@e BUILD_SKILL_INTERNAL_MTID
|
|
|
|
|
|
|
|
=
|
|
|
|
VMETHOD_TYPE(BUILD_SKILL_COMMAND_MTID,
|
|
|
|
build_skill *S, build_step *BS, text_stream *command, build_methodology *meth)
|
|
|
|
IMETHOD_TYPE(BUILD_SKILL_INTERNAL_MTID,
|
|
|
|
build_skill *S, build_step *BS, build_methodology *meth)
|
|
|
|
|
|
|
|
@h Build steps.
|
2020-01-29 21:58:43 +02:00
|
|
|
|
|
|
|
=
|
|
|
|
typedef struct build_step {
|
2020-02-24 01:49:56 +02:00
|
|
|
struct build_skill *what_to_do;
|
2020-02-22 16:09:13 +02:00
|
|
|
struct build_vertex *vertex;
|
|
|
|
struct linked_list *search_path; /* of |inbuild_nest| */
|
|
|
|
struct target_vm *for_vm;
|
|
|
|
struct inter_architecture *for_arch;
|
|
|
|
int for_release;
|
|
|
|
struct inbuild_copy *associated_copy;
|
2020-01-29 21:58:43 +02:00
|
|
|
MEMORY_MANAGEMENT
|
|
|
|
} build_step;
|
|
|
|
|
|
|
|
@
|
|
|
|
|
|
|
|
=
|
2020-02-24 01:49:56 +02:00
|
|
|
build_step *BuildSteps::attach(build_vertex *vertex, build_skill *to_do, linked_list *search,
|
2020-02-22 16:09:13 +02:00
|
|
|
int rel, target_vm *VM, inter_architecture *arch, inbuild_copy *assoc) {
|
2020-01-29 21:58:43 +02:00
|
|
|
build_step *S = CREATE(build_step);
|
2020-02-22 16:09:13 +02:00
|
|
|
S->vertex = vertex;
|
2020-01-29 21:58:43 +02:00
|
|
|
S->what_to_do = to_do;
|
2020-02-22 16:09:13 +02:00
|
|
|
S->search_path = search;
|
|
|
|
S->for_vm = VM;
|
|
|
|
S->for_arch = arch;
|
|
|
|
if ((VM) && (arch == NULL)) S->for_arch = TargetVMs::get_architecture(VM);
|
|
|
|
S->for_release = rel;
|
|
|
|
S->associated_copy = assoc;
|
|
|
|
BuildScripts::add_step(vertex->script, S);
|
2020-01-29 21:58:43 +02:00
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2020-02-22 16:09:13 +02:00
|
|
|
int BuildSteps::execute(build_vertex *V, build_step *S, build_methodology *meth) {
|
|
|
|
int rv = TRUE;
|
|
|
|
TEMPORARY_TEXT(command);
|
2020-02-24 01:49:56 +02:00
|
|
|
VMETHOD_CALL(S->what_to_do, BUILD_SKILL_COMMAND_MTID, S, command, meth);
|
2020-02-24 11:48:40 +02:00
|
|
|
if ((rv) && (Str::len(command) > 0)) rv = BuildSteps::shell(command, meth);
|
2020-02-24 01:49:56 +02:00
|
|
|
if ((rv) && (meth->methodology == INTERNAL_METHODOLOGY)) {
|
|
|
|
int returned = 0;
|
|
|
|
IMETHOD_CALL(returned, S->what_to_do, BUILD_SKILL_INTERNAL_MTID, S, meth);
|
|
|
|
if (returned != TRUE) rv = FALSE;
|
|
|
|
}
|
2020-02-22 16:09:13 +02:00
|
|
|
if (rv == FALSE) WRITE_TO(STDERR, "Build failed at '%S'\n", command);
|
|
|
|
DISCARD_TEXT(command);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
int BuildSteps::shell(text_stream *command, build_methodology *meth) {
|
|
|
|
int rv = TRUE;
|
|
|
|
WRITE_TO(STDOUT, "%S\n", command);
|
|
|
|
if (meth->methodology == SHELL_METHODOLOGY) rv = (Shell::run(command) == 0)?TRUE:FALSE;
|
|
|
|
return rv;
|
2020-01-29 21:58:43 +02:00
|
|
|
}
|