Plugin size only counted once now, no more huge "optimizations" when using one plugin a lot of times.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1703 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-11-14 19:43:14 +00:00
parent 2f8a2e37a7
commit 1f9aee2b38
5 changed files with 57 additions and 26 deletions

View file

@ -48,6 +48,9 @@ void Plugins::FindCommands(char* path,bool displayInfo)
delete[] pathAndWildcard; delete[] pathAndWildcard;
delete[] basePath; delete[] basePath;
} }
m_dataHandles.resize(m_funcsCount*sizeof(int));
memset(m_dataHandles.get(), -1, m_funcsCount*sizeof(int));
} }
} }
@ -115,9 +118,7 @@ void Plugins::GetExports(char* pathToDll,bool displayInfo)
char *name = (char*)exports + names[j] - ExportDirVA; char *name = (char*)exports + names[j] - ExportDirVA;
wsprintf(signature, "%s::%s", dllName, name); wsprintf(signature, "%s::%s", dllName, name);
m_commands.add(signature, pathToDll); m_commands.add(signature, pathToDll);
char *dll = new char[lstrlen(dllName)]; m_funcsCount++;
lstrcpy(dll, dllName);
m_storedDLLs.push_back(dll);
if (displayInfo) if (displayInfo)
fprintf(g_output, " - %s\n", signature); fprintf(g_output, " - %s\n", signature);
} }
@ -133,12 +134,23 @@ void Plugins::GetExports(char* pathToDll,bool displayInfo)
bool Plugins::IsPluginCommand(char* token) bool Plugins::IsPluginCommand(char* token)
{ {
return GetPluginDll(token) ? true : false; return GetPluginDll(token, 0) ? true : false;
} }
char* Plugins::GetPluginDll(char* command) char* Plugins::GetPluginDll(char* command, int* dataHandle)
{ {
return m_commands.find(command); char* ret = m_commands.find(command, dataHandle);
if (dataHandle && ret)
*dataHandle = ((int*)m_dataHandles.get())[*dataHandle];
return ret;
}
void Plugins::SetDllDataHandle(char* command, int dataHandle)
{
int idx = -1;
m_commands.find(command, &idx);
if (idx == -1) return;
((int*)m_dataHandles.get())[idx] = dataHandle;
} }
#endif #endif

View file

@ -14,17 +14,13 @@ class Plugins
public: public:
void FindCommands(char*,bool); void FindCommands(char*,bool);
bool IsPluginCommand(char*); bool IsPluginCommand(char*);
char* GetPluginDll(char*); char* GetPluginDll(char*, int*);
void StoreInstDLL(char*); void SetDllDataHandle(char*, int);
void StoreUninstDLL(char*);
char* GetInstDLL(int);
char* GetUninstDLL(int);
protected: protected:
DefineList m_commands; DefineList m_commands;
std::vector<char*> m_storedDLLs; GrowBuf m_dataHandles;
std::vector<char*> m_installDLLs; int m_funcsCount;
std::vector<char*> m_uninstallDLLs;
void GetExports(char*,bool); void GetExports(char*,bool);
}; };

View file

@ -84,7 +84,7 @@ class CEXEBuild {
void ps_addtoline(const char *str, GrowBuf &linedata, StringList &hist); void ps_addtoline(const char *str, GrowBuf &linedata, StringList &hist);
int doParse(const char *str, FILE *fp, const char *curfilename, int *lineptr); int doParse(const char *str, FILE *fp, const char *curfilename, int *lineptr);
int doCommand(int which_token, LineParser &line, FILE *fp, const char *curfilename, int linecnt); int doCommand(int which_token, LineParser &line, FILE *fp, const char *curfilename, int linecnt);
int do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override=0, int generatecode=1); int do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override=0, int generatecode=1, int *data_handle=0);
GrowBuf m_linebuild; // used for concatenating lines GrowBuf m_linebuild; // used for concatenating lines
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT #ifdef NSIS_CONFIG_PLUGIN_SUPPORT

View file

@ -3720,9 +3720,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
return PS_ERROR; return PS_ERROR;
case TOK__PLUGINCOMMAND: case TOK__PLUGINCOMMAND:
{ {
int ret; int ret, data_handle;
char* dllPath = m_plugins.GetPluginDll(line.gettoken_str(0)); char* dllPath = m_plugins.GetPluginDll(line.gettoken_str(0), &data_handle);
if (dllPath) if (dllPath)
{ {
if (uninstall_mode) uninst_plugin_used = true; if (uninstall_mode) uninst_plugin_used = true;
@ -3739,17 +3739,34 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
wsprintf(tempDLL, "$PLUGINSDIR%s", strrchr(dllPath,'\\')); wsprintf(tempDLL, "$PLUGINSDIR%s", strrchr(dllPath,'\\'));
// Add the DLL to the installer // Add the DLL to the installer
int files_added; if (data_handle == -1)
int old_build_overwrite=build_overwrite; {
build_overwrite=1; int files_added;
ret=do_add_file(dllPath,0,0,0,&files_added,tempDLL,2); // 2 means no size add int old_build_overwrite=build_overwrite;
if (ret != PS_OK) return ret; build_overwrite=1; // off
build_overwrite=old_build_overwrite; int old_build_datesave=build_datesave;
build_datesave=0; // off
ret=do_add_file(dllPath,0,0,linecnt,&files_added,tempDLL,2,&data_handle); // 2 means no size add
if (ret != PS_OK) return ret;
m_plugins.SetDllDataHandle(line.gettoken_str(0),data_handle);
build_overwrite=old_build_overwrite;
build_datesave=old_build_datesave;
}
else
{
ent.which=EW_EXTRACTFILE;
ent.offsets[0]=1; // overwrite off
ent.offsets[1]=add_string(tempDLL);
ent.offsets[2]=data_handle;
ret=add_entry(&ent);
if (ret != PS_OK) return ret;
}
// SetDetailsPrint lastused // SetDetailsPrint lastused
ent.which=EW_UPDATETEXT; ent.which=EW_UPDATETEXT;
ent.offsets[0]=0; ent.offsets[0]=0;
ent.offsets[1]=8; // lastused ent.offsets[1]=8; // lastused
ent.offsets[2]=0;
ret=add_entry(&ent); ret=add_entry(&ent);
if (ret != PS_OK) return ret; if (ret != PS_OK) return ret;
@ -3834,7 +3851,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
} }
#ifdef NSIS_SUPPORT_FILE #ifdef NSIS_SUPPORT_FILE
int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override, int generatecode) int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override, int generatecode, int *data_handle)
{ {
char dir[1024]; char dir[1024];
char newfn[1024], *s; char newfn[1024], *s;
@ -4009,6 +4026,11 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
return PS_ERROR; return PS_ERROR;
} }
if (data_handle)
{
*data_handle=ent.offsets[2];
}
{ {
DWORD s=getcurdbsize()-last_build_datablock_used; DWORD s=getcurdbsize()-last_build_datablock_used;
if (s) s-=4; if (s) s-=4;

View file

@ -186,13 +186,14 @@ public:
return 0; return 0;
} }
char *find(const char *str) // returns NULL if not found char *find(const char *str, int *idx=0) // returns NULL if not found
{ {
int id; int id;
int v=defines.find(str,0,&id); int v=defines.find(str,0,&id);
if (v<0) return NULL; if (v<0) return NULL;
v=values.idx2pos(id); v=values.idx2pos(id);
if (v<0) return NULL; if (v<0) return NULL;
if (idx) *idx=id;
return (char*)values.get()+v; return (char*)values.get()+v;
} }