[m-rev.] for review: fix mmc --make on windows
Peter Wang
wangp at students.cs.mu.OZ.AU
Mon Feb 6 15:49:41 AEDT 2006
Estimated hours taken: 3
Branches: main
Fix some problems with `mmc --make' on Windows (or possibly any platform
without symbolic links).
compiler/make.program_target.m:
Don't try to install `.mh' files into `inc/Mercury/mhs' as this is
(seems) unnecessary.
Make the symlinks or directories `ints/mhs' and `ints/mihs' when
installing libraries.
Correct a typo which created the directories
`lib/<grade>/inc/Mercury/mih' instead of
`lib/<grade>/inc/Mercury/mihs'.
compiler/modules.m:
Make `copy_file' first attempt to use the `--install-command' command,
in order to preserve more information about the file. In particular,
with `--use-grade-subdirs' we want executables copied from the grade
subdirectories to keep the executable bit.
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.38
diff -u -r1.38 make.program_target.m
--- compiler/make.program_target.m 3 Feb 2006 05:46:21 -0000 1.38
+++ compiler/make.program_target.m 6 Feb 2006 04:47:24 -0000
@@ -594,7 +594,7 @@
ModulesDir = Prefix/"lib"/"mercury"/"modules",
module_name_to_file_name(MainModuleName, ".init", no, InitFileName,
!IO),
- install_file(InitFileName, ModulesDir, InitSucceded, !IO),
+ install_file(InitFileName, ModulesDir, InitSucceeded, !IO),
list__map_foldl2(install_ints_and_headers(LinkSucceeded), AllModules,
IntsSucceeded, !Info, !IO),
@@ -604,7 +604,7 @@
install_library_grade_files(LinkSucceeded, Grade, MainModuleName,
AllModules, GradeSucceeded, !Info, !IO),
(
- InitSucceded = yes,
+ InitSucceeded = yes,
bool__and_list(IntsSucceeded) = yes,
GradeSucceeded = yes
->
@@ -665,18 +665,18 @@
( Target = c ; Target = asm )
% Imports ^ contains_foreign_export = contains_foreign_export
->
- install_subdir_file(SubdirLinkSucceeded, LibDir/"inc",
- ModuleName, "mh", HeaderSucceded1, !IO),
+ module_name_to_file_name(ModuleName, ".mh", no, FileName, !IO),
+ install_file(FileName, LibDir/"inc", HeaderSucceeded1, !IO),
% This is needed so that the file will be found in Mmake's VPATH.
install_subdir_file(SubdirLinkSucceeded, LibDir/"ints", ModuleName,
- "mh", HeaderSucceded2, !IO),
+ "mh", HeaderSucceeded2, !IO),
- HeaderSucceded = HeaderSucceded1 `and` HeaderSucceded2
+ HeaderSucceeded = HeaderSucceeded1 `and` HeaderSucceeded2
;
- HeaderSucceded = yes
+ HeaderSucceeded = yes
),
- Succeeded = bool__and_list([HeaderSucceded | Results])
+ Succeeded = bool__and_list([HeaderSucceeded | Results])
;
MaybeImports = no,
Succeeded = no
@@ -841,17 +841,17 @@
->
GradeIncDir = LibDir/"lib"/GradeDir/"inc",
install_subdir_file(LinkSucceeded, GradeIncDir, ModuleName, "mih",
- HeaderSucceded1, !IO),
+ HeaderSucceeded1, !IO),
% This is needed so that the file will be
% found in Mmake's VPATH.
IntDir = LibDir/"ints",
install_subdir_file(LinkSucceeded, IntDir, ModuleName, "mih",
- HeaderSucceded2, !IO),
+ HeaderSucceeded2, !IO),
- HeaderSucceded = HeaderSucceded1 `and` HeaderSucceded2
+ HeaderSucceeded = HeaderSucceeded1 `and` HeaderSucceeded2
;
- HeaderSucceded = yes
+ HeaderSucceeded = yes
),
globals__io_lookup_bool_option(intermodule_optimization, Intermod,
@@ -860,12 +860,12 @@
Intermod = yes,
GradeIntDir = LibDir/"ints"/GradeDir,
install_subdir_file(LinkSucceeded, GradeIntDir, ModuleName, "opt",
- OptSucceded, !IO)
+ OptSucceeded, !IO)
;
Intermod = no,
- OptSucceded = yes
+ OptSucceeded = yes
),
- Succeeded = HeaderSucceded `and` OptSucceded
+ Succeeded = HeaderSucceeded `and` OptSucceeded
;
MaybeImports = no,
Succeeded = no
@@ -934,7 +934,7 @@
Results0 = [Result1, Result2, Result3],
Subdirs = ["int0", "int", "int2", "int3", "opt", "trans_opt",
- "module_dep"],
+ "mh", "mih", "module_dep"],
list__map_foldl(make_install_symlink(IntsSubdir), Subdirs, LinkResults,
!IO),
LinkResult = bool__and_list(LinkResults),
@@ -975,7 +975,7 @@
Results = Results0
;
LinkResult = no,
- make_directory(GradeIncSubdir/"mih", Result4, !IO),
+ make_directory(GradeIncSubdir/"mihs", Result4, !IO),
make_directory(GradeIntsSubdir/"opts", Result5, !IO),
make_directory(GradeIntsSubdir/"trans_opts", Result6, !IO),
Results = [Result4, Result5, Result6 | Results0]
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.370
diff -u -r1.370 modules.m
--- compiler/modules.m 31 Jan 2006 05:20:41 -0000 1.370
+++ compiler/modules.m 6 Feb 2006 04:47:25 -0000
@@ -779,6 +779,7 @@
:- implementation.
+:- import_module hlds.passes_aux.
:- import_module libs.compiler_util.
:- import_module libs.handle_options.
:- import_module libs.options.
@@ -1066,25 +1067,36 @@
).
copy_file(Source, Destination, Res, !IO) :-
- io__open_binary_input(Source, SourceRes, !IO),
+ % Try to use the system's cp command in order to preserve metadata.
+ globals__io_lookup_string_option(install_command, InstallCommand, !IO),
+ Command = string__join_list(" ", list__map(quote_arg,
+ [InstallCommand, Source, Destination])),
+ io__output_stream(OutputStream, !IO),
+ invoke_system_command(OutputStream, verbose, Command, Succeeded, !IO),
(
- SourceRes = ok(InputStream),
- io__open_binary_output(Destination, DestRes, !IO),
+ Succeeded = yes,
+ Res = ok
+ ;
+ Succeeded = no,
+ io__open_binary_input(Source, SourceRes, !IO),
(
- DestRes = ok(OutputStream),
- % XXX Depending on file size it may be
- % faster to call the system's cp command.
- WriteByte = io__write_byte(OutputStream),
- io__binary_input_stream_foldl_io(InputStream, WriteByte, Res, !IO),
- io__close_binary_input(InputStream, !IO),
- io__close_binary_output(OutputStream, !IO)
+ SourceRes = ok(SourceStream),
+ io__open_binary_output(Destination, DestRes, !IO),
+ (
+ DestRes = ok(DestStream),
+ WriteByte = io__write_byte(DestStream),
+ io__binary_input_stream_foldl_io(SourceStream, WriteByte, Res,
+ !IO),
+ io__close_binary_input(SourceStream, !IO),
+ io__close_binary_output(DestStream, !IO)
+ ;
+ DestRes = error(Error),
+ Res = error(Error)
+ )
;
- DestRes = error(Error),
+ SourceRes = error(Error),
Res = error(Error)
)
- ;
- SourceRes = error(Error),
- Res = error(Error)
).
make_symlink_or_copy_file(SourceFileName, DestinationFileName, Succeeded,
--------------------------------------------------------------------------
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