From 0be416427028b8ea0b1c91c13647c89f5597615e Mon Sep 17 00:00:00 2001 From: anders_k Date: Tue, 17 Aug 2021 15:08:24 +0000 Subject: [PATCH] Added /LAUNCH compiler switch git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7292 212acab6-be3b-0410-9dea-997c60f758d6 --- Docs/src/history.but | 2 ++ Docs/src/usage.but | 2 ++ Source/SConscript | 1 + Source/build.h | 1 + Source/makenssi.cpp | 18 ++++++++++++++++-- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Docs/src/history.but b/Docs/src/history.but index f82afeaa..c1a7cf50 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -14,6 +14,8 @@ Released on ???? ??th, 20?? \b Disallow start maximized mode +\b Added /LAUNCH compiler switch + \H{v3.07} 3.07 Released on July 24th, 2021 diff --git a/Docs/src/usage.but b/Docs/src/usage.but index d0763dbb..175bb9ab 100644 --- a/Docs/src/usage.but +++ b/Docs/src/usage.but @@ -19,6 +19,8 @@ If you want to use MakeNSIS on the command line, the syntax of makensis is: \b The /O switch followed by a filename tells the compiler to print its log to that file (instead of the screen) +\b /LAUNCH executes the generated installer. + \b /PAUSE makes makensis pause before quitting, which is useful when executing directly from Windows. \b /NOCONFIG disables inclusion of nsisconf.nsh. Without this parameter, installer defaults are set from nsisconf.nsh. diff --git a/Source/SConscript b/Source/SConscript index ffd6c7d0..3728935a 100644 --- a/Source/SConscript +++ b/Source/SConscript @@ -57,6 +57,7 @@ libs = Split(""" iconv shlwapi oleaut32 + shell32 """) Import('env AddAvailableLibs AddZLib') diff --git a/Source/build.h b/Source/build.h index f73cddb4..583ca903 100644 --- a/Source/build.h +++ b/Source/build.h @@ -253,6 +253,7 @@ class CEXEBuild { unsigned int get_header_size() const { return (unsigned int)sizeof(header) + (is_target_64bit() ? (4 * BLOCKS_NUM) : 0); } void set_default_output_filename(const tstring& filename); + const TCHAR* get_output_filename() const { return build_output_filename; } // process a script (you can process as many scripts as you want, // it is as if they are concatenated) diff --git a/Source/makenssi.cpp b/Source/makenssi.cpp index ccca6635..bc85affa 100644 --- a/Source/makenssi.cpp +++ b/Source/makenssi.cpp @@ -181,6 +181,7 @@ static void print_usage() _T(" ") OPT_STR _T("Vx verbosity where x is 4=all,3=no script,2=no info,1=no warnings,0=none\n") _T(" ") OPT_STR _T("WX treat warnings as errors\n") _T(" ") OPT_STR _T("Ofile specifies a text file to log compiler output (default is stdout)\n") + _T(" ") OPT_STR _T("LAUNCH executes the generated installer\n") _T(" ") OPT_STR _T("PAUSE pauses after execution\n") _T(" ") OPT_STR _T("NOCONFIG disables inclusion of ") PLATFORM_PATH_SEPARATOR_STR _T("nsisconf.nsh\n") _T(" ") OPT_STR _T("NOCD disables the current directory change to that of the .nsi file\n") @@ -309,7 +310,7 @@ static inline int makensismain(int argc, TCHAR **argv) const TCHAR*stdoutredirname=0; NStreamEncoding inputenc, &outputenc = g_outputenc; int argpos=0; - bool do_cd=true, noconfig=false; + unsigned char do_cd=true, noconfig=false, do_exec=false; bool no_logo=true, warnaserror=false; bool initialparsefail=false, in_files=false; bool oneoutputstream=false; @@ -467,8 +468,9 @@ static inline int makensismain(int argc, TCHAR **argv) if (!_tcsicmp(swname,_T("PPO")) || !_tcsicmp(swname,_T("SafePPO"))) {} // Already parsed else if (!_tcsicmp(swname,_T("WX"))) {} // Already parsed else if (!_tcsicmp(swname,_T("NOCD"))) do_cd=false; - else if (!_tcsicmp(swname,_T("NOCONFIG"))) noconfig=true; + else if (!_tcsicmp(swname,_T("NOCONFIG"))) noconfig++; else if (!_tcsicmp(swname,_T("PAUSE"))) g_dopause=true; + else if (!_tcsicmp(swname,_T("LAUNCH"))) do_exec++; else if (!_tcsicmp(swname,_T("HELP"))) { print_usage(); @@ -670,6 +672,18 @@ static inline int makensismain(int argc, TCHAR **argv) build.ERROR_MSG(_T("Error - aborting creation process\n")); return 1; } + + if (do_exec) + { + const TCHAR *app = build.get_output_filename(); +#ifdef _WIN32 + ShellExecute(0, 0, app, 0, 0, SW_SHOW); +#else + const TCHAR *cmd = _tgetenv(_T("NSISLAUNCHCOMMAND")); + sane_system(replace_all(cmd ? cmd : _T("wine start '%1'"), _T("%1"), app).c_str()); +#endif + } + return 0; }