-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10069 from waTeim/waT/jconfig
Add a julia-config script for configuration of externals
- Loading branch information
Showing
3 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env julia | ||
|
||
const options = | ||
[ | ||
"--cflags", | ||
"--ldflags", | ||
"--ldlibs" | ||
]; | ||
|
||
function imagePath() | ||
opts = Base.JLOptions(); | ||
bytestring(opts.image_file); | ||
end | ||
|
||
function libDir() | ||
abspath(dirname(Sys.dlpath("libjulia"))); | ||
end | ||
|
||
function includeDir() | ||
joinpath(match(r"(.*)(bin)",JULIA_HOME).captures[1],"include","julia"); | ||
end | ||
|
||
function initDir() | ||
@unix_only return match(r"(.*)(/julia/sys.ji)",imagePath()).captures[1]; | ||
@windows_only return match(r"(.*)(\\julia\\sys.ji)",imagePath()).captures[1]; | ||
end | ||
|
||
function ldflags() | ||
replace("""-L$(libDir())""","\\","\\\\"); | ||
end | ||
|
||
function ldlibs() | ||
@unix_only return replace("""-Wl,-rpath,$(libDir()) -ljulia""","\\","\\\\"); | ||
@windows_only return replace("""-ljulia""","\\","\\\\"); | ||
end | ||
|
||
function cflags() | ||
arg1 = replace(initDir(),"\\","\\\\\\\\"); | ||
arg2 = replace(includeDir(),"\\","\\\\"); | ||
return """-DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2"""; | ||
end | ||
|
||
function check_args(args) | ||
checked = intersect(args,options); | ||
if length(checked) == 0 || length(checked) != length(args) | ||
println(STDERR,"Usage: julia-config [",reduce((x,y)->"$x|$y",options),"]"); | ||
exit(1); | ||
end | ||
end | ||
|
||
function main() | ||
check_args(ARGS); | ||
for args in ARGS | ||
if args == "--ldflags" | ||
println(ldflags()); | ||
elseif args == "--cflags" | ||
println(cflags()); | ||
elseif args == "--ldlibs" | ||
println(ldlibs()); | ||
end | ||
end | ||
end | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters