applied patch #1638974 - option to set process priority of makensis

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4913 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2007-01-27 16:53:37 +00:00
parent e92f1b0675
commit 41d2436490
2 changed files with 39 additions and 0 deletions

View file

@ -15,6 +15,8 @@ If you want to use MakeNSIS on the command line, the syntax of the makensis comm
\b The /V switch followed by a number between 0 and 4 will set the verbosity of output accordingly. 0=no output, 1=errors only, 2=warnings and errors, 3=info, warnings, and errors, 4=all output.
\b The /P switch followed by a number between 0 and 5 will set the priority of the compiler process accordingly. 0=idle, 1=below normal, 2=normal (default), 3=above normal, 4=high, 5=realtime.
\b The /O switch followed by a filename tells the compiler to print its log to that file (instead of the screen)
\b /PAUSE makes makensis pause before quitting, which is useful when executing directly from Windows.
@ -39,6 +41,8 @@ If you want to use MakeNSIS on the command line, the syntax of the makensis comm
\b If multiple scripts are specified, they are treated as one concatenated script.
\b On Windows 95, 98 and NT, below normal and above normal process priorities are not available. On those systems, below normal will actually set priority to idle and above normal will set to high.
\S1{usageenvironment} Environment variables
makensis checks a number of environment variables that tell it where to locate the things it needs in order to create installers. These variables include:

View file

@ -130,6 +130,8 @@ static void print_usage()
" " OPT_STR "HDRINFO prints information about what options makensis was compiled with\n"
" " OPT_STR "LICENSE prints the makensis software license\n"
" " OPT_STR "VERSION prints the makensis version and exits\n"
" " OPT_STR "Px sets the compiler process priority, where x is 5=realtime,4=high,\n"
" " " 3=above normal,2=normal,1=below normal,0=idle\n"
" " OPT_STR "Vx verbosity where x is 4=all,3=no script,2=no info,1=no warnings,0=none\n"
" " OPT_STR "Ofile specifies a text file to log compiler output (default is stdout)\n"
" " OPT_STR "PAUSE pauses after execution\n"
@ -387,6 +389,39 @@ int main(int argc, char **argv)
print_stub_info(build);
nousage++;
}
else if ((argv[argpos][1]=='P' || argv[argpos][1]=='p') &&
argv[argpos][2] >= '0' && argv[argpos][2] <= '5' && !argv[argpos][3])
{
#ifdef _WIN32
// priority setting added 01-2007 by Comm@nder21
int p=argv[argpos][2]-'0';
HANDLE hProc = GetCurrentProcess();
struct
{
DWORD priority;
DWORD fallback;
} classes[] = {
{IDLE_PRIORITY_CLASS, IDLE_PRIORITY_CLASS},
{BELOW_NORMAL_PRIORITY_CLASS, IDLE_PRIORITY_CLASS},
{NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS},
{ABOVE_NORMAL_PRIORITY_CLASS, HIGH_PRIORITY_CLASS},
{HIGH_PRIORITY_CLASS, HIGH_PRIORITY_CLASS},
{REALTIME_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS}
};
if (SetPriorityClass(hProc, classes[p].priority) == FALSE)
{
SetPriorityClass(hProc, classes[p].fallback);
}
if (p == 5)
build.warning("makensis is running in REALTIME priority mode!");
#else
build.warning(OPT_STR "Px is disabled for non Win32 platforms.");
#endif
}
else break;
}
else