#1977885: adding !finalize preprocessor commands for post-build execution
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6103 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
487e37ffb7
commit
51a7c3d647
5 changed files with 28 additions and 1 deletions
|
@ -172,7 +172,7 @@ CEXEBuild::CEXEBuild() :
|
||||||
build_cursection_isfunc=0;
|
build_cursection_isfunc=0;
|
||||||
build_cursection=NULL;
|
build_cursection=NULL;
|
||||||
// init public data.
|
// init public data.
|
||||||
build_packname[0]=build_packcmd[0]=build_output_filename[0]=0;
|
build_packname[0]=build_packcmd[0]=build_output_filename[0]=postbuild_cmd[0]=0;
|
||||||
|
|
||||||
// Added by ramon 23 May 2003
|
// Added by ramon 23 May 2003
|
||||||
build_allowskipfiles=1;
|
build_allowskipfiles=1;
|
||||||
|
@ -2898,6 +2898,24 @@ int CEXEBuild::write_output(void)
|
||||||
ftell(fp),total_usize,pc/10,pc%10);
|
ftell(fp),total_usize,pc/10,pc%10);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
if (postbuild_cmd[0])
|
||||||
|
{
|
||||||
|
LPTSTR arg = _tcsstr(postbuild_cmd, _T("%1"));
|
||||||
|
if (arg) // if found, replace %1 by build_output_filename
|
||||||
|
{
|
||||||
|
memmove(arg+_tcslen(build_output_filename), arg+2, (_tcslen(arg+2)+1)*sizeof(TCHAR));
|
||||||
|
memmove(arg, build_output_filename, _tcslen(build_output_filename)*sizeof(TCHAR));
|
||||||
|
}
|
||||||
|
SCRIPT_MSG(_T("\nFinalize command: %s\n"),postbuild_cmd);
|
||||||
|
#ifdef _WIN32
|
||||||
|
int ret=sane_system(postbuild_cmd);
|
||||||
|
#else
|
||||||
|
PATH_CONVERT(postbuild_cmd);
|
||||||
|
int ret=system(postbuild_cmd);
|
||||||
|
#endif
|
||||||
|
if (ret != 0)
|
||||||
|
INFO_MSG(_T("Finalize command returned %d\n"),ret);
|
||||||
|
}
|
||||||
print_warnings();
|
print_warnings();
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,6 +402,7 @@ class CEXEBuild {
|
||||||
bool has_called_write_output;
|
bool has_called_write_output;
|
||||||
|
|
||||||
TCHAR build_packname[1024], build_packcmd[1024];
|
TCHAR build_packname[1024], build_packcmd[1024];
|
||||||
|
TCHAR postbuild_cmd[1024];
|
||||||
int build_overwrite, build_last_overwrite, build_crcchk,
|
int build_overwrite, build_last_overwrite, build_crcchk,
|
||||||
build_datesave, build_optimize_datablock,
|
build_datesave, build_optimize_datablock,
|
||||||
build_allowskipfiles; // Added by ramon 23 May 2003
|
build_allowskipfiles; // Added by ramon 23 May 2003
|
||||||
|
|
|
@ -2960,6 +2960,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
SCRIPT_MSG(_T("!packhdr: filename=\"%s\", command=\"%s\"\n"),
|
SCRIPT_MSG(_T("!packhdr: filename=\"%s\", command=\"%s\"\n"),
|
||||||
build_packname, build_packcmd);
|
build_packname, build_packcmd);
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
|
case TOK_P_FINALIZE:
|
||||||
|
if (postbuild_cmd[0])
|
||||||
|
warning_fl(_T("Several !finalize instructions encountered. Only last one was executed"));
|
||||||
|
_tcsnccpy(postbuild_cmd,line.gettoken_str(1),COUNTOF(postbuild_cmd)-1);
|
||||||
|
SCRIPT_MSG(_T("!finalize: \"%s\"\n"),postbuild_cmd);
|
||||||
|
return PS_OK;
|
||||||
case TOK_P_SYSTEMEXEC:
|
case TOK_P_SYSTEMEXEC:
|
||||||
{
|
{
|
||||||
TCHAR *exec=line.gettoken_str(1);
|
TCHAR *exec=line.gettoken_str(1);
|
||||||
|
|
|
@ -240,6 +240,7 @@ static tokenType tokenlist[TOK__LAST] =
|
||||||
{TOK_XPSTYLE, _T("XPStyle"),1,0,_T("(on|off)"),TP_GLOBAL},
|
{TOK_XPSTYLE, _T("XPStyle"),1,0,_T("(on|off)"),TP_GLOBAL},
|
||||||
{TOK_REQEXECLEVEL, _T("RequestExecutionLevel"),1,0,_T("none|user|highest|admin"),TP_GLOBAL},
|
{TOK_REQEXECLEVEL, _T("RequestExecutionLevel"),1,0,_T("none|user|highest|admin"),TP_GLOBAL},
|
||||||
{TOK_P_PACKEXEHEADER,_T("!packhdr"),2,0,_T("temp_file_name command_line_to_compress_that_temp_file"),TP_ALL},
|
{TOK_P_PACKEXEHEADER,_T("!packhdr"),2,0,_T("temp_file_name command_line_to_compress_that_temp_file"),TP_ALL},
|
||||||
|
{TOK_P_FINALIZE,_T("!finalize"),1,0,_T("command_with_%1"),TP_ALL},
|
||||||
{TOK_P_SYSTEMEXEC,_T("!system"),1,2,_T("command [<|>|<>|=) retval]"),TP_ALL},
|
{TOK_P_SYSTEMEXEC,_T("!system"),1,2,_T("command [<|>|<>|=) retval]"),TP_ALL},
|
||||||
{TOK_P_EXECUTE,_T("!execute"),1,0,_T("command"),TP_ALL},
|
{TOK_P_EXECUTE,_T("!execute"),1,0,_T("command"),TP_ALL},
|
||||||
{TOK_P_ADDINCLUDEDIR,_T("!AddIncludeDir"),1,0,_T("dir"),TP_ALL},
|
{TOK_P_ADDINCLUDEDIR,_T("!AddIncludeDir"),1,0,_T("dir"),TP_ALL},
|
||||||
|
|
|
@ -101,6 +101,7 @@ enum
|
||||||
TOK_P_DEFINE,
|
TOK_P_DEFINE,
|
||||||
TOK_P_UNDEF,
|
TOK_P_UNDEF,
|
||||||
TOK_P_PACKEXEHEADER,
|
TOK_P_PACKEXEHEADER,
|
||||||
|
TOK_P_FINALIZE,
|
||||||
TOK_P_SYSTEMEXEC,
|
TOK_P_SYSTEMEXEC,
|
||||||
TOK_P_EXECUTE,
|
TOK_P_EXECUTE,
|
||||||
TOK_P_ADDINCLUDEDIR,
|
TOK_P_ADDINCLUDEDIR,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue