Reloading externals
Hi,
is it possible to force Max to reload an external from disk? Having to close and restart Max just to try a different compile of an external under development is extremely annoying.
Any help is very much appreciated.
So in other words: no. A Max setting to reload externals properly when possible would be really nice and save developers heaploads of time, but that sounds like the kind of thing that will never happen.
This is a workaround that avoids restarting Max. You will have to create a new object in Max though. What I do is generate an ending based on the number of seconds since 1970 and append it to the object name.
Assuming you're using xcode to build and your object is called "myobj~", make a bash script "build_script.sh"
# build_script.sh
#!/bin/bash
file_suffix=$(date "+%s")
xcodebuild -project myobj~.xcodeproj/ \
GCC_PREPROCESSOR_DEFINITIONS='MAX_OBJ_NAME_SUFFIX="\"'$file_suffix'\""'
cp -r build/Development/myobj~.mxo build/Development/myobj~$file_suffix.mxo
echo "wrote to myobj~$file_suffix"
Then you can run the script by doing
# only need to do the first time to make the script executable
$chmod u+x ./build_script.sh
# run this every time to build after changing the file
$./build_script
Then in the source file "myobj~.c" you have to append the generated ending to the object name registered with max
void ext_main(void *r)
{
t_class *c = class_new("myobj~" MAX_OBJ_NAME_SUFFIX, (method)myobj_new, (method)dsp_free, (long)sizeof(t_myobj), 0L, A_GIMME, 0);
...
}
After building your object, the script will say
"wrote to myobj~12345678" (or some othernumber)
use this number to create an object in Max (assuming where the object has been placed is in Max's search path). You won't need to restart Max for it to see the changes to the file.
For production builds just set file_suffix to nothing
file_suffix=
in the script.