Skip to content

Commit

Permalink
Merge pull request oscar-system#104 from sebasguts/caller
Browse files Browse the repository at this point in the history
First version of caller for libs
  • Loading branch information
wbhart authored Sep 26, 2019
2 parents 2dad4e0 + c0f1e64 commit 3501be5
Show file tree
Hide file tree
Showing 23 changed files with 907 additions and 106 deletions.
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
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" )
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

0 comments on commit 3501be5

Please sign in to comment.