Skip to content

Commit

Permalink
Make saved state test shlibs available for test_installation
Browse files Browse the repository at this point in the history
  • Loading branch information
erlanger committed Feb 12, 2019
1 parent 0c1f5a5 commit 9ce4881
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,11 @@ endif(0)
add_custom_target(check
COMMAND ${PROG_SWIPL} -q -g test -t halt ${CMAKE_CURRENT_SOURCE_DIR}/test.pl)

add_custom_target(test_save_shlibs
ALL
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/Tests/save &&
${PROG_SWIPL} -q -g build_test_shlibs -t halt ${CMAKE_CURRENT_SOURCE_DIR}/Tests/save/test_saved_states.pl)

set(SWIPL_TEST_DIRS unprotected core attvar library charset eclipse clp
GC save)
if(MULTI_THREADED)
Expand Down
30 changes: 21 additions & 9 deletions src/Tests/save/test_saved_states.pl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
*/

:- module(test_saved_states,
[ test_saved_states/0
[ test_saved_states/0,
build_test_shlibs/0
]).

:- prolog_load_context(directory, Here),
Expand Down Expand Up @@ -197,19 +198,30 @@
remove_state(State) :-
catch(delete_file(State), _, true).

swipl_ld(SwiplLd) :-
current_prolog_flag(executable,SwiplExe),
file_directory_name(SwiplExe, Dir),
format(atom(SwiplLd0), "~w/swipl-ld",[Dir]),
prolog_to_os_filename(SwiplLd0,SwiplLd).

build_shlib(Name) :-
format(atom(Cmd), "swipl-ld -shared -fPIC -o input/~w.so input/~w.c",[Name, Name]),
shell(Cmd).
swipl_ld(SwiplLd),
format(atom(Cmd),
"~w -shared -fPIC -o input/~w.so input/~w.c",
[SwiplLd,Name, Name]),
shell(Cmd).

build_shlib(Name, Dep, DepDir) :-
format(atom(Cmd), "swipl-ld -shared -fPIC -L~w -l~w -o input/~w.so input/~w.c ",[DepDir, Dep, Name, Name]),
format(user_error, '~w~n', Cmd),
shell(Cmd).
swipl_ld(SwiplLd),
format(atom(Cmd),
"~w -shared -fPIC -L~w -l~w -o input/~w.so input/~w.c ",
[SwiplLd, DepDir, Dep, Name, Name]),
shell(Cmd).

build_test_shlibs :-
build_shlib("shlib_no_deps"),
build_shlib("libdep"),
build_shlib("shlib_with_dep", "dep", "input").
build_shlib("shlib_no_deps"),
build_shlib("libdep"),
build_shlib("shlib_with_dep", "dep", "input").

%% read_terms(+In:stream, -Data:list)
%
Expand Down

0 comments on commit 9ce4881

Please sign in to comment.