-
-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathMyApp.jl
More file actions
125 lines (98 loc) · 2.5 KB
/
Copy pathMyApp.jl
File metadata and controls
125 lines (98 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
module MyApp
using Example
using HelloWorldC_jll
using Artifacts
using Distributed
using Random
if VERSION >= v"1.7.0"
using LLVMExtra_jll
end
using MKL_jll
const myrand = rand()
const outputo = begin
o = Base.JLOptions().outputo
o == C_NULL ? "ok" : unsafe_string(o)
end
fooifier_path() = joinpath(artifact"fooifier", "bin", "fooifier" * (Sys.iswindows() ? ".exe" : ""))
function julia_main()::Cint
try
real_main()
catch
Base.invokelatest(Base.display_error, Base.catch_stack())
return 1
end
return 0
end
function is_crayons_loaded()
Base.PkgId(Base.UUID("a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"), "Crayons") in keys(Base.loaded_modules)
end
function real_main()
@show ARGS
@show Base.PROGRAM_FILE
@show DEPOT_PATH
@show LOAD_PATH
@show pwd()
@show Base.active_project()
@show Sys.BINDIR
@show Base.JLOptions().opt_level
@show Base.JLOptions().nthreads
@show Base.JLOptions().check_bounds
display(Base.loaded_modules)
println()
println("Running a jll package:")
HelloWorldC_jll.hello_world() do x
println("HelloWorld artifact at $(realpath(x))")
run(`$x`)
end
println()
@show is_crayons_loaded()
println("Running the artifact")
res = read(`$(fooifier_path()) 5 10`, String)
println("The result of 2*5^2 - 10 == $res")
@show unsafe_string(Base.JLOptions().image_file)
@show Example.domath(5)
@show sin(0.0)
println("outputo: $outputo")
# Check that the RNG is seeded during precompilation
println("myrand: ", myrand == 0.0 ? "fail" : "ok")
rand() # Check that RNG state is ok
if nworkers() != 4
addprocs(4)
@eval @everywhere using MyApp
end
n = @distributed (+) for i = 1:20000000
1
end
println("n = $n")
@eval @everywhere using Example
@everywhere println(Example.domath(3))
if VERSION >= v"1.7.0"
if isfile(LLVMExtra_jll.libLLVMExtra_path)
println("LLVMExtra path: ok!")
else
println("LLVMExtra path: fail!")
end
end
if isfile(MKL_jll.libmkl_core_path)
println("MKL_jll path: ok!")
else
println("MKL_jll path: fail!")
end
return
end
if abspath(PROGRAM_FILE) == @__FILE__
real_main()
end
# Used for testing
function second_main()::Cint
println("Hello from second main")
return 0
end
function wrong_return_type()
return "oops"
end
function erroring()
1 + "foo"
return 0
end
end # module