[m-rev.] diff: improve handling of `--object-file-extension'
Simon Taylor
stayl at cs.mu.OZ.AU
Tue Oct 2 17:10:26 AEST 2001
Estimated hours taken: 0.25
Branches: main
The compiler usually considers a file extension to include the `.',
so pass `.o' rather than `o' as the value of `--object-file-extension'.
This change avoids the need to handle `--executable-file-extension' (which
can be empty) as a special case.
scripts/mmc.in:
Pass `.o' as the value of `--object-file-extension', rather than `o'.
compiler/mercury_compile.m:
Remove code to prepend a `.' to the value of `--object-file-extension'
before passing it to `module_name_to_file_name'.
compiler/options.m:
Update the default values for the various `--*-extension' options
to include the `.'.
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.219
diff -u -u -r1.219 mercury_compile.m
--- compiler/mercury_compile.m 16 Sep 2001 21:51:05 -0000 1.219
+++ compiler/mercury_compile.m 2 Oct 2001 06:34:36 -0000
@@ -295,7 +295,8 @@
globals__io_lookup_bool_option(target_code_only,
TargetCodeOnly),
( { Result = ok, TargetCodeOnly = no } ->
- object_extension(Obj),
+ globals__io_lookup_string_option(object_file_extension,
+ Obj),
module_name_to_file_name(ModuleName, Obj,
yes, O_File),
mercury_compile__asm_to_obj(
@@ -854,7 +855,8 @@
% We don't know how many chunks there should
% be, so just check the first.
{ Chunk = 0 },
- object_extension(Obj),
+ globals__io_lookup_string_option(object_file_extension,
+ Obj),
module_name_to_split_c_file_name(ModuleName, Chunk,
Obj, FileName)
)
@@ -1069,7 +1071,8 @@
( { ContainsCCode = yes } ->
module_name_to_file_name(ModuleName,
".c", no, CCode_C_File),
- object_extension(Obj),
+ globals__io_lookup_string_option(
+ object_file_extension, Obj),
module_name_to_file_name(ModuleName,
"__c_code" ++ Obj,
yes, CCode_O_File),
@@ -1096,7 +1099,8 @@
;
module_name_to_file_name(ModuleName, ".c", no,
C_File),
- object_extension(Obj),
+ globals__io_lookup_string_option(
+ object_file_extension, Obj),
module_name_to_file_name(ModuleName, Obj, yes,
O_File),
mercury_compile__single_c_to_obj(
@@ -3338,7 +3342,7 @@
mercury_compile__c_to_obj_list(ModuleName, 0, NumChunks,
Succeeded)
;
- object_extension(Obj),
+ globals__io_lookup_string_option(object_file_extension, Obj),
module_name_to_file_name(ModuleName, ".c", no, C_File),
module_name_to_file_name(ModuleName, Obj, yes, O_File),
mercury_compile__single_c_to_obj(C_File, O_File, Succeeded)
@@ -3354,7 +3358,7 @@
( { Chunk > NumChunks } ->
{ Succeeded = yes }
;
- object_extension(Obj),
+ globals__io_lookup_string_option(object_file_extension, Obj),
module_name_to_split_c_file_name(ModuleName, Chunk,
".c", C_File),
module_name_to_split_c_file_name(ModuleName, Chunk,
@@ -3708,7 +3712,7 @@
),
{ file_name_to_module_name(OutputFileName, ModuleName) },
- object_extension(Obj),
+ globals__io_lookup_string_option(object_file_extension, Obj),
{ string__append("_init", Obj, InitObj) },
module_name_to_file_name(ModuleName, "_init.c", yes, InitCFileName),
module_name_to_file_name(ModuleName, InitObj, yes, InitObjFileName),
@@ -3999,14 +4003,5 @@
[]
).
-%-----------------------------------------------------------------------------%
-
- % Extension for object files.
-:- pred object_extension(string::out, io__state::di, io__state::uo) is det.
-
-object_extension(Extension) -->
- globals__io_lookup_string_option(object_file_extension, Extension0),
- { string__append(".", Extension0, Extension) }.
-
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.337
diff -u -u -r1.337 options.m
--- compiler/options.m 2 Oct 2001 06:22:22 -0000 1.337
+++ compiler/options.m 2 Oct 2001 06:32:39 -0000
@@ -758,10 +758,10 @@
% the `mmc' script will override the
% above default with a value determined
% at configuration time
- object_file_extension - string("o"),
- pic_object_file_extension - string("o"),
- shared_library_extension - string("so"),
- library_extension - string("a"),
+ object_file_extension - string(".o"),
+ pic_object_file_extension - string(".o"),
+ shared_library_extension - string(".so"),
+ library_extension - string(".a"),
executable_file_extension - string(""),
create_archive_command - string("ar"),
create_archive_command_flags - accumulating([]), % "cr"
Index: scripts/mmc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmc.in,v
retrieving revision 1.16
diff -u -u -r1.16 mmc.in
--- scripts/mmc.in 9 Apr 2001 08:54:05 -0000 1.16
+++ scripts/mmc.in 2 Oct 2001 06:39:48 -0000
@@ -25,7 +25,7 @@
CFLAGS_FOR_GOTOS="@CFLAGS_FOR_GOTOS@"
CFLAGS_FOR_THREADS="@CFLAGS_FOR_THREADS@"
CFLAG_TO_NAME_OBJECT_FILE="@OBJFILE_OPT@"
-OBJECT_FILE_EXTENSION="@OBJ_SUFFIX@"
+OBJECT_FILE_EXTENSION=". at OBJ_SUFFIX@"
LOW_TAG_BITS=@LOW_TAG_BITS@
BITS_PER_WORD=@BITS_PER_WORD@
BYTES_PER_WORD=@BYTES_PER_WORD@
--------------------------------------------------------------------------
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