1
- # Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
2
- # Spack Project Developers. See the top-level COPYRIGHT file for details.
1
+ # Copyright Spack Project Developers. See COPYRIGHT file for details.
3
2
#
4
3
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
5
4
6
- import glob
7
5
import os
8
6
import shutil
9
7
import socket
@@ -41,10 +39,14 @@ class Axom(CachedCMakePackage, CudaPackage, ROCmPackage):
41
39
git = "https://github.com/LLNL/axom.git"
42
40
tags = ["radiuss" ]
43
41
42
+ test_requires_compiler = True
43
+
44
44
license ("BSD-3-Clause" )
45
45
46
46
version ("main" , branch = "main" )
47
47
version ("develop" , branch = "develop" )
48
+ version ("0.10.1" , tag = "v0.10.1" , commit = "6626ee1c5668176fb64dd9a52dec3e8596b3ba6b" )
49
+ version ("0.10.0" , tag = "v0.10.0" , commit = "ea853a34a834415ea75f824160fc44cba9a0755d" )
48
50
version ("0.9.0" , tag = "v0.9.0" , commit = "5f531595d941d16fa3b8583bfc347a845d9feb6d" )
49
51
version ("0.8.1" , tag = "v0.8.1" , commit = "0da8a5b1be596887158ac2fcd321524ba5259e15" )
50
52
version ("0.8.0" , tag = "v0.8.0" , commit = "71fab3262eb7e1aa44a04c21d072b77f06362f7b" )
@@ -59,6 +61,10 @@ class Axom(CachedCMakePackage, CudaPackage, ROCmPackage):
59
61
version ("0.3.0" , tag = "v0.3.0" , commit = "20068ccab4b4f70055918b4f17960ec3ed6dbce8" )
60
62
version ("0.2.9" , tag = "v0.2.9" , commit = "9e9a54ede3326817c05f35922738516e43b5ec3d" )
61
63
64
+ depends_on ("c" , type = "build" )
65
+ depends_on ("cxx" , type = "build" )
66
+ depends_on ("fortran" , type = "build" , when = "+fortran" )
67
+
62
68
# https://github.com/spack/spack/issues/31829
63
69
patch ("examples-oneapi.patch" , when = "@0.6.1 +examples %oneapi" )
64
70
@@ -250,11 +256,11 @@ def cache_name(self):
250
256
# Are we on a LLNL system then strip node number
251
257
hostname = hostname .rstrip ("1234567890" )
252
258
special_case = ""
253
- if "+cuda" in self . spec :
259
+ if self . spec . satisfies ( "+cuda" ) :
254
260
special_case += "_cuda"
255
- if "~fortran" in self . spec :
261
+ if self . spec . satisfies ( "~fortran" ) :
256
262
special_case += "_nofortran"
257
- if "+rocm" in self . spec :
263
+ if self . spec . satisfies ( "+rocm" ) :
258
264
special_case += "_hip"
259
265
return "{0}-{1}-{2}@{3}{4}.cmake" .format (
260
266
hostname ,
@@ -268,7 +274,7 @@ def initconfig_compiler_entries(self):
268
274
spec = self .spec
269
275
entries = super ().initconfig_compiler_entries ()
270
276
271
- if "+fortran" in spec :
277
+ if spec . satisfies ( "+fortran" ) :
272
278
entries .append (cmake_cache_option ("ENABLE_FORTRAN" , True ))
273
279
if self .is_fortran_compiler ("gfortran" ) and "clang" in self .compiler .cxx :
274
280
libdir = pjoin (os .path .dirname (os .path .dirname (self .compiler .cxx )), "lib" )
@@ -285,7 +291,7 @@ def initconfig_compiler_entries(self):
285
291
else :
286
292
entries .append (cmake_cache_option ("ENABLE_FORTRAN" , False ))
287
293
288
- if "+cpp14" in spec and spec .satisfies ("@:0.6.1" ):
294
+ if spec . satisfies ( "+cpp14" ) and spec .satisfies ("@:0.6.1" ):
289
295
entries .append (cmake_cache_string ("BLT_CXX_STD" , "c++14" , "" ))
290
296
291
297
# Add optimization flag workaround for builds with cray compiler
@@ -298,7 +304,7 @@ def initconfig_hardware_entries(self):
298
304
spec = self .spec
299
305
entries = super ().initconfig_hardware_entries ()
300
306
301
- if "+cuda" in spec :
307
+ if spec . satisfies ( "+cuda" ) :
302
308
entries .append (cmake_cache_option ("ENABLE_CUDA" , True ))
303
309
entries .append (cmake_cache_option ("CMAKE_CUDA_SEPARABLE_COMPILATION" , True ))
304
310
@@ -311,7 +317,7 @@ def initconfig_hardware_entries(self):
311
317
312
318
if spec .satisfies ("^blt@:0.5.1" ):
313
319
# This is handled internally by BLT now
314
- if "+cpp14" in spec :
320
+ if spec . satisfies ( "+cpp14" ) :
315
321
cudaflags += " -std=c++14"
316
322
else :
317
323
cudaflags += " -std=c++11"
@@ -320,7 +326,7 @@ def initconfig_hardware_entries(self):
320
326
entries .append ("# nvcc does not like gtest's 'pthreads' flag\n " )
321
327
entries .append (cmake_cache_option ("gtest_disable_pthreads" , True ))
322
328
323
- if "+rocm" in spec :
329
+ if spec . satisfies ( "+rocm" ) :
324
330
entries .append ("#------------------{0}\n " .format ("-" * 60 ))
325
331
entries .append ("# Axom ROCm specifics\n " )
326
332
entries .append ("#------------------{0}\n \n " .format ("-" * 60 ))
@@ -335,22 +341,26 @@ def initconfig_hardware_entries(self):
335
341
# Recommended MPI flags
336
342
hip_link_flags += "-lxpmem "
337
343
hip_link_flags += "-L/opt/cray/pe/mpich/{0}/gtl/lib " .format (spec ["mpi" ].version )
338
- hip_link_flags += "-Wl,-rpath,/opt/cray/pe/mpich/{0}/gtl/lib " .format (spec ["mpi" ].version )
344
+ hip_link_flags += "-Wl,-rpath,/opt/cray/pe/mpich/{0}/gtl/lib " .format (
345
+ spec ["mpi" ].version
346
+ )
339
347
hip_link_flags += "-lmpi_gtl_hsa "
340
348
341
349
# Fixes for mpi for rocm until wrapper paths are fixed
342
350
# These flags are already part of the wrapped compilers on TOSS4 systems
343
- if "+fortran" in spec and self .is_fortran_compiler ("amdflang" ):
351
+ if spec . satisfies ( "+fortran" ) and self .is_fortran_compiler ("amdflang" ):
344
352
hip_link_flags += "-Wl,--disable-new-dtags "
345
353
346
354
if spec .
satisfies (
"^[email protected] :" ):
347
- hip_link_flags += "-L{0}/lib/llvm/lib -Wl,-rpath,{0}/lib/llvm/lib " .format (rocm_root )
355
+ hip_link_flags += "-L{0}/lib/llvm/lib -Wl,-rpath,{0}/lib/llvm/lib " .format (
356
+ rocm_root
357
+ )
348
358
else :
349
359
hip_link_flags += "-L{0}/llvm/lib -Wl,-rpath,{0}/llvm/lib " .format (rocm_root )
350
360
hip_link_flags += "-lpgmath -lflang -lflangrti -lompstub "
351
361
352
362
# Remove extra link library for crayftn
353
- if "+fortran" in spec and self .is_fortran_compiler ("crayftn" ):
363
+ if spec . satisfies ( "+fortran" ) and self .is_fortran_compiler ("crayftn" ):
354
364
entries .append (
355
365
cmake_cache_string ("BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE" , "unwind" )
356
366
)
@@ -374,7 +384,7 @@ def initconfig_hardware_entries(self):
374
384
)
375
385
)
376
386
377
- if "+fortran" in spec and self .is_fortran_compiler ("xlf" ):
387
+ if spec . satisfies ( "+fortran" ) and self .is_fortran_compiler ("xlf" ):
378
388
# Grab lib directory for the current fortran compiler
379
389
libdir = pjoin (os .path .dirname (os .path .dirname (self .compiler .fc )), "lib" )
380
390
description = (
@@ -385,7 +395,7 @@ def initconfig_hardware_entries(self):
385
395
386
396
entries .append (cmake_cache_string ("BLT_EXE_LINKER_FLAGS" , linker_flags , description ))
387
397
388
- if "+shared" in spec :
398
+ if spec . satisfies ( "+shared" ) :
389
399
linker_flags = "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath," + libdir
390
400
entries .append (
391
401
cmake_cache_string ("CMAKE_SHARED_LINKER_FLAGS" , linker_flags , description )
@@ -399,9 +409,9 @@ def initconfig_hardware_entries(self):
399
409
)
400
410
401
411
if (
402
- "+openmp" in spec
412
+ spec . satisfies ( "+openmp" )
403
413
and "clang" in self .compiler .cxx
404
- and "+fortran" in spec
414
+ and spec . satisfies ( "+fortran" )
405
415
and self .is_fortran_compiler ("xlf" )
406
416
):
407
417
openmp_gen_exp = (
@@ -440,7 +450,7 @@ def initconfig_mpi_entries(self):
440
450
spec = self .spec
441
451
entries = super ().initconfig_mpi_entries ()
442
452
443
- if "+mpi" in spec :
453
+ if spec . satisfies ( "+mpi" ) :
444
454
entries .append (cmake_cache_option ("ENABLE_MPI" , True ))
445
455
if spec ["mpi" ].name == "spectrum-mpi" :
446
456
entries .append (cmake_cache_string ("BLT_MPI_COMMAND_APPEND" , "mpibind" ))
@@ -491,25 +501,25 @@ def initconfig_package_entries(self):
491
501
492
502
# optional tpls
493
503
for dep in ("c2c" , "mfem" , "hdf5" , "lua" , "raja" , "umpire" , "opencascade" ):
494
- if "+%s" % dep in spec :
504
+ if spec . satisfies ( "+%s" % dep ) :
495
505
dep_dir = get_spec_path (spec , dep , path_replacements )
496
506
entries .append (cmake_cache_path ("%s_DIR" % dep .upper (), dep_dir ))
497
507
else :
498
508
entries .append ("# %s not built\n " % dep .upper ())
499
509
500
- if "+profiling" in spec :
510
+ if spec . satisfies ( "+profiling" ) :
501
511
dep_dir = get_spec_path (spec , "adiak" , path_replacements )
502
512
entries .append (cmake_cache_path ("ADIAK_DIR" , dep_dir ))
503
513
504
514
dep_dir = get_spec_path (spec , "caliper" , path_replacements )
505
515
entries .append (cmake_cache_path ("CALIPER_DIR" , dep_dir ))
506
516
507
- if "+umpire" in spec and spec .satisfies ("^camp" ):
517
+ if spec . satisfies ( "+umpire" ) and spec .satisfies ("^camp" ):
508
518
dep_dir = get_spec_path (spec , "camp" , path_replacements )
509
519
entries .append (cmake_cache_path ("CAMP_DIR" , dep_dir ))
510
520
511
521
# SCR does not export it's targets so we need to pull in its dependencies
512
- if "+scr" in spec :
522
+ if spec . satisfies ( "+scr" ) :
513
523
dep_dir = get_spec_path (spec , "scr" , path_replacements )
514
524
entries .append (cmake_cache_path ("SCR_DIR" , dep_dir ))
515
525
@@ -542,20 +552,20 @@ def initconfig_package_entries(self):
542
552
entries .append ("#------------------{0}\n " .format ("-" * 60 ))
543
553
544
554
# Add common prefix to path replacement list
545
- if "+devtools" in spec :
555
+ if spec . satisfies ( "+devtools" ) :
546
556
# Grab common devtools root and strip the trailing slash
547
557
path1 = os .path .realpath (spec ["cppcheck" ].prefix )
548
558
path2 = os .path .realpath (spec ["doxygen" ].prefix )
549
559
self .find_path_replacement (path1 , path2 , path_replacements , "DEVTOOLS_ROOT" , entries )
550
560
551
- if "+devtools" in spec and spec .satisfies ("^llvm" ):
561
+ if spec . satisfies ( "+devtools" ) and spec .satisfies ("^llvm" ):
552
562
clang_fmt_path = spec ["llvm" ].prefix .bin .join ("clang-format" )
553
563
entries .append (cmake_cache_path ("CLANGFORMAT_EXECUTABLE" , clang_fmt_path ))
554
564
else :
555
565
entries .append ("# ClangFormat disabled due to llvm and devtools not in spec\n " )
556
566
entries .append (cmake_cache_option ("ENABLE_CLANGFORMAT" , False ))
557
567
558
- if "+python" in spec or "+devtools" in spec :
568
+ if spec . satisfies ( "+python" ) or spec . satisfies ( "+devtools" ) :
559
569
python_path = os .path .realpath (spec ["python" ].command .path )
560
570
for key in path_replacements :
561
571
python_path = python_path .replace (key , path_replacements [key ])
@@ -601,7 +611,7 @@ def cmake_args(self):
601
611
options .append (self .define_from_variant ("BUILD_SHARED_LIBS" , "shared" ))
602
612
options .append (self .define_from_variant ("AXOM_ENABLE_EXAMPLES" , "examples" ))
603
613
options .append (self .define_from_variant ("AXOM_ENABLE_TOOLS" , "tools" ))
604
- if "+ raja" not in self .spec or "+umpire" not in self . spec :
614
+ if self . spec . satisfies ( "~ raja") or self .spec . satisfies ( "+umpire" ) :
605
615
options .append ("-DAXOM_ENABLE_MIR:BOOL=OFF" )
606
616
607
617
return options
@@ -623,34 +633,29 @@ def build_test(self):
623
633
624
634
@run_after ("install" )
625
635
@on_package_attributes (run_tests = True )
626
- def check_install (self ):
627
- """
628
- Checks the spack install of axom using axom's
629
- using-with-cmake example
630
- """
631
-
632
- print ("Checking Axom installation..." )
633
- spec = self .spec
634
- install_prefix = spec .prefix
635
- example_src_dir = join_path (install_prefix , "examples" , "axom" , "using-with-cmake" )
636
- example_build_dir = join_path (example_src_dir , "build" )
637
- print ("Checking using-with-cmake example..." )
638
- with working_dir (example_build_dir , create = True ):
636
+ def test_install_using_cmake (self ):
637
+ """build example with cmake and run"""
638
+ example_src_dir = join_path (self .prefix .examples .axom , "using-with-cmake" )
639
+ example_stage_dir = "./cmake"
640
+ shutil .copytree (example_src_dir , example_stage_dir )
641
+ with working_dir (join_path (example_stage_dir , "build" ), create = True ):
639
642
cmake_args = ["-C ../host-config.cmake" , example_src_dir ]
643
+ cmake = self .spec ["cmake" ].command
640
644
cmake (* cmake_args )
641
645
make ()
642
646
example = Executable ("./example" )
643
647
example ()
644
- print ("Checking using-with-make example..." )
645
- example_src_dir = join_path (install_prefix , "examples" , "axom" , "using-with-make" )
646
- example_build_dir = join_path (example_src_dir , "build" )
647
- example_files = glob .glob (join_path (example_src_dir , "*" ))
648
- with working_dir (example_build_dir , create = True ):
649
- for example_file in example_files :
650
- shutil .copy (example_file , "." )
651
- make ("AXOM_DIR={0}" .format (install_prefix ))
648
+ make ("clean" )
649
+
650
+ @run_after ("install" )
651
+ @on_package_attributes (run_tests = True )
652
+ def test_install_using_make (self ):
653
+ """build example with make and run"""
654
+ example_src_dir = join_path (self .prefix .examples .axom , "using-with-make" )
655
+ example_stage_dir = "./make"
656
+ shutil .copytree (example_src_dir , example_stage_dir )
657
+ with working_dir (example_stage_dir , create = True ):
658
+ make (f"AXOM_DIR={ self .prefix } " )
652
659
example = Executable ("./example" )
653
660
example ()
654
-
655
- def test_install (self ):
656
- self .check_install ()
661
+ make ("clean" )
0 commit comments