simplify boot
rename boot vars for consistency small fixes
This commit is contained in:
parent
54e3d48fb1
commit
f798372fb1
@ -1978,6 +1978,8 @@ X_API Int YAP_RunGoalOnce(Term t) {
|
||||
Yap_TrimTrail();
|
||||
}
|
||||
B = cut_pt;
|
||||
} else {
|
||||
Yap_CloseSlots(CSlot);
|
||||
}
|
||||
ASP = B->cp_env;
|
||||
ENV = (CELL *)ASP[E_E];
|
||||
|
@ -530,8 +530,6 @@ typedef struct scanner_internals {
|
||||
size_t CommentsBuffLim;
|
||||
} scanner_internals;
|
||||
|
||||
static struct stream_desc *inp0;
|
||||
|
||||
// standard get char, uses conversion table
|
||||
// and converts to wide
|
||||
static inline int getchr(struct stream_desc *inp) {
|
||||
|
2
C/text.c
2
C/text.c
@ -192,7 +192,7 @@ void *Realloc(void *pt, size_t sz USES_REGS) {
|
||||
* @return new object
|
||||
*/
|
||||
const void *MallocExportAsRO(const void *pt USES_REGS) {
|
||||
struct mblock *old = pt, *o = old-1;
|
||||
struct mblock *old = (void *)pt, *o = old-1;
|
||||
if (old == NULL)
|
||||
return NULL;
|
||||
size_t sz = o->sz;
|
||||
|
498
C/yap-args.c
498
C/yap-args.c
@ -145,19 +145,10 @@ static void init_globals(YAP_init_args *yap_init) {
|
||||
}
|
||||
}
|
||||
|
||||
static void start_modules(void) {
|
||||
Term cm = CurrentModule;
|
||||
size_t i;
|
||||
for (i = 0; i < n_mdelays; i++) {
|
||||
CurrentModule = MkAtomTerm(YAP_LookupAtom(m_delays[i].s));
|
||||
m_delays[i].f();
|
||||
}
|
||||
CurrentModule = cm;
|
||||
}
|
||||
|
||||
const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR,
|
||||
*Yap_PLDIR, *Yap_BOOTPLDIR, *Yap_BOOTSTRAPPLDIR, *Yap_COMMONSDIR,
|
||||
*Yap_STARTUP, *Yap_OUTPUT_STARTUP, *Yap_BOOTFILE;
|
||||
*Yap_STARTUP, *Yap_OUTPUT_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR;
|
||||
|
||||
/* do initial boot by consulting the file boot.yap */
|
||||
static void consult(const char *b_file USES_REGS) {
|
||||
@ -220,315 +211,171 @@ static void consult(const char *b_file USES_REGS) {
|
||||
pop_text_stack(lvl);
|
||||
}
|
||||
|
||||
/** @brief A simple language for detecting where YAP stuff can be found
|
||||
*
|
||||
* @long The options are
|
||||
* `[V]` use a configuration variable YAP_XXXDIR, prefixed by "DESTDIR"
|
||||
* `(V)PATH` compute V and add /PATH,
|
||||
* `$V` search the environment
|
||||
* `?V` search the WINDOWS registry
|
||||
* ~` search HOME
|
||||
* `@` query user option.
|
||||
*
|
||||
*/
|
||||
typedef struct config {
|
||||
char *name;
|
||||
const char **root;
|
||||
const char **lib;
|
||||
const char **share;
|
||||
const char **include;
|
||||
const char **pl;
|
||||
const char **commons;
|
||||
const char **dll;
|
||||
const char **ss;
|
||||
const char **oss;
|
||||
const char **bootpldir;
|
||||
const char **bootpl;
|
||||
} config_t;
|
||||
///
|
||||
///
|
||||
static const char * sel(bool dir, ...) {
|
||||
CACHE_REGS
|
||||
va_list args;
|
||||
va_start(args ,dir);
|
||||
while (true) {
|
||||
bool init = va_arg(args, int);
|
||||
const char *fmt = va_arg(args, char *);
|
||||
if (init) {
|
||||
va_end(args);
|
||||
return fmt;
|
||||
|
||||
#if __ANDROID__
|
||||
const char *gd_root[] = {"@RootDir", "/assets"};
|
||||
const char *gd_lib[] = {"@LibDir", "[lib]",
|
||||
"(root)/lib/"
|
||||
"x86"};
|
||||
const char *gd_share[] = {"@ShareDir", "(root)"};
|
||||
const char *gd_include[] = {"@IncludeDir", "[include]", "(root)/include"};
|
||||
const char *gd_dll[] = {"@DLLDir", "(lib)"};
|
||||
const char *gd_pl[] = {"@PlDir", "(share)/Yap", "@BootPlDir/../library"};
|
||||
const char *gd_commons[] = {"@CommonsDir", "(share)/PrologCommons"};
|
||||
const char *gd_ss[] = {"(dll)"};
|
||||
const char *gd_oss[] = {"."};
|
||||
const char *gd_bootpldir[] = {"@BootPlDir", "@PrologBootFile/..", "(pl)/pl"};
|
||||
const char *gd_bootpl[] = {"(bootpldir)"};
|
||||
#else
|
||||
const char *gd_root[] = {"@RootDir", "[root]", "(execdir)/.."};
|
||||
const char *gd_lib[] = {"@LibDir", "[lib]", "(root)/lib"};
|
||||
const char *gd_share[] = {"@ShareDir", "[share]", "(root)/share"};
|
||||
const char *gd_include[] = {"@IncludeDir", "[include]", "(root)/include"};
|
||||
const char *gd_dll[] = {"@DLLDir", "(lib)/Yap"};
|
||||
const char *gd_pl[] = {"@PlDir", "(share)/Yap", "@BootPlDir/../library"};
|
||||
const char *gd_commons[] = {"@CommonsDir", "(share)/PrologCommons"};
|
||||
const char *gd_ss[] = {"(dll)"};
|
||||
const char *gd_oss[] = {"."};
|
||||
const char *gd_bootpldir[] = {"@BootPlDir", "@PrologBootFile/..", "(pl)/pl"};
|
||||
const char *gd_bootpl[] = {"@PrologBootFile", "(bootpldir)/setup.yap"};
|
||||
#endif
|
||||
|
||||
static config_t *cfg(config_t *i) {
|
||||
i->root = gd_root;
|
||||
i->lib = gd_lib;
|
||||
i->share = gd_share;
|
||||
i->include = gd_include;
|
||||
i->dll = gd_dll;
|
||||
i->pl = gd_pl;
|
||||
i->commons = gd_commons;
|
||||
i->ss = gd_ss;
|
||||
i->oss = gd_oss;
|
||||
i->bootpldir = gd_bootpldir;
|
||||
i->bootpl = gd_bootpl;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search
|
||||
*/
|
||||
char *location(YAP_init_args *iap, const char *inp) {
|
||||
if (inp == NULL || inp[0] == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
char *out = Malloc(FILENAME_MAX + 1);
|
||||
out[0] = '\0';
|
||||
if (inp[0] == '(') {
|
||||
if (strstr(inp + 1, "root") == inp + 1 && Yap_ROOTDIR &&
|
||||
Yap_ROOTDIR[0] != '\0') {
|
||||
strcpy(out, Yap_ROOTDIR);
|
||||
strcat(out, inp + strlen("(root)"));
|
||||
} else if (strstr(inp + 1, "bin") == inp + 1 && Yap_BINDIR &&
|
||||
Yap_BINDIR[0] != '\0') {
|
||||
strcpy(out, Yap_BINDIR);
|
||||
strcat(out, inp + strlen("(bin)"));
|
||||
} else if (strstr(inp + 1, "lib") == inp + 1 && Yap_LIBDIR &&
|
||||
Yap_LIBDIR[0] != '\0') {
|
||||
strcpy(out, Yap_LIBDIR);
|
||||
strcat(out, inp + strlen("(lib)"));
|
||||
} else if (strstr(inp + 1, "dll") == inp + 1 && Yap_DLLDIR &&
|
||||
Yap_DLLDIR[0] != '\0') {
|
||||
strcpy(out, Yap_DLLDIR);
|
||||
strcat(out, inp + strlen("(dll)"));
|
||||
} else if (strstr(inp + 1, "share") == inp + 1 && Yap_SHAREDIR &&
|
||||
Yap_SHAREDIR[0] != '\0') {
|
||||
strcpy(out, Yap_SHAREDIR);
|
||||
strcat(out, inp + strlen("(share)"));
|
||||
} else if (strstr(inp + 1, "pl") == inp + 1 && Yap_PLDIR &&
|
||||
Yap_PLDIR[0] != '\0') {
|
||||
strcpy(out, Yap_PLDIR);
|
||||
strcat(out, inp + strlen("(pl)"));
|
||||
} else if (strstr(inp + 1, "bootpldir") == inp + 1 && Yap_BOOTPLDIR &&
|
||||
Yap_BOOTPLDIR[0] != '\0') {
|
||||
strcpy(out, Yap_BOOTPLDIR);
|
||||
strcat(out, inp + strlen("(bootpldir)"));
|
||||
} else if (strstr(inp + 1, "bootpl") == inp + 1 && Yap_BOOTFILE &&
|
||||
Yap_BOOTFILE[0] != '\0') {
|
||||
strcpy(out, Yap_BOOTFILE);
|
||||
strcat(out, inp + strlen("(bootpl)"));
|
||||
} else if (strstr(inp + 1, "execdir") == inp + 1) {
|
||||
const char *ex = Yap_AbsoluteFile(Yap_FindExecutable(), true);
|
||||
if (ex != NULL) {
|
||||
strcpy(out, dirname((char *)ex));
|
||||
strcat(out, "/");
|
||||
strcat(out, inp + strlen("(execdir)"));
|
||||
}
|
||||
}
|
||||
} else if (inp[0] == '@') {
|
||||
|
||||
if (strstr(inp + 1, "RootDir") == inp + 1) {
|
||||
const char *tmp = iap->RootDir;
|
||||
if (tmp && tmp[0])
|
||||
strcpy(out, tmp);
|
||||
} else if (strstr(inp + 1, "LibDir") == inp + 1) {
|
||||
const char *tmp = iap->LibDir;
|
||||
if (tmp && tmp[0])
|
||||
strcpy(out, tmp);
|
||||
} else if (strstr(inp + 1, "IncludeDir") == inp + 1) {
|
||||
const char *tmp = iap->IncludeDir;
|
||||
if (tmp && tmp[0])
|
||||
strcpy(out, tmp);
|
||||
} else if (strstr(inp + 1, "SharedDir") == inp + 1) {
|
||||
const char *tmp = iap->SharedDir;
|
||||
if (tmp && tmp[0])
|
||||
strcpy(out, tmp);
|
||||
} else if (strstr(inp + 1, "DLLDir") == inp + 1) {
|
||||
const char *tmp = iap->DLLDir;
|
||||
if (tmp && tmp[0])
|
||||
strcpy(out, tmp);
|
||||
} else if (strstr(inp + 1, "PlDir") == inp + 1) {
|
||||
const char *tmp = iap->PlDir;
|
||||
if (tmp && tmp[0])
|
||||
strcpy(out, tmp);
|
||||
} else if (strstr(inp + 1, "BootPlDir") == inp + 1) {
|
||||
const char *tmp = iap->BootPlDir;
|
||||
if (tmp && tmp[0])
|
||||
strcpy(out, tmp);
|
||||
} else if (strstr(inp + 1, "PrologBootFile") == inp + 1) {
|
||||
const char *tmp = iap->PrologBootFile;
|
||||
if (tmp && tmp[0])
|
||||
strcpy(out, tmp);
|
||||
} else if (strstr(inp + 1, "SavedState") == inp + 1) {
|
||||
const char *tmp = iap->SavedState;
|
||||
if (tmp && tmp[0])
|
||||
strcpy(out, tmp);
|
||||
}
|
||||
} else if (inp[0] == '$') {
|
||||
char *e;
|
||||
if ((e = getenv(inp + 1)) != NULL) {
|
||||
strcpy(out, e);
|
||||
}
|
||||
} else if (inp[0] == '?') {
|
||||
#if _WINDOWS_
|
||||
char *e;
|
||||
if ((e = Yap_RegistryGetString(inp + 1)) != NULL) {
|
||||
strcpy(out, e);
|
||||
}
|
||||
#endif
|
||||
} else if (inp[0] == '~') {
|
||||
char *e;
|
||||
if ((e = getenv("HOME")) != NULL) {
|
||||
if (inp[1] == '\0') {
|
||||
strcpy(out, e);
|
||||
} else if (inp[1] == '/') {
|
||||
strcpy(out, e);
|
||||
strcat(out, inp + 1);
|
||||
}
|
||||
}
|
||||
} else if (inp[0] == '[') {
|
||||
char *o = out;
|
||||
const char *e;
|
||||
if ((e = getenv("DESTDIR"))) {
|
||||
strcpy(out, e);
|
||||
o += strlen(e);
|
||||
}
|
||||
if (strstr(inp + 1, "root") == inp + 1) {
|
||||
#ifdef YAP_ROOTDIR
|
||||
strcpy(o, YAP_ROOTDIR);
|
||||
#endif
|
||||
} else if (strstr(inp + 1, "lib") == inp + 1) {
|
||||
#ifdef YAP_LIBDIR
|
||||
strcpy(o, YAP_LIBDIR);
|
||||
#endif
|
||||
} else if (strstr(inp + 1, "share") == inp + 1) {
|
||||
#ifdef YAP_SHAREDIR
|
||||
strcpy(o, YAP_SHAREDIR);
|
||||
#endif
|
||||
} else if (strstr(inp + 1, "dll") == inp + 1) {
|
||||
#ifdef YAP_DLLDIR
|
||||
strcpy(o, YAP_DLLDIR);
|
||||
#endif
|
||||
} else if (strstr(inp + 1, "pl") == inp + 1) {
|
||||
#ifdef YAP_PLDIR
|
||||
strcpy(o, YAP_PLDIR);
|
||||
#endif
|
||||
} else if (strstr(inp + 1, "commons") == inp + 1) {
|
||||
#ifdef YAP_COMMONSDIR
|
||||
strcpy(o, YAP_COMMONSDIR);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
strcpy(out, inp);
|
||||
}
|
||||
if (out[0]) {
|
||||
return out;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief find default paths for main YAP variables
|
||||
*
|
||||
* This function is called once at boot time to set the main paths; it
|
||||
* searches a list of paths to instantiate a number of variables. Paths must
|
||||
* be directories.
|
||||
*
|
||||
* It treats the following variables as :
|
||||
* ROOTDIR, SHAREDIR, LIBDIR, EXECUTABLE
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static const char *find_directory(YAP_init_args *iap, const char *paths[],
|
||||
const char *filename) {
|
||||
static const char * join(const char *s, ...) {
|
||||
CACHE_REGS
|
||||
va_list args;
|
||||
va_start(args , s);
|
||||
int lvl = push_text_stack();
|
||||
const char *inp;
|
||||
if (filename) {
|
||||
if (Yap_IsAbsolutePath(filename, true)) {
|
||||
return pop_output_text_stack(lvl, filename);
|
||||
char *buf = Malloc(FILENAME_MAX+1);
|
||||
if (s && s[0])
|
||||
strcpy(buf, s);
|
||||
while (true) {
|
||||
const char *fmt = va_arg(args, char *);
|
||||
if (fmt == NULL) {
|
||||
va_end(args);
|
||||
return pop_output_text_stack(lvl,buf);
|
||||
}
|
||||
strcat(buf, fmt);
|
||||
}
|
||||
int i = 0;
|
||||
while ((inp = paths[i++]) != NULL) {
|
||||
char *o = location(iap, inp);
|
||||
const char *rc;
|
||||
if (filename && o) {
|
||||
strcat(o, "/");
|
||||
strcat(o, filename);
|
||||
if ((rc = Yap_AbsoluteFile(o, false))) {
|
||||
return pop_output_text_stack(lvl, rc);
|
||||
}
|
||||
} else if (o && Yap_isDirectory(o)) {
|
||||
return pop_output_text_stack(lvl, o);
|
||||
}
|
||||
}
|
||||
pop_text_stack(lvl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void Yap_set_locations(YAP_init_args *iap) {
|
||||
config_t t, *template;
|
||||
static void Yap_set_locations(YAP_init_args *iap) {
|
||||
|
||||
template = cfg(&t);
|
||||
/// ROOT_DIR is the home of the YAP system. It can be:
|
||||
/// -- provided by the user;
|
||||
/// -- obtained from DESTDIR + DE=efalkRoot
|
||||
///
|
||||
/// It is:
|
||||
// --_not useful in Android, WIN32;
|
||||
/// -- DESTDIR/ in Anaconda
|
||||
/// -- /usr/local in most Unix style systems
|
||||
Yap_ROOTDIR = sel(true, iap->ROOTDIR != NULL, iap->ROOTDIR,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
Yap_ROOTDIR = "/assets";
|
||||
Yap_LIBDIR = "/assets/lib";
|
||||
// Yap_BINDIR = MallocExportAsROfind_directory(iap, template->bin, NULL);
|
||||
Yap_SHAREDIR = "/assets/Yap";
|
||||
Yap_DLLDIR = "/assets/lib";
|
||||
Yap_PLDIR = iap->PlDir;
|
||||
Yap_BOOTPLDIR = iap->PrologBootFile;
|
||||
Yap_BOOTFILE = iap->PrologBootFile;
|
||||
Yap_COMMONSDIR =NULL;
|
||||
if (iap->SavedState == NULL) {
|
||||
if (iap->OutputSavedState)
|
||||
iap->SavedState = iap->OutputSavedState;
|
||||
else
|
||||
iap->SavedState = "startup.yss";
|
||||
}
|
||||
Yap_STARTUP = NULL;
|
||||
iap->OutputSavedState = "startup.yss";
|
||||
Yap_OUTPUT_STARTUP = NULL;
|
||||
NULL,
|
||||
#else
|
||||
Yap_ROOTDIR = find_directory(iap, template->root, NULL) ;
|
||||
Yap_LIBDIR = find_directory(iap, template->lib, NULL) ;
|
||||
// Yap_BINDIR = MallocExportAsROfind_directory(iap, template->bin, NULL;
|
||||
Yap_SHAREDIR = find_directory(iap, template->share, NULL) ;
|
||||
Yap_DLLDIR = find_directory(iap, template->dll, NULL) ;
|
||||
Yap_PLDIR = find_directory(iap, template->pl, NULL) ;
|
||||
Yap_BOOTPLDIR = find_directory(iap, template->bootpldir, NULL);
|
||||
if (iap->PrologBootFile == NULL)
|
||||
iap->PrologBootFile = "boot.yap";
|
||||
Yap_BOOTFILE = find_directory(iap, template->bootpldir, iap->PrologBootFile);
|
||||
Yap_COMMONSDIR = find_directory(iap, template->commons, NULL);
|
||||
if (iap->SavedState == NULL) {
|
||||
if (iap->OutputSavedState)
|
||||
iap->SavedState = iap->OutputSavedState;
|
||||
else
|
||||
iap->SavedState = "startup.yss";
|
||||
}
|
||||
Yap_STARTUP = find_directory(iap, template->ss, iap->SavedState);
|
||||
if (iap->OutputSavedState == NULL)
|
||||
iap->OutputSavedState = "startup.yss";
|
||||
Yap_OUTPUT_STARTUP = find_directory(iap, template->ss, iap->OutputSavedState) ;
|
||||
|
||||
join(getenv("DESTDIR"),YAP_ROOTDIR, NULL),
|
||||
#endif
|
||||
if (Yap_ROOTDIR)
|
||||
false
|
||||
);
|
||||
/// BINDIR: where the OS stores header files, namely libYap...
|
||||
Yap_BINDIR = sel(true,
|
||||
iap->BINDIR != NULL, iap->BINDIR,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
NULL,
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_BINDIR, NULL),
|
||||
#endif
|
||||
false );
|
||||
/// LIBDIR: where the OS stores dynamic libraries, namely libYap...
|
||||
Yap_LIBDIR = sel(true,
|
||||
iap->LIBDIR != NULL, iap->LIBDIR,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
NULL,
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_LIBDIR,NULL),
|
||||
#endif
|
||||
false );
|
||||
/// DLLDIR: where libraries can find expicitely loaded DLLs
|
||||
Yap_DLLDIR = sel(true,
|
||||
iap->DLLDIR != NULL, iap->DLLDIR,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
NULL
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_DLLDIR, NULL),
|
||||
#endif
|
||||
false );
|
||||
/// INCLUDEDIR: where the OS stores header files, namely libYap...
|
||||
Yap_INCLUDEDIR = sel(true,
|
||||
iap->INCLUDEDIR != NULL, iap->INCLUDEDIR,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
NULL,
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_INCLUDEDIR, NULL),
|
||||
#endif
|
||||
false );
|
||||
/// SHAREDIR: where OS & ARCH independent files live
|
||||
Yap_SHAREDIR = sel(true,
|
||||
iap->SHAREDIR != NULL, iap->SHAREDIR,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
"/assets",
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_SHAREDIR, NULL),
|
||||
#endif
|
||||
false );
|
||||
/// PLDIR: where we can find Prolog files
|
||||
Yap_PLDIR = sel(true,
|
||||
iap->PLDIR != NULL, iap->PLDIR,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
"/assets/Yap",
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_PLDIR, NULL),
|
||||
#endif
|
||||
false );
|
||||
/// ``COMMONSDIR: Prolog Commons
|
||||
Yap_COMMONSDIR = sel(true,
|
||||
iap->COMMONSDIR != NULL, iap->COMMONSDIR,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
"/assets/PrologCommons",
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_SHAREDIR "/PrologCommons", NULL),
|
||||
#endif
|
||||
false );
|
||||
/// BOOTPLDIR: where we can find Prolog bootstrap files
|
||||
Yap_BOOTPLDIR = sel(true,
|
||||
iap->BOOTPLDIR != NULL, iap->BOOTPLDIR,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
"/assets/Yap/pl",
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_PLDIR "/pl", NULL),
|
||||
#endif
|
||||
false );
|
||||
/// BOOTFILE: where we can find the core Prolog bootstrap file
|
||||
Yap_BOOTFILE = sel(false,
|
||||
iap->BOOTFILE != NULL, iap->BOOTFILE,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
"/assets/Yap/pl/boot.yap",
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_BOOTFILE, NULL),
|
||||
#endif
|
||||
false );
|
||||
/// STARTUP: where we can find the core Prolog bootstrap file
|
||||
Yap_STARTUP = sel(false,
|
||||
iap->STARTUP != NULL, iap->STARTUP,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
NULL,
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_STARTUP,NULL),
|
||||
#endif
|
||||
false );
|
||||
Yap_OUTPUT_STARTUP = sel(false,
|
||||
iap->OUTPUT_STARTUP != NULL, iap->OUTPUT_STARTUP,
|
||||
true,
|
||||
#if __ANDROID__
|
||||
NULL,
|
||||
#else
|
||||
join(getenv("DESTDIR"),YAP_STARTUP,NULL),
|
||||
#endif
|
||||
false );
|
||||
if (Yap_ROOTDIR)
|
||||
setAtomicGlobalPrologFlag(HOME_FLAG,
|
||||
MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR)));
|
||||
if (Yap_PLDIR)
|
||||
@ -643,7 +490,7 @@ X_API YAP_file_type_t Yap_InitDefaults(void *x, char *saved_state, int argc,
|
||||
iap->assetManager = NULL;
|
||||
#else
|
||||
iap->boot_file_type = YAP_QLY;
|
||||
iap->SavedState = saved_state;
|
||||
iap->STARTUP = saved_state;
|
||||
#endif
|
||||
iap->Argc = argc;
|
||||
iap->Argv = argv;
|
||||
@ -670,18 +517,18 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
|
||||
case 'b':
|
||||
iap->boot_file_type = YAP_PL;
|
||||
if (p[1])
|
||||
iap->PrologBootFile = p + 1;
|
||||
iap->BOOTFILE = p + 1;
|
||||
else if (argv[1] && *argv[1] != '-') {
|
||||
iap->PrologBootFile = *++argv;
|
||||
iap->BOOTFILE = *++argv;
|
||||
argc--;
|
||||
}
|
||||
break;
|
||||
case 'B':
|
||||
iap->boot_file_type = YAP_BOOT_PL;
|
||||
if (p[1])
|
||||
iap->PrologBootFile = p + 1;
|
||||
iap->BOOTFILE = p + 1;
|
||||
else if (argv[1] && *argv[1] != '-') {
|
||||
iap->PrologBootFile = *++argv;
|
||||
iap->BOOTFILE = *++argv;
|
||||
argc--;
|
||||
}
|
||||
iap->install = true;
|
||||
@ -958,27 +805,23 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
|
||||
break;
|
||||
} else if (!strncmp("-output-saved-state=", p,
|
||||
strlen("-output-saved-state="))) {
|
||||
iap->OutputSavedState = p + strlen("-output-saved-state=");
|
||||
iap->OUTPUT_STARTUP = p + strlen("-output-saved-state=");
|
||||
} else if (!strncmp("-home=", p, strlen("-home="))) {
|
||||
iap->RootDir = p + strlen("-home=");
|
||||
iap->ROOTDIR = p + strlen("-home=");
|
||||
} else if (!strncmp("-system-library-directory=", p,
|
||||
strlen("-system-library-directory="))) {
|
||||
iap->LibDir = p + strlen("-system-library-directory=");
|
||||
iap->LIBDIR = p + strlen("-system-library-directory=");
|
||||
} else if (!strncmp("-system-shared-directory=", p,
|
||||
strlen("-system-shared-directory="))) {
|
||||
iap->SharedDir = p + strlen("-system-shared-directory=");
|
||||
iap->SHAREDIR = p + strlen("-system-shared-directory=");
|
||||
} else if (!strncmp("-prolog-library-directory=", p,
|
||||
strlen("-prolog-library-directory="))) {
|
||||
iap->PlDir = p + strlen("-prolog-library-directory=");
|
||||
iap->PLDIR = p + strlen("-prolog-library-directory=");
|
||||
} else if (!strncmp("-dll-library-directory=", p,
|
||||
strlen("-dll-library-directory="))) {
|
||||
iap->DLLDir = p + strlen("-dll-library-directory=");
|
||||
iap->DLLDIR = p + strlen("-dll-library-directory=");
|
||||
} else if (!strncmp("-home=", p, strlen("-home="))) {
|
||||
iap->RootDir = p + strlen("-home=");
|
||||
} else if (!strncmp("-home=", p, strlen("-home="))) {
|
||||
iap->RootDir = p + strlen("-home=");
|
||||
} else if (!strncmp("-home=", p, strlen("-home="))) {
|
||||
iap->RootDir = p + strlen("-home=");
|
||||
iap->ROOTDIR = p + strlen("-home=");
|
||||
} else if (!strncmp("-cwd=", p, strlen("-cwd="))) {
|
||||
if (!Yap_ChDir(p + strlen("-cwd="))) {
|
||||
fprintf(stderr, " [ YAP unrecoverable error in setting cwd: %s ]\n",
|
||||
@ -1069,7 +912,7 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
|
||||
}
|
||||
}
|
||||
else {
|
||||
iap->SavedState = p;
|
||||
iap->STARTUP = p;
|
||||
}
|
||||
}
|
||||
return iap->boot_file_type;
|
||||
@ -1163,6 +1006,17 @@ static YAP_file_type_t end_init(YAP_init_args *yap_init, YAP_file_type_t rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void start_modules(void) {
|
||||
Term cm = CurrentModule;
|
||||
size_t i;
|
||||
for (i = 0; i < n_mdelays; i++) {
|
||||
CurrentModule = MkAtomTerm(YAP_LookupAtom(m_delays[i].s));
|
||||
m_delays[i].f();
|
||||
}
|
||||
CurrentModule = cm;
|
||||
}
|
||||
|
||||
|
||||
/* this routine is supposed to be called from an external program
|
||||
that wants to control Yap */
|
||||
|
||||
@ -1218,7 +1072,7 @@ X_API YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
|
||||
|
||||
start_modules();
|
||||
consult(Yap_BOOTFILE PASS_REGS);
|
||||
if (yap_init->install) {
|
||||
if (yap_init->install && Yap_OUTPUT_STARTUP == NULL) {
|
||||
Term t = MkAtomTerm(Yap_LookupAtom(Yap_OUTPUT_STARTUP));
|
||||
Term g = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("qsave_program"), 1),
|
||||
1, &t);
|
||||
|
@ -602,7 +602,7 @@ YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm ts[])
|
||||
goal = YAPApplTerm(f, ts).term();
|
||||
nts = RepAppl(goal) + 1;
|
||||
size_t arity = f.arity();
|
||||
for (int i = 0; i < arity; i++)
|
||||
for (arity_t i = 0; i < arity; i++)
|
||||
XREGS[i + 1] = nts[i];
|
||||
} else {
|
||||
goal = MkVarTerm();
|
||||
|
39
CXX/yapq.hh
39
CXX/yapq.hh
@ -219,39 +219,40 @@ public:
|
||||
inline bool getMaxTrailSize() { return MaxTrailSize; };
|
||||
|
||||
inline void setLibDir(const char *fl) {
|
||||
LibDir = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)LibDir, fl);
|
||||
LIBDIR = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)LIBDIR, fl);
|
||||
};
|
||||
|
||||
inline const char *getLibDir() { return LibDir; };
|
||||
inline const char *getLIBDIR() { return LIBDIR; };
|
||||
|
||||
inline void setSharedDir(const char *fl) {
|
||||
SharedDir = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)SharedDir, fl);
|
||||
inline void setSHAREDIR(const char *fl) {
|
||||
SHAREDIR = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)SHAREDIR, fl);
|
||||
};
|
||||
|
||||
inline const char *getSharedDir() { return SharedDir; };
|
||||
inline const char *getSHAREDIR() { return SHAREDIR; };
|
||||
|
||||
inline void setSavedState(const char *fl) {
|
||||
SavedState = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)SavedState, fl);
|
||||
|
||||
inline void setRESTORE(const char *fl) {
|
||||
STARTUP = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)STARTUP, fl);
|
||||
};
|
||||
|
||||
inline const char *getSavedState() { return SavedState; };
|
||||
inline const char *getSTARTUP() { return STARTUP; };
|
||||
|
||||
inline void setPrologBootFile(const char *fl) {
|
||||
PrologBootFile = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)PrologBootFile, fl);
|
||||
inline void setBOOTFILE(const char *fl) {
|
||||
BOOTFILE = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)BOOTFILE, fl);
|
||||
};
|
||||
|
||||
inline const char *getPrologBootFile() { return PrologBootFile; };
|
||||
inline const char *getBOOTFILE() { return BOOTFILE; };
|
||||
|
||||
inline void setPrologBootDir(const char *fl) {
|
||||
BootPlDir = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)BootPlDir, fl);
|
||||
inline void setPrologBOOTPLDIR(const char *fl) {
|
||||
BOOTPLDIR = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)BOOTPLDIR, fl);
|
||||
};
|
||||
|
||||
inline const char *getPrologBootDir() { return BootPlDir; };
|
||||
inline const char *getBOOTPLDIR() { return BOOTPLDIR; };
|
||||
|
||||
inline void setPrologGoal(const char *fl) { PrologGoal = fl; };
|
||||
|
||||
|
@ -499,9 +499,9 @@ class X_API YAPAtomTerm : public YAPTerm {
|
||||
|
||||
public:
|
||||
YAPAtomTerm(Atom a) { mk(MkAtomTerm(a)); }
|
||||
// Constructor: receives an atom;
|
||||
//> Constructor: receives an atom;
|
||||
YAPAtomTerm(YAPAtom a) : YAPTerm() { mk(MkAtomTerm(a.a)); }
|
||||
// Constructor: receives a sequence of UTF-8 codes;
|
||||
//> Constructor: receives a sequence of UTF-8 codes;
|
||||
YAPAtomTerm(char s[]);
|
||||
// Constructor: receives a sequence of up to n UTF-8 codes;
|
||||
YAPAtomTerm(char *s, size_t len);
|
||||
@ -510,7 +510,7 @@ public:
|
||||
// Constructor: receives a sequence of n wchar_ts, whatever they may be;
|
||||
YAPAtomTerm(wchar_t *s, size_t len);
|
||||
// Constructor: receives a std::string;
|
||||
YAPAtomTerm(std::string s) { mk(MkAtomTerm(Yap_LookupAtom(s.c_str()))); };
|
||||
// YAPAtomTerm(std::string s) { mk(MkAtomTerm(Yap_LookupAtom(s.c_str()))); };
|
||||
bool isVar() { return false; } /// type check for unbound
|
||||
bool isAtom() { return true; } /// type check for atom
|
||||
bool isInteger() { return false; } /// type check for integer
|
||||
|
2
H/Yap.h
2
H/Yap.h
@ -151,7 +151,7 @@ typedef void *(*fptr_t)(void);
|
||||
main exports in YapInterface.h
|
||||
*************************************************************************************************/
|
||||
|
||||
extern const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR, *Yap_PLDIR, *Yap_COMMONSDIR, *Yap_STARTUP, *Yap_BOOTFILE;
|
||||
extern const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR, *Yap_PLDIR, *Yap_COMMONSDIR, *Yap_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR;
|
||||
|
||||
|
||||
/* Basic exports */
|
||||
|
@ -216,8 +216,6 @@ set (INCLUDE_HEADERS
|
||||
set (CONFIGURATION_HEADERS
|
||||
${CMAKE_BINARY_DIR}/YapConfig.h
|
||||
${CMAKE_BINARY_DIR}/YapTermConfig.h
|
||||
${CMAKE_BINARY_DIR}/config.h
|
||||
${CMAKE_BINARY_DIR}/cudd_config.h
|
||||
${CMAKE_BINARY_DIR}/dlocals.h
|
||||
${CMAKE_BINARY_DIR}/YapIOConfig.h
|
||||
)
|
||||
|
@ -1998,6 +1998,11 @@ significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#define YAP_BINDIR "${YAP_BINDIR}"
|
||||
#endif
|
||||
|
||||
/* name of YAP headers */
|
||||
#ifndef YAP_INCLUDEDIR
|
||||
#define YAP_INCLUDEDIR "${YAP_INCLUDEDIR}"
|
||||
#endif
|
||||
|
||||
/* name of YAP library */
|
||||
#ifndef YAP_LIBDIR
|
||||
#define YAP_LIBDIR "${YAP_LIBDIR}"
|
||||
|
4
configure
vendored
4
configure
vendored
@ -165,7 +165,7 @@ print_help() {
|
||||
--mandir=DIR man documentation [DATAROOTDIR/man]
|
||||
--docdir=DIR documentation root [DATAROOTDIR/doc/PROJECT_NAME]
|
||||
|
||||
--generato=Generator Specify the tool used to send callss
|
||||
--generator=Generator Specify the tool used to send callss
|
||||
EOF
|
||||
|
||||
first=y
|
||||
@ -291,7 +291,7 @@ while [ $# != 0 ]; do
|
||||
"--docdir")
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "$2")"; shift;;
|
||||
|
||||
"--generator="*)
|
||||
"-G=|--generator="*)
|
||||
GENERATOR="$CMAKE_ARGS -G $(1#*=)";;
|
||||
|
||||
"-G"|"--generator")
|
||||
|
@ -180,27 +180,32 @@ typedef struct yap_boot_params {
|
||||
//> how files are organised: NULL is GNU/Linux way
|
||||
// const char *directory_structure;
|
||||
//> if NON-NULL, set value for Yap_ROOTDIR
|
||||
const char *RootDir;
|
||||
const char *ROOTDIR;
|
||||
//> if NON-NULL, location of yaap, sets Yap_BINDIR
|
||||
const char *BINDIR;
|
||||
//> if NON-NULL, location of libYap, sets Yap_LIBDIR
|
||||
const char *LibDir;
|
||||
const char *LIBDIR;
|
||||
//> if NON-NULL, architecture independent files, sets Yap_SHAREDIR
|
||||
const char *SharedDir;
|
||||
const char *SHAREDIR;
|
||||
//> if NON-NULL, include files, sets Yap_INCLUDEDIR
|
||||
const char *IncludeDir;
|
||||
const char *INCLUDEDIR;
|
||||
//> if NON-NULL, Prolog DLL location, sets Yap_DLLDIR
|
||||
const char *DLLDir;
|
||||
const char *DLLDIR;
|
||||
//> if NON-NULL, Prolog library, sets Yap_DLLDIR
|
||||
const char *PlDir;
|
||||
const char *PLDIR;
|
||||
//> if NON-NULL, Prolog library, sets Yap_COMMONSDIR
|
||||
const char *COMMONSDIR;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting
|
||||
const char *PrologBootFile;
|
||||
const char *BOOTFILE;
|
||||
//> if NON-NULL, directory for a Prolog file to be when booting
|
||||
const char *BootPlDir;
|
||||
const char *BOOTPLDIR;
|
||||
const char *BOOTPLFILE;
|
||||
//> if NON-NULL, path where we can find the saved state
|
||||
const char *SavedState;
|
||||
const char *STARTUP;
|
||||
//> bootstrapping mode: YAP is not properly installed
|
||||
bool install;
|
||||
//> generats a saved space at this path
|
||||
char *OutputSavedState;
|
||||
const char *OUTPUT_STARTUP;
|
||||
//> if NON-0, minimal size for Heap or Code Area
|
||||
size_t HeapSize;
|
||||
//> if NON-0, maximal size for Heap or Code Area
|
||||
|
@ -2194,12 +2194,12 @@ X_API int PL_initialise(int myargc, char **myargv) {
|
||||
init_args.Argv = myargv;
|
||||
init_args.Argc = myargc;
|
||||
#if BOOT_FROM_SAVED_STATE
|
||||
init_args.SavedState = "startup.yss";
|
||||
init_args.STARTUP = "startup.yss";
|
||||
#else
|
||||
init_args.SavedState = NULL;
|
||||
init_args.STARTUP = NULL;
|
||||
#endif
|
||||
init_args.LibDir = NULL;
|
||||
init_args.PrologBootFile = NULL;
|
||||
init_args.LIBDIR = NULL;
|
||||
init_args.BOOTFILE = NULL;
|
||||
init_args.HaltAfterConsult = FALSE;
|
||||
init_args.FastBoot = FALSE;
|
||||
init_args.MaxTableSpaceSize = 0;
|
||||
|
@ -225,7 +225,6 @@ Yap_InitAssetManager(void) {
|
||||
|
||||
#if __ANDROID__
|
||||
VFS_t *me;
|
||||
return NULL;
|
||||
/* init standard VFS */
|
||||
me = (VFS_t *) Yap_AllocCodeSpace(sizeof(struct vfs));
|
||||
me->name = "/assets";
|
||||
|
@ -408,7 +408,6 @@ static Int access_file(USES_REGS1) {
|
||||
}
|
||||
VFS_t *vfs;
|
||||
if ((vfs = vfs_owner(ares))) {
|
||||
bool rc = true;
|
||||
vfs_stat o;
|
||||
if (vfs->stat(vfs, ares, &o)) {
|
||||
if (atmode == AtomExist)
|
||||
@ -430,7 +429,7 @@ static Int access_file(USES_REGS1) {
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
rc = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#if HAVE_ACCESS
|
||||
@ -522,7 +521,6 @@ static Int exists_directory(USES_REGS1) {
|
||||
if (!s) return false;
|
||||
if ((vfs = vfs_owner(s))) {
|
||||
bool rc = true;
|
||||
void *o;
|
||||
return vfs->isdir(vfs, s);
|
||||
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
|
@ -50,7 +50,9 @@ IF (CUDD_FOUND)
|
||||
add_subdirectory(simplecudd_lfi)
|
||||
set(YAP_SYSTEM_OPTIONS "cudd " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
|
||||
|
||||
install(TARGETS cudd
|
||||
INSTALL(FILES ${CMAKE_BINARY_DIR}/cudd_config.h DESTINATION ${includedir})
|
||||
|
||||
install(TARGETS cudd
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
|
Reference in New Issue
Block a user