@@ -252,6 +252,118 @@ def cmake_install(tag: str, base: str, no_cache: bool = False) -> Image:
252
252
)
253
253
254
254
255
+ def build_all (
256
+ tag : str ,
257
+ base : str ,
258
+ copy_path : os .PathLike | None ,
259
+ archive_url : str | None ,
260
+ directory : os .PathLike ,
261
+ build_type : str ,
262
+ no_cuda : bool ,
263
+ no_cache : bool = False ,
264
+ ) -> dict [str , Image ]:
265
+ """
266
+ Fully compiles and builds a Git repo with cmake.
267
+
268
+ Parameters
269
+ ----------
270
+ tag : str
271
+ The image tag prefix.
272
+ base : str
273
+ The base image tag.
274
+ copy_path : str
275
+ The path to a directory to copy to an image.
276
+ archive_url : str or None
277
+ The URL of the Git archive to install on an image. No archive will be installed
278
+ if `copy_dir` is given.
279
+ directory : str
280
+ The path to place the contents of the Git archive or copied directory to.
281
+ build_type : str
282
+ The CMake build type. See
283
+ `here <https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html>`_
284
+ for possible values.
285
+ no_cuda : bool
286
+ If True, build without CUDA.
287
+ no_cache : bool, optional
288
+ Run Docker build with no cache if True. Defaults to False.
289
+
290
+ Returns
291
+ -------
292
+ dict[str, Image]
293
+ A dict of images produced by this process.
294
+ """
295
+
296
+ prefixed_tag : str = prefix_image_tag (tag )
297
+ prefixed_base_tag : str = prefix_image_tag (base )
298
+
299
+ images : dict [str , Image ] = {}
300
+
301
+ # If the user has indicated a path to copy, the code should copy that.
302
+ # Otherwise, the code should fetch a git repository.
303
+ is_insert = copy_path is not None
304
+
305
+ initial_tag : str = ""
306
+ if is_insert :
307
+ assert isinstance (copy_path , str )
308
+ path_absolute = os .path .abspath (copy_path )
309
+ if os .path .isdir (copy_path ):
310
+ top_dir = os .path .basename (path_absolute )
311
+ else :
312
+ top_dir = os .path .basename (os .path .dirname (path_absolute ))
313
+
314
+ insert_tag = f"{ prefixed_tag } -file-{ top_dir } "
315
+ insert_image = copy_dir (
316
+ base = prefixed_base_tag ,
317
+ tag = insert_tag ,
318
+ directory = directory ,
319
+ target_path = copy_path ,
320
+ no_cache = no_cache ,
321
+ )
322
+ images [insert_tag ] = insert_image
323
+ initial_tag = insert_tag
324
+ else :
325
+ git_repo_tag = f"{ prefixed_tag } -git-repo"
326
+ assert archive_url is not None
327
+
328
+ git_repo_image = get_archive (
329
+ base = prefixed_base_tag ,
330
+ tag = git_repo_tag ,
331
+ archive_url = archive_url ,
332
+ directory = directory ,
333
+ no_cache = no_cache ,
334
+ )
335
+ images [git_repo_tag ] = git_repo_image
336
+ initial_tag = git_repo_tag
337
+
338
+ configure_tag = f"{ prefixed_tag } -configured"
339
+ configure_image = configure_cmake (
340
+ tag = configure_tag ,
341
+ base = initial_tag ,
342
+ build_type = build_type ,
343
+ no_cuda = no_cuda ,
344
+ no_cache = no_cache ,
345
+ )
346
+ images [configure_tag ] = configure_image
347
+
348
+ build_tag = f"{ prefixed_tag } -built"
349
+ build_image = compile_cmake (
350
+ tag = build_tag ,
351
+ base = configure_tag ,
352
+ no_cache = no_cache ,
353
+ )
354
+ images [build_tag ] = build_image
355
+
356
+ install_tag = f"{ prefixed_tag } -installed"
357
+ install_image = cmake_install (
358
+ tag = install_tag ,
359
+ base = build_tag ,
360
+ no_cache = no_cache ,
361
+ )
362
+ images [install_tag ] = install_image
363
+
364
+ return images
365
+
366
+
255
367
def dropin (tag : str ) -> None :
256
368
"""
257
369
Initiates a drop-in session on an image.
0 commit comments