Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First version of caller for libs #104

Merged
merged 17 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ docs/build
*.jl.*.cov
*.jl.mem
.gitattributes
/src/libraryfuncdictionary.jl
3 changes: 3 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ withenv("CPP_FLAGS"=>"-I$vdir/include", "LD_LIBRARY_PATH"=>"$vdir/lib:$nemodir/l
cmd = split(
"""
$srcs/configure
--with-libparse
--prefix=$vdir
--libdir=$vdir/lib
--disable-static
Expand Down Expand Up @@ -152,3 +153,5 @@ print("Running cmake")
run(`make VERBOSE=1`)
run(`make install`)

include("parselibs.jl")

53 changes: 53 additions & 0 deletions deps/parselibs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
function execute(cmd::Cmd)
out = Pipe()
err = Pipe()

process = run(pipeline(ignorestatus(cmd), stdout = out, stderr = err))
close(out.in)
close(err.in)

(stdout = String(read(out)),
stderr = String(read(err)),
code = process.exitcode)
end

libparsepath = abspath(joinpath(@__DIR__, "..", "local", "bin", "libparse"))

library_dir = ""

if haskey(ENV, "SINGULAR_LIBRARY_DIR")
library_dir = ENV["SINGULAR_LIBRARY_DIR"]
else
library_dir = abspath(joinpath(@__DIR__, "..", "local", "share", "singular", "LIB"))
end

filenames = filter(x -> endswith(x, ".lib"), readdir(library_dir))

output_filename = abspath(joinpath(@__DIR__, "..", "src", "libraryfuncdictionary.jl"))

#=
Loops over all libraries and executes libparse on it.
The first three lines of the libparse output are general information
about the library, so we ignore it. We are only interested in the
first column (library name) and the third column (globally exposed or not).
All other columns (containing info such as line numbers, library name, etc)
are ignored.
=#
open(output_filename, "w") do outputfile
println(outputfile, "libraryfunctiondictionary = Dict(")
for i in filenames
full_path = joinpath(library_dir, i)
libs = execute(`$libparsepath $full_path`)
if libs.stderr != ""
error("from libparse: $(libs.stderr)")
end
libs_splitted = split(libs.stdout,"\n")[4:end - 1]
libs_splitted = [split(i, " ", keepempty = false) for i in libs_splitted]
println(outputfile, ":$(i[1:end - 4]) => [")
for j in libs_splitted
println(outputfile, """[ "$(j[1])", "$(j[3])" ],""")
end
println(outputfile, "],\n")
end
println(outputfile, ")\n")
end
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 3 additions & 2 deletions deps/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ include_directories(${nemo_includes})
include_directories(${singular_includes})
include_directories(${singular_includes}/singular)

SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -g" )
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${JULIA_LIB_DIR} -Wl,-rpath,${JULIA_LIB_DIR} -L${singular_libdir} -Wl,-rpath,${singular_libdir}" )

add_library(singularwrap SHARED singular.cpp rings.cpp coeffs.cpp ideals.cpp matrices.cpp coeff_rings.cpp)
add_library(singularwrap SHARED singular.cpp rings.cpp coeffs.cpp ideals.cpp matrices.cpp caller.cpp coeff_rings.cpp)

target_link_libraries(singularwrap JlCxx::cxxwrap_julia -ljulia "-lSingular -lpolys -lsingular_resources -lfactory -lomalloc -ldl")

install(TARGETS
Expand Down
Loading