Changed keyword UnicodeInstaller to a more versatile TargetMinimalOS <version> keyword

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6102 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
wizou 2010-06-14 15:24:50 +00:00
parent 52408912ab
commit 487e37ffb7
6 changed files with 44 additions and 21 deletions

View file

@ -492,7 +492,7 @@ def BuildStub(compression, solid, unicode):
if solid: if solid:
suffix = '_solid' suffix = '_solid'
if unicode: if unicode:
suffix += 'W' suffix += '.5_0'
env = stub_uenv.Clone() env = stub_uenv.Clone()
else: else:
env = stub_env.Clone() env = stub_env.Clone()

View file

@ -57,6 +57,12 @@
return rc; \ return rc; \
} while (false) } while (false)
const LONG available_stub_variants[] =
{
0x00000000, // classic ANSI stub
0x00050000 // Unicode stub for Windows 2000 and more recent (5.0+)
};
using namespace std; using namespace std;
namespace { // begin anonymous namespace namespace { // begin anonymous namespace
@ -116,8 +122,9 @@ CEXEBuild::CEXEBuild() :
definedlist.add(_T("NSIS_VERSION"), NSIS_VERSION); definedlist.add(_T("NSIS_VERSION"), NSIS_VERSION);
target_minimal_OS=0;
build_unicode=false; build_unicode=false;
definedlist.add(_T("NSIS_CHAR_SIZE"), _T("1")); // this can change after a UnicodeInstaller instruction is found definedlist.add(_T("NSIS_CHAR_SIZE"), _T("1")); // this can change after a TargetMinimalOS instruction is found
// automatically generated header file containing all defines // automatically generated header file containing all defines
#include <nsis-defines.h> #include <nsis-defines.h>
@ -3564,12 +3571,13 @@ void CEXEBuild::VerifyDeclaredUserVarRefs(UserVarsStringList *pVarsStringList)
} }
#ifdef _UNICODE #ifdef _UNICODE
int CEXEBuild::set_build_unicode(bool unicode_installer) int CEXEBuild::set_target_minimal_OS(int major, int minor)
{ {
build_unicode = unicode_installer; target_minimal_OS = MAKELONG(minor,major);
build_unicode = major>=5;
definedlist.del(_T("NSIS_UNICODE")); definedlist.del(_T("NSIS_UNICODE"));
definedlist.del(_T("NSIS_CHAR_SIZE")); definedlist.del(_T("NSIS_CHAR_SIZE"));
if (unicode_installer) // update defines depending on target installer type if (build_unicode) // update defines depending on target installer type
{ {
definedlist.add(_T("NSIS_UNICODE")); definedlist.add(_T("NSIS_UNICODE"));
definedlist.add(_T("NSIS_CHAR_SIZE"), _T("2")); definedlist.add(_T("NSIS_CHAR_SIZE"), _T("2"));
@ -3589,14 +3597,26 @@ int CEXEBuild::set_compressor(const tstring& compressor, const bool solid) {
return load_stub(); return load_stub();
} }
tstring CEXEBuild::get_stub_variant_suffix()
{
LONG variant = 0;
for (int index = 0; index < COUNTOF(available_stub_variants); index++)
{
if (target_minimal_OS >= available_stub_variants[index])
variant = available_stub_variants[index];
else
break;
}
if (variant == 0)
return tstring();
TCHAR buf[32];
_stprintf(buf, _T(".%d_%d"), HIWORD(variant), LOWORD(variant));
return tstring(buf);
}
int CEXEBuild::load_stub() int CEXEBuild::load_stub()
{ {
#ifdef _UNICODE return update_exehead(stub_filename+get_stub_variant_suffix(), &m_exehead_original_size);
if (build_unicode)
return update_exehead(stub_filename+_T('W'), &m_exehead_original_size);
else
#endif
return update_exehead(stub_filename, &m_exehead_original_size);
} }
int CEXEBuild::update_exehead(const tstring& file, size_t *size/*=NULL*/) { int CEXEBuild::update_exehead(const tstring& file, size_t *size/*=NULL*/) {

View file

@ -136,8 +136,9 @@ class CEXEBuild {
int prepare_uninstaller(); int prepare_uninstaller();
int pack_exe_header(); int pack_exe_header();
int set_build_unicode(bool unicode_installer); int set_target_minimal_OS(int major, int minor);
int set_compressor(const tstring& compressor, const bool solid); int set_compressor(const tstring& compressor, const bool solid);
tstring get_stub_variant_suffix();
int load_stub(); int load_stub();
int update_exehead(const tstring& file, size_t *size=NULL); int update_exehead(const tstring& file, size_t *size=NULL);
void update_exehead(const unsigned char *new_exehead, size_t new_size); void update_exehead(const unsigned char *new_exehead, size_t new_size);
@ -395,6 +396,7 @@ class CEXEBuild {
int build_compress_dict_size; int build_compress_dict_size;
bool no_space_texts; bool no_space_texts;
LONG target_minimal_OS;
bool build_unicode; bool build_unicode;
bool has_called_write_output; bool has_called_write_output;

View file

@ -2686,20 +2686,21 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_OK; return PS_OK;
#ifdef _UNICODE #ifdef _UNICODE
case TOK_UNICODEINSTALLER: case TOK_TARGETMINIMALOS:
{ {
if (build_compressor_set) { if (build_compressor_set) {
ERROR_MSG(_T("Error: can't change type of installer after data already got compressed or header already changed!\n")); ERROR_MSG(_T("Error: can't change target minimal OS version after data already got compressed or header already changed!\n"));
return PS_ERROR; return PS_ERROR;
} }
int param=line.gettoken_enum(1,_T("off\0on\0")); int major = 0, minor = 0;
if (param==-1) PRINTHELP() if (_stscanf(line.gettoken_str(1), _T("%d.%d"), &major, &minor) == 0)
SCRIPT_MSG(_T("UnicodeInstaller: %s\n"),line.gettoken_str(1)); PRINTHELP()
if (set_build_unicode(param != 0) != PS_OK) if (set_target_minimal_OS(major,minor) != PS_OK) // Windows 5.0 or more recent requested? => Unicode support
{ {
ERROR_MSG(_T("Error: error while setting type of installer! (stub not found?)\n")); ERROR_MSG(_T("Error: error while setting target minimal OS! (adequate stub not found?)\n"));
return PS_ERROR; return PS_ERROR;
} }
SCRIPT_MSG(_T("TargetMinimalOS: %d.%d %s\n"),major,minor,build_unicode?_T("(Unicode installer)"):_T(""));
} }
return PS_OK; return PS_OK;
#endif #endif

View file

@ -217,7 +217,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_STRLEN,_T("StrLen"),2,0,_T("$(user_var: length output) str"),TP_CODE}, {TOK_STRLEN,_T("StrLen"),2,0,_T("$(user_var: length output) str"),TP_CODE},
{TOK_SUBCAPTION,_T("SubCaption"),2,0,_T("page_number(0-4) new_subcaption"),TP_GLOBAL}, {TOK_SUBCAPTION,_T("SubCaption"),2,0,_T("page_number(0-4) new_subcaption"),TP_GLOBAL},
#ifdef _UNICODE #ifdef _UNICODE
{TOK_UNICODEINSTALLER,_T("UnicodeInstaller"),1,0,_T("(on|off)"),TP_GLOBAL}, {TOK_TARGETMINIMALOS,_T("TargetMinimalOS"),1,0,_T("windows_version"),TP_GLOBAL},
#endif #endif
{TOK_UNINSTALLEXENAME,_T("UninstallExeName"),0,0,_T("no longer supported, use WriteUninstaller from section."),TP_ALL}, {TOK_UNINSTALLEXENAME,_T("UninstallExeName"),0,0,_T("no longer supported, use WriteUninstaller from section."),TP_ALL},
{TOK_UNINSTCAPTION,_T("UninstallCaption"),1,0,_T("uninstaller_caption"),TP_GLOBAL}, {TOK_UNINSTCAPTION,_T("UninstallCaption"),1,0,_T("uninstaller_caption"),TP_GLOBAL},

View file

@ -71,7 +71,7 @@ enum
TOK_VI_ADDKEY, TOK_VI_ADDKEY,
TOK_VI_SETPRODUCTVERSION, TOK_VI_SETPRODUCTVERSION,
#ifdef _UNICODE #ifdef _UNICODE
TOK_UNICODEINSTALLER, TOK_TARGETMINIMALOS,
#endif #endif
TOK_MISCBUTTONTEXT, TOK_MISCBUTTONTEXT,