Skip to content

Commit 090d448

Browse files
committed
add precompile execution, remove precompile statements, use args for build script
1 parent 2b13e5f commit 090d448

File tree

4 files changed

+63
-8
lines changed

4 files changed

+63
-8
lines changed

compile/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[deps]
2+
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
23
JetReconstruction = "44e8cb2c-dfab-4825-9c70-d4808a591196"
34
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
45

compile/build.jl

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
using PackageCompiler
2+
using ArgParse
23

3-
output_directory = joinpath(splitdir(@__DIR__) |> first, "JetReconstructionCompiled")
4+
s = ArgParseSettings()
5+
@add_arg_table s begin
6+
"--source-dir"
7+
help = "Directory containing the source files"
8+
arg_type = String
9+
default = splitdir(@__DIR__) |> first
410

5-
@info "Creating library in $output_directory"
6-
PackageCompiler.create_library(".", output_directory;
11+
"--output-dir"
12+
help = "Directory to save the compiled library"
13+
arg_type = String
14+
default = joinpath(splitdir(@__DIR__) |> first, "JetReconstructionCompiled")
15+
end
16+
17+
parsed_args = parse_args(s)
18+
source_dir = parsed_args["source-dir"]
19+
output_dir = parsed_args["output-dir"]
20+
21+
@info "Compiling package from $source_dir"
22+
@info "Creating library in $output_dir"
23+
PackageCompiler.create_library(source_dir, output_dir;
724
lib_name = "jetreconstruction",
825
header_files = [joinpath(@__DIR__, "include",
926
"JetReconstruction.h")],
10-
# precompile_execution_file = [joinpath(@__DIR__,
11-
# "precompile_execution.jl")],
12-
# precompile_statements_file = [jointpath(@__DIR__,
13-
# "precompile_statements.jl")],
27+
precompile_execution_file = [joinpath(@__DIR__,
28+
"precompile_execution.jl")],
1429
incremental = false,
1530
filter_stdlibs = true,
1631
force = true)

compile/precompile_execution.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
11

2+
using JetReconstruction
3+
using JetReconstruction.C_JetReconstruction: jetreconstruction_PseudoJet_init,
4+
C_ClusterSequence,
5+
jetreconstruction_ClusterSequence_free_members_,
6+
C_JetsResult,
7+
jetreconstruction_JetsResult_free_members_,
8+
jetreconstruction_jet_reconstruct,
9+
jetreconstruction_inclusive_jets,
10+
jetreconstruction_exclusive_jets_njets,
11+
jetreconstruction_exclusive_jets_dcut
12+
13+
pseudoJets_len = Csize_t(2)
14+
pseudoJets_ptr = Ptr{PseudoJet}(Libc.malloc(pseudoJets_len * sizeof(PseudoJet)))
15+
16+
jetreconstruction_PseudoJet_init(pseudoJets_ptr, 0.0, 1.0, 2.0, 3.0)
17+
jetreconstruction_PseudoJet_init(pseudoJets_ptr + sizeof(PseudoJet), 1.0, 2.0, 3.0, 4.0)
18+
19+
strategy = RecoStrategy.Best
20+
algorithm = JetAlgorithm.CA
21+
R = 2.0
22+
23+
clustersequence_ptr = Ptr{C_ClusterSequence{PseudoJet}}(Libc.malloc(sizeof(C_ClusterSequence{PseudoJet})))
24+
jetreconstruction_jet_reconstruct(pseudoJets_ptr, pseudoJets_len, algorithm, R,
25+
RecoStrategy.Best,
26+
clustersequence_ptr)
27+
28+
results = C_JetsResult{PseudoJet}(C_NULL, 0)
29+
results_ptr = Base.unsafe_convert(Ptr{C_JetsResult{PseudoJet}}, Ref(results))
30+
jetreconstruction_exclusive_jets_njets(clustersequence_ptr, Csize_t(2), results_ptr)
31+
jetreconstruction_JetsResult_free_members_(results_ptr)
32+
33+
jetreconstruction_exclusive_jets_dcut(clustersequence_ptr, 1.0, results_ptr)
34+
jetreconstruction_JetsResult_free_members_(results_ptr)
35+
36+
jetreconstruction_inclusive_jets(clustersequence_ptr, 0.0, results_ptr)
37+
jetreconstruction_JetsResult_free_members_(results_ptr)
38+
39+
jetreconstruction_ClusterSequence_free_members_(clustersequence_ptr)
40+
Libc.free(pseudoJets_ptr)
41+
Libc.free(clustersequence_ptr)

compile/precompile_statements.jl

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)