1
1
module Extrae
2
2
3
3
using Extrae_jll
4
-
5
- include (" FFI.jl" )
6
- include (" API.jl" )
7
- include (" Macros.jl" )
4
+ using Libdl
5
+ using Preferences
8
6
9
7
export version,
10
8
init,
@@ -29,4 +27,70 @@ function __init__()
29
27
return nothing
30
28
end
31
29
30
+ const libextrae = @load_preference (" libextrae" , Extrae_jll. libseqtrace)
31
+
32
+ function use_system_binary (;
33
+ library_names= [
34
+ " libseqtrace" ,
35
+ " libpttrace" ,
36
+ " libmpitrace" ,
37
+ " libptmpitrace" ,
38
+ " libcudatrace" ,
39
+ " libptcudatrace" ,
40
+ " libcudampitrace" ,
41
+ " libptcudampitrace" ,
42
+ ],
43
+ extra_paths= String[],
44
+ export_prefs= false ,
45
+ force= true ,
46
+ )
47
+ libextrae = find_library (library_names, extra_paths)
48
+ if libextrae == " "
49
+ error ("""
50
+ Extrae library could not be found with the following name(s):
51
+ $(library_names)
52
+ in the following extra directories (in addition to the default ones):
53
+ $(extra_paths)
54
+ If you want to try different name(s) for the Extrae library, use
55
+ Extrae.use_system_binary(; library_names=[...])""" )
56
+ end
57
+
58
+ set_preferences! (Extrae, " libextrae" => libextrae; export_prefs, force)
59
+
60
+ if libextrae != Extrae. libextrae
61
+ @info " Extrae preferences changed" libextrae
62
+ error (" You will need to restart Julia for the changes to take effect" )
63
+ end
64
+ end
65
+
66
+ function use_jll_binary (binary; export_prefs= false , force= true )
67
+ known_binaries = (
68
+ :libseqtrace ,
69
+ :libpttrace ,
70
+ :libmpitrace ,
71
+ :libptmpitrace ,
72
+ :libcudatrace ,
73
+ :libptcudatrace ,
74
+ :libcudampitrace ,
75
+ :libptcudampitrace ,
76
+ )
77
+ binary in known_binaries || error ("""
78
+ Unknown jll: $binary
79
+ Accepted options are:
80
+ $(join (string .(known_binaries), " , " )) """ )
81
+
82
+ libextrae = getproperty (Extrae_jll, binary)
83
+
84
+ set_preferences! (Extrae, " libextrae" => libextrae; export_prefs, force)
85
+
86
+ if libextrae != Extrae. libextrae
87
+ @info " Extrae preferences changed" libextrae
88
+ error (" You will need to restart Julia for the changes to take effect" )
89
+ end
90
+ end
91
+
92
+ include (" FFI.jl" )
93
+ include (" API.jl" )
94
+ include (" Macros.jl" )
95
+
32
96
end
0 commit comments