Installers with plugins now load faster too

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1112 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-09-21 13:11:28 +00:00
parent 654102c28c
commit 1d98414847
4 changed files with 15 additions and 59 deletions

View file

@ -141,32 +141,4 @@ char* Plugins::GetPluginDll(char* command)
return m_commands.find(command); return m_commands.find(command);
} }
void Plugins::StoreInstDLL(char* dllName)
{
for (int i = 0; i < m_installDLLs.size(); i++)
if (!strcmp(m_installDLLs[i], dllName))
return;
m_installDLLs.push_back(strdup(dllName));
}
void Plugins::StoreUninstDLL(char* dllName)
{
for (int i = 0; i < m_uninstallDLLs.size(); i++)
if (!strcmp(m_uninstallDLLs[i], dllName))
return;
m_uninstallDLLs.push_back(strdup(dllName));
}
char* Plugins::GetInstDLL(int i)
{
if (i >= 0 && i < m_installDLLs.size()) return m_installDLLs[i];
else return 0;
}
char* Plugins::GetUninstDLL(int i)
{
if (i >= 0 && i < m_uninstallDLLs.size()) return m_uninstallDLLs[i];
else return 0;
}
#endif #endif

View file

@ -1076,7 +1076,7 @@ int CEXEBuild::write_output(void)
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT #ifdef NSIS_CONFIG_PLUGIN_SUPPORT
// Added by Amir Szekely 9th August 2002 // Added by Amir Szekely 9th August 2002
int err=add_plugin_initializer(); int err=add_plugins_dir_initializer();
if (err != PS_OK) return err; if (err != PS_OK) return err;
#endif //NSIS_CONFIG_PLUGIN_SUPPORT #endif //NSIS_CONFIG_PLUGIN_SUPPORT
@ -1890,15 +1890,15 @@ void CEXEBuild::build_plugin_table(void)
} }
} }
int CEXEBuild::add_plugin_initializer(void) int CEXEBuild::add_plugins_dir_initializer(void)
{ {
if (!plugin_used) return PS_OK; if (!plugin_used) return PS_OK;
SCRIPT_MSG("Adding plug-ins initializing function...\n"); SCRIPT_MSG("Adding plug-ins initializing function... ");
bool uninstall = false; bool uninstall = false;
int ret, i; int ret;
entry ent; entry ent;
int zero_offset; int zero_offset;
@ -1949,26 +1949,6 @@ again:
ret=add_entry(&ent); ret=add_entry(&ent);
if (ret != PS_OK) return ret; if (ret != PS_OK) return ret;
int files_added;
if (uninstall) {
char* dll;
for (i = 0; dll = m_plugins.GetUninstDLL(i); i++) {
char tempPath[NSIS_MAX_STRLEN];
wsprintf(tempPath,"$PLUGINSDIR%s",strrchr(dll,'\\'));
ret=do_add_file(dll,0,0,0,&files_added,tempPath);
if (ret != PS_OK) return ret;
}
}
else {
char* dll;
for (i = 0; dll = m_plugins.GetInstDLL(i); i++) {
char tempPath[NSIS_MAX_STRLEN];
wsprintf(tempPath,"$PLUGINSDIR%s",strrchr(dll,'\\'));
ret=do_add_file(dll,0,0,0,&files_added,tempPath);
if (ret != PS_OK) return ret;
}
}
if (add_label("Initialize_____Plugins_done")) return PS_ERROR; if (add_label("Initialize_____Plugins_done")) return PS_ERROR;
ret=function_end(); ret=function_end();

View file

@ -87,7 +87,7 @@ class CEXEBuild {
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT #ifdef NSIS_CONFIG_PLUGIN_SUPPORT
// Added by Amir Szekely 9th August 2002 // Added by Amir Szekely 9th August 2002
int add_plugin_initializer(void); int add_plugins_dir_initializer(void);
#endif //NSIS_CONFIG_PLUGIN_SUPPORT #endif //NSIS_CONFIG_PLUGIN_SUPPORT
void ERROR_MSG(const char *s, ...); void ERROR_MSG(const char *s, ...);

View file

@ -3540,6 +3540,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
if (uninstall_mode) uninst_plugin_used = true; if (uninstall_mode) uninst_plugin_used = true;
else plugin_used = true; else plugin_used = true;
// Initialize $PLUGINSDIR
ent.which=EW_CALL; ent.which=EW_CALL;
ent.offsets[0]=ns_func.add(uninstall_mode?"un.Initialize_____Plugins":"Initialize_____Plugins",0); ent.offsets[0]=ns_func.add(uninstall_mode?"un.Initialize_____Plugins":"Initialize_____Plugins",0);
ret=add_entry(&ent); ret=add_entry(&ent);
@ -3548,13 +3549,16 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
// DLL name on the user machine // DLL name on the user machine
char tempDLL[NSIS_MAX_STRLEN]; char tempDLL[NSIS_MAX_STRLEN];
wsprintf(tempDLL, "$PLUGINSDIR%s", strrchr(dllPath,'\\')); wsprintf(tempDLL, "$PLUGINSDIR%s", strrchr(dllPath,'\\'));
int tempDLLtab = add_string(tempDLL);
// Store the DLL // Add the DLL to the installer
if (uninstall_mode) m_plugins.StoreUninstDLL(dllPath); int files_added;
else m_plugins.StoreInstDLL(dllPath); int old_build_overwrite=build_overwrite;
build_overwrite=1;
ret=do_add_file(dllPath,0,0,0,&files_added,tempDLL);
if (ret != PS_OK) return ret;
build_overwrite=old_build_overwrite;
// Finally call the DLL // Call the DLL
char* command = strstr(line.gettoken_str(0),"::"); char* command = strstr(line.gettoken_str(0),"::");
if (command) command += 2; if (command) command += 2;
else command = line.gettoken_str(0); else command = line.gettoken_str(0);
@ -3580,7 +3584,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
// next, call it // next, call it
ent.which=EW_REGISTERDLL; ent.which=EW_REGISTERDLL;
ent.offsets[0]=tempDLLtab; ent.offsets[0]=add_string(tempDLL);;
ent.offsets[1]=add_string(command); ent.offsets[1]=add_string(command);
ent.offsets[2]=-1; ent.offsets[2]=-1;
ent.offsets[3]=nounload; ent.offsets[3]=nounload;