[m-rev.] for review: canonicalise --libgrade grade strings
Peter Wang
wangp at students.cs.mu.OZ.AU
Fri Feb 3 15:30:57 AEDT 2006
On 2006-02-01, Julien Fischer <juliensf at cs.mu.OZ.AU> wrote:
>
> On Wed, 1 Feb 2006, Peter Wang wrote:
>
> > Estimated hours taken: 1
> > Branches: main
> >
> > compiler/handle_options.m:
> > Canonicalise the grade strings passed to `--libgrade'. This solves a
> > problem where "mmc --make libfoo.install --libgrade <bar>" would
> > install into a grade subdirectory named <bar> in non-canonical form.
> >
> That's fine.
Sorry, it turns out that was _really_ broken.
Estimated hours taken: 2
Branches: main
This is a follow up to a previous patch designed to solve a
problem where "mmc --make libfoo.install --libgrade <bar>" would
install into a grade subdirectory named <bar> in non-canonical form.
The previous patch was completely broken for "hlc" grades (at least).
compiler/handle_options.m:
Revert r1.252 as it did not properly canonicalise grade strings.
compiler/make.program_target.m:
Use `grade_directory_component' to find out which directory a grade's
files should be installed into instead of assuming the verbatim grade
string passed in with `--libgrade'.
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.252
diff -u -r1.252 handle_options.m
--- compiler/handle_options.m 1 Feb 2006 23:38:20 -0000 1.252
+++ compiler/handle_options.m 3 Feb 2006 03:35:45 -0000
@@ -644,12 +644,6 @@
% without checking timestamps.
option_implies(rebuild, make, bool(yes), !Globals),
- % Canonicalise the arguments to --libgrade options.
- % Unrecognised grade strings are left as is and will be caught later.
- globals__lookup_accumulating_option(!.Globals, libgrades, LibGrades0),
- LibGrades = list__map(canonical_grade_or_identity, LibGrades0),
- globals__set_option(libgrades, accumulating(LibGrades), !Globals),
-
% If no --lib-linkage option has been specified, default to the
% set of all possible linkages.
globals__lookup_accumulating_option(!.Globals, lib_linkages,
@@ -1965,24 +1959,6 @@
compute_grade(Globals, Grade) :-
globals__get_options(Globals, Options),
compute_grade_components(Options, Components),
- components_to_grade(Components, Grade).
-
-:- func canonical_grade_or_identity(string) = string is det.
-
-canonical_grade_or_identity(Grade0) =
- (if canonical_grade(Grade0) = Grade then Grade else Grade0).
-
-:- func canonical_grade(string) = string is semidet.
-
-canonical_grade(GradeString) = Grade :-
- convert_grade_option(GradeString, map__init, Options),
- compute_grade_components(Options, Components),
- components_to_grade(Components, Grade).
-
-:- pred components_to_grade(list(pair(grade_component, string))::in,
- string::out) is det.
-
-components_to_grade(Components, Grade) :-
(
Components = [],
Grade = "none"
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.37
diff -u -r1.37 make.program_target.m
--- compiler/make.program_target.m 25 Jan 2006 03:27:35 -0000 1.37
+++ compiler/make.program_target.m 3 Feb 2006 04:20:51 -0000
@@ -708,7 +708,7 @@
install_library_grade_2(LinkSucceeded0, Grade, ModuleName, AllModules,
Info0, Succeeded, !IO) :-
- globals__io_get_globals(Globals, !IO),
+ globals__io_get_globals(OrigGlobals, !IO),
% Set up so that grade-dependent files for the current grade
% don't overwrite the files for the default grade.
@@ -756,15 +756,19 @@
Info1, Info2, !IO),
(
LibSucceeded = yes,
- install_library_grade_files(LinkSucceeded0, Grade, ModuleName,
- AllModules, Succeeded, Info2, Info3, !IO),
+ % `GradeDir' differs from `Grade' in that it is in canonical form,
+ % and it does not include any `.picreg' component.
+ globals__io_get_globals(Globals, !IO),
+ grade_directory_component(Globals, GradeDir),
+ install_library_grade_files(LinkSucceeded0, GradeDir,
+ ModuleName, AllModules, Succeeded, Info2, Info3, !IO),
make_grade_clean(ModuleName, AllModules, Info3, _, !IO)
;
LibSucceeded = no,
Succeeded = no
)
),
- globals__io_set_globals(unsafe_promise_unique(Globals), !IO).
+ globals__io_set_globals(unsafe_promise_unique(OrigGlobals), !IO).
% Install the `.a', `.so', `.jar', `.opt' and `.mih' files
% for the current grade.
@@ -773,9 +777,9 @@
list(module_name)::in, bool::out, make_info::in, make_info::out,
io::di, io::uo) is det.
-install_library_grade_files(LinkSucceeded0, Grade, ModuleName, AllModules,
+install_library_grade_files(LinkSucceeded0, GradeDir, ModuleName, AllModules,
Succeeded, !Info, !IO) :-
- make_grade_install_dirs(Grade, DirResult, LinkSucceeded1, !IO),
+ make_grade_install_dirs(GradeDir, DirResult, LinkSucceeded1, !IO),
LinkSucceeded = LinkSucceeded0 `and` LinkSucceeded1,
(
DirResult = yes,
@@ -786,11 +790,11 @@
globals__io_lookup_string_option(install_prefix, Prefix, !IO),
- ( Grade = "java" ->
+ ( GradeDir = "java" ->
GradeLibDir = Prefix/"lib"/"mercury"/"lib"/"java",
install_file(JarFileName, GradeLibDir, LibsSucceeded, !IO)
;
- GradeLibDir = Prefix/"lib"/"mercury"/"lib"/Grade,
+ GradeLibDir = Prefix/"lib"/"mercury"/"lib"/GradeDir,
maybe_install_library_file("static", LibFileName, GradeLibDir,
LibSuccess, !IO),
( LibFileName = SharedLibFileName ->
@@ -802,7 +806,8 @@
)
),
- list__map_foldl2(install_grade_ints_and_headers(LinkSucceeded, Grade),
+ list__map_foldl2(
+ install_grade_ints_and_headers(LinkSucceeded, GradeDir),
AllModules, IntsHeadersSucceeded, !Info, !IO),
Succeeded = bool__and_list([LibsSucceeded | IntsHeadersSucceeded])
;
@@ -815,7 +820,7 @@
:- pred install_grade_ints_and_headers(bool::in, string::in, module_name::in,
bool::out, make_info::in, make_info::out, io::di, io::uo) is det.
-install_grade_ints_and_headers(LinkSucceeded, Grade, ModuleName, Succeeded,
+install_grade_ints_and_headers(LinkSucceeded, GradeDir, ModuleName, Succeeded,
!Info, !IO) :-
get_module_dependencies(ModuleName, MaybeImports, !Info, !IO),
(
@@ -834,7 +839,7 @@
Imports ^ foreign_code = contains_foreign_code(_)
)
->
- GradeIncDir = LibDir/"lib"/Grade/"inc",
+ GradeIncDir = LibDir/"lib"/GradeDir/"inc",
install_subdir_file(LinkSucceeded, GradeIncDir, ModuleName, "mih",
HeaderSucceded1, !IO),
@@ -853,7 +858,7 @@
!IO),
(
Intermod = yes,
- GradeIntDir = LibDir/"ints"/Grade,
+ GradeIntDir = LibDir/"ints"/GradeDir,
install_subdir_file(LinkSucceeded, GradeIntDir, ModuleName, "opt",
OptSucceded, !IO)
;
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list