[m-rev.] for review: Print version information on two lines.

Paul Bone paul at bone.id.au
Tue Mar 4 11:28:36 AEDT 2014


For review by anyone.

Branches: master, version-14.01-branch

---

In the Mercury compiler itself, and in a number of tools we print a version
string on one line,

    $ mmc --version
    Mercury Compiler, version rotd-2013-10-01, configured for x86_64-unknown-linux-gnu
    Copyright (C) 1993-2013 The University of Melbourne

When the version number is sufficiently long, such as for an ROTD release, this
will wrap on 80 column terminals.  This change splits these strings into two
parts.

    $ mmc --version
    Mercury Compiler, version rotd-2013-10-01,
    configured for x86_64-unknown-linux-gnu
    Copyright (C) 1993-2013 The University of Melbourne

library/library.m:
    Make the version predicate return two values, one for the version number
    and the other for the architecture name.  This makes it easier to format
    the version information in the various places it is used.

compiler/handle_options.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_report_feedback.m:
deep_profiler/mdprof_test.m:
profiler/mercury_profile.m:
    Format this as shown above for the Mercury compiler and other tools.

compiler/c_util.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/fact_table.m:
compiler/llds_out_file.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/write_deps_file.m:
    Format version information on two lines when it is used in the
    compiler's various output files.
---
 compiler/c_util.m                      | 10 ++++++----
 compiler/elds_to_erlang.m              |  5 +++--
 compiler/export.m                      |  5 +++--
 compiler/fact_table.m                  |  5 +++--
 compiler/handle_options.m              | 10 ++++++----
 compiler/llds_out_file.m               |  5 +++--
 compiler/mlds_to_c.m                   |  5 +++--
 compiler/mlds_to_cs.m                  |  5 ++++-
 compiler/mlds_to_java.m                |  5 ++++-
 compiler/mlds_to_managed.m             |  7 +++----
 compiler/write_deps_file.m             |  8 ++++++--
 deep_profiler/mdprof_cgi.m             | 10 ++++------
 deep_profiler/mdprof_create_feedback.m |  7 ++++---
 deep_profiler/mdprof_report_feedback.m | 10 ++++------
 deep_profiler/mdprof_test.m            | 10 ++++------
 library/library.m                      | 30 +++++++++++++++++-------------
 profiler/mercury_profile.m             | 10 ++++++----
 17 files changed, 83 insertions(+), 64 deletions(-)

diff --git a/compiler/c_util.m b/compiler/c_util.m
index fc81414..59968fc 100644
--- a/compiler/c_util.m
+++ b/compiler/c_util.m
@@ -160,7 +160,7 @@
 
 %-----------------------------------------------------------------------------%
 
-    % output_c_file_intro_and_grade(SourceFileName, Version):
+    % output_c_file_intro_and_grade(SourceFileName, Version, Fullarch, !IO):
     %
     % Outputs a comment which includes the settings used to generate
     % the C file. This is used by configure to check the any existing C files
@@ -169,7 +169,7 @@
     % version name of the mercury compiler.
     %
 :- pred output_c_file_intro_and_grade(globals::in, string::in, string::in,
-    io::di, io::uo) is det.
+    string::in, io::di, io::uo) is det.
 
 %-----------------------------------------------------------------------------%
 
