Skip to content

Commit

Permalink
Merge pull request #426 from ccrma/2024-dl-info
Browse files Browse the repository at this point in the history
chugin ck_info() support added to host; CK_LOG_SEVERE --> CK_LOG_HERALD
  • Loading branch information
gewang authored Jan 17, 2024
2 parents 2a42d9e + 2570a93 commit 4e2e015
Show file tree
Hide file tree
Showing 18 changed files with 224 additions and 187 deletions.
31 changes: 31 additions & 0 deletions VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@
ChucK VERSIONS log
------------------

1.5.2.1 (December 2023) patch release
=======
- (added) ChuGL (alpha) is now part of the standard chuck distribution
https://chuck.stanford.edu/chugl/
=======
- (added) chugins can now implement a "info query function" to provide
chugin-specific infomation to be accessible from host, including:
* chugin author(s)
* chugin version (not to be confused with compatbility version)
* chugin description
* (optional) chugin URL
* (optional) contact email
for example, in the chugin source:
```
// chugin info func
CK_DLL_INFO( MyChugin )
{
// set info
QUERY->setinfo( QUERY, CHUGIN_INFO_AUTHORS, "Ana B. Croft" );
QUERY->setinfo( QUERY, CHUGIN_INFO_CHUGIN_VERSION, "v3.6.1" );
QUERY->setinfo( QUERY, CHUGIN_INFO_DESCRIPTION, "what does it do?" );
QUERY->setinfo( QUERY, CHUGIN_INFO_URL, "https://foo.com/FooBar" );
QUERY->setinfo( QUERY, CHUGIN_INFO_EMAIL, "ana@foo.com" );
}
```
- (updated) revert chugin/host compatibility policy
chugin major version must == host major version
chugin minor version must <= host minor version
(previously in 1.5.2.0) chugin AND host API version must match


1.5.2.0 (November 2023) "Better Late Than Never...constructors"
=======
- (added) class constructors
Expand Down
20 changes: 11 additions & 9 deletions src/core/chuck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ t_CKBOOL ChucK::initCompiler()
if( (cstr_cwd = getcwd(NULL, 0)) == NULL )
{
// uh...
EM_log( CK_LOG_SEVERE, "error: unable to determine current working directory!" );
EM_log( CK_LOG_HERALD, "error: unable to determine current working directory!" );
}
else
{
Expand Down Expand Up @@ -713,7 +713,7 @@ t_CKBOOL ChucK::initChugins()

EM_pushlog();
// print host version
EM_log( CK_LOG_SEVERE, TC::green("host API version: %d.%d", true).c_str(), CK_DLL_VERSION_MAJOR, CK_DLL_VERSION_MINOR );
EM_log( CK_LOG_HERALD, TC::green("host API version: %d.%d", true).c_str(), CK_DLL_VERSION_MAJOR, CK_DLL_VERSION_MINOR );
EM_poplog();

//---------------------------------------------------------------------
Expand Down Expand Up @@ -758,7 +758,7 @@ t_CKBOOL ChucK::initChugins()
std::string filename = *j;

// log
EM_log( CK_LOG_SEVERE, "preloading '%s'...", filename.c_str() );
EM_log( CK_LOG_HERALD, "preloading '%s'...", filename.c_str() );
// push indent
EM_pushlog();

Expand Down Expand Up @@ -829,18 +829,20 @@ void ChucK::probeChugins()
{
// ck files to pre load
std::list<std::string> ck_libs_to_preload;
// host verison
ostringstream ostr; ostr << CK_DLL_VERSION_MAJOR << "." << CK_DLL_VERSION_MINOR;

// print whether chugins enabled
EM_log( CK_LOG_SYSTEM, "chugin system: %s", getParamInt( CHUCK_PARAM_CHUGIN_ENABLE ) ? "ON" : "OFF" );
// print host version
EM_log( CK_LOG_SYSTEM, TC::green("host API version: %d.%d", true).c_str(), CK_DLL_VERSION_MAJOR, CK_DLL_VERSION_MINOR );
EM_log( CK_LOG_SYSTEM, "chugin host API version: %s", TC::green(ostr.str(),true).c_str() );
// push
EM_pushlog();
// print host version
EM_log( CK_LOG_SYSTEM, "note: chugin API version must match that of host" ); // 1.5.2.0
// previously:
// EM_log( CK_LOG_SYSTEM, "chugin major version must == host major version" );
// EM_log( CK_LOG_SYSTEM, "chugin minor version must <= host major version" );
// print version compatbility information
EM_log( CK_LOG_SYSTEM, "chugin major version must == host major version" );
EM_log( CK_LOG_SYSTEM, "chugin minor version must <= host minor version" );
// print chuck language version
EM_log( CK_LOG_SYSTEM, "language version: %s", TC::green(CHUCK_VERSION_STRING,true).c_str() );
// pop
EM_poplog();

Expand Down
68 changes: 43 additions & 25 deletions src/core/chuck_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ t_CKBOOL load_module( Chuck_Compiler * compiler, Chuck_Env * env, f_ck_query que
t_CKBOOL load_internal_modules( Chuck_Compiler * compiler )
{
// log
EM_log( CK_LOG_SEVERE, "loading built-in modules..." );
EM_log( CK_LOG_HERALD, "loading built-in modules..." );
// push indent level
EM_pushlog();

Expand All @@ -717,48 +717,48 @@ t_CKBOOL load_internal_modules( Chuck_Compiler * compiler )
#endif // __DISABLE_MIDI__

// load
EM_log( CK_LOG_SEVERE, "module 'math'" );
EM_log( CK_LOG_HERALD, "module 'math'" );
if( !load_module( compiler, env, libmath_query, "math", "global" ) ) goto error;
EM_log( CK_LOG_SEVERE, "module 'osc'" );
EM_log( CK_LOG_HERALD, "module 'osc'" );
load_module( compiler, env, osc_query, "osc", "global" );
EM_log( CK_LOG_SEVERE, "module 'ai'" );
EM_log( CK_LOG_HERALD, "module 'ai'" );
if( !load_module( compiler, env, libai_query, "ai", "global" ) ) goto error;
EM_log( CK_LOG_SEVERE, "module 'extract'" );
EM_log( CK_LOG_HERALD, "module 'extract'" );
load_module( compiler, env, extract_query, "extract", "global" );
EM_log( CK_LOG_SEVERE, "module 'filter'" );
EM_log( CK_LOG_HERALD, "module 'filter'" );
load_module( compiler, env, filter_query, "filter", "global" );
EM_log( CK_LOG_SEVERE, "module 'STK'" );
EM_log( CK_LOG_HERALD, "module 'STK'" );
load_module( compiler, env, stk_query, "stk", "global" );
EM_log( CK_LOG_SEVERE, "module 'xform'" );
EM_log( CK_LOG_HERALD, "module 'xform'" );
load_module( compiler, env, xform_query, "xform", "global" );
EM_log( CK_LOG_SEVERE, "module 'xxx'" );
EM_log( CK_LOG_HERALD, "module 'xxx'" );
load_module( compiler, env, xxx_query, "xxx", "global" );
EM_log( CK_LOG_SEVERE, "module 'std'" );
EM_log( CK_LOG_HERALD, "module 'std'" );
if( !load_module( compiler, env, libstd_query, "std", "global" ) ) goto error;

// load
EM_log( CK_LOG_SEVERE, "module 'machine'" );
EM_log( CK_LOG_HERALD, "module 'machine'" );
if( !load_module( compiler, env, machine_query, "machine", "global" ) ) goto error;

#ifndef __DISABLE_NETWORK__
EM_log( CK_LOG_SEVERE, "module 'opsc'" );
EM_log( CK_LOG_HERALD, "module 'opsc'" );
if( !load_module( compiler, env, opensoundcontrol_query, "opsc", "global" ) ) goto error;
#endif

// deprecated:
// if( !load_module( compiler, env, net_query, "net", "global" ) ) goto error;

#ifndef __DISABLE_HID__
EM_log( CK_LOG_SEVERE, "module 'HID'" );
EM_log( CK_LOG_HERALD, "module 'HID'" );
if( !init_class_HID( env ) ) goto error;
#endif

#ifndef __DISABLE_SERIAL__
EM_log( CK_LOG_SEVERE, "module 'SerialIO'" );
EM_log( CK_LOG_HERALD, "module 'SerialIO'" );
if( !init_class_serialio( env ) ) goto error;
#endif

EM_log( CK_LOG_SEVERE, "module 'CKDoc'" );
EM_log( CK_LOG_HERALD, "module 'CKDoc'" );
if( !load_module( compiler, env, ckdoc_query, "ckdoc", "global" ) ) goto error;

// clear context
Expand Down Expand Up @@ -983,7 +983,7 @@ t_CKBOOL load_external_module_at_path( Chuck_Compiler * compiler,

// log with no newline; print status next
// NOTE this is more informative if the chugin crashes, we can see the name
EM_log_opts( CK_LOG_SEVERE, EM_LOG_NO_NEWLINE, "[%s] %s ", TC::magenta("chugin",true).c_str(), name );
EM_log_opts( CK_LOG_HERALD, EM_LOG_NO_NEWLINE, "[%s] %s ", TC::magenta("chugin",true).c_str(), name );

Chuck_DLL * dll = new Chuck_DLL( compiler->carrier(), name );
t_CKBOOL query_failed = FALSE;
Expand All @@ -997,10 +997,10 @@ t_CKBOOL load_external_module_at_path( Chuck_Compiler * compiler,
if( !dll->compatible() )
{
// print
EM_log_opts( CK_LOG_SEVERE, EM_LOG_NO_PREFIX, "[%s] (API version: %d.%d)", TC::red("FAILED",true).c_str(), dll->versionMajor(), dll->versionMinor() );
EM_log_opts( CK_LOG_HERALD, EM_LOG_NO_PREFIX, "[%s] (API version: %d.%d)", TC::red("FAILED",true).c_str(), dll->versionMajor(), dll->versionMinor() );
// push
EM_pushlog();
EM_log( CK_LOG_SEVERE, "reason: %s", TC::orange(dll->last_error(),true).c_str() );
EM_log( CK_LOG_HERALD, "reason: %s", TC::orange(dll->last_error(),true).c_str() );
EM_poplog();
// go to error for cleanup
goto error;
Expand All @@ -1012,15 +1012,15 @@ t_CKBOOL load_external_module_at_path( Chuck_Compiler * compiler,
if( query_failed || !type_engine_add_dll2( env, dll, "global" ) )
{
// print
EM_log_opts( CK_LOG_SEVERE, EM_LOG_NO_PREFIX, "[%s] (API version: %d.%d)", TC::red("FAILED",true).c_str(), dll->versionMajor(), dll->versionMinor() );
EM_log_opts( CK_LOG_HERALD, EM_LOG_NO_PREFIX, "[%s] (API version: %d.%d)", TC::red("FAILED",true).c_str(), dll->versionMajor(), dll->versionMinor() );
EM_pushlog();
// if add_dll2 failed, an error should have already been output
if( query_failed )
{
// print reason
EM_log( CK_LOG_SEVERE, "reason: %s", TC::orange(dll->last_error(),true).c_str() );
EM_log( CK_LOG_HERALD, "reason: %s", TC::orange(dll->last_error(),true).c_str() );
}
EM_log( CK_LOG_SEVERE, "%s '%s'...", TC::blue("skipping",true).c_str(), dl_path );
EM_log( CK_LOG_HERALD, "%s '%s'...", TC::blue("skipping",true).c_str(), dl_path );
EM_poplog();
// go to error for cleanup
goto error;
Expand All @@ -1029,17 +1029,17 @@ t_CKBOOL load_external_module_at_path( Chuck_Compiler * compiler,
else
{
// print
EM_log_opts( CK_LOG_SEVERE, EM_LOG_NO_PREFIX, "[%s]", TC::red("FAILED",true).c_str() );
EM_log_opts( CK_LOG_HERALD, EM_LOG_NO_PREFIX, "[%s]", TC::red("FAILED",true).c_str() );
// more info
EM_pushlog();
EM_log( CK_LOG_SEVERE, "reason: %s", TC::orange(dll->last_error(),true).c_str() );
EM_log( CK_LOG_HERALD, "reason: %s", TC::orange(dll->last_error(),true).c_str() );
EM_poplog();
// go to error for cleanup
goto error;
}

// print
EM_log_opts( CK_LOG_SEVERE, EM_LOG_NO_PREFIX, "[%s]", TC::green("OK",true).c_str() );
EM_log_opts( CK_LOG_HERALD, EM_LOG_NO_PREFIX, "[%s]", TC::green("OK",true).c_str() );
// add to compiler
compiler->m_dlls.push_back(dll);
// commit operator overloads | 1.5.1.5
Expand Down Expand Up @@ -1073,7 +1073,7 @@ t_CKBOOL load_external_modules_in_directory( Chuck_Compiler * compiler,
vector<string> ckfiles2load;

// print directory to examine
EM_log( CK_LOG_SEVERE, "searching '%s'", format_dir_name_for_display(directory).c_str() );
EM_log( CK_LOG_HERALD, "searching '%s'", format_dir_name_for_display(directory).c_str() );
// push
EM_pushlog();

Expand Down Expand Up @@ -1222,7 +1222,25 @@ t_CKBOOL probe_external_module_at_path( const char * name, const char * dl_path
EM_pushlog();
EM_log( CK_LOG_SYSTEM, "reason: %s", TC::orange(dll->last_error(),true).c_str() );
EM_poplog();
}

// print info if available
string name = dll->name();
string authors = dll->getinfo( CHUGIN_INFO_AUTHORS );
string version = dll->getinfo( CHUGIN_INFO_CHUGIN_VERSION );
string desc = dll->getinfo( CHUGIN_INFO_DESCRIPTION );
string url = dll->getinfo( CHUGIN_INFO_URL );
string email = dll->getinfo( CHUGIN_INFO_EMAIL );

if( authors.length() || version.length() || desc.length() || url.length() )
{
EM_pushlog();
if( version.length() ) EM_log( CK_LOG_SYSTEM, "version: %s", version.c_str() );
if( authors.length() ) EM_log( CK_LOG_SYSTEM, "author: %s", authors.c_str() );
if( desc.length() ) EM_log( CK_LOG_HERALD, "description: %s", desc.c_str() );
if( url.length() ) EM_log( CK_LOG_HERALD, "URL: %s", url.c_str() );
if( email.length() ) EM_log( CK_LOG_INFO, "email: %s", email.c_str() );
EM_poplog();
}
}
else
Expand Down
Loading

0 comments on commit 4e2e015

Please sign in to comment.