Skip to content

Commit

Permalink
bootstrap: Add minimal package require support
Browse files Browse the repository at this point in the history
Makes it easier to run the test suite if a minmal 'package require'
is supported.

Also omit SSL code from jim-aio.c

Signed-off-by: Steve Bennett <steveb@workware.net.au>
  • Loading branch information
msteveb committed Aug 17, 2016
1 parent 0f35c01 commit 97fd553
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
15 changes: 12 additions & 3 deletions bootstrap.tcl
@@ -1,3 +1,12 @@
# No need for package support in the bootstrap jimsh, but
# Tcl extensions call package require
proc package {args} {}
# Minimal support for package require
# No error on failure since C extensions aren't handled
proc package {cmd pkg} {
if {$cmd eq "require"} {
foreach path $::auto_path {
if {[file exists $path/$pkg.tcl]} {
uplevel #0 [list source $path/$pkg.tcl]
return
}
}
}
}
20 changes: 10 additions & 10 deletions jim-aio.c
Expand Up @@ -192,7 +192,7 @@ static const JimAioFopsType stdio_fops = {
NULL
};

#if defined(JIM_SSL)
#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP)

static SSL_CTX *JimAioSslCtx(Jim_Interp *interp);

Expand Down Expand Up @@ -270,7 +270,7 @@ static const JimAioFopsType ssl_fops = {
ssl_strerror,
ssl_verify
};
#endif
#endif /* JIM_BOOTSTRAP */

static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
static AioFile *JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filename,
Expand Down Expand Up @@ -1053,7 +1053,7 @@ static int aio_cmd_onexception(Jim_Interp *interp, int argc, Jim_Obj *const *arg
}
#endif

#if defined(JIM_SSL)
#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP)
static int aio_cmd_ssl(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
Expand Down Expand Up @@ -1156,7 +1156,7 @@ static int aio_cmd_verify(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
}
return ret;
}
#endif
#endif /* JIM_BOOTSTRAP */

static const jim_subcmd_type aio_command_table[] = {
{ "read",
Expand Down Expand Up @@ -1315,7 +1315,7 @@ static const jim_subcmd_type aio_command_table[] = {
/* Description: Returns script, or invoke exception-script when oob data, {} to remove */
},
#endif
#if defined(JIM_SSL)
#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP)
{ "ssl",
"?-server cert priv?",
aio_cmd_ssl,
Expand All @@ -1331,7 +1331,7 @@ static const jim_subcmd_type aio_command_table[] = {
0,
/* Description: Verifies the certificate of a SSL/TLS channel */
},
#endif
#endif /* JIM_BOOTSTRAP */
{ NULL }
};

Expand Down Expand Up @@ -1371,7 +1371,7 @@ static int JimAioOpenCommand(Jim_Interp *interp, int argc,
return JimMakeChannel(interp, NULL, -1, argv[1], "aio.handle%ld", 0, mode) ? JIM_OK : JIM_ERR;
}

#if defined(JIM_SSL)
#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP)
static void JimAioSslContextDelProc(struct Jim_Interp *interp, void *privData)
{
SSL_CTX_free((SSL_CTX *)privData);
Expand All @@ -1394,7 +1394,7 @@ static SSL_CTX *JimAioSslCtx(Jim_Interp *interp)
}
return ssl_ctx;
}
#endif
#endif /* JIM_BOOTSTRAP */

/**
* Creates a channel for fh/fd/filename.
Expand Down Expand Up @@ -1824,7 +1824,7 @@ int Jim_MakeTempFile(Jim_Interp *interp, const char *template)
#endif
}

#if defined(JIM_SSL)
#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP)
static int JimAioLoadSSLCertsCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
SSL_CTX *ssl_ctx;
Expand All @@ -1844,7 +1844,7 @@ static int JimAioLoadSSLCertsCommand(Jim_Interp *interp, int argc, Jim_Obj *cons
Jim_SetResultString(interp, ERR_error_string(ERR_get_error(), NULL), -1);
return JIM_ERR;
}
#endif
#endif /* JIM_BOOTSTRAP */

int Jim_aioInit(Jim_Interp *interp)
{
Expand Down
2 changes: 1 addition & 1 deletion make-bootstrap-jim
Expand Up @@ -44,7 +44,7 @@ cexts="aio readdir regexp file exec clock array"
tclexts="bootstrap initjimsh glob stdlib tclcompat"

# Note ordering
allexts="bootstrap aio readdir glob regexp file exec clock array stdlib tclcompat"
allexts="bootstrap aio readdir regexp file glob exec clock array stdlib tclcompat"

echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */"

Expand Down

0 comments on commit 97fd553

Please sign in to comment.