@@ -659,7 +659,8 @@ binop_category_string(float_from_dword, float_macro_binop,
 
 %-----------------------------------------------------------------------------%
 
-output_c_file_intro_and_grade(Globals, SourceFileName, Version, !IO) :-
+output_c_file_intro_and_grade(Globals, SourceFileName, Version, Fullarch,
+        !IO) :-
     globals.lookup_int_option(Globals, num_tag_bits, NumTagBits),
     string.int_to_string(NumTagBits, NumTagBitsStr),
     globals.lookup_bool_option(Globals, unboxed_float, UnboxedFloat),
@@ -673,7 +674,8 @@ output_c_file_intro_and_grade(Globals, SourceFileName, Version, !IO) :-
         "/*\n",
         "** Automatically generated from `", SourceFileName, "'\n",
         "** by the Mercury compiler,\n",
-        "** version ", Version, ".\n",
+        "** version ", Version, "\n",
+        "** configured for ", Fullarch, ".\n",
         "** Do not edit.\n",
         "**\n",
         "** The autoconfigured grade settings governing\n",
diff --git a/compiler/elds_to_erlang.m b/compiler/elds_to_erlang.m
index c91151b..635ac5a 100644
--- a/compiler/elds_to_erlang.m
+++ b/compiler/elds_to_erlang.m
@@ -170,12 +170,13 @@ output_erl_file(ModuleInfo, ELDS, SourceFileName, !IO) :-
 :- pred output_do_no_edit_comment(string::in, io::di, io::uo) is det.
 
 output_do_no_edit_comment(SourceFileName, !IO) :-
-    library.version(Version),
+    library.version(Version, Fullarch),
     io.write_strings([
         "%\n",
         "% Automatically generated from `", SourceFileName, "'\n",
         "% by the Mercury compiler,\n",
-        "% version ", Version, ".\n",
+        "% version ", Version, "\n",
+        "% configured for ", Fullarch, ".\n",
         "% Do not edit.\n",
         "%\n",
         "\n"
diff --git a/compiler/export.m b/compiler/export.m
index 45365f9..e62f847 100644
--- a/compiler/export.m
+++ b/compiler/export.m
@@ -700,12 +700,13 @@ produce_header_file(ModuleInfo, ForeignExportDecls, ModuleName, !IO) :-
         io.set_output_stream(FileStream, OutputStream, !IO),
         module_name_to_file_name(Globals, ModuleName, ".m", do_not_create_dirs,
             SourceFileName, !IO),
-        library.version(Version),
+        library.version(Version, Fullarch),
         io.write_strings([
             "/*\n",
             "** Automatically generated from `", SourceFileName, "'\n",
             "** by the Mercury compiler,\n",
-            "** version ", Version, ".\n",
+            "** version ", Version, "\n",
+            "** configured for ", Fullarch, ".\n",
             "** Do not edit.\n",
             "*/\n"], !IO),
         MangledModuleName = sym_name_mangle(ModuleName),
diff --git a/compiler/fact_table.m b/compiler/fact_table.m
index ffe4d68..376793b 100644
--- a/compiler/fact_table.m
+++ b/compiler/fact_table.m
@@ -567,11 +567,12 @@ report_type_error(Context, ArgNum, RemainingTerms, PredOrFunc, !Errors) :-
 :- func fact_table_file_header(string) = string.
 
 fact_table_file_header(FileName) = FileHeader :-
-    library.version(Version),
+    library.version(Version, Fullarch),
     string.append_list(
         ["/*\n",
         "** Automatically generated from `", FileName, "'\n",
-        "** by the Mercury compiler, version ", Version, "\n",
+        "** by the Mercury compiler, version ", Version, ",\n",
+        "** configured for ", Fullarch, ".\n",
         "** Do not edit.\n",
         "*/\n",
         "\n",
diff --git a/compiler/handle_options.m b/compiler/handle_options.m
index 3d27a98..6ebaebd 100644
--- a/compiler/handle_options.m
+++ b/compiler/handle_options.m
@@ -2563,9 +2563,10 @@ usage_errors(Errors, !IO) :-
     usage(!IO).
 
 display_compiler_version(!IO) :-
-    library.version(Version),
+    library.version(Version, Fullarch),
     io.write_strings([
-        "Mercury Compiler, version ", Version, "\n",
+        "Mercury Compiler, version ", Version, ",\n",
+        "configured for ", Fullarch, "\n",
         "Copyright (C) 1993-2014 The University of Melbourne\n"
     ], !IO).
 
@@ -2592,9 +2593,10 @@ long_usage(!IO) :-
     % long_usage is called from only one place, so can't print duplicate
     % copies of the long usage message. We can print both a short and along
     % usage message, but there is no simple way to avoid that.
-    library.version(Version),
+    library.version(Version, Fullarch),
     io.write_strings(["Name: mmc -- Melbourne Mercury Compiler, version ",
-        Version, "\n"], !IO),
+        Version, ",\n",
+        "configured for ", Fullarch, "\n"], !IO),
     io.write_string("Copyright: Copyright (C) 1993-2014 " ++
         "The University of Melbourne\n", !IO),
     io.write_string("Usage: mmc [<options>] <arguments>\n", !IO),
diff --git a/compiler/llds_out_file.m b/compiler/llds_out_file.m
index 8e60898..4578a0c 100644
--- a/compiler/llds_out_file.m
+++ b/compiler/llds_out_file.m
@@ -168,11 +168,12 @@ output_single_c_file(Globals, CFile, FileStream, !DeclSet, !IO) :-
     Info = init_llds_out_info(ModuleName, Globals,
         InternalLabelToLayoutMap, EntryLabelToLayoutMap, TableIoDeclMap,
         AllocSiteMap),
-    library.version(Version),
+    library.version(Version, Fullarch),
     io.set_output_stream(FileStream, OutputStream, !IO),
     module_name_to_file_name(Globals, ModuleName, ".m", do_not_create_dirs,
         SourceFileName, !IO),
-    output_c_file_intro_and_grade(Globals, SourceFileName, Version, !IO),
+    output_c_file_intro_and_grade(Globals, SourceFileName, Version, Fullarch,
+        !IO),
     module_gather_env_var_names(Modules, set.init, EnvVarNameSet),
     EnvVarNames = set.to_sorted_list(EnvVarNameSet),
     output_init_comment(ModuleName, UserInitPredCNames, UserFinalPredCNames,
diff --git a/compiler/mlds_to_c.m b/compiler/mlds_to_c.m
index 8fa8d8a..6df2bd6 100644
--- a/compiler/mlds_to_c.m
+++ b/compiler/mlds_to_c.m
@@ -640,11 +640,12 @@ mlds_output_src_end(Indent, ModuleName, !IO) :-
     io::di, io::uo) is det.
 
 mlds_output_auto_gen_comment(Opts, ModuleName, !IO) :-
-    library.version(Version),
+    library.version(Version, Fullarch),
     Globals = Opts ^ m2co_all_globals,
     module_name_to_file_name(Globals, ModuleName, ".m", do_not_create_dirs,
         SourceFileName, !IO),
-    output_c_file_intro_and_grade(Globals, SourceFileName, Version, !IO),
+    output_c_file_intro_and_grade(Globals, SourceFileName, Version,
+        Fullarch, !IO),
     io.nl(!IO).
 
     % Output a reference to the mangled grade name for the grade that the C
diff --git a/compiler/mlds_to_cs.m b/compiler/mlds_to_cs.m
index e8d2659..e181586 100644
--- a/compiler/mlds_to_cs.m
+++ b/compiler/mlds_to_cs.m
@@ -849,7 +849,7 @@ output_src_end(Indent, ModuleName, !IO) :-
     io::di, io::uo) is det.
 
 output_auto_gen_comment(Globals, ModuleName, !IO)  :-
-    library.version(Version),
+    library.version(Version, Fullarch),
     module_name_to_file_name(Globals, ModuleName, ".m", do_not_create_dirs,
         SourceFileName, !IO),
     io.write_string("//\n//\n// Automatically generated from ", !IO),
@@ -858,6 +858,9 @@ output_auto_gen_comment(Globals, ModuleName, !IO)  :-
     io.write_string("// version ", !IO),
     io.write_string(Version, !IO),
     io.nl(!IO),
+    io.write_string("// configured for ", !IO),
+    io.write_string(Fullarch, !IO),
+    io.nl(!IO),
     io.write_string("//\n", !IO),
     io.write_string("//\n", !IO),
     io.nl(!IO).
diff --git a/compiler/mlds_to_java.m b/compiler/mlds_to_java.m
index fcf3b90..ebcfce9 100644
--- a/compiler/mlds_to_java.m
+++ b/compiler/mlds_to_java.m
@@ -2098,7 +2098,7 @@ output_debug_class_init(ModuleName, State, !IO) :-
     io::di, io::uo) is det.
 
 output_auto_gen_comment(Globals, ModuleName, !IO)  :-
-    library.version(Version),
+    library.version(Version, Fullarch),
     module_name_to_file_name(Globals, ModuleName, ".m", do_not_create_dirs,
         SourceFileName, !IO),
     io.write_string("//\n//\n// Automatically generated from ", !IO),
@@ -2107,6 +2107,9 @@ output_auto_gen_comment(Globals, ModuleName, !IO)  :-
     io.write_string("// version ", !IO),
     io.write_string(Version, !IO),
     io.nl(!IO),
+    io.write_string("// configured for ", !IO),
+    io.write_string(Fullarch, !IO),
+    io.nl(!IO),
     io.write_string("//\n", !IO),
     io.write_string("//\n", !IO),
     io.nl(!IO).
diff --git a/compiler/mlds_to_managed.m b/compiler/mlds_to_managed.m
index 1df06a1..ea75294 100644
--- a/compiler/mlds_to_managed.m
+++ b/compiler/mlds_to_managed.m
@@ -119,14 +119,13 @@ output_csharp_code(Globals, MLDS, !IO) :-
 %-----------------------------------------------------------------------------%
 
 output_src_start(ModuleName, !IO) :-
-    library.version(Version),
+    library.version(Version, Fullarch),
     io.write_strings(
         ["//\n// Automatically generated from `",
         sym_name_to_string(ModuleName),
         ".m' by the\n",
-        "// Mercury compiler, version ",
-        Version,
-        ".\n",
+        "// Mercury compiler, version ", Version, ",\n",
+        "// configured for ", Fullarch, ".\n",
         "// Do not edit.\n",
         "\n\n"], !IO).
 
diff --git a/compiler/write_deps_file.m b/compiler/write_deps_file.m
index bc7e0f9..8c540b0 100644
--- a/compiler/write_deps_file.m
+++ b/compiler/write_deps_file.m
@@ -1064,10 +1064,12 @@ generate_dv_file(Globals, SourceFileName, ModuleName, DepsMap, DepStream,
     io.write_string(DepStream, SourceFileName, !IO),
     io.write_string(DepStream, "'\n", !IO),
 
-    library.version(Version),
+    library.version(Version, Fullarch),
     io.write_string(DepStream,
         "# Generated by the Mercury compiler, version ", !IO),
     io.write_string(DepStream, Version, !IO),
+    io.write_string(DepStream, ",\n# configured for ", !IO),
+    io.write_string(DepStream, Fullarch, !IO),
     io.write_string(DepStream, ".\n\n", !IO),
 
     map.keys(DepsMap, Modules0),
@@ -1579,10 +1581,12 @@ generate_dep_file(Globals, SourceFileName, ModuleName, DepsMap, DepStream,
     io.write_string(DepStream, SourceFileName, !IO),
     io.write_string(DepStream, "'\n", !IO),
 
-    library.version(Version),
+    library.version(Version, Fullarch),
     io.write_string(DepStream,
         "# Generated by the Mercury compiler, version ", !IO),
     io.write_string(DepStream, Version, !IO),
+    io.write_string(DepStream, "\n# configured for ", !IO),
+    io.write_string(DepStream, Fullarch, !IO),
     io.write_string(DepStream, ".\n\n", !IO),
 
     module_name_to_make_var_name(ModuleName, MakeVarName),
diff --git a/deep_profiler/mdprof_cgi.m b/deep_profiler/mdprof_cgi.m
index 8659da2..3250371 100644
--- a/deep_profiler/mdprof_cgi.m
+++ b/deep_profiler/mdprof_cgi.m
@@ -225,12 +225,10 @@ mdprof_cgi_progname = "mdprof_cgi".
 :- pred write_version_message(string::in, io::di, io::uo) is det.
 
 write_version_message(ProgName, !IO) :-
-    library.version(Version),
-    io.write_string(ProgName, !IO),
-    io.write_string(": Mercury deep profiler", !IO),
-    io.nl(!IO),
-    io.write_string(Version, !IO),
-    io.nl(!IO).
+    library.version(Version, Fullarch),
+    io.format("%s: Mercury deep profiler\n", [s(ProgName)], !IO),
+    io.format("version: %s,\nconfigured for %s.\n",
+        [s(Version), s(Fullarch)], !IO).
 
 :- pred write_help_message(string::in, io::di, io::uo) is det.
 
diff --git a/deep_profiler/mdprof_create_feedback.m b/deep_profiler/mdprof_create_feedback.m
index 044eb7c..8ecd784 100644
--- a/deep_profiler/mdprof_create_feedback.m
+++ b/deep_profiler/mdprof_create_feedback.m
@@ -294,9 +294,10 @@ write_help_message(ProgName, !IO) :-
 :- pred write_version_message(string::in, io::di, io::uo) is det.
 
 write_version_message(ProgName, !IO) :-
-    library.version(Version),
-    io.format("%s: Mercury deep profiler\n%s\n",
-        [s(ProgName), s(Version)], !IO).
+    library.version(Version, Fullarch),
+    io.format("%s: Mercury deep profiler\n", [s(ProgName)], !IO),
+    io.format("version %s\nconfigured for %s.\n",
+        [s(Version), s(Fullarch)], !IO).
 
     % Read a deep profiling data file.
     %
diff --git a/deep_profiler/mdprof_report_feedback.m b/deep_profiler/mdprof_report_feedback.m
index 7edc037..7e04dec 100644
--- a/deep_profiler/mdprof_report_feedback.m
+++ b/deep_profiler/mdprof_report_feedback.m
@@ -121,12 +121,10 @@ write_help_message(ProgName, !IO) :-
 :- pred write_version_message(string::in, io::di, io::uo) is det.
 
 write_version_message(ProgName, !IO) :-
-    library.version(Version),
-    io.write_string(ProgName, !IO),
-    io.write_string(": Mercury deep profiler", !IO),
-    io.nl(!IO),
-    io.write_string(Version, !IO),
-    io.nl(!IO).
+    library.version(Version, Fullarch),
+    io.format("%s: Mercury deep profiler\n", [s(ProgName)], !IO),
+    io.format("version: %s\nconfigured for %s.\n",
+        [s(Version), s(Fullarch)], !IO).
 
 %----------------------------------------------------------------------------%
 %
diff --git a/deep_profiler/mdprof_test.m b/deep_profiler/mdprof_test.m
index 9846e76..9950ab4 100644
--- a/deep_profiler/mdprof_test.m
+++ b/deep_profiler/mdprof_test.m
@@ -182,12 +182,10 @@ verify_profile_2(ProgName, Options, FileName, !IO) :-
 :- pred write_version_message(string::in, io::di, io::uo) is det.
 
 write_version_message(ProgName, !IO) :-
-    library.version(Version),
-    io.write_string(ProgName, !IO),
-    io.write_string(": Mercury deep profiler", !IO),
-    io.nl(!IO),
-    io.write_string(Version, !IO),
-    io.nl(!IO).
+    library.version(Version, Fullarch),
+    io.format("%s: Mercury deep profiler\n", [s(ProgName)], !IO),
+    io.format("version: %s, configured for %s.\n",
+        [s(Version), s(Fullarch)], !IO).
 
 :- pred write_help_message(string::in, io::di, io::uo) is det.
 
diff --git a/library/library.m b/library/library.m
index 7e1f0ab..1e1d29b 100644
--- a/library/library.m
+++ b/library/library.m
@@ -17,7 +17,9 @@
 :- module library.
 :- interface.
 
-:- pred library.version(string::out) is det.
+    % version(VersionString, FullarchString)
+    %
+:- pred library.version(string::out, string::out) is det.
 
 :- implementation.
 
@@ -162,42 +164,44 @@
 % We can't allow library.version to inlined into other modules.  The Erlang
 % definition depends on erlang_conf.hrl, which will only be included by this
 % module and not installed.
-:- pragma no_inline(library.version/1).
+:- pragma no_inline(library.version/2).
 
 :- pragma foreign_proc("C",
-    library.version(Version::out),
+    library.version(Version::out, Fullarch::out),
     [will_not_call_mercury, promise_pure, will_not_modify_trail],
 "
-    MR_ConstString version_string =
-        MR_VERSION "", configured for "" MR_FULLARCH;
+    MR_ConstString version_string = MR_VERSION;
+    MR_ConstString fullarch_string = MR_FULLARCH;
     /*
     ** Cast away const needed here, because Mercury declares Version
     ** with type MR_String rather than MR_ConstString.
     */
     Version = (MR_String) (MR_Word) version_string;
+    Fullarch = (MR_String) (MR_Word) fullarch_string;
 ").
 
 :- pragma foreign_proc("C#",
-    library.version(Version::out),
+    library.version(Version::out, Fullarch::out),
     [will_not_call_mercury, promise_pure],
 "
-    Version = runtime.Constants.MR_VERSION + "" configured for ""
-        + runtime.Constants.MR_FULLARCH;
+    Version = runtime.Constants.MR_VERSIONi;
+    Fullarch = runtime.Constants.MR_FULLARCH;
 ").
 
 :- pragma foreign_proc("Java",
-    library.version(Version::out),
+    library.version(Version::out, Fullarch::out),
     [will_not_call_mercury, promise_pure],
 "
-    Version = jmercury.runtime.Constants.MR_VERSION + "" configured for ""
-        + jmercury.runtime.Constants.MR_FULLARCH;
+    Version = jmercury.runtime.Constants.MR_VERSION;
+    Fullarch = jmercury.runtime.Constants.MR_FULLARCH;
 ").
 
 :- pragma foreign_proc("Erlang",
-    library.version(Version::out),
+    library.version(Version::out, Fullarch::out),
     [will_not_call_mercury, promise_pure, thread_safe],
 "
-    Version = << ?MR_VERSION "" configured for "" ?MR_FULLARCH >>
+    Version = MR_VERSION
+    Fullarch = MR_FULLARCH
 ").
 
 %---------------------------------------------------------------------------%
diff --git a/profiler/mercury_profile.m b/profiler/mercury_profile.m
index ab858f9..6c569b6 100644
--- a/profiler/mercury_profile.m
+++ b/profiler/mercury_profile.m
@@ -105,9 +105,10 @@ usage_error(ErrorMessage, !IO) :-
 usage(!IO) :-
     io.progname_base("mprof", ProgName, !IO),
     io.stderr_stream(StdErr, !IO),
-    library.version(Version),
+    library.version(Version, Fullarch),
     io.write_strings(StdErr, [
-        "Mercury Profiler, version ", Version, "\n",
+        "Mercury Profiler, version ", Version, ",\n",
+        "configured for ", Fullarch, ".\n",
         "Copyright (C) 1995-2014 The University of Melbourne\n",
             "Usage: ", ProgName, " [<options>] [<files>]\n",
             "Use `", ProgName, " --help' for more information.\n"
@@ -117,9 +118,10 @@ usage(!IO) :-
 
 long_usage(!IO) :-
     io.progname_base("mprof", ProgName, !IO),
-    library.version(Version),
+    library.version(Version, Fullarch),
     io.write_strings([
-        "Mercury Profiler, version ", Version, "\n",
+        "Mercury Profiler, version ", Version, ",\n",
+        "configured for ", Fullarch, ".\n",
         "Copyright (C) 1995-2014 The University of Melbourne\n\n",
             "Usage: ", ProgName, "[<options>] [<files>]\n",
         "\n",
-- 
1.8.5.3




More information about the reviews mailing list