From 143684731ef878fcdc5a419927fd69f5ab3c45c9 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Wed, 3 Feb 2016 09:22:23 +0000 Subject: [PATCH] foreign files --- CMakeLists.txt | 13 ++++-- cmake/Sources.cmake | 5 +-- config.h.cmake | 10 ++++- library/dialect/swi/CMakeLists.txt | 1 + library/dialect/swi/fli/CMakeLists.txt | 13 +++--- library/system.yap | 13 +++--- os/iopreds.c | 6 +-- packages/jpl/CMakeLists.txt | 57 ++++++++++---------------- packages/jpl/jpl.pl | 14 ++++--- packages/jpl/src/c/CMakeLists.txt | 6 +-- packages/jpl/src/c/jpl.c | 2 +- packages/real/real.pl | 4 +- pl/preds.yap | 12 +++--- pl/protect.yap | 2 +- pl/qly.yap | 8 +++- 15 files changed, 87 insertions(+), 79 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99c505b55..d5cee0a3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,12 +6,16 @@ project(YAP) -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required (VERSION 2.8) # where we have most scripts # set path to additional CMake modules set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) +include(disallow) + +disallow_intree_builds() + # set(CMAKE_BUILD_TYPE Debug) @@ -113,8 +117,9 @@ add_library(libYap ${HEADERS} $ $ - $ - ) + $ + $ +) set_property(DIRECTORY PROPERTY CXX_STANDARD 11) @@ -411,7 +416,7 @@ add_subDIRECTORY (packages/raptor) add_subDIRECTORY (packages/xml) -add_subDIRECTORY (docs) +# add_subDIRECTORY (docs) # add_subDIRECTORY (packages/cuda) diff --git a/cmake/Sources.cmake b/cmake/Sources.cmake index ce735dc05..71198919d 100644 --- a/cmake/Sources.cmake +++ b/cmake/Sources.cmake @@ -79,8 +79,6 @@ set (ENGINE_SOURCES C/utilpreds.c C/yap-args.c C/write.c - library/dialect/swi/fli/swi.c - library/dialect/swi/fli/blobs.c C/udi.c #packages/udi/rtree.c #packages/udi/rtree_udi.c @@ -161,8 +159,7 @@ set(C_INTERFACE_SOURCES CXX/yapdb.hh CXX/yapi.hh BEAM/eam.h BEAM/eamamasm.h - library/dialect/swi/fli/swi.h - ) + ) diff --git a/config.h.cmake b/config.h.cmake index 11b4b1e4e..7740acd90 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1913,7 +1913,15 @@ signal. */ /* library search variable */ #ifndef SO_PATH -#define SO_PATH "${dlls}" +#ifdef __APPLE__ +#define SO_PATH "DYLD_LIBRARY_PATH" +#elif _WIN32 +#define SO_PATH "PATH" +#elif __unix__ +#define SO_PATH "LD_LIBRARY_PATH" +#else +#define SO_PATH NULL +#endif #endif /* enable condor distributed execution, static compilation */ diff --git a/library/dialect/swi/CMakeLists.txt b/library/dialect/swi/CMakeLists.txt index 639413e30..bc544e9cc 100644 --- a/library/dialect/swi/CMakeLists.txt +++ b/library/dialect/swi/CMakeLists.txt @@ -4,6 +4,7 @@ set (SDIALECTS_PL syspred_options.pl ) +add_SubDirectory( fli ) install(FILES ${SDIALECTS_PL} DESTINATION ${libpl}/dialect/swi diff --git a/library/dialect/swi/fli/CMakeLists.txt b/library/dialect/swi/fli/CMakeLists.txt index cc69baf67..6e566a8dd 100644 --- a/library/dialect/swi/fli/CMakeLists.txt +++ b/library/dialect/swi/fli/CMakeLists.txt @@ -1,24 +1,25 @@ -set (LIBSWIFLI_SOURCES +set (LIBSWI_SOURCES swi.c blobs.c) set (POSITION_INDEPENDENT_CODE TRUE) -add_library (libSWIFLi OBJECT - ${LIBSWIFLI_SOURCES}) +add_library (libswi OBJECT + ${LIBSWI_SOURCES}) -set_target_properties(libSWIFLi +set_target_properties(libswi PROPERTIES # RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION} # SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION} - POSITION_INDEPENDENT_CODE TRUE - OUTPUT_NAME swiFLI + POSITION_INDEPENDENT_CODE ON ) include_directories (../../../H ../.../../include ../os ${CMAKE_BINARY_DIR} ${GMP_INCLUDE_DIR}) target_link_libraries( libYap) +set (YAP_SWILIB $ ) + set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GMP_INCLUDE_DIR} ) #set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${GMP_LIBRARIES} ) diff --git a/library/system.yap b/library/system.yap index 828d2495e..1a2144edc 100644 --- a/library/system.yap +++ b/library/system.yap @@ -27,7 +27,7 @@ -:- module( operating_system_support, +:- module(operating_system_support, [ datime/1, delete_file/1, @@ -35,8 +35,7 @@ directory_files/2, environ/2, exec/3, - file_exists/1, - file_exists/2, + file_exists/2, file_property/2, host_id/1, host_name/1, @@ -46,7 +45,7 @@ mktemp/2, make_directory/1, popen/3, - rename_file/2, + rename_file/2, shell/0, shell/1, shell/2, @@ -142,7 +141,7 @@ recursively, and `ignore` if errors are not to be reported. This example is equivalent to using the delete_file/1 predicate: ~~~~~ - ?- delete_file(x, [recursive]). + ?- delete_file(x, [recursive]). ~~~~~ @@ -266,7 +265,7 @@ tmpnam/1 instead. The `mktime/2` procedure receives a term of the form _datime(+ _Year_, + _Month_, + _DayOfTheMonth_, + _Hour_, + _Minute_, + _Second_)_ and -returns the number of _Seconds_ elapsed since 00:00:00 on January 1, + returns the number of _Seconds_ elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC). The user provides information on _Year_, _Month_, _DayOfTheMonth_, _Hour_, _Minute_, and _Second_. The _Hour_ is given on local time. This function uses the @@ -558,7 +557,7 @@ file_property(File, Type, Size, Date, Permissions, LinkName) :- file_property(File, Type, Size, Date, Permissions, LinkName, Error), handle_system_internal(Error, off, file_property(File)). - + file_exists(File, Permissions) :- var(File), !, throw(error(instantiation_error,file_exists(File, Permissions))). diff --git a/os/iopreds.c b/os/iopreds.c index e71ba14d0..ae750b2d8 100644 --- a/os/iopreds.c +++ b/os/iopreds.c @@ -1433,10 +1433,10 @@ static Int open4(USES_REGS1) { /* '$open'(+File,+Mode,?Stream,-ReturnCode) */ static Int p_file_expansion(USES_REGS1) { /* '$file_expansion'(+File,-Name) */ Term file_name = Deref(ARG1); - + /* we know file_name is bound */ - if (!IsAtomTerm(file_name)) { - PlIOError(TYPE_ERROR_ATOM, file_name, "absolute_file_name/3"); + if (IsVarTerm(file_name)) { + PlIOError(INSTANTIATION_ERROR, file_name, "absolute_file_name/3"); return (FALSE); } if (!Yap_TrueFileName(RepAtom(AtomOfTerm(file_name))->StrOfAE, diff --git a/packages/jpl/CMakeLists.txt b/packages/jpl/CMakeLists.txt index b1f131a1a..fe41449cb 100644 --- a/packages/jpl/CMakeLists.txt +++ b/packages/jpl/CMakeLists.txt @@ -11,31 +11,31 @@ macro_log_feature (Java_Development_FOUND "Java" "http://www.java.org" FALSE) if (Java_Development_FOUND) - # Java_JAVA_EXECUTABLE = the full path to the Java runtime - # Java_JAVAC_EXECUTABLE = the full path to the Java compiler - # Java_JAVAH_EXECUTABLE = the full path to the Java header generator - # Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator - # Java_JAR_EXECUTABLE = the full path to the Java archiver - # Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 - # Java_VERSION_MAJOR = The major version of the package found. - # Java_VERSION_MINOR = The minor version of the package found. - # Java_VERSION_PATCH = The patch version of the package found. - # Java_VERSION_TWEAK = The tweak version of the package found (after '_') - # Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) - # JAVA_LIBRARIES - path to the java library - # JAVA_INCLUDE_PATH - path to where Java.h is found (deprecated) - # JAVA_INCLUDE_DIRS - path to where Java.h is found - # JAVA_DEBUG_LIBRARIES - path to the debug library (deprecated) - # JAVALIBS_VERSION_STRING - version of the Java libs found (since CMake 2.8.8) - # + + find_package(JNI) + include(UseJava) + # + # Java_JAVA_EXECUTABLE = the full path to the Java runtime + # Java_JAVAC_EXECUTABLE = the full path to the Java compiler + # Java_JAVAH_EXECUTABLE = the full path to the Java header generator + # Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator + # Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler + # Java_JAR_EXECUTABLE = the full path to the Java archiver + # Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer + # Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 + # Java_VERSION_MAJOR = The major version of the package found. + # Java_VERSION_MINOR = The minor version of the package found. + # Java_VERSION_PATCH = The patch version of the package found. + # Java_VERSION_TWEAK = The tweak version of the package found (after '_') + # Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) # # The Java_ADDITIONAL_VERSIONS variable can be used to specify a list # of version numbers that should be taken into account when searching # for Java. You need to set this variable before calling # find_package(JavaLibs). # - macro_optional_find_package(JNI ON) + #macro_optional_find_package(JNI ON) # JNI_INCLUDE_DIRS = the include dirs to use # JNI_LIBRARIES = the libraries to use # JNI_FOUND = TRUE if JNI headers and libraries were found. @@ -45,23 +45,10 @@ if (Java_Development_FOUND) # JAVA_INCLUDE_PATH2 = the include path to jni_md.h # JAVA_AWT_INCLUDE_PATH = the include path to jawt.h - add_library (jplYap SHARED src/c/jpl.c) - - add_subdirectory (src/java) - - include_directories (${JAVA_INCLUDE_DIRS} ${JNI_INCLUDE_DIRS}) - - target_link_libraries(jplYap libYap ${JAVA_LIBRARIES} ${JNI_LIBRARIES}) - - set_target_properties(jplYap PROPERTIES - OUTPUT_NAME jpl ) - - set(YAP_SYSTEM_OPTIONS "jpl " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE) - - install(TARGETS jplYap - LIBRARY DESTINATION ${dlls} - ) - + add_subdirectory (src/c) + + add_subdirectory (src/java) + install(FILES jpl.pl DESTINATION ${libpl} ) diff --git a/packages/jpl/jpl.pl b/packages/jpl/jpl.pl index 0f52acd8a..d299343f5 100644 --- a/packages/jpl/jpl.pl +++ b/packages/jpl/jpl.pl @@ -4488,8 +4488,8 @@ search_path_separator(:). % we do not check for that. check_java_environment :- - check_lib(java), - check_lib(jvm). + check_lib(jvm), + check_lib(java). check_lib(Name) :- check_shared_object(Name, File, EnvVar, Absolute), @@ -4666,13 +4666,17 @@ java_home(Home) :- atomic_list_concat([Key0, Version], /, Key), win_registry_get_value(Key, 'JavaHome', WinHome), prolog_to_os_filename(Home, WinHome), - exists_directory(Home), !. + exists_directory(Home). :- else. java_home(Home) :- member(Home, [ '/usr/lib/java', - '/usr/local/lib/java' + '/usr/lib/jvm', + '/usr/lib/jvm/jre', + '/usr/local/lib/java', + '/usr/local/lib/jvm', + '/usr/local/lib/jvm/jre' ]), - exists_directory(Home), !. + exists_directory(Home). :- endif. :- dynamic diff --git a/packages/jpl/src/c/CMakeLists.txt b/packages/jpl/src/c/CMakeLists.txt index 91ef655c5..b8d5f8849 100644 --- a/packages/jpl/src/c/CMakeLists.txt +++ b/packages/jpl/src/c/CMakeLists.txt @@ -6,10 +6,10 @@ include_directories (${JAVA_INCLUDE_DIRS} ${JNI_INCLUDE_DIRS} ) target_link_libraries(jplYap libYap ${JNI_LIBRARIES} ${JAVA_LIBRARIES}) set_target_properties(jplYap PROPERTIES - OUTPUT_NAME jpl ) - - set(YAP_SYSTEM_OPTIONS "jpl " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE) + OUTPUT_NAME jpl + INSTALL_RPATH_USE_LINK_PATH TRUE ) + # set(YAP_SYSTEM_OPTIONS "jpl " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE) install(TARGETS jplYap LIBRARY DESTINATION ${dlls} ) diff --git a/packages/jpl/src/c/jpl.c b/packages/jpl/src/c/jpl.c index e0fdfed1d..03a7c3fb7 100755 --- a/packages/jpl/src/c/jpl.c +++ b/packages/jpl/src/c/jpl.c @@ -1969,7 +1969,7 @@ jni_ensure_jvm_plc(void) #if __YAP_PROLOG__ -#include "hacks.c" +#include "hacks.h" #endif /* NB after any JNI call which clearly indicates success, */ diff --git a/packages/real/real.pl b/packages/real/real.pl index 104a4caca..812d7e857 100755 --- a/packages/real/real.pl +++ b/packages/real/real.pl @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Author: Nicos Angelopoulos, Vitor Santos Costa, Jan Wielemaker % E-mail: Nicos Angelopoulos -% Copyright (C): Nicos Angelopoulos, Universidade do Porto, VU University Amsterdam + % Copyright (C): Nicos Angelopoulos, Universidade do Porto, VU University Amsterdam %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % This file is part of real @@ -49,12 +49,12 @@ op(100, fy, '.') ]). + :- use_module(library(shlib)). :- use_module(library(lists)). :- use_module(library(apply_macros)). :- use_module(library(charsio)). :- use_module(library(readutil)). -:- use_module(library(debug)). :- dynamic( real:r_started/1 ). diff --git a/pl/preds.yap b/pl/preds.yap index 832823a17..fd2a7b41f 100644 --- a/pl/preds.yap +++ b/pl/preds.yap @@ -604,11 +604,11 @@ Defines the relation: _P_ is a currently defined predicate whose name is the at */ current_predicate(A,T0) :- '$yap_strip_module'(T0, M, T), - ( - '$current_predicate'(A,M, T, user) + ( + '$current_predicate'(A,M, T, user) ; - '$imported_predicate'(T, M, T1, M1), - \+ '$is_system_predicate'(T1,M1) + '$imported_predicate'(T, M, T1, M1), + \+ '$is_system_predicate'(T1,M1) ). /** @pred system_predicate( ?_P_ ) @@ -661,9 +661,9 @@ system_predicate(P0) :- current_predicate(F0) :- '$yap_strip_module'(F0, M, F), (var(F) -> - F = A/N, + F = A/N, current_predicate(A, M:S), - functor(S, A, N) + functor(S, A, N) ; ( functor(F,AN,2) diff --git a/pl/protect.yap b/pl/protect.yap index cdba357d5..c9ff256e9 100755 --- a/pl/protect.yap +++ b/pl/protect.yap @@ -20,7 +20,7 @@ xc/************************************************************************* % This protects all code from further changes % and also makes it impossible from some predicates to be seen '$protect' :- - '$current_predicate'(Name,M,P,_),riteln(P), + '$current_predicate'(Name,M,P,_), M \= user, functor(P,Name,Arity), '$new_system_predicate'(Name,Arity,M), diff --git a/pl/qly.yap b/pl/qly.yap index c54d3aadd..f044bfd80 100755 --- a/pl/qly.yap +++ b/pl/qly.yap @@ -318,6 +318,9 @@ qend_program :- prompt(_,'| '), catch(once(user:G),Error,user:'$Error'(Error)), fail. +'$init_from_saved_state_and_args' :- + '$protect', + fail. '$init_from_saved_state_and_args'. '$init_path_extensions' :- @@ -371,6 +374,9 @@ qend_program :- call(db_open(mysql,myddas,Host/Db,User,Pass)), '$myddas_import_all', fail. +'$startup_goals' :- + '$protect', + fail. '$startup_goals'. % @@ -475,7 +481,7 @@ qsave_module(Mod) :- qsave_module(Mod, OF). /** -@pred restore(+ _F_) + @pred restore(+ _F_) Restores a previously saved state of YAP from file _F_. */