src/Pure/Tools/build.scala
changeset 78421 fd24f380b588
parent 78420 c157af5f346e
child 78435 a623cb346b4a
equal deleted inserted replaced
78420:c157af5f346e 78421:fd24f380b588
    21 
    21 
    22   def engine_name(options: Options): String = options.string("build_engine")
    22   def engine_name(options: Options): String = options.string("build_engine")
    23 
    23 
    24 
    24 
    25 
    25 
       
    26   /* context */
       
    27 
       
    28   sealed case class Context(
       
    29     store: Store,
       
    30     build_deps: isabelle.Sessions.Deps,
       
    31     afp_root: Option[Path] = None,
       
    32     build_hosts: List[Build_Cluster.Host] = Nil,
       
    33     ml_platform: String = Isabelle_System.getenv("ML_PLATFORM"),
       
    34     hostname: String = Isabelle_System.hostname(),
       
    35     numa_shuffling: Boolean = false,
       
    36     build_heap: Boolean = false,
       
    37     max_jobs: Int = 1,
       
    38     fresh_build: Boolean = false,
       
    39     no_build: Boolean = false,
       
    40     session_setup: (String, Session) => Unit = (_, _) => (),
       
    41     build_uuid: String = UUID.random().toString,
       
    42     master: Boolean = false
       
    43   ) {
       
    44     override def toString: String =
       
    45       "Build.Context(build_uuid = " + quote(build_uuid) + if_proper(master, ", master = true") + ")"
       
    46 
       
    47     def build_options: Options = store.options
       
    48 
       
    49     def sessions_structure: isabelle.Sessions.Structure = build_deps.sessions_structure
       
    50 
       
    51     def worker_active: Boolean = max_jobs > 0
       
    52   }
       
    53 
       
    54 
    26   /* results */
    55   /* results */
    27 
    56 
    28   object Results {
    57   object Results {
    29     def apply(context: Build_Process.Context, results: Map[String, Process_Result]): Results =
    58     def apply(context: Context, results: Map[String, Process_Result]): Results =
    30       new Results(context.store, context.build_deps, results)
    59       new Results(context.store, context.build_deps, results)
    31   }
    60   }
    32 
    61 
    33   class Results private(
    62   class Results private(
    34     val store: Store,
    63     val store: Store,
    84       Isabelle_Fonts.init()
   113       Isabelle_Fonts.init()
    85       store
   114       store
    86     }
   115     }
    87 
   116 
    88     def build_process(
   117     def build_process(
    89       build_context: Build_Process.Context,
   118       build_context: Context,
    90       build_progress: Progress,
   119       build_progress: Progress,
    91       server: SSH.Server
   120       server: SSH.Server
    92     ): Build_Process = new Build_Process(build_context, build_progress, server)
   121     ): Build_Process = new Build_Process(build_context, build_progress, server)
    93 
   122 
    94     final def run_process(
   123     final def run_process(
    95       context: Build_Process.Context,
   124       context: Context,
    96       progress: Progress,
   125       progress: Progress,
    97       server: SSH.Server
   126       server: SSH.Server
    98     ): Results = {
   127     ): Results = {
    99       Isabelle_Thread.uninterruptible {
   128       Isabelle_Thread.uninterruptible {
   100         using(build_process(context, progress, server))(
   129         using(build_process(context, progress, server))(
   195 
   224 
   196 
   225 
   197         /* build process and results */
   226         /* build process and results */
   198 
   227 
   199         val build_context =
   228         val build_context =
   200           Build_Process.Context(store, build_deps, afp_root = afp_root, build_hosts = build_hosts,
   229           Context(store, build_deps, afp_root = afp_root, build_hosts = build_hosts,
   201             hostname = hostname(build_options), build_heap = build_heap,
   230             hostname = hostname(build_options), build_heap = build_heap,
   202             numa_shuffling = numa_shuffling, max_jobs = max_jobs, fresh_build = fresh_build,
   231             numa_shuffling = numa_shuffling, max_jobs = max_jobs, fresh_build = fresh_build,
   203             no_build = no_build, session_setup = session_setup, master = true)
   232             no_build = no_build, session_setup = session_setup, master = true)
   204 
   233 
   205         if (clean_build) {
   234         if (clean_build) {
   492 
   521 
   493           val build_deps =
   522           val build_deps =
   494             Sessions.deps(sessions_structure, progress = progress, inlined_files = true).check_errors
   523             Sessions.deps(sessions_structure, progress = progress, inlined_files = true).check_errors
   495 
   524 
   496           val build_context =
   525           val build_context =
   497             Build_Process.Context(store, build_deps, afp_root = afp_root,
   526             Context(store, build_deps, afp_root = afp_root,
   498               hostname = hostname(build_options), numa_shuffling = numa_shuffling,
   527               hostname = hostname(build_options), numa_shuffling = numa_shuffling,
   499               max_jobs = max_jobs, build_uuid = build_master.build_uuid)
   528               max_jobs = max_jobs, build_uuid = build_master.build_uuid)
   500 
   529 
   501           Some(build_engine.run_process(build_context, progress, server))
   530           Some(build_engine.run_process(build_context, progress, server))
   502         }
   531         }