1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-06-26 04:00:43 +03:00

Added -missing and -archive

This commit is contained in:
Graham Nelson 2020-03-10 20:21:55 +00:00
parent 1277610f9f
commit 1a996f2724
18 changed files with 147 additions and 41 deletions

View file

@ -10,6 +10,9 @@ this plan out.
@e INSPECT_TTASK from 1
@e GRAPH_TTASK
@e NEEDS_TTASK
@e ARCHIVE_TTASK
@e ARCHIVE_TO_TTASK
@e MISSING_TTASK
@e BUILD_TTASK
@e REBUILD_TTASK
@e COPY_TO_TTASK
@ -70,6 +73,15 @@ int main(int argc, char **argv) {
case INSPECT_TTASK: Copies::inspect(STDOUT, C); break;
case GRAPH_TTASK: Copies::show_graph(STDOUT, C); break;
case NEEDS_TTASK: Copies::show_needs(STDOUT, C); break;
case ARCHIVE_TTASK:
destination_nest = Inbuild::materials_nest();
if (destination_nest == NULL)
Errors::with_text("no -project in use, so ignoring -archive", NULL);
else
Copies::archive(STDOUT, C, destination_nest, BM);
break;
case ARCHIVE_TO_TTASK: if (destination_nest) Copies::archive(STDOUT, C, destination_nest, BM); break;
case MISSING_TTASK: Copies::show_missing(STDOUT, C); break;
case BUILD_TTASK: Copies::build(STDOUT, C, BM); break;
case REBUILD_TTASK: Copies::rebuild(STDOUT, C, BM); break;
case COPY_TO_TTASK: if (destination_nest) Nests::copy_to(C, destination_nest, FALSE, BM); break;
@ -92,6 +104,9 @@ int main(int argc, char **argv) {
@e REBUILD_CLSW
@e GRAPH_CLSW
@e NEEDS_CLSW
@e MISSING_CLSW
@e ARCHIVE_CLSW
@e ARCHIVE_TO_CLSW
@e INSPECT_CLSW
@e DRY_CLSW
@e BUILD_TRACE_CLSW
@ -119,7 +134,13 @@ int main(int argc, char **argv) {
CommandLine::declare_switch(GRAPH_CLSW, L"graph", 1,
L"show dependency graph of target(s) but take no action");
CommandLine::declare_switch(NEEDS_CLSW, L"needs", 1,
L"show the extensions, kits and so on needed to build");
L"show all the extensions, kits and so on needed to build");
CommandLine::declare_switch(MISSING_CLSW, L"missing", 1,
L"show the extensions, kits and so on which are needed but missing");
CommandLine::declare_switch(ARCHIVE_CLSW, L"archive", 1,
L"sync copies of all extensions, kits and so on needed for -project into Materials");
CommandLine::declare_switch(ARCHIVE_TO_CLSW, L"archive-to", 2,
L"sync copies of all extensions, kits and so on needed into nest X");
CommandLine::declare_switch(TOOLS_CLSW, L"tools", 2,
L"make X the directory of intools executables, and exit developer mode");
CommandLine::declare_boolean_switch(DRY_CLSW, L"dry", 1,
@ -175,6 +196,14 @@ void Main::option(int id, int val, text_stream *arg, void *state) {
case INSPECT_CLSW: inbuild_task = INSPECT_TTASK; break;
case GRAPH_CLSW: inbuild_task = GRAPH_TTASK; break;
case NEEDS_CLSW: inbuild_task = NEEDS_TTASK; break;
case ARCHIVE_TO_CLSW:
destination_nest = Nests::new(Pathnames::from_text(arg));
inbuild_task = ARCHIVE_TO_TTASK;
break;
case ARCHIVE_CLSW:
inbuild_task = ARCHIVE_TTASK;
break;
case MISSING_CLSW: inbuild_task = MISSING_TTASK; break;
case TOOLS_CLSW: path_to_tools = Pathnames::from_text(arg); break;
case MATCHING_CLSW: filter_text = Str::duplicate(arg); break;
case CONTENTS_OF_CLSW: Main::load_many(Pathnames::from_text(arg)); break;

View file

@ -196,7 +196,6 @@ inbuild_copy *Inbuild::optioneering_complete(inbuild_copy *C, int compile_only)
if (pipeline_vars == NULL)
pipeline_vars = CodeGen::Pipeline::basic_dictionary(I"output.z8");
#endif
target_vm *VM = NULL;
text_stream *ext = story_filename_extension;
if (Str::len(ext) == 0) ext = I"ulx";
@ -211,15 +210,16 @@ inbuild_copy *Inbuild::optioneering_complete(inbuild_copy *C, int compile_only)
inbuild_phase = TINKERING_INBUILD_PHASE;
Inbuild::sort_nest_list();
inbuild_phase = NESTED_INBUILD_PHASE;
#ifdef CORE_MODULE
NaturalLanguages::scan();
#endif
if (project) Projects::set_to_English(project);
#ifdef CORE_MODULE
Semantics::read_preform(Projects::get_language_of_syntax(project));
#endif
Inbuild::pass_kit_requests();
// #ifndef CORE_MODULE
current_target_VM = VM;
if (project) Copies::read_source_text_for(project->as_copy);
// #endif
inbuild_phase = PROJECTED_INBUILD_PHASE;
if (project) {
@ -373,6 +373,11 @@ pathname *Inbuild::materials(void) {
return shared_materials_nest->location;
}
inbuild_nest *Inbuild::materials_nest(void) {
RUN_ONLY_FROM_PHASE(NESTED_INBUILD_PHASE)
return shared_materials_nest;
}
@ As noted above, the transient area is used for ephemera such as dynamically
written documentation and telemetry files. |-transient| sets it, but otherwise
the external nest is used.

View file

@ -79,6 +79,17 @@ void Copies::show_graph(OUTPUT_STREAM, inbuild_copy *C) {
void Copies::show_needs(OUTPUT_STREAM, inbuild_copy *C) {
Graphs::show_needs(OUT, C->vertex);
}
void Copies::show_missing(OUTPUT_STREAM, inbuild_copy *C) {
int N = Graphs::show_missing(OUT, C->vertex);
if (N == 0) WRITE("Nothing is missing\n");
}
void Copies::archive(OUTPUT_STREAM, inbuild_copy *C, inbuild_nest *N, build_methodology *BM) {
int NM = Graphs::show_missing(OUT, C->vertex);
if (NM > 0) WRITE("Because there are missing resources, -archive is cancelled\n");
else {
Graphs::archive(OUT, C->vertex, N, BM);
}
}
int Copies::source_text_has_been_read(inbuild_copy *C) {
if (C == NULL) internal_error("no copy");

View file

@ -9,17 +9,19 @@ few of these.
=
typedef struct inbuild_genre {
text_stream *genre_name;
int stored_in_nests;
METHOD_CALLS
MEMORY_MANAGEMENT
} inbuild_genre;
inbuild_genre *Genres::new(text_stream *name) {
inbuild_genre *Genres::new(text_stream *name, int nested) {
inbuild_genre *gen;
LOOP_OVER(gen, inbuild_genre)
if (Str::eq(gen->genre_name, name))
return gen;
gen = CREATE(inbuild_genre);
gen->genre_name = Str::duplicate(name);
gen->stored_in_nests = nested;
ENABLE_METHOD_CALLS(gen);
return gen;
}
@ -29,6 +31,11 @@ text_stream *Genres::name(inbuild_genre *G) {
return G->genre_name;
}
int Genres::stored_in_nests(inbuild_genre *G) {
if (G == NULL) return FALSE;
return G->stored_in_nests;
}
@
@e GENRE_WRITE_WORK_MTID

View file

@ -179,6 +179,71 @@ void Graphs::show_needs_r(OUTPUT_STREAM, build_vertex *V, int depth, int true_de
}
}
int Graphs::show_missing(OUTPUT_STREAM, build_vertex *V) {
return Graphs::show_missing_r(OUT, V, 0);
}
int Graphs::show_missing_r(OUTPUT_STREAM, build_vertex *V, int true_depth) {
int N = 0;
if (V->type == REQUIREMENT_VERTEX) {
WRITE("missing %S: ", V->findable->work->genre->genre_name);
Works::write(OUT, V->findable->work);
if (VersionNumbers::is_any_range(V->findable->version_range) == FALSE) {
WRITE(", need version in range "); VersionNumbers::write_range(OUT, V->findable->version_range);
} else {
WRITE(", any version will do");
}
WRITE("\n");
N = 1;
}
build_vertex *W;
LOOP_OVER_LINKED_LIST(W, build_vertex, V->build_edges)
N += Graphs::show_missing_r(OUT, W, true_depth+1);
if ((V->type == COPY_VERTEX) && (true_depth > 0)) {
LOOP_OVER_LINKED_LIST(W, build_vertex, V->use_edges)
N += Graphs::show_missing_r(OUT, W, true_depth+1);
}
return N;
}
void Graphs::archive(OUTPUT_STREAM, build_vertex *V, inbuild_nest *N, build_methodology *BM) {
Graphs::archive_r(OUT, V, 0, N, BM);
}
void Graphs::archive_r(OUTPUT_STREAM, build_vertex *V, int true_depth, inbuild_nest *N, build_methodology *BM) {
if (V->type == COPY_VERTEX) {
inbuild_copy *C = V->buildable_if_copy;
if ((Genres::stored_in_nests(C->edition->work->genre)) &&
((Str::ne(C->edition->work->title, I"English")) ||
(Str::len(C->edition->work->author_name) > 0))) {
WRITE("%S: ", C->edition->work->genre->genre_name);
Copies::write_copy(OUT, C);
pathname *P = C->location_if_path;
if (C->location_if_file) P = Filenames::get_path_to(C->location_if_file);
TEMPORARY_TEXT(nl);
TEMPORARY_TEXT(cl);
WRITE_TO(nl, "%p/", N->location);
WRITE_TO(cl, "%p/", P);
if (Str::prefix_eq(cl, nl, Str::len(nl))) {
WRITE(" -- already there\n");
} else {
WRITE(" -- archiving\n");
Nests::copy_to(C, N, TRUE, BM);
}
DISCARD_TEXT(nl);
DISCARD_TEXT(cl);
}
}
build_vertex *W;
LOOP_OVER_LINKED_LIST(W, build_vertex, V->build_edges)
Graphs::archive_r(OUT, W, true_depth+1, N, BM);
if ((V->type == COPY_VERTEX) && (true_depth > 0)) {
LOOP_OVER_LINKED_LIST(W, build_vertex, V->use_edges)
Graphs::archive_r(OUT, W, true_depth+1, N, BM);
}
}
time_t Graphs::timestamp_for(build_vertex *V) {
time_t latest = (time_t) 0;

View file

@ -15,7 +15,7 @@ length to one character less than the following constants:
@ =
void ExtensionManager::start(void) {
extension_genre = Genres::new(I"extension");
extension_genre = Genres::new(I"extension", TRUE);
METHOD_ADD(extension_genre, GENRE_WRITE_WORK_MTID, ExtensionManager::write_work);
METHOD_ADD(extension_genre, GENRE_CLAIM_AS_COPY_MTID, ExtensionManager::claim_as_copy);
METHOD_ADD(extension_genre, GENRE_SCAN_COPY_MTID, Extensions::scan);

View file

@ -7,7 +7,7 @@ A kit is a combination of Inter code with an Inform 7 extension.
=
inbuild_genre *kit_genre = NULL;
void KitManager::start(void) {
kit_genre = Genres::new(I"kit");
kit_genre = Genres::new(I"kit", TRUE);
METHOD_ADD(kit_genre, GENRE_WRITE_WORK_MTID, KitManager::write_work);
METHOD_ADD(kit_genre, GENRE_CLAIM_AS_COPY_MTID, KitManager::claim_as_copy);
METHOD_ADD(kit_genre, GENRE_SCAN_COPY_MTID, Kits::scan);

View file

@ -9,7 +9,7 @@ inbuild_genre *language_genre = NULL;
@ =
void LanguageManager::start(void) {
language_genre = Genres::new(I"language");
language_genre = Genres::new(I"language", TRUE);
METHOD_ADD(language_genre, GENRE_WRITE_WORK_MTID, LanguageManager::write_work);
METHOD_ADD(language_genre, GENRE_CLAIM_AS_COPY_MTID, LanguageManager::claim_as_copy);
METHOD_ADD(language_genre, GENRE_SEARCH_NEST_FOR_MTID, LanguageManager::search_nest_for);

View file

@ -9,7 +9,7 @@ inbuild_genre *pipeline_genre = NULL;
@ =
void PipelineManager::start(void) {
pipeline_genre = Genres::new(I"pipeline");
pipeline_genre = Genres::new(I"pipeline", TRUE);
METHOD_ADD(pipeline_genre, GENRE_WRITE_WORK_MTID, PipelineManager::write_work);
METHOD_ADD(pipeline_genre, GENRE_CLAIM_AS_COPY_MTID, PipelineManager::claim_as_copy);
METHOD_ADD(pipeline_genre, GENRE_SEARCH_NEST_FOR_MTID, PipelineManager::search_nest_for);

View file

@ -7,7 +7,7 @@ A project bundle is a folder holding an Inform 7 work. The app creates these.
=
inbuild_genre *project_bundle_genre = NULL;
void ProjectBundleManager::start(void) {
project_bundle_genre = Genres::new(I"projectbundle");
project_bundle_genre = Genres::new(I"projectbundle", FALSE);
METHOD_ADD(project_bundle_genre, GENRE_WRITE_WORK_MTID, ProjectBundleManager::write_work);
METHOD_ADD(project_bundle_genre, GENRE_CLAIM_AS_COPY_MTID, ProjectBundleManager::claim_as_copy);
METHOD_ADD(project_bundle_genre, GENRE_SEARCH_NEST_FOR_MTID, ProjectBundleManager::search_nest_for);

View file

@ -7,7 +7,7 @@ A project file is a plain text file of Inform 7 source text.
=
inbuild_genre *project_file_genre = NULL;
void ProjectFileManager::start(void) {
project_file_genre = Genres::new(I"projectfile");
project_file_genre = Genres::new(I"projectfile", FALSE);
METHOD_ADD(project_file_genre, GENRE_WRITE_WORK_MTID, ProjectFileManager::write_work);
METHOD_ADD(project_file_genre, GENRE_CLAIM_AS_COPY_MTID, ProjectFileManager::claim_as_copy);
METHOD_ADD(project_file_genre, GENRE_SEARCH_NEST_FOR_MTID, ProjectFileManager::search_nest_for);

View file

@ -7,7 +7,7 @@ A template is the outline for a website presenting an Inform work.
=
inbuild_genre *template_genre = NULL;
void TemplateManager::start(void) {
template_genre = Genres::new(I"template");
template_genre = Genres::new(I"template", TRUE);
METHOD_ADD(template_genre, GENRE_WRITE_WORK_MTID, TemplateManager::write_work);
METHOD_ADD(template_genre, GENRE_CLAIM_AS_COPY_MTID, TemplateManager::claim_as_copy);
METHOD_ADD(template_genre, GENRE_SEARCH_NEST_FOR_MTID, TemplateManager::search_nest_for);

View file

@ -48,7 +48,9 @@ inform_project *Projects::new_ip(text_stream *name, filename *F, pathname *P) {
void Projects::set_to_English(inform_project *proj) {
if (proj == NULL) internal_error("no project");
inbuild_requirement *req = Requirements::any_version_of(Works::new(language_genre, I"English", I""));
inbuild_search_result *R = Nests::first_found(req, Inbuild::nest_list());
linked_list *L = NEW_LINKED_LIST(inbuild_nest);
ADD_TO_LINKED_LIST(Inbuild::internal(), inbuild_nest, L);
inbuild_search_result *R = Nests::first_found(req, L);
if (R) {
inform_language *E = LanguageManager::from_copy(R->copy);
proj->language_of_play = E;
@ -78,9 +80,6 @@ inform_language *Projects::get_language_of_index(inform_project *proj) {
void Projects::set_language_of_syntax(inform_project *proj, inform_language *L) {
if (proj == NULL) internal_error("no project");
proj->language_of_syntax = L;
#ifdef CORE_MODULE
English_language = L;
#endif
}
inform_language *Projects::get_language_of_syntax(inform_project *proj) {
if (proj == NULL) return NULL;

View file

@ -30,7 +30,7 @@ int CoreMain::main(int argc, char *argv[]) {
@<Build the project identified for us by Inbuild@>;
}
ParseTree::log_tree(DL, Task::syntax_tree()->root_node);
// ParseTree::log_tree(DL, Task::syntax_tree()->root_node);
@<Post mortem logging@>;
if (proceed) @<Shutdown and rennab@>;

View file

@ -48,10 +48,6 @@ int Task::carry_out(build_step *S) {
latest_syntax_tree = project->syntax_tree;
Task::issue_problems_arising(project->as_copy->vertex);
// SourceProblems::issue_problems_arising(project->as_copy);
// inform_extension *E;
// LOOP_OVER(E, inform_extension)
// SourceProblems::issue_problems_arising(E->as_copy);
if (problem_count > 0) return FALSE;
@ -66,20 +62,26 @@ int Task::carry_out(build_step *S) {
inform7_task->existing_storyfile = NULL;
inform7_task->stage_of_compilation = -1;
inform7_task->next_resource_number = 3;
inform_language *En = NaturalLanguages::English();
Projects::set_language_of_syntax(project, En);
Projects::set_language_of_index(project, En);
Projects::set_language_of_play(project, En);
English_language = Projects::get_language_of_syntax(project);
int rv = Sequence::carry_out(TargetVMs::debug_enabled(inform7_task->task->for_vm));
inform7_task = NULL;
return rv;
}
@ All manner of low-level problems emerge when reading in the text of the
project, or any extensions it uses: these have already been found by inbuild
and are attached to the relevant nodes in the build graph. We issue them
here as Inform problem messages. (Inbuild wasn't able to do that for us
because the Inform problems file wasn't open back then; and besides, it can
only issue stubby Unix-like command line errors.)
=
void Task::issue_problems_arising(build_vertex *V) {
if (V->type == COPY_VERTEX) {
LOG("Issue from copy of %X at %08x\n", V->buildable_if_copy->edition->work, V->buildable_if_copy);
LOG("Issue from copy of %X at %08x\n",
V->buildable_if_copy->edition->work, V->buildable_if_copy);
SourceProblems::issue_problems_arising(V->buildable_if_copy);
}
build_vertex *W;

View file

@ -65,7 +65,6 @@ a bitmap made up of the following modes:
@d BEGIN_DASH_MODE int s_dm = dash_mode; kind **s_kvc = kind_of_var_to_create; parse_node *s_invl = Dash_ambiguity_list;
@d DASH_MODE_ENTER(mode) dash_mode |= mode;
@d DASH_MODE_CREATE(K) kind_of_var_to_create = K;
@d DASH_MODE_INVL(invl) Dash_ambiguity_list = invl;
@d DASH_MODE_EXIT(mode) dash_mode &= (~mode);
@d END_DASH_MODE dash_mode = s_dm; kind_of_var_to_create = s_kvc; Dash_ambiguity_list = s_invl;
@d TEST_DASH_MODE(mode) (dash_mode & mode)
@ -774,7 +773,7 @@ in (4I) either directly or via (4A). For everything else, it's (4S) for us.
case INVOCATION_LIST_NT: case INVOCATION_LIST_SAY_NT: case AMBIGUITY_NT:
if (p->down == NULL) @<Unknown found text occurs as a command@>;
BEGIN_DASH_MODE;
DASH_MODE_INVL(p);
Dash_ambiguity_list = p;
outcome = Dash::typecheck_recursive(p->down, context, TRUE);
END_DASH_MODE;
break;

View file

@ -24,16 +24,6 @@ void NaturalLanguages::scan(void) {
}
}
@h Language of play.
=
inform_language *NaturalLanguages::English(void) {
NaturalLanguages::scan();
inform_language *L = Languages::from_name(I"english");
if (L == NULL) internal_error("unable to find English language bundle");
return L;
}
@h Indexing.
=
@ -122,7 +112,7 @@ wording NaturalLanguages::load_preform(inform_language *L) {
if (L == NULL) internal_error("can't load preform from null language");
language_being_read_by_Preform = L;
filename *preform_file = Filenames::in_folder(Languages::path_to_bundle(L), I"Syntax.preform");
LOG("Reading language definition from <%f>\n", preform_file);
PRINT("Reading language definition from <%f>\n", preform_file);
return Preform::load_from_file(preform_file);
}

View file

@ -210,7 +210,6 @@ whole thing into a |specification| for the rest of Inform to use.
=
void Semantics::read_preform(inform_language *L) {
@<Mark certain nonterminals to have their vocabularies numbered and flagged@>;
NaturalLanguages::scan();
wording W = NaturalLanguages::load_preform(L);
int nonterminals_declared = Preform::parse_preform(W, FALSE);