Skip to content

Commit

Permalink
add config variable JULIA_P4EST_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha committed Oct 11, 2020
1 parent 0c5d45b commit 1d532c3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .travis_install_p4est.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

if [ "${P4EST_TEST}" = "P4EST_JLL_NON_MPI" ]; then
echo "Nothing to do for P4EST_TEST=P4EST_JLL_NON_MPI"
fi
if [ "${P4EST_TEST}" = "P4EST_CUSTOM_NON_MPI" ]; then
pushd `pwd`
export P4EST_TMP=`pwd`/libp4est_tmp
Expand Down
53 changes: 41 additions & 12 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ end

config = TOML.parsefile(config_toml)

# P4est.toml has 2 keys
# P4est.toml has 3 keys
# path = "" (default) | path to p4est containing subdirectories lib and include
# library = "" (default) | library name/path
# include = "" (default) | include name/path


# Step 1: Check environment variables and update preferences accordingly
if haskey(ENV, "JULIA_P4EST_PATH")
config["path"] = ENV["JULIA_P4EST_PATH"]
else
config["path"] = ""
end

if haskey(ENV, "JULIA_P4EST_LIBRARY")
config["library"] = ENV["JULIA_P4EST_LIBRARY"]
else
Expand All @@ -40,27 +47,49 @@ end


# Step 2: Choose the library according to the settings
if isempty(config["library"])
println("Use p4est library provided by P4est_jll")
p4est_library = P4est_jll.libp4est_path
else
println("Use custom p4est library $(config["library"])")
p4est_library = ""
if !isempty(config["library"])
p4est_library = config["library"]
println("Use custom p4est library $p4est_library")
elseif !isempty(config["path"])
# TODO: Linux only
p4est_library = joinpath(config["path"], "lib", "libp4est.so")
if isfile(p4est_library)
println("Use custom p4est library $p4est_library")
else
p4est_library = ""
end
end

if isempty(p4est_library)
p4est_library = P4est_jll.libp4est_path
println("Use p4est library provided by P4est_jll")
end



# Step 3: Choose the include path according to the settings
include_directories = String[]
if isempty(config["include"])
p4est_include = ""
if !isempty(config["include"])
p4est_include = config["include"]
println("Use custom p4est include path $p4est_include")
elseif !isempty(config["path"])
p4est_include = joinpath(config["path"], "include")
if isdir(p4est_include)
println("Use custom p4est include path $p4est_include")
else
p4est_include = ""
end
end

if isempty(p4est_include)
p4est_include = joinpath(dirname(dirname(P4est_jll.libp4est_path)), "include")
println("Use p4est include path provided by P4est_jll")
push!(include_directories,
joinpath(dirname(dirname(P4est_jll.libp4est_path)), "include"))
else
println("Use custom p4est include path $(config["include"])")
push!(include_directories, config["include"])
end

push!(include_directories, p4est_include)



# Step 4: Generate binding using the include path according to the settings
Expand Down

0 comments on commit 1d532c3

Please sign in to comment.