[m-rev.] diff: fix problems with batch file launchers and --use-grade-subdirs

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Jan 10 01:55:41 AEDT 2011


Branches: main, 11.01

Fix up the handling of batch file launchers for the erlang and java grades with
--use-grade-subdirs.

compiler/module_cmds.m:
 	Pass the correct file extension for a batch file to the code
 	that converts module names to file names so that --use-grade-subdirs
 	puts them in the expected subdirectory.

compiler/file_names.m:
 	Consider files with the extension ".bat" to be executable.

 	Add a comment.

compiler/compile_target_code.m:
 	Launchers have a ".bat" extension if --target-env-type=windows
 	is set.

Julien.

Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.163
diff -u -r1.163 compile_target_code.m
--- compiler/compile_target_code.m	30 Dec 2010 11:17:52 -0000	1.163
+++ compiler/compile_target_code.m	9 Jan 2011 14:48:48 -0000
@@ -1771,8 +1771,18 @@
          ( LinkTargetType = java_launcher
          ; LinkTargetType = erlang_launcher
          ),
-        % These are shell scripts.
-        Ext = "",
+        % These may be shell scripts or batch files.
+        globals.get_target_env_type(Globals, TargetEnvType),
+        (
+            TargetEnvType = env_type_win_cmd, 
+            Ext = ".bat"
+        ;
+            ( TargetEnvType = env_type_posix
+            ; TargetEnvType = env_type_cygwin
+            ; TargetEnvType = env_type_msys
+            ),
+            Ext = ""
+        ),
          module_name_to_file_name(Globals, ModuleName, Ext,
              do_create_dirs, OutputFileName, !IO)
      ;
Index: compiler/file_names.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/file_names.m,v
retrieving revision 1.14
diff -u -r1.14 file_names.m
--- compiler/file_names.m	30 Dec 2010 11:17:54 -0000	1.14
+++ compiler/file_names.m	9 Jan 2011 14:48:48 -0000
@@ -289,6 +289,7 @@
          (
              % Executable files.
              ( Ext = ""
+            ; Ext = ".bat"
              ; Ext = ".exe"
              ; Ext = ".dll"

@@ -413,6 +414,7 @@
          ->
              string.append(ExtName, "s", SubDirName)
          ;
+            % Launcher scripts go in the `bin' subdirectory.
              Ext = ""
          ->
              SubDirName = "bin"
Index: compiler/module_cmds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/module_cmds.m,v
retrieving revision 1.18
diff -u -r1.18 module_cmds.m
--- compiler/module_cmds.m	7 Jan 2011 04:56:04 -0000	1.18
+++ compiler/module_cmds.m	9 Jan 2011 14:48:48 -0000
@@ -1105,17 +1105,15 @@
  %-----------------------------------------------------------------------------%

  create_launcher_batch_file(Globals, MainModuleName, Pred, Succeeded, !IO) :-
-    Extension = "",
+    Extension = ".bat",
      module_name_to_file_name(Globals, MainModuleName, Extension,
-        do_not_create_dirs, BaseFileName, !IO),
-
-    FileName = BaseFileName ++ ".bat",
+        do_not_create_dirs, FileName, !IO),

      globals.lookup_bool_option(Globals, verbose, Verbose),
      maybe_write_string(Verbose, "% Generating batch file `" ++
          FileName ++ "'...\n", !IO),

-    % Remove symlink in the way, if any.
+    % Remove an existing batch file of the same name, if any.
      io.remove_file(FileName, _, !IO),
      io.open_output(FileName, OpenResult, !IO),
      (

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list