Merge branch 'master' of github.com:vscosta/yap-6.3

This commit is contained in:
Vitor Santos Costa 2017-11-18 00:27:26 +00:00
commit 484213efb6
21 changed files with 229 additions and 149 deletions

View File

@ -88,6 +88,7 @@ struct foreign_context {
struct PL_local_data *engine; /* invoking engine */
};
X_API bool python_in_python;
X_API int YAP_Reset(yap_reset_t mode);
@ -2426,7 +2427,6 @@ static void do_bootfile(const char *bootfilename USES_REGS) {
/* ignore repeated calls to YAP_Init */
if (YAP_initialized)
return YAP_FOUND_BOOT_ERROR;
Yap_embedded = yap_init->Embedded;
Yap_page_size = Yap_InitPageSize(); /* init memory page size, required by
later functions */

View File

@ -79,9 +79,8 @@ char *Yap_FindExecutable(void) {
}
return "yap";
#elif defined(__linux__)
enum { BUFFERSIZE = 1024 };
char *buf = malloc(BUFFERSIZE);
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
char *buf = malloc(YAP_FILENAME_MAX);
ssize_t len = readlink("/proc/self/exe", buf, YAP_FILENAME_MAX - 1);
if (len != -1) {
buf[len] = '\0';
@ -194,7 +193,6 @@ static Int LoadForeign(StringList ofiles, StringList libs, char *proc_name,
/* load libraries first so that their symbols are available to
other routines */
/* dlopen wants to follow the LD_CONFIG_PATH */
const char *file = AtomName(ofiles->name);
if (!Yap_findFile(file, NULL, NULL, LOCAL_FileNameBuf, true, YAP_OBJ, true,
true)) {

View File

@ -79,11 +79,18 @@ static char *Yap_AlwaysAllocCodeSpace(UInt size) {
return out;
}
static void QLYR_ERROR(qlfr_err_t my_err) {
#define QLYR_ERROR(err) \
QLYR_ERROR__(__FILE__, __FUNCTION__, __LINE__, err)
static void QLYR_ERROR__(const char *file, const char *function, int lineno,
qlfr_err_t my_err) {
// __android_log_print(ANDROID_LOG_INFO, "YAP ", "error %s in saved state
// %s",GLOBAL_RestoreFile, qlyr_error[my_err]);
Yap_Error(SYSTEM_ERROR_SAVED_STATE, TermNil, "error %s in saved state %s",
GLOBAL_RestoreFile, qlyr_error[my_err]);
Yap_Error__(file, function, lineno, SYSTEM_ERROR_SAVED_STATE, TermNil, "error %s in saved state %s",
GLOBAL_RestoreFile, qlyr_error[my_err]);
Yap_exit(1);
}
@ -638,7 +645,7 @@ static bool checkChars(FILE *stream, char s[]) {
}
static Atom do_header(FILE *stream) {
char s[2560], *p = s, ch;
char s[2048], *p = s, ch;
Atom at;
if (!checkChars(stream, "#!/bin/sh\nexec_dir=${YAPBINDIR:-"))
@ -1044,6 +1051,8 @@ static void ReInitProlog(void) {
static Int qload_program(USES_REGS1) {
FILE *stream;
Term t1 = Deref(ARG1);
if (IsVarTerm(t1)) {

View File

@ -727,14 +727,15 @@ static size_t save_ops(FILE *stream, Term mod) {
return 1;
}
static int save_header(FILE *stream, char type[]) {
char msg[256 * 16];
static size_t save_header(FILE *stream, char type[]) {
char msg[2048];
memset(msg, 0, 2048);
sprintf(msg,
"#!/bin/sh\nexec_dir=${YAPBINDIR:-%s}\nexec $exec_dir/yap $0 "
"\"$@\"\n%s %s\n",
YAP_BINDIR, type, YAP_FULL_VERSION);
return save_bytes(stream, msg, strlen(msg) + 1);
return save_bytes(stream, msg, 2048);
}
static size_t save_module(FILE *stream, Term mod) {

View File

@ -45,6 +45,18 @@
#include <direct.h>
#endif
#ifndef YAP_ROOTDIR
#include <libgen.h>
char
*YAP_BINDIR,
*YAP_ROOTDIR,
*YAP_SHAREDIR,
*YAP_LIBDIR,
*YAP_YAPLIB;
#endif
static void print_usage(void) {
fprintf(stderr, "\n[ Valid switches for command line arguments: ]\n");
fprintf(stderr, " -? Shows this screen\n");
@ -147,6 +159,7 @@ YAP_file_type_t Yap_InitDefaults(YAP_init_args *iap, char saved_state[],
#endif
iap->Argc = argc;
iap->Argv = argv;
iap->YapLibDir = YAP_YAPLIB;
return iap->boot_file_type;
}
@ -155,6 +168,33 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
char *p;
size_t *ssize;
#ifndef YAP_ROOTDIR
{
char *b0=Yap_FindExecutable(), *b1, *b2;
char b[YAP_FILENAME_MAX + 1];
strncpy(b, b0, YAP_FILENAME_MAX);
b1 = dirname(b);
YAP_BINDIR = malloc(strlen(b1)+1);
strcpy(YAP_BINDIR, b1);
b2 = dirname(b1);
YAP_ROOTDIR = malloc(strlen(b2)+1);
strcpy(YAP_ROOTDIR, b2);
strncpy(b, YAP_ROOTDIR, YAP_FILENAME_MAX);
strncat( b, "/share", YAP_FILENAME_MAX);
YAP_SHAREDIR= malloc(strlen(b)+1);
strcpy(YAP_SHAREDIR, b);
strncpy(b, YAP_ROOTDIR, YAP_FILENAME_MAX);
strncat( b, "/lib", YAP_FILENAME_MAX);
YAP_LIBDIR= malloc(strlen(b)+1);
strcpy(YAP_LIBDIR, b);
strncpy(b, YAP_ROOTDIR, YAP_FILENAME_MAX);
strncat( b, "/lib/Yap", YAP_FILENAME_MAX);
YAP_YAPLIB= malloc(strlen(b)+1);
strcpy(YAP_YAPLIB, b);
};
#endif
Yap_InitDefaults(iap, NULL, argc, argv);
while (--argc > 0) {
p = *++argv;

View File

@ -222,7 +222,7 @@ if (ANACONDA)
#set( CMAKE_INSTALL_PREFIX $ENV{PREFIX} )
set( PYTHON_LIBRARY $ENV{PREFIX}/lib/libpython$ENV{PY_VER}m$ENV{SHLIB_EXT})
set( PYTHON_INCLUDE_DIR $ENV{PREFIX}/include/python$ENV{PY_VER}m)
set(YAP_IS_MOVABLE 1)
endif()
ADD_CUSTOM_TARGET(run_install COMMAND ${CMAKE_MAKE_PROGRAM} install)
@ -504,12 +504,13 @@ add_corelib( # Sets the name of the library.
)
if (WIN32)
target_link_libraries(libYap ${WINDLLS})
if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES)
target_link_libraries(libYap ${WINDLLS})
if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES)
target_link_libraries(libYap ${PYTHON_LIBRARIES})
endif ()
endif (WIN32)
target_link_libraries(libYap m)
if (GMP_FOUND)
#config.h needs this (TODO: change in code latter)
@ -546,31 +547,25 @@ set_property(DIRECTORY PROPERTY CXX_STANDARD 11)
# rpath stuff, hopefully it works
# use, i.e. don't skip the full RPATH for the build tree
# SET(CMAKE_SKIP_BUILD_RPATH FALSE)
#SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
# SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
#SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
# SET(CMAKE_INSTALL_RPATH ${CMAKE_CURRENT_BUILD_PATH})
# SET(CMAKE_INSTALL_RPATH ${CMAKE_TOP_BINARY_DIR})
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory#LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir}" isSystemDir)
# IF("${isSystemDir}" STREQUAL "-1")
if (ANACONDA)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(CMAKE_INSTALL_RPATH ${CMAKE_BINARY_DIR})
else ()
SET(CMAKE_INSTALL_RPATH "${libdir}")
endif ()
# ENDIF("${isSystemDir}" STREQUAL "-1")
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir}" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH ${libdir})
ENDIF("${isSystemDir}" STREQUAL "-1")
include_directories(H
H/generated

View File

@ -193,6 +193,10 @@ static inline Term options(Term inp) {
return Yap_IsGroundTerm(inp) ? inp : TermZERO;
}
static inline Term rootdir(Term inp) {
return MkAtomTerm(Yap_LookupAtom(YAP_ROOTDIR));
}
// INLINE_ONLY inline EXTERN Term ok( Term inp );
static inline Term ok(Term inp) { return inp; }

View File

@ -236,7 +236,7 @@ process, namely, on choice-points.
YAP_FLAG(GMP_VERSION_FLAG, "gmp_version", false, isatom, "4.8.12", NULL),
YAP_FLAG(HALT_AFTER_CONSULT_FLAG, "halt_after_consult", false, booleanFlag,
"false", NULL),
YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL), /**< home `
/* YAP_FLAG(HOME_FLAG, "home", false, isatom, rootdir, NULL),*/ /**< home `
the root of the YAP installation, by default `/usr/local` in Unix or
`c:\Yap` in Windows system. Can only be set at configure time

View File

@ -1932,8 +1932,10 @@ significant byte first (like Motorola and SPARC, unlike Intel). */
#define YAP_PL_SRCDIR "${PROJECT_SOURCE_DIR}/pl"
#endif
#ifndef YAP_SHAREDIR
#define YAP_SHAREDIR "${YAP_SHAREDIR}"
/* YAP_IS_MOVABLE */
#ifndef YAP_IS_MOVABLE
#cmakedefine YAP_IS_MOVABLE "${YAP_IS_MOVABLE}"
#endif
/* saved state file */
@ -1961,24 +1963,26 @@ significant byte first (like Motorola and SPARC, unlike Intel). */
#define YAP_COMPILED_AT "${YAP_TIMESTAMP}@${YAP_SITE}"
#endif
/* name of YAP library */
#ifndef YAP_YAPLIB
#define YAP_YAPLIB "${YAP_YAPLIB}"
#endif
/* name of YAP library */
#ifndef YAP_BINDIR
#define YAP_BINDIR "${bindir}"
#endif
/* name of YAP library */
#ifndef YAP_IS_MOVABLE
/* name of YAP instaii */
#ifndef YAP_ROOTDIR
#define YAP_ROOTDIR "${YAP_ROOTDIR}"
#endif
/* name of YAP binaries */
#ifndef YAP_BINDIR
#define YAP_BINDIR "${YAP_ROOTDIR}/bin"
#endif
/* name of YAP library */
#ifndef YAP_LIBDIR
#define YAP_LIBDIR "${YAP_LIBDIR}"
#define YAP_LIBDIR "${YAP_ROOTDIR}/lib"
#endif
/* name of YAP DLL library */
#ifndef YAP_YAPLIB
#define YAP_YAPLIB "${YAP_LIBDIR}/Yap"
#endif
/* name of YAP JIT library */
@ -1986,6 +1990,21 @@ significant byte first (like Motorola and SPARC, unlike Intel). */
#define YAP_YAPJITLIB "${YAP_YAPJITLIB}"
#endif
#ifndef YAP_SHAREDIR
#define YAP_SHAREDIR "${YAP_ROOTDIR}/share"
#endif
#else
extern char
*YAP_BINDIR,
*YAP_ROOTDIR,
*YAP_SHAREDIR,
*YAP_LIBDIR,
*YAP_YAPLIB;
#endif
/* HP-UX old socket stuff */
#ifndef _XOPEN_SOURCE
#cmakedefine _XOPEN_SOURCE "${_XOPEN_SOURCE}"

View File

@ -1,31 +1,22 @@
#!/bin/bash
export MACOSX_DEPLOYMENT_TARGET=10.9
# export CC=$SYS_PREFIX/bin/clang
# export CXX=$SYS_PREFIX/bin/clang++
export CMAKE_BUILD_TYPE=Debug
export CMAKE=$PREFIX/bin/cmake
export MAKE=$PREFIX/bin/make
export GENERATOR="-GNinja"
#export CMAKE_INCLUDE_PATH=$PREFIX/include
#export CMAKE_LIBRARY_PATH=$PREFIX/lib
#export CMAKE_INSTALL_PREFIX=$PREFIX
#export PYTHON_EXECUTABLE="$PYTHON"
#export PYTHON_LIBRARY="$CMAKE_LIBRARY_PATH/libpython${PY_VER}m$SHLIB_EXT"
#export PYTHON_INCLUDE_DIR="$CMAKE_INCLUDE_PATH/python$PY_VER"m
#export R_COMMAND=$R
export PATH=$PREFIX/bin:$SYS_PREFIX/bin:$PATH
mkdir $PREFIX/conda
cd $PREFIX/conda
# The datarootdir option places the docs into a temp folder that won't
$CMAKE --build=. --target=install --DPATH=$PATH\
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
$CMAKE --build=. --target=install \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
$RECIPE_DIR/..
make -j install CMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX"
#./yap -B
#
make -j install
# Remove the created lib64 directory
rm -rf $PREFIX/conda

View File

@ -3,6 +3,8 @@ package:
version: 1.8.0
requirements:
ignore_prefix_files:
- startup.yss
build:
- cmake
- swig

View File

@ -1242,7 +1242,8 @@ const char *Yap_findFile(const char *isource, const char *idef,
if (ftype == YAP_PL) {
root = YAP_SHAREDIR;
} else if (ftype == YAP_BOOT_PL) {
root = YAP_SHAREDIR "/pl";
root = YAP_SHAREDIR;
strcat(root,"/pl");
} else {
root = YAP_LIBDIR;
}
@ -1761,21 +1762,24 @@ static Int p_yap_paths(USES_REGS1) {
if (env_destdir) {
strncat(destdir, env_destdir, YAP_FILENAME_MAX);
strncat(destdir, "/" YAP_LIBDIR, YAP_FILENAME_MAX);
strncat(destdir, "/", YAP_FILENAME_MAX);
strncat(destdir, YAP_LIBDIR, YAP_FILENAME_MAX);
out1 = MkAtomTerm(Yap_LookupAtom(destdir));
} else {
out1 = MkAtomTerm(Yap_LookupAtom(YAP_LIBDIR));
}
if (env_destdir) {
strncat(destdir, env_destdir, YAP_FILENAME_MAX);
strncat(destdir, "/" YAP_SHAREDIR, YAP_FILENAME_MAX);
strncat(destdir, "/", YAP_FILENAME_MAX);
strncat(destdir, YAP_SHAREDIR, YAP_FILENAME_MAX);
out2 = MkAtomTerm(Yap_LookupAtom(destdir));
} else {
out2 = MkAtomTerm(Yap_LookupAtom(YAP_SHAREDIR));
}
if (env_destdir) {
strncat(destdir, env_destdir, YAP_FILENAME_MAX);
strncat(destdir, "/" YAP_BINDIR, YAP_FILENAME_MAX);
strncat(destdir, "/", YAP_FILENAME_MAX);
strncat(destdir, YAP_BINDIR, YAP_FILENAME_MAX);
out3 = MkAtomTerm(Yap_LookupAtom(destdir));
} else {
out3 = MkAtomTerm(Yap_LookupAtom(YAP_BINDIR));

View File

@ -64,7 +64,7 @@ if (CMAKE_MAJOR_VERSION GREATER 2)
set_target_properties (HorusCli PROPERTIES OUTPUT_NAME hcli CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
target_link_libraries(HorusCli horus )
target_link_libraries(HorusCli m horus )
install(TARGETS horus HorusCli

View File

@ -35,11 +35,13 @@ IF (CUDD_FOUND)
if(DEFINED YAP_MAJOR_VERSION)
TARGET_LINK_LIBRARIES(cudd
${CUDD_LIBRARIES}
m
libYap
)
else()
TARGET_LINK_LIBRARIES(cudd
${CUDD_LIBRARIES}
m
${YAP_LIBRARY}
)
endif()

View File

@ -14,7 +14,8 @@ set_target_properties (Problogbdd PROPERTIES
)
target_link_libraries(Problogbdd
${CUDD_LIBRARIES}
${CUDD_LIBRARIES}
m
libYap
)

View File

@ -18,7 +18,8 @@ set_target_properties (Problogbdd-Lfi PROPERTIES
)
target_link_libraries(Problogbdd-Lfi
${CUDD_LIBRARIES}
${CUDD_LIBRARIES}
m
libYap
)

View File

@ -139,6 +139,7 @@ IF (CUDD_FOUND)
TARGET_LINK_LIBRARIES(bddem
${CUDD_LIBRARIES}
libYap
m
)
set_target_properties (bddem PROPERTIES

View File

@ -15,6 +15,7 @@ set_target_properties (LPADbdd PROPERTIES
)
target_link_libraries(LPADbdd
m
${CUDD_LIBRARIES}
libYap
)

View File

@ -4,9 +4,22 @@
YAP_KERNEL.md
)
set (PL_SOURCES
yap_ipython/prolog/jupyter.yap
)
set (PYTHON_SOURCES
yap_ipython/core/getipython.py
yap_ipython/core/__init__.py
yap_ipython/core/interactiveshell.py
yap_ipython/core/modulefind.py
yap_ipython/core/oinspect.py
yap_ipython/core/release.py
yap_ipython/core/shellapp.py
yap_ipython/display.py
yap_ipython/__init__.py
yap_ipython/shellapp.py
yap_kernel_launcher.py
data_kernelspec/kernel.json
yap_kernel/__init__.py
yap_kernel/__main__.py
yap_kernel/_version.py
@ -69,5 +82,5 @@
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --ignore-installed --no-deps .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
# install(FILES jupyter.yap
# DESTINATION ${libpl} )
install(FILES ${PL_FILES} DESTINATION ${libpl} )

View File

@ -106,9 +106,8 @@ class YAPInteractive(InteractiveShell):
super(YAPInteractive, self).__init__(**kwargs)
# type: (object, object) -> object
pjoin = os.path.join
here = os.path.dirname(__file__)
self.yapeng = yap4py.yapi.Engine()
self.yapeng.goal(use_module(pjoin(here, '../prolog/jupyter.yap')))
self.yapeng.goal(use_module(library("jupyter")))
self.q = None
self.run = False
self.os = ""

View File

@ -1,86 +1,85 @@
set(PL_BOOT_SOURCES
absf.yap
arith.yap
arithpreds.yap
arrays.yap
atoms.yap
attributes.yap
boot.yap
bootlists.yap
callcount.yap
checker.yap
consult.yap
control.yap
corout.yap
dbload.yap
debug.yap
depth_bound.yap
dialect.yap
directives.yap
eam.yap
error.yap
errors.yap
eval.yap
flags.yap
grammar.yap
ground.yap
hacks.yap
init.yap
listing.yap
load_foreign.yap
messages.yap
meta.yap
modules.yap
newmod.yap
os.yap
pathconf.yap
preddecls.yap
preddyns.yap
preds.yap
profile.yap
protect.yap
qly.yap
save.yap
setof.yap
signals.yap
sort.yap
spy.yap
statistics.yap
strict_iso.yap
swi.yap
tabling.yap
threads.yap
udi.yap
undefined.yap
utils.yap
yapor.yap
)
absf.yap
arith.yap
arithpreds.yap
arrays.yap
atoms.yap
attributes.yap
boot.yap
bootlists.yap
callcount.yap
checker.yap
consult.yap
control.yap
corout.yap
dbload.yap
debug.yap
depth_bound.yap
dialect.yap
directives.yap
eam.yap
error.yap
errors.yap
eval.yap
flags.yap
grammar.yap
ground.yap
hacks.yap
init.yap
listing.yap
load_foreign.yap
messages.yap
meta.yap
modules.yap
newmod.yap
os.yap
pathconf.yap
preddecls.yap
preddyns.yap
preds.yap
profile.yap
protect.yap
qly.yap
save.yap
setof.yap
signals.yap
sort.yap
spy.yap
statistics.yap
strict_iso.yap
swi.yap
tabling.yap
threads.yap
udi.yap
undefined.yap
utils.yap
yapor.yap
)
add_to_group( PL_BOOT_SOURCES pl_boot_library )
add_to_group(PL_BOOT_SOURCES pl_boot_library)
if (CMAKE_CROSSCOMPILING)
add_custom_target (STARTUP ALL SOURCES
DEPENDS ${PL_BOOT_SOURCES}
)
else()
add_custom_target (STARTUP ALL
DEPENDS ${YAP_STARTUP}
WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR}
)
add_custom_command (OUTPUT ${YAP_STARTUP}
COMMAND yap-bin -B
VERBATIM
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS yap-bin ${PL_SOURCES}
)
install (FILES ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
DESTINATION ${dlls}
)
add_custom_target(STARTUP ALL SOURCES
DEPENDS ${PL_BOOT_SOURCES}
)
else ()
add_custom_target(STARTUP ALL
DEPENDS ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
)
add_custom_command(OUTPUT ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
COMMAND ldd yap
COMMAND ./yap -B
VERBATIM
WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR}
DEPENDS ${PL_BOOT_SOURCES} yap-bin
)
install(FILES ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
DESTINATION ${dlls}
)
endif()
install (FILES ${PL_SOURCES}
DESTINATION ${libpl}/pl
)
install(FILES ${PL_SOURCES}
DESTINATION ${libpl}/pl
)