option build_hostname allows to change hostname easily;
authorwenzelm
Sun, 26 Feb 2023 21:05:39 +0100
changeset 77384 ef6673859c38
parent 77383 cb75171d8c9f
child 77385 4a7c42c84743
option build_hostname allows to change hostname easily;
etc/options
src/Pure/System/isabelle_system.scala
src/Pure/Tools/build.scala
--- a/etc/options	Sun Feb 26 20:52:14 2023 +0100
+++ b/etc/options	Sun Feb 26 21:05:39 2023 +0100
@@ -177,6 +177,9 @@
 option build_pide_reports : bool = true
   -- "report PIDE markup (in batch build)"
 
+option build_hostname : string = ""
+  -- "alternative hostname for build process (default $ISABELLE_HOSTNAME)"
+
 option build_engine : string = ""
   -- "alternative session build engine"
 
--- a/src/Pure/System/isabelle_system.scala	Sun Feb 26 20:52:14 2023 +0100
+++ b/src/Pure/System/isabelle_system.scala	Sun Feb 26 21:05:39 2023 +0100
@@ -47,7 +47,8 @@
     proper_string(getenv(name, env)) getOrElse
       error("Undefined Isabelle environment variable: " + quote(name))
 
-  def hostname(): String = getenv_strict("ISABELLE_HOSTNAME")
+  def hostname(default: String = ""): String =
+    proper_string(default) getOrElse getenv_strict("ISABELLE_HOSTNAME")
 
 
   /* services */
--- a/src/Pure/Tools/build.scala	Sun Feb 26 20:52:14 2023 +0100
+++ b/src/Pure/Tools/build.scala	Sun Feb 26 21:05:39 2023 +0100
@@ -152,6 +152,7 @@
 
     val build_context =
       Build_Process.Context(store, build_deps, progress = progress,
+        hostname = Isabelle_System.hostname(build_options.string("build_hostname")),
         build_heap = build_heap, numa_shuffling = numa_shuffling, max_jobs = max_jobs,
         fresh_build = fresh_build, no_build = no_build, verbose = verbose,
         session_setup = session_setup)
@@ -294,9 +295,10 @@
       val start_date = Date.now()
 
       if (verbose) {
+        val hostname = Isabelle_System.hostname(options.string("build_hostname"))
         progress.echo(
           "Started at " + Build_Log.print_date(start_date) +
-            " (" + Isabelle_System.getenv("ML_IDENTIFIER") + " on " + Isabelle_System.hostname() +")")
+            " (" + Isabelle_System.getenv("ML_IDENTIFIER") + " on " + hostname +")")
         progress.echo(Build_Log.Settings.show() + "\n")
       }