Skip to content

Commit

Permalink
add tilde expansion for --chugin and --chugin-path flags
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Aug 13, 2024
1 parent 639d15d commit 53c8894
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
8 changes: 8 additions & 0 deletions VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
ChucK VERSIONS log
------------------

1.5.2.6
=======
- (added, macOS and Linux) --chugin: and --chugin-path: flags now expands '~' in filepath
- (developer) updated set/getParam() key names:
was: CHUCK_PARAM_USER_CHUGINS now: CHUCK_PARAM_CHUGIN_LIST_USER
was: CHUCK_PARAM_USER_CHUGIN_DIRECTORIES now: CHUCK_PARAM_CHUGIN_LIST_USER_DIR


1.5.2.5 (July 2024)
=======
- (updated) chugin API version from 10.1 to 10.2
Expand Down
29 changes: 15 additions & 14 deletions src/core/chuck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@
#define CHUCK_PARAM_AUTO_DEPEND_DEFAULT "0"
#define CHUCK_PARAM_DEPRECATE_LEVEL_DEFAULT "1"
#define CHUCK_PARAM_WORKING_DIRECTORY_DEFAULT ""
#define CHUCK_PARAM_CHUGIN_ENABLE_DEFAULT "1"
#define CHUCK_PARAM_IS_REALTIME_AUDIO_HINT_DEFAULT "0"
#define CHUCK_PARAM_COMPILER_HIGHLIGHT_ON_ERROR_DEFAULT "1"
#define CHUCK_PARAM_TTY_COLOR_DEFAULT "0"
#define CHUCK_PARAM_TTY_WIDTH_HINT_DEFAULT "80"
// chugin-relate param defaults
#define CHUCK_PARAM_CHUGIN_ENABLE_DEFAULT "1"
#ifndef __PLATFORM_WINDOWS__
// 1.4.1.0 (ge) changed to ""; was "/usr/local/lib/chuck"
// redundant with g_default_chugin_path, which already contains
Expand All @@ -98,11 +102,8 @@
// redundant with g_default_chugin_path, which already contains
#define CHUCK_PARAM_CHUGIN_DIRECTORY_DEFAULT ""
#endif // __PLATFORM_WINDOWS__
#define CHUCK_PARAM_USER_CHUGINS_DEFAULT std::list<std::string>()
#define CHUCK_PARAM_USER_CHUGIN_DIRECTORIES_DEFAULT std::list<std::string>()
#define CHUCK_PARAM_COMPILER_HIGHLIGHT_ON_ERROR_DEFAULT "1"
#define CHUCK_PARAM_TTY_COLOR_DEFAULT "0"
#define CHUCK_PARAM_TTY_WIDTH_HINT_DEFAULT "80"
#define CHUCK_PARAM_CHUGIN_LIST_USER_DEFAULT std::list<std::string>()
#define CHUCK_PARAM_CHUGIN_LIST_USER_DIR_DEFAULT std::list<std::string>()



Expand Down Expand Up @@ -212,10 +213,10 @@ void ChucK::initDefaultParams()
initParam( CHUCK_PARAM_TTY_WIDTH_HINT, CHUCK_PARAM_TTY_WIDTH_HINT_DEFAULT, ck_param_int );

// initialize list params manually (take care to use tolower())
m_listParams[tolower(CHUCK_PARAM_USER_CHUGINS)] = CHUCK_PARAM_USER_CHUGINS_DEFAULT;
m_param_types[tolower(CHUCK_PARAM_USER_CHUGINS)] = ck_param_string_list;
m_listParams[tolower(CHUCK_PARAM_USER_CHUGIN_DIRECTORIES)] = CHUCK_PARAM_USER_CHUGIN_DIRECTORIES_DEFAULT;
m_param_types[tolower(CHUCK_PARAM_USER_CHUGIN_DIRECTORIES)] = ck_param_string_list;
m_listParams[tolower(CHUCK_PARAM_CHUGIN_LIST_USER)] = CHUCK_PARAM_CHUGIN_LIST_USER_DEFAULT;
m_param_types[tolower(CHUCK_PARAM_CHUGIN_LIST_USER)] = ck_param_string_list;
m_listParams[tolower(CHUCK_PARAM_CHUGIN_LIST_USER_DIR)] = CHUCK_PARAM_CHUGIN_LIST_USER_DIR_DEFAULT;
m_param_types[tolower(CHUCK_PARAM_CHUGIN_LIST_USER_DIR)] = ck_param_string_list;
}


Expand Down Expand Up @@ -704,13 +705,13 @@ t_CKBOOL ChucK::initChugins()
// chugin dur
std::string chuginDir = getParamString( CHUCK_PARAM_CHUGIN_DIRECTORY );
// list of search pathes (added 1.3.0.0)
std::list<std::string> dl_search_path = getParamStringList( CHUCK_PARAM_USER_CHUGIN_DIRECTORIES );
std::list<std::string> dl_search_path = getParamStringList( CHUCK_PARAM_CHUGIN_LIST_USER_DIR );
if( chuginDir != std::string("") )
{
dl_search_path.push_back( chuginDir );
}
// list of individually named chug-ins (added 1.3.0.0)
std::list<std::string> named_dls = getParamStringList( CHUCK_PARAM_USER_CHUGINS );
std::list<std::string> named_dls = getParamStringList( CHUCK_PARAM_CHUGIN_LIST_USER );

EM_pushlog();
// print host version
Expand Down Expand Up @@ -850,14 +851,14 @@ void ChucK::probeChugins()
// chugin dur
std::string chuginDir = getParamString( CHUCK_PARAM_CHUGIN_DIRECTORY );
// list of search pathes (added 1.3.0.0)
std::list<std::string> dl_search_path = getParamStringList( CHUCK_PARAM_USER_CHUGIN_DIRECTORIES );
std::list<std::string> dl_search_path = getParamStringList( CHUCK_PARAM_CHUGIN_LIST_USER_DIR );
if( chuginDir != "" )
{
// add to search path
dl_search_path.push_back( chuginDir );
}
// list of individually named chug-ins (added 1.3.0.0)
std::list<std::string> named_dls = getParamStringList( CHUCK_PARAM_USER_CHUGINS );
std::list<std::string> named_dls = getParamStringList( CHUCK_PARAM_CHUGIN_LIST_USER );

// log
EM_log( CK_LOG_SYSTEM, "probing chugins (.chug)..." );
Expand Down
11 changes: 7 additions & 4 deletions src/core/chuck.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,20 @@
#define CHUCK_PARAM_AUTO_DEPEND "AUTO_DEPEND"
#define CHUCK_PARAM_DEPRECATE_LEVEL "DEPRECATE_LEVEL"
#define CHUCK_PARAM_WORKING_DIRECTORY "WORKING_DIRECTORY"
#define CHUCK_PARAM_CHUGIN_ENABLE "CHUGIN_ENABLE"
#define CHUCK_PARAM_CHUGIN_DIRECTORY "CHUGIN_DIRECTORY"
#define CHUCK_PARAM_USER_CHUGINS "USER_CHUGINS"
#define CHUCK_PARAM_USER_CHUGIN_DIRECTORIES "USER_CHUGIN_DIRECTORIES"
#define CHUCK_PARAM_IS_REALTIME_AUDIO_HINT "IS_REALTIME_AUDIO_HINT"
#define CHUCK_PARAM_COMPILER_HIGHLIGHT_ON_ERROR "COMPILER_HIGHLIGHT_ON_ERROR"
#define CHUCK_PARAM_TTY_COLOR "TTY_COLOR"
#define CHUCK_PARAM_TTY_WIDTH_HINT "TTY_WIDTH_HINT"
// chugin-relate param names
#define CHUCK_PARAM_CHUGIN_ENABLE "CHUGIN_ENABLE"
#define CHUCK_PARAM_CHUGIN_DIRECTORY "CHUGIN_DIRECTORY"
#define CHUCK_PARAM_CHUGIN_LIST_USER "CHUGIN_LIST_USER"
#define CHUCK_PARAM_CHUGIN_LIST_USER_DIR "CHUGIN_LIST_USER_DIR"

// legacy compatibiity (new code should use newer version of these, on the right)
#define CHUCK_PARAM_HINT_IS_REALTIME_AUDIO CHUCK_PARAM_IS_REALTIME_AUDIO_HINT
#define CHUCK_PARAM_USER_CHUGINS CHUCK_PARAM_CHUGIN_LIST_USER
#define CHUCK_PARAM_USER_CHUGIN_DIRECTORIES CHUCK_PARAM_CHUGIN_LIST_USER_DIR



Expand Down
12 changes: 10 additions & 2 deletions src/core/chuck_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,8 @@ t_CKBOOL Chuck_Compiler::load_external_modules( const char * extension,
{
// get chugin name
std::string & dl_path = *i_dl;
// expand the filepath (e.g., ~) | 1.5.2.6 (ge) added
dl_path = expand_filepath(dl_path);
// check extension, append if no match
if( !extension_matches(dl_path.c_str(), extension) )
dl_path += extension;
Expand All @@ -1171,8 +1173,10 @@ t_CKBOOL Chuck_Compiler::load_external_modules( const char * extension,
for( std::list<std::string>::iterator i_sp = chugin_search_paths.begin();
i_sp != chugin_search_paths.end(); i_sp++ )
{
// expand the filepath (e.g., ~) | 1.5.2.6 (ge) added
string dl_path = expand_filepath(*i_sp);
// search directory and load contents
load_external_modules_in_directory( this, (*i_sp).c_str(), extension, recursiveSearch );
load_external_modules_in_directory( this, dl_path.c_str(), extension, recursiveSearch );
}

// clear context
Expand Down Expand Up @@ -1358,6 +1362,8 @@ t_CKBOOL Chuck_Compiler::probe_external_modules( const char * extension,
{
// get chugin name
std::string & dl_path = *i_dl;
// expand the filepath (e.g., ~) | 1.5.2.6 (ge) added
dl_path = expand_filepath(dl_path);
// check extension, append if no match
if( !extension_matches(dl_path.c_str(), extension) )
dl_path += extension;
Expand All @@ -1380,8 +1386,10 @@ t_CKBOOL Chuck_Compiler::probe_external_modules( const char * extension,
for( std::list<std::string>::iterator i_sp = chugin_search_paths.begin();
i_sp != chugin_search_paths.end(); i_sp++ )
{
// expand the filepath (e.g., ~) | 1.5.2.6 (ge) added
string dl_path = expand_filepath(*i_sp);
// search directory and load contents
probe_external_modules_in_directory( (*i_sp).c_str(), extension, recursiveSearch, ck_libs );
probe_external_modules_in_directory( dl_path.c_str(), extension, recursiveSearch, ck_libs );
}

// pop
Expand Down
4 changes: 2 additions & 2 deletions src/host/chuck_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,8 @@ t_CKBOOL go( int argc, const char ** argv )
//-------------------- VIRTUAL MACHINE SETUP (PART 1) ---------------------
// set chugins parameters
the_chuck->setParam( CHUCK_PARAM_CHUGIN_ENABLE, chugin_load );
the_chuck->setParam( CHUCK_PARAM_USER_CHUGINS, named_dls );
the_chuck->setParam( CHUCK_PARAM_USER_CHUGIN_DIRECTORIES, dl_search_path );
the_chuck->setParam( CHUCK_PARAM_CHUGIN_LIST_USER, named_dls );
the_chuck->setParam( CHUCK_PARAM_CHUGIN_LIST_USER_DIR, dl_search_path );

//-----------------------------------------------------------------
// probe chugins | 1.5.0.4 (ge) added
Expand Down

0 comments on commit 53c8894

Please sign in to comment.