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:
parent
2f8a2e37a7
commit
1f9aee2b38
5 changed files with 57 additions and 26 deletions
|
@ -48,6 +48,9 @@ void Plugins::FindCommands(char* path,bool displayInfo)
|
|||
delete[] pathAndWildcard;
|
||||
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;
|
||||
wsprintf(signature, "%s::%s", dllName, name);
|
||||
m_commands.add(signature, pathToDll);
|
||||
char *dll = new char[lstrlen(dllName)];
|
||||
lstrcpy(dll, dllName);
|
||||
m_storedDLLs.push_back(dll);
|
||||
m_funcsCount++;
|
||||
if (displayInfo)
|
||||
fprintf(g_output, " - %s\n", signature);
|
||||
}
|
||||
|
@ -133,12 +134,23 @@ void Plugins::GetExports(char* pathToDll,bool displayInfo)
|
|||
|
||||
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
|
|
@ -14,17 +14,13 @@ class Plugins
|
|||
public:
|
||||
void FindCommands(char*,bool);
|
||||
bool IsPluginCommand(char*);
|
||||
char* GetPluginDll(char*);
|
||||
void StoreInstDLL(char*);
|
||||
void StoreUninstDLL(char*);
|
||||
char* GetInstDLL(int);
|
||||
char* GetUninstDLL(int);
|
||||
char* GetPluginDll(char*, int*);
|
||||
void SetDllDataHandle(char*, int);
|
||||
|
||||
protected:
|
||||
DefineList m_commands;
|
||||
std::vector<char*> m_storedDLLs;
|
||||
std::vector<char*> m_installDLLs;
|
||||
std::vector<char*> m_uninstallDLLs;
|
||||
DefineList m_commands;
|
||||
GrowBuf m_dataHandles;
|
||||
int m_funcsCount;
|
||||
|
||||
void GetExports(char*,bool);
|
||||
};
|
||||
|
|
|
@ -84,7 +84,7 @@ class CEXEBuild {
|
|||
void ps_addtoline(const char *str, GrowBuf &linedata, StringList &hist);
|
||||
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 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
|
||||
|
||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
|
|
|
@ -3720,9 +3720,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
return PS_ERROR;
|
||||
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 (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,'\\'));
|
||||
|
||||
// Add the DLL to the installer
|
||||
int files_added;
|
||||
int old_build_overwrite=build_overwrite;
|
||||
build_overwrite=1;
|
||||
ret=do_add_file(dllPath,0,0,0,&files_added,tempDLL,2); // 2 means no size add
|
||||
if (ret != PS_OK) return ret;
|
||||
build_overwrite=old_build_overwrite;
|
||||
if (data_handle == -1)
|
||||
{
|
||||
int files_added;
|
||||
int old_build_overwrite=build_overwrite;
|
||||
build_overwrite=1; // off
|
||||
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
|
||||
ent.which=EW_UPDATETEXT;
|
||||
ent.offsets[0]=0;
|
||||
ent.offsets[1]=8; // lastused
|
||||
ent.offsets[2]=0;
|
||||
ret=add_entry(&ent);
|
||||
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
|
||||
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 newfn[1024], *s;
|
||||
|
@ -4009,6 +4026,11 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
return PS_ERROR;
|
||||
}
|
||||
|
||||
if (data_handle)
|
||||
{
|
||||
*data_handle=ent.offsets[2];
|
||||
}
|
||||
|
||||
{
|
||||
DWORD s=getcurdbsize()-last_build_datablock_used;
|
||||
if (s) s-=4;
|
||||
|
|
|
@ -186,13 +186,14 @@ public:
|
|||
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 v=defines.find(str,0,&id);
|
||||
if (v<0) return NULL;
|
||||
v=values.idx2pos(id);
|
||||
if (v<0) return NULL;
|
||||
if (idx) *idx=id;
|
||||
return (char*)values.get()+v;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue