[m-rev.] for review: delete unused support for directory copying
Julien Fischer
jfischer at opturion.com
Tue Jan 9 15:33:30 AEDT 2024
For review by anyone.
--------------------
Delete unused support for directory copying.
The compiler has long had code for recursively copying directories (via
"cp -R"), but it does not, in fact, use it anywhere.
compiler/make.program_target.m:
compiler/file_util.m:
compiler/module_cmds.m:
Delete unused predicates for copying directories.
compiler/globals.m:
compiler/handle_options.m:
Do not store the flag for copying directories in file_install_cmd
values.
compiler/options.m:
docs/user_guide.texi:
Delete the documentation for the --install-command-dir-option.
compiler/copy_util.m:
Delete the comment about moving directory copying to this module.
Delete the XXX about the Mercury copying code not preserving
permissions; it now attempts to do so.
NEWS.md:
Announce the deprecation of --install-command-dir-option.
Julien.
diff --git a/NEWS.md b/NEWS.md
index 68df3d2..dc27e27 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1245,11 +1245,15 @@ Changes to the Mercury compiler
deployment target, if set.
* The `--no-ansi-c` option has been deprecated and will be removed in a future
- release. The option has not had any effect for a long time.
+ release. The option has not had any effect for a long time.
* We have deleted the `--java-object-file-extension` option, which has
only ever had one useful value, which is the default value, ".class".
+* The `--install-command-dir-option` option has been deprecated and will be
+ removed in a future release. This option has not had any effect for a long
+ time.
+
Changes to the Mercury debugger
-------------------------------
diff --git a/compiler/copy_util.m b/compiler/copy_util.m
index 42b2e26..c5b69cb 100644
--- a/compiler/copy_util.m
+++ b/compiler/copy_util.m
@@ -54,12 +54,6 @@
% Regardless of the mechanism, we must ensure that copying preserves
% as much of the file's metadata as possible. Notably, this must include
% the execute permission bits on platforms that use them.
-% (XXX Copying via library code does *not* currently do this).
-%
-% XXX This module should eventually also provide a mechanism for copying
-% entire directory trees (see install_directory/7 in make.program_target.m),
-% but currently we only support doing that via invoking an external command
-% in the shell.
%
%-----------------------------------------------------------------------------%
diff --git a/compiler/file_util.m b/compiler/file_util.m
index b0f2abd..549fa07 100644
--- a/compiler/file_util.m
+++ b/compiler/file_util.m
@@ -96,12 +96,6 @@
%
:- func make_install_file_command(globals, string, string) = string.
- % make_install_dir_command(Globals, SourceDirName, InstallDir) = Command:
- % Command is the command required to install directory SourceDirName
- % in directory InstallDir.
- %
-:- func make_install_dir_command(globals, string, string) = string.
-
%---------------------------------------------------------------------------%
% open_temp_output(Dir, Prefix, Suffix, Result, !IO):
@@ -329,7 +323,7 @@ report_error(Stream, ErrorMessage, !IO) :-
make_install_file_command(Globals, FileName, InstallDir) = Command :-
globals.get_file_install_cmd(Globals, FileInstallCmd),
(
- FileInstallCmd = install_cmd_user(InstallCmd, _InstallCmdDirOpt)
+ FileInstallCmd = install_cmd_user(InstallCmd)
;
FileInstallCmd = install_cmd_cp,
InstallCmd = "cp"
@@ -337,18 +331,6 @@ make_install_file_command(Globals, FileName, InstallDir) = Command :-
Command = string.join_list(" ", list.map(quote_shell_cmd_arg,
[InstallCmd, FileName, InstallDir])).
-make_install_dir_command(Globals, SourceDirName, InstallDir) = Command :-
- globals.get_file_install_cmd(Globals, FileInstallCmd),
- (
- FileInstallCmd = install_cmd_user(InstallCmd, InstallCmdDirOpt)
- ;
- FileInstallCmd = install_cmd_cp,
- InstallCmd = "cp",
- InstallCmdDirOpt = "-R"
- ),
- Command = string.join_list(" ", list.map(quote_shell_cmd_arg,
- [InstallCmd, InstallCmdDirOpt, SourceDirName, InstallDir])).
-
%---------------------------------------------------------------------------%
open_temp_output_with_naming_scheme(Dir, Prefix, Suffix, Result, !IO) :-
diff --git a/compiler/globals.m b/compiler/globals.m
index 15401d9..d0cc4d7 100644
--- a/compiler/globals.m
+++ b/compiler/globals.m
@@ -267,12 +267,9 @@
%
:- type file_install_cmd
---> install_cmd_user(
- string, % Cmd.
- string % Flag for copying directories.
+ string % Cmd.
)
- % Command specified by the user using --install-command and the
- % option for copying directories specified by
- % --install-command-dir-option.
+ % Command specified by the user using --install-command.
; install_cmd_cp.
% POSIX conformant cp command.
diff --git a/compiler/handle_options.m b/compiler/handle_options.m
index aba9d89..7b802bf 100644
--- a/compiler/handle_options.m
+++ b/compiler/handle_options.m
@@ -866,9 +866,7 @@ convert_options_to_globals(ProgressStream, DefaultOptionTable, OptionTable0,
( if InstallCmd = "" then
FileInstallCmd = install_cmd_cp
else
- lookup_string_option(OptionTable0, install_command_dir_option,
- InstallCmdDirOption),
- FileInstallCmd = install_cmd_user(InstallCmd, InstallCmdDirOption)
+ FileInstallCmd = install_cmd_user(InstallCmd)
),
% The use_cur_dir we pass here as the subdir setting is a dummy;
diff --git a/compiler/make.program_target.m b/compiler/make.program_target.m
index a73d7c4..87092d8 100644
--- a/compiler/make.program_target.m
+++ b/compiler/make.program_target.m
@@ -2109,21 +2109,6 @@ install_file(ProgressStream, Globals, FileName, InstallDir, Succeeded, !IO) :-
copy_file_to_directory(Globals, ProgressStream, FileName,
InstallDir, Succeeded, !IO).
-:- pred install_directory(io.text_output_stream::in, globals::in,
- dir_name::in, dir_name::in, maybe_succeeded::out, io::di, io::uo) is det.
-:- pragma consider_used(pred(install_directory/7)).
-
-install_directory(ProgressStream, Globals, SourceDirName, InstallDir,
- Succeeded, !IO) :-
- % XXX MAKE_STREAM
- OutputStream = ProgressStream,
- verbose_make_four_part_msg(Globals, "Installing directory", SourceDirName,
- "in", InstallDir, InstallMsg),
- maybe_write_msg(ProgressStream, InstallMsg, !IO),
- Command = make_install_dir_command(Globals, SourceDirName, InstallDir),
- invoke_system_command(Globals, ProgressStream, OutputStream,
- cmd_verbose, Command, Succeeded, !IO).
-
:- pred make_install_dirs(io.text_output_stream::in, globals::in,
maybe_succeeded::out, maybe_succeeded::out, io::di, io::uo) is det.
diff --git a/compiler/module_cmds.m b/compiler/module_cmds.m
index f6d5ca8..6b63cf0 100644
--- a/compiler/module_cmds.m
+++ b/compiler/module_cmds.m
@@ -79,11 +79,6 @@
:- pred make_symlink_or_copy_file(globals::in, io.text_output_stream::in,
file_name::in, file_name::in, maybe_succeeded::out, io::di, io::uo) is det.
- % As above, but for when LinkTarget is a directory rather than a file.
- %
-:- pred make_symlink_or_copy_dir(globals::in, io.text_output_stream::in,
- file_name::in, file_name::in, maybe_succeeded::out, io::di, io::uo) is det.
-
%-----------------------------------------------------------------------------%
% touch_module_ext_datestamp(Globals, ProgressStream,
@@ -169,7 +164,6 @@
:- import_module libs.compute_grade. % for grade_directory_component
:- import_module libs.copy_util.
:- import_module libs.options.
-:- import_module libs.system_cmds.
:- import_module parse_tree.java_names.
:- import_module bool.
@@ -280,15 +274,6 @@ copy_dot_tmp_to_base_file_create_file(Globals, ProgressStream,
%-----------------------------------------------------------------------------%
-:- pred copy_dir(globals::in, io.text_output_stream::in,
- dir_name::in, dir_name::in, maybe_succeeded::out, io::di, io::uo) is det.
-
-copy_dir(Globals, ProgressStream, Source, Destination,
- Succeeded, !IO) :-
- Command = make_install_dir_command(Globals, Source, Destination),
- invoke_system_command(Globals, ProgressStream, ProgressStream,
- cmd_verbose, Command, Succeeded, !IO).
-
maybe_make_symlink(Globals, LinkTarget, LinkName, Result, !IO) :-
globals.lookup_bool_option(Globals, use_symlinks, UseSymLinks),
(
@@ -349,40 +334,6 @@ make_symlink_or_copy_file(Globals, ProgressStream,
DestinationFileName, Succeeded, !IO)
).
-make_symlink_or_copy_dir(Globals, ProgressStream,
- SourceDirName, DestinationDirName, Succeeded, !IO) :-
- globals.lookup_bool_option(Globals, use_symlinks, UseSymLinks),
- (
- UseSymLinks = yes,
- io.file.make_symlink(SourceDirName, DestinationDirName, Result, !IO),
- (
- Result = ok,
- Succeeded = succeeded
- ;
- Result = error(Error),
- Succeeded = did_not_succeed,
- io.progname_base("mercury_compile", ProgName, !IO),
- io.format(ProgressStream, "%s: error linking `%s' to `%s': %s\n",
- [s(ProgName), s(SourceDirName), s(DestinationDirName),
- s(io.error_message(Error))], !IO),
- io.flush_output(ProgressStream, !IO)
- )
- ;
- UseSymLinks = no,
- copy_dir(Globals, ProgressStream, SourceDirName, DestinationDirName,
- Succeeded, !IO),
- (
- Succeeded = succeeded
- ;
- Succeeded = did_not_succeed,
- io.progname_base("mercury_compile", ProgName, !IO),
- io.format(ProgressStream,
- "%s: error copying directory `%s' to `%s'\n",
- [s(ProgName), s(SourceDirName), s(DestinationDirName)], !IO),
- io.flush_output(ProgressStream, !IO)
- )
- ).
-
%-----------------------------------------------------------------------------%
touch_module_ext_datestamp(Globals, ProgressStream, ModuleName, Ext,
diff --git a/compiler/options.m b/compiler/options.m
index 94ab8ff..9463fcb 100644
--- a/compiler/options.m
+++ b/compiler/options.m
@@ -6701,11 +6701,10 @@ options_help_build_system(Stream, !IO) :-
"\tMercury libraries. The given command will be invoked as",
"\t`<command> <source> <target>' to install each file",
"\tin a Mercury library. The default command is `cp'.",
- "--install-command-dir-option <option>",
- "\tSpecify the flag to pass to the install command to install",
- "\ta directory. The given command will be invoked as",
- "\t`<command> <option> <source> <target>'",
- "\tto install each directory. The default option is `-R'.",
+
+ % --install-command-dir-option no longer has any effect and is
+ % only still present for backwards compatibility.
+
"--no-detect-libgrades",
"\tDo not scan the installation directory to determine which",
"\tstandard library grades are available.",
diff --git a/doc/user_guide.texi b/doc/user_guide.texi
index 539d9f5..05b3df2 100644
--- a/doc/user_guide.texi
+++ b/doc/user_guide.texi
@@ -10456,14 +10456,6 @@ to install each file in a Mercury library.
The default command is @samp{cp}.
@sp 1
- at item --install-command-dir-option @var{option}
- at findex --install-command-dir-command
-Specify the flag to pass to the install command to install
-a directory. The given command will be invoked as
- at code{@var{command} @var{option} @var{source} @var{target}}
-to install each directory. The default option is @samp{-R}.
-
- at sp 1
@item --no-detect-libgrades
@findex --no-detect-libgrades
Do not scan the installation directory to determine which
More information about the reviews
mailing list