src/Pure/Tools/build.scala
author wenzelm
Thu, 02 Mar 2023 14:58:59 +0100
changeset 77477 f376aebca9c1
parent 77453 e72b1f5fd88d
child 77505 7ee426daafa3
permissions -rw-r--r--
clarified modules; tuned signature; tuned comments;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50686
d703e3aafa8c moved files;
wenzelm
parents: 50566
diff changeset
     1
/*  Title:      Pure/Tools/build.scala
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
57923
cdae2467311d tuned comments;
wenzelm
parents: 56890
diff changeset
     3
    Options:    :folding=explicit:
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     4
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     5
Build and manage Isabelle sessions.
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     6
*/
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     7
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     8
package isabelle
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     9
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    10
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74845
diff changeset
    11
object Build {
77330
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    12
  /* results */
48424
wenzelm
parents: 48423
diff changeset
    13
77311
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    14
  object Results {
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    15
    def apply(context: Build_Process.Context, results: Map[String, Process_Result]): Results =
77453
e72b1f5fd88d tuned signature;
wenzelm
parents: 77411
diff changeset
    16
      new Results(context.store, context.build_deps, results)
77311
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    17
  }
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    18
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    19
  class Results private(
76206
769a7cd5a16a clarified signature: re-use store/cache from build results;
wenzelm
parents: 76202
diff changeset
    20
    val store: Sessions.Store,
76209
365f6a621fc5 clarified signature;
wenzelm
parents: 76206
diff changeset
    21
    val deps: Sessions.Deps,
77253
792dad9cb04f clarified data structure: absorb Option[Process_Result] into Process_Result, e.g. to simplify database storage;
wenzelm
parents: 77252
diff changeset
    22
    results: Map[String, Process_Result]
76198
fb4215da4919 clarified presentation_sessions: work with partial results;
wenzelm
parents: 76197
diff changeset
    23
  ) {
76206
769a7cd5a16a clarified signature: re-use store/cache from build results;
wenzelm
parents: 76202
diff changeset
    24
    def cache: Term.Cache = store.cache
769a7cd5a16a clarified signature: re-use store/cache from build results;
wenzelm
parents: 76202
diff changeset
    25
77311
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    26
    def sessions_ok: List[String] =
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    27
      (for {
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    28
        name <- deps.sessions_structure.build_topological_order.iterator
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    29
        result <- results.get(name) if result.ok
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    30
      } yield name).toList
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
    31
77250
22016642d6af clarified data structure: use static info from deps, not dynamic results;
wenzelm
parents: 77246
diff changeset
    32
    def info(name: String): Sessions.Info = deps.sessions_structure(name)
62403
1d7aba20a332 explicit class Build_Results;
wenzelm
parents: 62402
diff changeset
    33
    def sessions: Set[String] = results.keySet
77253
792dad9cb04f clarified data structure: absorb Option[Process_Result] into Process_Result, e.g. to simplify database storage;
wenzelm
parents: 77252
diff changeset
    34
    def cancelled(name: String): Boolean = !results(name).defined
792dad9cb04f clarified data structure: absorb Option[Process_Result] into Process_Result, e.g. to simplify database storage;
wenzelm
parents: 77252
diff changeset
    35
    def apply(name: String): Process_Result = results(name).strict
792dad9cb04f clarified data structure: absorb Option[Process_Result] into Process_Result, e.g. to simplify database storage;
wenzelm
parents: 77252
diff changeset
    36
    val rc: Int = results.valuesIterator.map(_.strict.rc).foldLeft(Process_Result.RC.ok)(_ max _)
74306
a117c076aa22 clarified signature;
wenzelm
parents: 73826
diff changeset
    37
    def ok: Boolean = rc == Process_Result.RC.ok
62406
b5b8fb87447a tuned signature;
wenzelm
parents: 62405
diff changeset
    38
76202
d535db35388e proper filter (amending fb4215da4919);
wenzelm
parents: 76201
diff changeset
    39
    def unfinished: List[String] = sessions.iterator.filterNot(apply(_).ok).toList.sorted
76199
6bf42525f111 tuned signature;
wenzelm
parents: 76198
diff changeset
    40
62406
b5b8fb87447a tuned signature;
wenzelm
parents: 62405
diff changeset
    41
    override def toString: String = rc.toString
62403
1d7aba20a332 explicit class Build_Results;
wenzelm
parents: 62402
diff changeset
    42
  }
1d7aba20a332 explicit class Build_Results;
wenzelm
parents: 62402
diff changeset
    43
77330
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    44
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    45
  /* engine */
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    46
77411
149cc77f7348 clafified signature: simplify object-oriented reuse;
wenzelm
parents: 77384
diff changeset
    47
  class Engine(val name: String) extends Isabelle_System.Service {
77330
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    48
    override def toString: String = name
77411
149cc77f7348 clafified signature: simplify object-oriented reuse;
wenzelm
parents: 77384
diff changeset
    49
    def init(build_context: Build_Process.Context): Build_Process =
149cc77f7348 clafified signature: simplify object-oriented reuse;
wenzelm
parents: 77384
diff changeset
    50
      new Build_Process(build_context)
77330
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    51
  }
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    52
77411
149cc77f7348 clafified signature: simplify object-oriented reuse;
wenzelm
parents: 77384
diff changeset
    53
  class Default_Engine extends Engine("") { override def toString: String = "<default>" }
77330
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    54
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    55
  lazy val engines: List[Engine] =
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    56
    Isabelle_System.make_services(classOf[Engine])
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    57
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    58
  def get_engine(name: String): Engine =
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    59
    engines.find(_.name == name).getOrElse(error("Bad build engine " + quote(name)))
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    60
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    61
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    62
  /* build */
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
    63
62641
0b1b7465f2ef always build with full results;
wenzelm
parents: 62638
diff changeset
    64
  def build(
50404
898cac1dad5e avoid startup within GUI thread -- it is only required later for dialog;
wenzelm
parents: 50367
diff changeset
    65
    options: Options,
71981
0be06f99b210 clarified signature;
wenzelm
parents: 71978
diff changeset
    66
    selection: Sessions.Selection = Sessions.Selection.empty,
75942
603852abed8f clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents: 75941
diff changeset
    67
    browser_info: Browser_Info.Config = Browser_Info.Config.none,
71726
a5fda30edae2 clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents: 71718
diff changeset
    68
    progress: Progress = new Progress,
65832
2fb85623c386 implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents: 65831
diff changeset
    69
    check_unknown_files: Boolean = false,
48511
37999ee01156 remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents: 48509
diff changeset
    70
    build_heap: Boolean = false,
48595
231e6fa96dbb added build option -c;
wenzelm
parents: 48594
diff changeset
    71
    clean_build: Boolean = false,
56890
7f120d227ca5 tuned signature;
wenzelm
parents: 56873
diff changeset
    72
    dirs: List[Path] = Nil,
7f120d227ca5 tuned signature;
wenzelm
parents: 56873
diff changeset
    73
    select_dirs: List[Path] = Nil,
66968
9991671c98aa allow to augment session context via explicit session infos;
wenzelm
parents: 66962
diff changeset
    74
    infos: List[Sessions.Info] = Nil,
64265
8eb6365f5916 isabelle build -N;
wenzelm
parents: 64173
diff changeset
    75
    numa_shuffling: Boolean = false,
48509
4854ced3e9d7 support session groups;
wenzelm
parents: 48508
diff changeset
    76
    max_jobs: Int = 1,
48903
1621b3f26095 added build option -l (list files);
wenzelm
parents: 48883
diff changeset
    77
    list_files: Boolean = false,
59891
9ce697050455 added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents: 59811
diff changeset
    78
    check_keywords: Set[String] = Set.empty,
66841
5c32a072ca8b added isablle build option -f;
wenzelm
parents: 66822
diff changeset
    79
    fresh_build: Boolean = false,
48509
4854ced3e9d7 support session groups;
wenzelm
parents: 48508
diff changeset
    80
    no_build: Boolean = false,
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
    81
    soft_build: Boolean = false,
48509
4854ced3e9d7 support session groups;
wenzelm
parents: 48508
diff changeset
    82
    verbose: Boolean = false,
73805
b73777a0c076 allow build session setup, e.g. for protocol handlers;
wenzelm
parents: 73804
diff changeset
    83
    export_files: Boolean = false,
76927
da13da82f6f9 treat update_options as part of Sessions.Info meta_digest, for proper re-build of updated sessions;
wenzelm
parents: 76919
diff changeset
    84
    augment_options: String => List[Options.Spec] = _ => Nil,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74845
diff changeset
    85
    session_setup: (String, Session) => Unit = (_, _) => ()
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74845
diff changeset
    86
  ): Results = {
71677
ff2c26b8ffb1 clarified build_options vs. job options;
wenzelm
parents: 71676
diff changeset
    87
    val build_options =
71679
eeaa4021f080 proper "editor_tracing_messages=0" as in "isabelle dump";
wenzelm
parents: 71677
diff changeset
    88
      options +
eeaa4021f080 proper "editor_tracing_messages=0" as in "isabelle dump";
wenzelm
parents: 71677
diff changeset
    89
        "completion_limit=0" +
eeaa4021f080 proper "editor_tracing_messages=0" as in "isabelle dump";
wenzelm
parents: 71677
diff changeset
    90
        "editor_tracing_messages=0" +
72728
caa182bdab7a clarified options: batch-build has pide_reports disabled by default (requires significant resources);
wenzelm
parents: 72693
diff changeset
    91
        ("pide_reports=" + options.bool("build_pide_reports"))
51220
e140c8fa485a recover timing information from old log files;
wenzelm
parents: 51218
diff changeset
    92
69854
cc0b3e177b49 system option "system_heaps" supersedes various command-line options for "system build mode";
wenzelm
parents: 69811
diff changeset
    93
    val store = Sessions.store(build_options)
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
    94
69369
6ecc85955e04 prefer "Isabelle DejaVu Sans", even for headless batch-build (session_graph.pdf);
wenzelm
parents: 68957
diff changeset
    95
    Isabelle_Fonts.init()
6ecc85955e04 prefer "Isabelle DejaVu Sans", even for headless batch-build (session_graph.pdf);
wenzelm
parents: 68957
diff changeset
    96
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
    97
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
    98
    /* session selection and dependencies */
65422
b606c98e6d10 tuned signature;
wenzelm
parents: 65420
diff changeset
    99
66961
wenzelm
parents: 66944
diff changeset
   100
    val full_sessions =
76927
da13da82f6f9 treat update_options as part of Sessions.Info meta_digest, for proper re-build of updated sessions;
wenzelm
parents: 76919
diff changeset
   101
      Sessions.load_structure(build_options, dirs = dirs, select_dirs = select_dirs, infos = infos,
da13da82f6f9 treat update_options as part of Sessions.Info meta_digest, for proper re-build of updated sessions;
wenzelm
parents: 76919
diff changeset
   102
        augment_options = augment_options)
73012
238ddf525da4 clarified HTML presentation, e.g. avoid bulky jobs like HOL or HOL-Analysis in applications;
wenzelm
parents: 72993
diff changeset
   103
    val full_sessions_selection = full_sessions.imports_selection(selection)
238ddf525da4 clarified HTML presentation, e.g. avoid bulky jobs like HOL or HOL-Analysis in applications;
wenzelm
parents: 72993
diff changeset
   104
75948
f0a8b7ae9192 clarified names;
wenzelm
parents: 75947
diff changeset
   105
    val build_deps = {
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   106
      val deps0 =
71896
ce06d6456cc8 clarified signature --- fit within limit of 22 arguments;
wenzelm
parents: 71895
diff changeset
   107
        Sessions.deps(full_sessions.selection(selection),
66962
e1bde71bace6 clarified signature: global_theories is always required;
wenzelm
parents: 66961
diff changeset
   108
          progress = progress, inlined_files = true, verbose = verbose,
e1bde71bace6 clarified signature: global_theories is always required;
wenzelm
parents: 66961
diff changeset
   109
          list_files = list_files, check_keywords = check_keywords).check_errors
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   110
66841
5c32a072ca8b added isablle build option -f;
wenzelm
parents: 66822
diff changeset
   111
      if (soft_build && !fresh_build) {
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   112
        val outdated =
68204
a554da2811f2 clarified signature;
wenzelm
parents: 68198
diff changeset
   113
          deps0.sessions_structure.build_topological_order.flatMap(name =>
72634
5cea0993ee4f clarified access to single database server vs. collection of database files;
wenzelm
parents: 72624
diff changeset
   114
            store.try_open_database(name) match {
68214
b0e2a19df95b more abstract database access;
wenzelm
parents: 68213
diff changeset
   115
              case Some(db) =>
68216
wenzelm
parents: 68214
diff changeset
   116
                using(db)(store.read_build(_, name)) match {
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   117
                  case Some(build)
77204
d69732bc3dbe prefer explicit shasum;
wenzelm
parents: 77192
diff changeset
   118
                  if build.ok && build.sources == deps0.sources_shasum(name) => None
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   119
                  case _ => Some(name)
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   120
                }
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   121
              case None => Some(name)
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   122
            })
68204
a554da2811f2 clarified signature;
wenzelm
parents: 68198
diff changeset
   123
a554da2811f2 clarified signature;
wenzelm
parents: 68198
diff changeset
   124
        Sessions.deps(full_sessions.selection(Sessions.Selection(sessions = outdated)),
70671
cb1776c8e216 clarified signature: retain global session information, unaffected by later restriction;
wenzelm
parents: 70509
diff changeset
   125
          progress = progress, inlined_files = true).check_errors
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   126
      }
68204
a554da2811f2 clarified signature;
wenzelm
parents: 68198
diff changeset
   127
      else deps0
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   128
    }
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   129
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   130
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   131
    /* check unknown files */
48504
21dfd6c04482 actually check source vs. target stamps, based on information from log files;
wenzelm
parents: 48494
diff changeset
   132
65832
2fb85623c386 implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents: 65831
diff changeset
   133
    if (check_unknown_files) {
2fb85623c386 implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents: 65831
diff changeset
   134
      val source_files =
2fb85623c386 implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents: 65831
diff changeset
   135
        (for {
75948
f0a8b7ae9192 clarified names;
wenzelm
parents: 75947
diff changeset
   136
          (_, base) <- build_deps.session_bases.iterator
75741
17b1c4fbc008 tuned signature;
wenzelm
parents: 75731
diff changeset
   137
          (path, _) <- base.session_sources.iterator
65832
2fb85623c386 implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents: 65831
diff changeset
   138
        } yield path).toList
76670
b04d45bebbc5 discontinued somewhat pointless dependency: avoid illusion of extra accuracy (see also 09fb749d1a1e and 0f750a6dc754);
wenzelm
parents: 76669
diff changeset
   139
      Mercurial.check_files(source_files)._2 match {
b04d45bebbc5 discontinued somewhat pointless dependency: avoid illusion of extra accuracy (see also 09fb749d1a1e and 0f750a6dc754);
wenzelm
parents: 76669
diff changeset
   140
        case Nil =>
b04d45bebbc5 discontinued somewhat pointless dependency: avoid illusion of extra accuracy (see also 09fb749d1a1e and 0f750a6dc754);
wenzelm
parents: 76669
diff changeset
   141
        case unknown_files =>
b04d45bebbc5 discontinued somewhat pointless dependency: avoid illusion of extra accuracy (see also 09fb749d1a1e and 0f750a6dc754);
wenzelm
parents: 76669
diff changeset
   142
          progress.echo_warning("Unknown files (not part of the underlying Mercurial repository):" +
76883
wenzelm
parents: 76871
diff changeset
   143
            unknown_files.map(File.standard_path).sorted.mkString("\n  ", "\n  ", ""))
65832
2fb85623c386 implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents: 65831
diff changeset
   144
      }
2fb85623c386 implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents: 65831
diff changeset
   145
    }
2fb85623c386 implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents: 65831
diff changeset
   146
51220
e140c8fa485a recover timing information from old log files;
wenzelm
parents: 51218
diff changeset
   147
77257
68a7ad1385bc clarified modules;
wenzelm
parents: 77256
diff changeset
   148
    /* build process and results */
51220
e140c8fa485a recover timing information from old log files;
wenzelm
parents: 51218
diff changeset
   149
77315
f34559b24277 clarified signature: move all parameters into Build_Process.Context;
wenzelm
parents: 77311
diff changeset
   150
    val build_context =
f34559b24277 clarified signature: move all parameters into Build_Process.Context;
wenzelm
parents: 77311
diff changeset
   151
      Build_Process.Context(store, build_deps, progress = progress,
77384
ef6673859c38 option build_hostname allows to change hostname easily;
wenzelm
parents: 77372
diff changeset
   152
        hostname = Isabelle_System.hostname(build_options.string("build_hostname")),
77315
f34559b24277 clarified signature: move all parameters into Build_Process.Context;
wenzelm
parents: 77311
diff changeset
   153
        build_heap = build_heap, numa_shuffling = numa_shuffling, max_jobs = max_jobs,
f34559b24277 clarified signature: move all parameters into Build_Process.Context;
wenzelm
parents: 77311
diff changeset
   154
        fresh_build = fresh_build, no_build = no_build, verbose = verbose,
f34559b24277 clarified signature: move all parameters into Build_Process.Context;
wenzelm
parents: 77311
diff changeset
   155
        session_setup = session_setup)
77254
8d34f53871b4 clarified signature: make dynamic Queue from static Context;
wenzelm
parents: 77253
diff changeset
   156
68219
c0341c0080e2 clarified store directories;
wenzelm
parents: 68217
diff changeset
   157
    store.prepare_output_dir()
48373
527e2bad7cca further imitation of "usedir" shell script;
wenzelm
parents: 48370
diff changeset
   158
48595
231e6fa96dbb added build option -c;
wenzelm
parents: 48594
diff changeset
   159
    if (clean_build) {
73012
238ddf525da4 clarified HTML presentation, e.g. avoid bulky jobs like HOL or HOL-Analysis in applications;
wenzelm
parents: 72993
diff changeset
   160
      for (name <- full_sessions.imports_descendants(full_sessions_selection)) {
68220
8fc4e3d1df86 clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents: 68219
diff changeset
   161
        val (relevant, ok) = store.clean_output(name)
8fc4e3d1df86 clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents: 68219
diff changeset
   162
        if (relevant) {
8fc4e3d1df86 clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents: 68219
diff changeset
   163
          if (ok) progress.echo("Cleaned " + name)
8fc4e3d1df86 clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents: 68219
diff changeset
   164
          else progress.echo(name + " FAILED to clean")
8fc4e3d1df86 clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents: 68219
diff changeset
   165
        }
48595
231e6fa96dbb added build option -c;
wenzelm
parents: 48594
diff changeset
   166
      }
231e6fa96dbb added build option -c;
wenzelm
parents: 48594
diff changeset
   167
    }
231e6fa96dbb added build option -c;
wenzelm
parents: 48594
diff changeset
   168
77311
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
   169
    val results =
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
   170
      Isabelle_Thread.uninterruptible {
77330
47eb96592aa2 support alternative build engines, via system option "build_engine";
wenzelm
parents: 77326
diff changeset
   171
        val engine = get_engine(build_options.string("build_engine"))
77372
44fe9fe96130 support for build database: still inactive;
wenzelm
parents: 77330
diff changeset
   172
        using(engine.init(build_context)) { build_process =>
44fe9fe96130 support for build database: still inactive;
wenzelm
parents: 77330
diff changeset
   173
          val res = build_process.run()
44fe9fe96130 support for build database: still inactive;
wenzelm
parents: 77330
diff changeset
   174
          Results(build_context, res)
44fe9fe96130 support for build database: still inactive;
wenzelm
parents: 77330
diff changeset
   175
        }
77311
5212446f3d7f clarified signature;
wenzelm
parents: 77310
diff changeset
   176
      }
62641
0b1b7465f2ef always build with full results;
wenzelm
parents: 62638
diff changeset
   177
69811
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   178
    if (export_files) {
76196
wenzelm
parents: 75967
diff changeset
   179
      for (name <- full_sessions_selection.iterator if results(name).ok) {
69811
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   180
        val info = results.info(name)
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   181
        if (info.export_files.nonEmpty) {
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   182
          progress.echo("Exporting " + info.name + " ...")
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   183
          for ((dir, prune, pats) <- info.export_files) {
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   184
            Export.export_files(store, name, info.dir + dir,
71726
a5fda30edae2 clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents: 71718
diff changeset
   185
              progress = if (verbose) progress else new Progress,
69811
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   186
              export_prune = prune,
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   187
              export_patterns = pats)
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   188
          }
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   189
        }
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   190
      }
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   191
    }
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   192
76901
93ccf8b7a660 clarified signature;
wenzelm
parents: 76883
diff changeset
   193
    val presentation_sessions =
93ccf8b7a660 clarified signature;
wenzelm
parents: 76883
diff changeset
   194
      results.sessions_ok.filter(name => browser_info.enabled(results.info(name)))
76230
fc19de122712 clarified signature;
wenzelm
parents: 76209
diff changeset
   195
    if (presentation_sessions.nonEmpty && !progress.stopped) {
fc19de122712 clarified signature;
wenzelm
parents: 76209
diff changeset
   196
      Browser_Info.build(browser_info, results.store, results.deps, presentation_sessions,
76198
fb4215da4919 clarified presentation_sessions: work with partial results;
wenzelm
parents: 76197
diff changeset
   197
        progress = progress, verbose = verbose)
fb4215da4919 clarified presentation_sessions: work with partial results;
wenzelm
parents: 76197
diff changeset
   198
    }
fb4215da4919 clarified presentation_sessions: work with partial results;
wenzelm
parents: 76197
diff changeset
   199
76196
wenzelm
parents: 75967
diff changeset
   200
    if (!results.ok && (verbose || !no_build)) {
76199
6bf42525f111 tuned signature;
wenzelm
parents: 76198
diff changeset
   201
      progress.echo("Unfinished session(s): " + commas(results.unfinished))
62641
0b1b7465f2ef always build with full results;
wenzelm
parents: 62638
diff changeset
   202
    }
0b1b7465f2ef always build with full results;
wenzelm
parents: 62638
diff changeset
   203
0b1b7465f2ef always build with full results;
wenzelm
parents: 62638
diff changeset
   204
    results
48341
752de4e10162 tuned source structure;
wenzelm
parents: 48340
diff changeset
   205
  }
752de4e10162 tuned source structure;
wenzelm
parents: 48340
diff changeset
   206
752de4e10162 tuned source structure;
wenzelm
parents: 48340
diff changeset
   207
62833
29dfa2ed9343 prefer internal tool;
wenzelm
parents: 62825
diff changeset
   208
  /* Isabelle tool wrapper */
48341
752de4e10162 tuned source structure;
wenzelm
parents: 48340
diff changeset
   209
72763
3cc73d00553c added document antiquotation @{tool};
wenzelm
parents: 72728
diff changeset
   210
  val isabelle_tool = Isabelle_Tool("build", "build and manage Isabelle sessions",
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   211
    Scala_Project.here,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   212
    { args =>
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   213
      val build_options = Word.explode(Isabelle_System.getenv("ISABELLE_BUILD_OPTIONS"))
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   214
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   215
      var base_sessions: List[String] = Nil
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   216
      var select_dirs: List[Path] = Nil
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   217
      var numa_shuffling = false
75942
603852abed8f clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents: 75941
diff changeset
   218
      var browser_info = Browser_Info.Config.none
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   219
      var requirements = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   220
      var soft_build = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   221
      var exclude_session_groups: List[String] = Nil
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   222
      var all_sessions = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   223
      var build_heap = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   224
      var clean_build = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   225
      var dirs: List[Path] = Nil
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   226
      var export_files = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   227
      var fresh_build = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   228
      var session_groups: List[String] = Nil
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   229
      var max_jobs = 1
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   230
      var check_keywords: Set[String] = Set.empty
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   231
      var list_files = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   232
      var no_build = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   233
      var options = Options.init(opts = build_options)
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   234
      var verbose = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   235
      var exclude_sessions: List[String] = Nil
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   236
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   237
      val getopts = Getopts("""
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   238
Usage: isabelle build [OPTIONS] [SESSIONS ...]
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   239
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   240
  Options are:
66737
2edc0c42c883 option -B for "isabelle build" and "isabelle imports";
wenzelm
parents: 66736
diff changeset
   241
    -B NAME      include session NAME and all descendants
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   242
    -D DIR       include session directory and select its sessions
64265
8eb6365f5916 isabelle build -N;
wenzelm
parents: 64173
diff changeset
   243
    -N           cyclic shuffling of NUMA CPU nodes (performance tuning)
72648
1cbac4ae934d more explicit presentation directory;
wenzelm
parents: 72640
diff changeset
   244
    -P DIR       enable HTML/PDF presentation in directory (":" for default)
71807
cdfa8f027bb9 tuned messages;
wenzelm
parents: 71727
diff changeset
   245
    -R           refer to requirements of selected sessions
66745
e7ac579b883c option -S for "isabelle build";
wenzelm
parents: 66744
diff changeset
   246
    -S           soft build: only observe changes of sources, not heap images
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   247
    -X NAME      exclude sessions from group NAME and all descendants
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   248
    -a           select all sessions
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   249
    -b           build heap images
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   250
    -c           clean build
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   251
    -d DIR       include session directory
69811
18f61ce86425 clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents: 69777
diff changeset
   252
    -e           export files from session specification into file-system
66841
5c32a072ca8b added isablle build option -f;
wenzelm
parents: 66822
diff changeset
   253
    -f           fresh build
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   254
    -g NAME      select session group NAME
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   255
    -j INT       maximum number of parallel jobs (default 1)
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   256
    -k KEYWORD   check theory sources for conflicts with proposed keywords
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   257
    -l           list session source files
76919
293c8a567f71 tuned message;
wenzelm
parents: 76901
diff changeset
   258
    -n           no build -- take existing build databases
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   259
    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   260
    -v           verbose
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   261
    -x NAME      exclude session NAME and all descendants
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   262
62596
cf79f8866bc3 tuned messages;
wenzelm
parents: 62595
diff changeset
   263
  Build and manage Isabelle sessions, depending on implicit settings:
cf79f8866bc3 tuned messages;
wenzelm
parents: 62595
diff changeset
   264
73736
a8ff6e4ee661 tuned signature;
wenzelm
parents: 73702
diff changeset
   265
""" + Library.indent_lines(2,  Build_Log.Settings.show()) + "\n",
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   266
        "B:" -> (arg => base_sessions = base_sessions ::: List(arg)),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   267
        "D:" -> (arg => select_dirs = select_dirs ::: List(Path.explode(arg))),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   268
        "N" -> (_ => numa_shuffling = true),
75942
603852abed8f clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents: 75941
diff changeset
   269
        "P:" -> (arg => browser_info = Browser_Info.Config.make(arg)),
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   270
        "R" -> (_ => requirements = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   271
        "S" -> (_ => soft_build = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   272
        "X:" -> (arg => exclude_session_groups = exclude_session_groups ::: List(arg)),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   273
        "a" -> (_ => all_sessions = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   274
        "b" -> (_ => build_heap = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   275
        "c" -> (_ => clean_build = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   276
        "d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   277
        "e" -> (_ => export_files = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   278
        "f" -> (_ => fresh_build = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   279
        "g:" -> (arg => session_groups = session_groups ::: List(arg)),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   280
        "j:" -> (arg => max_jobs = Value.Int.parse(arg)),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   281
        "k:" -> (arg => check_keywords = check_keywords + arg),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   282
        "l" -> (_ => list_files = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   283
        "n" -> (_ => no_build = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   284
        "o:" -> (arg => options = options + arg),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   285
        "v" -> (_ => verbose = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   286
        "x:" -> (arg => exclude_sessions = exclude_sessions ::: List(arg)))
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   287
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   288
      val sessions = getopts(args)
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   289
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   290
      val progress = new Console_Progress(verbose = verbose)
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   291
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   292
      val start_date = Date.now()
64140
96d398871124 modernized date format;
wenzelm
parents: 64115
diff changeset
   293
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   294
      if (verbose) {
77384
ef6673859c38 option build_hostname allows to change hostname easily;
wenzelm
parents: 77372
diff changeset
   295
        val hostname = Isabelle_System.hostname(options.string("build_hostname"))
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   296
        progress.echo(
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   297
          "Started at " + Build_Log.print_date(start_date) +
77384
ef6673859c38 option build_hostname allows to change hostname easily;
wenzelm
parents: 77372
diff changeset
   298
            " (" + Isabelle_System.getenv("ML_IDENTIFIER") + " on " + hostname +")")
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   299
        progress.echo(Build_Log.Settings.show() + "\n")
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   300
      }
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   301
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   302
      val results =
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   303
        progress.interrupt_handler {
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   304
          build(options,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   305
            selection = Sessions.Selection(
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   306
              requirements = requirements,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   307
              all_sessions = all_sessions,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   308
              base_sessions = base_sessions,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   309
              exclude_session_groups = exclude_session_groups,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   310
              exclude_sessions = exclude_sessions,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   311
              session_groups = session_groups,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   312
              sessions = sessions),
75942
603852abed8f clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents: 75941
diff changeset
   313
            browser_info = browser_info,
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   314
            progress = progress,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   315
            check_unknown_files = Mercurial.is_repository(Path.ISABELLE_HOME),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   316
            build_heap = build_heap,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   317
            clean_build = clean_build,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   318
            dirs = dirs,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   319
            select_dirs = select_dirs,
77477
f376aebca9c1 clarified modules;
wenzelm
parents: 77453
diff changeset
   320
            numa_shuffling = Host.numa_check(progress, numa_shuffling),
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   321
            max_jobs = max_jobs,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   322
            list_files = list_files,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   323
            check_keywords = check_keywords,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   324
            fresh_build = fresh_build,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   325
            no_build = no_build,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   326
            soft_build = soft_build,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   327
            verbose = verbose,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   328
            export_files = export_files)
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   329
        }
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   330
      val end_date = Date.now()
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   331
      val elapsed_time = end_date.time - start_date.time
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   332
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   333
      if (verbose) {
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   334
        progress.echo("\nFinished at " + Build_Log.print_date(end_date))
62833
29dfa2ed9343 prefer internal tool;
wenzelm
parents: 62825
diff changeset
   335
      }
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   336
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   337
      val total_timing =
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   338
        results.sessions.iterator.map(a => results(a).timing).foldLeft(Timing.zero)(_ + _).
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   339
          copy(elapsed = elapsed_time)
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   340
      progress.echo(total_timing.message_resources)
62590
0c837beeb5e7 upgrade "isabelle build" to Isabelle/Scala;
wenzelm
parents: 62573
diff changeset
   341
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   342
      sys.exit(results.rc)
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   343
    })
68305
5321218147d3 clarified signature;
wenzelm
parents: 68292
diff changeset
   344
5321218147d3 clarified signature;
wenzelm
parents: 68292
diff changeset
   345
5321218147d3 clarified signature;
wenzelm
parents: 68292
diff changeset
   346
  /* build logic image */
5321218147d3 clarified signature;
wenzelm
parents: 68292
diff changeset
   347
5321218147d3 clarified signature;
wenzelm
parents: 68292
diff changeset
   348
  def build_logic(options: Options, logic: String,
71726
a5fda30edae2 clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents: 71718
diff changeset
   349
    progress: Progress = new Progress,
68305
5321218147d3 clarified signature;
wenzelm
parents: 68292
diff changeset
   350
    build_heap: Boolean = false,
5321218147d3 clarified signature;
wenzelm
parents: 68292
diff changeset
   351
    dirs: List[Path] = Nil,
70791
02edce6f0c71 clarified signature: more options;
wenzelm
parents: 70712
diff changeset
   352
    fresh: Boolean = false,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74845
diff changeset
   353
    strict: Boolean = false
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74845
diff changeset
   354
  ): Int = {
71896
ce06d6456cc8 clarified signature --- fit within limit of 22 arguments;
wenzelm
parents: 71895
diff changeset
   355
    val selection = Sessions.Selection.session(logic)
69540
a1e8bcda8cec tuned signature;
wenzelm
parents: 69369
diff changeset
   356
    val rc =
71981
0be06f99b210 clarified signature;
wenzelm
parents: 71978
diff changeset
   357
      if (!fresh && build(options, selection = selection,
74306
a117c076aa22 clarified signature;
wenzelm
parents: 73826
diff changeset
   358
            build_heap = build_heap, no_build = true, dirs = dirs).ok) Process_Result.RC.ok
69540
a1e8bcda8cec tuned signature;
wenzelm
parents: 69369
diff changeset
   359
      else {
a1e8bcda8cec tuned signature;
wenzelm
parents: 69369
diff changeset
   360
        progress.echo("Build started for Isabelle/" + logic + " ...")
71981
0be06f99b210 clarified signature;
wenzelm
parents: 71978
diff changeset
   361
        Build.build(options, selection = selection, progress = progress,
0be06f99b210 clarified signature;
wenzelm
parents: 71978
diff changeset
   362
          build_heap = build_heap, fresh_build = fresh, dirs = dirs).rc
69540
a1e8bcda8cec tuned signature;
wenzelm
parents: 69369
diff changeset
   363
      }
74306
a117c076aa22 clarified signature;
wenzelm
parents: 73826
diff changeset
   364
    if (strict && rc != Process_Result.RC.ok) error("Failed to build Isabelle/" + logic) else rc
68305
5321218147d3 clarified signature;
wenzelm
parents: 68292
diff changeset
   365
  }
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
   366
}