Skip to content

Instantly share code, notes, and snippets.

@timholy
Last active December 14, 2015 17:48
Show Gist options
  • Save timholy/5124493 to your computer and use it in GitHub Desktop.
Save timholy/5124493 to your computer and use it in GitHub Desktop.
Clang/libav
import Clang.wrap_c
if (!has(ENV, "JULIAHOME"))
error("Please set JULIAHOME variable to the root of your julia install")
end
clang_includes = map(x->joinpath(ENV["JULIAHOME"], x), [
"deps/llvm-3.2/build/Release/lib/clang/3.2/include",
"deps/llvm-3.2/include",
"deps/llvm-3.2/include",
"deps/llvm-3.2/build/include/",
"deps/llvm-3.2/include/"
])
av_bpath = "/usr/include/libavcodec/"
push!(clang_includes, av_bpath)
av_hpath = av_bpath
av_headers = map(x->joinpath(av_hpath, x),split(readall(`ls $av_hpath` | `sort`)) )
# called to determine if cursor should be included
check_use_header(hpath) = begin
hbase = av_bpath
hl=length(hbase)
!ccall(:strcmp, Bool, (Ptr{Uint8}, Ptr{Uint8}), hbase, hpath)
end
println(av_headers)
wrap_c.wrap_c_headers(av_headers, clang_includes, {}, check_use_header, "/home/tim/src/julia-modules/libav/src/libav.jl")
import Clang.wrap_c
if (!has(ENV, "JULIAHOME"))
error("Please set JULIAHOME variable to the root of your julia install")
end
clang_includes = map(x->joinpath(ENV["JULIAHOME"], x), [
"deps/llvm-3.2/build/Release/lib/clang/3.2/include",
"deps/llvm-3.2/include",
"deps/llvm-3.2/include",
"deps/llvm-3.2/build/include/",
"deps/llvm-3.2/include/"
])
av_hpath = ["/usr/include/libavcodec/","/usr/include/libavformat/","/usr/include/libswscale/"]
append!(clang_includes, av_hpath)
av_headers = Array(ASCIIString, 0)
for path in av_hpath
tmp = map(x->joinpath(path, x),split(readall(`ls $av_hpath` | `sort`)) )
append!(av_headers, tmp)
end
println(av_headers)
# called to determine if cursor should be included
check_use_header(hpath) = begin
hbase = av_hpath
ret = false
for d in hbase
l = min(length(hpath), length(d))
ret = ret | (hpath[1:l] == d[1:l])
end
println(hpath, " ", ret)
ret
end
wrap_c.wrap_c_headers(av_headers, clang_includes, {}, check_use_header, "/home/tim/src/julia-modules/libav/src/libav.jl")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment