Skip to content

Commit

Permalink
fix --chugin with local path
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Nov 8, 2024
1 parent 8ea6e21 commit ddf27b3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
ChucK VERSIONS log
------------------

1.5.4.2
=======
(fixed) an issue with --chugin: where local paths aren't resolved correctly


1.5.4.1 (November 2024)
=======
Expand Down
18 changes: 12 additions & 6 deletions src/core/chuck_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,7 @@ t_CKBOOL Chuck_Compiler::import_chugin_opt( const string & path, const string &

// NOTE this (verbose >= 5) is more informative if the chugin crashes, we can see the name
EM_log( CK_LOG_INFO, "@import loading [chugin] %s...", name.c_str() );
EM_log( CK_LOG_FINE, " |- path: '%s'", path.c_str() );

// create chuck DLL data structure
Chuck_DLL * dll = new Chuck_DLL( this->carrier(), name != "" ? name.c_str() : (extract_filepath_file(path)).c_str() );
Expand Down Expand Up @@ -1830,12 +1831,14 @@ t_CKBOOL Chuck_Compiler::load_external_modules( const string & extension,
// error string
std::string error_str;
// expand the filepath (e.g., ~) | 1.5.2.6 (ge) added
dl_path = expand_filepath(dl_path);
dl_path = expand_filepath( dl_path );
// make full path
dl_path = get_full_path( dl_path );
// check extension, append if no match
if( !extension_matches(dl_path, extension) )
if( !extension_matches( dl_path, extension ) )
dl_path += extension;
// load the module, in its own namespace == FALSE
this->importChugin( dl_path, FALSE, "", error_str );
this->importChugin( dl_path, FALSE, mini(dl_path.c_str()), error_str );
}

// now recurse through search paths and load any DLs or .ck files found
Expand Down Expand Up @@ -1876,6 +1879,7 @@ t_CKBOOL Chuck_Compiler::probe_external_chugin( const string & path, const strin

// NOTE this (verbose >= 5) is more informative if the chugin crashes, we can see the name
EM_log( CK_LOG_INFO, "probing [chugin] %s...", name.c_str() );
EM_log( CK_LOG_FINE, " |- path: '%s'", path.c_str() );

// load the dll, lazy mode
if( dll->load(path.c_str(), CK_QUERY_FUNC, TRUE) )
Expand Down Expand Up @@ -2047,12 +2051,14 @@ t_CKBOOL Chuck_Compiler::probe_external_modules( const string & 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);
dl_path = expand_filepath( dl_path );
// get full path
dl_path = get_full_path( dl_path );
// check extension, append if no match
if( !extension_matches(dl_path, extension) )
if( !extension_matches( dl_path, extension ) )
dl_path += extension;
// load the module
probe_external_chugin( dl_path, dl_path );
probe_external_chugin( dl_path, mini(dl_path.c_str()) );
}

// check
Expand Down
4 changes: 4 additions & 0 deletions src/core/chuck_dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3037,6 +3037,10 @@ void * dlopen( const char * path, int mode )
std::replace( platformPath.begin(), platformPath.end(), '/', '\\' );
// the dll search path to add
string dll_path = extract_filepath_dir( platformPath );
// if empty string, use current directory
if( dll_path == "" ) dll_path = ".\\";
// AddDllDirectory expects only fullpaths
dll_path = get_full_path( dll_path );
// the relateive _deps directory
string dll_deps_path = dll_path + "_deps\\";
// convert to wchar
Expand Down

0 comments on commit ddf27b3

Please sign in to comment.