- stubs are no longer included in makensis but read from the Stubs directory
- new /SOLID switch for SetCompressor allows setting solid compression without recompiling makensis git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3945 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
c345108cc0
commit
9613c8988f
10 changed files with 157 additions and 211 deletions
132
Source/build.cpp
132
Source/build.cpp
|
@ -3,8 +3,6 @@
|
||||||
#include "exehead/config.h"
|
#include "exehead/config.h"
|
||||||
#include "exehead/fileform.h"
|
#include "exehead/fileform.h"
|
||||||
|
|
||||||
#include "exedata.h"
|
|
||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -86,19 +84,6 @@ CEXEBuild::CEXEBuild() :
|
||||||
ns_func.add("",0); // make sure offset 0 is special on these (i.e. never used by a label)
|
ns_func.add("",0); // make sure offset 0 is special on these (i.e. never used by a label)
|
||||||
ns_label.add("",0);
|
ns_label.add("",0);
|
||||||
|
|
||||||
exehead_original_size = zlib_exehead_size;
|
|
||||||
update_exehead(zlib_exehead, zlib_exehead_size);
|
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
|
||||||
// Changed by Amir Szekely 11th July 2002
|
|
||||||
// No need to check for uninstaller icon if uninstall support is disabled.
|
|
||||||
if (unicondata_size != icondata_size)
|
|
||||||
{
|
|
||||||
ERROR_MSG("Internal compiler error #12345: installer,uninstaller icon size mismatch (%d,%d)\n",icondata_size,unicondata_size);
|
|
||||||
extern void quit(); quit();
|
|
||||||
}
|
|
||||||
#endif // NSIS_CONFIG_UNINSTALL_SUPPORT
|
|
||||||
|
|
||||||
extern const char *NSIS_VERSION;
|
extern const char *NSIS_VERSION;
|
||||||
definedlist.add("NSIS_VERSION", NSIS_VERSION);
|
definedlist.add("NSIS_VERSION", NSIS_VERSION);
|
||||||
|
|
||||||
|
@ -363,12 +348,8 @@ definedlist.add("NSIS_SUPPORT_LANG_IN_STRINGS");
|
||||||
build_font[0]=0;
|
build_font[0]=0;
|
||||||
build_font_size=0;
|
build_font_size=0;
|
||||||
|
|
||||||
m_unicon_data=(unsigned char *)malloc(unicondata_size+3*sizeof(DWORD));
|
m_unicon_data=NULL;
|
||||||
memcpy(m_unicon_data+2*sizeof(DWORD),unicon_data+22,unicondata_size);
|
m_unicon_size=0;
|
||||||
*(DWORD*)(m_unicon_data) = unicondata_size;
|
|
||||||
*(DWORD*)(m_unicon_data + sizeof(DWORD)) = 0;
|
|
||||||
*(DWORD*)(m_unicon_data + 2*sizeof(DWORD) + unicondata_size) = 0;
|
|
||||||
unicondata_size += 3*sizeof(DWORD);
|
|
||||||
|
|
||||||
branding_image_found=false;
|
branding_image_found=false;
|
||||||
|
|
||||||
|
@ -476,15 +457,32 @@ definedlist.add("NSIS_SUPPORT_LANG_IN_STRINGS");
|
||||||
m_ShellConstants.add("CDBURN_AREA", CSIDL_CDBURN_AREA, CSIDL_CDBURN_AREA);
|
m_ShellConstants.add("CDBURN_AREA", CSIDL_CDBURN_AREA, CSIDL_CDBURN_AREA);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEXEBuild::setdirs(const char *argv0)
|
void CEXEBuild::initialize(const char *makensis_path)
|
||||||
{
|
{
|
||||||
string nsis_dir = get_executable_dir(argv0);
|
string nsis_dir = get_executable_dir(makensis_path);
|
||||||
|
|
||||||
definedlist.add("NSISDIR",nsis_dir.c_str());
|
definedlist.add("NSISDIR",nsis_dir.c_str());
|
||||||
|
|
||||||
nsis_dir += PLATFORM_PATH_SEPARATOR_STR;
|
string includes_dir = nsis_dir;
|
||||||
nsis_dir += "Include";
|
includes_dir += PLATFORM_PATH_SEPARATOR_STR;
|
||||||
include_dirs.add(nsis_dir.c_str(),0);
|
includes_dir += "Include";
|
||||||
|
include_dirs.add(includes_dir.c_str(),0);
|
||||||
|
|
||||||
|
stubs_dir = nsis_dir;
|
||||||
|
stubs_dir += PLATFORM_PATH_SEPARATOR_STR;
|
||||||
|
stubs_dir += "Stubs";
|
||||||
|
|
||||||
|
if (set_compressor("zlib", false) != PS_OK)
|
||||||
|
{
|
||||||
|
throw runtime_error("error setting default stub");
|
||||||
|
}
|
||||||
|
|
||||||
|
string uninst = stubs_dir + PLATFORM_PATH_SEPARATOR_STR + "uninst";
|
||||||
|
m_unicon_data = generate_uninstall_icon_data(uninst.c_str(), m_unicon_size);
|
||||||
|
if (!m_unicon_data)
|
||||||
|
{
|
||||||
|
throw runtime_error("invalid default uninstall icon");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2301,31 +2299,16 @@ int CEXEBuild::pack_exe_header()
|
||||||
ERROR_MSG("Error: calling packer on \"%s\"\n",build_packname);
|
ERROR_MSG("Error: calling packer on \"%s\"\n",build_packname);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
tmpfile=FOPEN(build_packname,"rb");
|
|
||||||
if (!tmpfile)
|
int result = update_exehead(build_packname);
|
||||||
|
remove(build_packname);
|
||||||
|
|
||||||
|
if (result != PS_OK)
|
||||||
{
|
{
|
||||||
remove(build_packname);
|
|
||||||
ERROR_MSG("Error: reading temporary file \"%s\" after pack\n",build_packname);
|
ERROR_MSG("Error: reading temporary file \"%s\" after pack\n",build_packname);
|
||||||
return PS_ERROR;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read header from file
|
|
||||||
|
|
||||||
fseek(tmpfile,0,SEEK_END);
|
|
||||||
size_t exehead_size = ftell(tmpfile);
|
|
||||||
|
|
||||||
unsigned char *exehead = new unsigned char[exehead_size];
|
|
||||||
fseek(tmpfile,0,SEEK_SET);
|
|
||||||
fread(exehead,1,exehead_size,tmpfile);
|
|
||||||
fclose(tmpfile);
|
|
||||||
|
|
||||||
update_exehead(exehead, exehead_size);
|
|
||||||
|
|
||||||
// cleanup
|
|
||||||
// TODO: use resource-controlling classes (e.g. Boost)
|
|
||||||
delete [] exehead;
|
|
||||||
remove(build_packname);
|
|
||||||
|
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2579,9 +2562,9 @@ int CEXEBuild::write_output(void)
|
||||||
INFO_MSG("\nUsing %s%s compression.\n\n", compressor->GetName(), build_compress_whole?" (compress whole)":"");
|
INFO_MSG("\nUsing %s%s compression.\n\n", compressor->GetName(), build_compress_whole?" (compress whole)":"");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int total_usize=exehead_original_size;
|
int total_usize=m_exehead_original_size;
|
||||||
|
|
||||||
INFO_MSG("EXE header size: %10d / %d bytes\n",m_exehead_size,exehead_original_size);
|
INFO_MSG("EXE header size: %10d / %d bytes\n",m_exehead_size,m_exehead_original_size);
|
||||||
|
|
||||||
if (build_compress_whole) {
|
if (build_compress_whole) {
|
||||||
INFO_MSG("Install code: (%d bytes)\n",
|
INFO_MSG("Install code: (%d bytes)\n",
|
||||||
|
@ -2795,8 +2778,7 @@ int CEXEBuild::uninstall_generate()
|
||||||
// Get offsets of icons to replace for uninstall
|
// Get offsets of icons to replace for uninstall
|
||||||
// Also makes sure that the icons are there and in the right size.
|
// Also makes sure that the icons are there and in the right size.
|
||||||
// TODO: fix generate_unicons_offsets to check ranges (!)
|
// TODO: fix generate_unicons_offsets to check ranges (!)
|
||||||
icon_offset = generate_unicons_offsets(m_exehead, m_unicon_data);
|
if (generate_unicons_offsets(m_exehead, m_unicon_data) == 0)
|
||||||
if (icon_offset == 0)
|
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
|
|
||||||
entry *ent = (entry *) build_entries.get();
|
entry *ent = (entry *) build_entries.get();
|
||||||
|
@ -2810,7 +2792,7 @@ int CEXEBuild::uninstall_generate()
|
||||||
if (ent->which == EW_WRITEUNINSTALLER)
|
if (ent->which == EW_WRITEUNINSTALLER)
|
||||||
{
|
{
|
||||||
ent->offsets[1] = uninstdata_offset;
|
ent->offsets[1] = uninstdata_offset;
|
||||||
ent->offsets[2] = unicondata_size;
|
ent->offsets[2] = m_unicon_size;
|
||||||
uns--;
|
uns--;
|
||||||
if (!uns)
|
if (!uns)
|
||||||
break;
|
break;
|
||||||
|
@ -2818,7 +2800,7 @@ int CEXEBuild::uninstall_generate()
|
||||||
ent++;
|
ent++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_db_data((char *)m_unicon_data,unicondata_size) < 0)
|
if (add_db_data((char *)m_unicon_data,m_unicon_size) < 0)
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
||||||
|
@ -2980,7 +2962,7 @@ int CEXEBuild::uninstall_generate()
|
||||||
udata.clear();
|
udata.clear();
|
||||||
|
|
||||||
//uninstall_size_full=fh.length_of_all_following_data + sizeof(int) + unicondata_size - 32 + sizeof(int);
|
//uninstall_size_full=fh.length_of_all_following_data + sizeof(int) + unicondata_size - 32 + sizeof(int);
|
||||||
uninstall_size_full=fh.length_of_all_following_data+unicondata_size;
|
uninstall_size_full=fh.length_of_all_following_data+m_unicon_size;
|
||||||
|
|
||||||
// compressed size
|
// compressed size
|
||||||
uninstall_size=build_datablock.getlen()-uninstdata_offset;
|
uninstall_size=build_datablock.getlen()-uninstdata_offset;
|
||||||
|
@ -2991,7 +2973,6 @@ int CEXEBuild::uninstall_generate()
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define SWAP(x,y,i) { i _ii; _ii=x; x=y; y=_ii; }
|
#define SWAP(x,y,i) { i _ii; _ii=x; x=y; y=_ii; }
|
||||||
|
|
||||||
void CEXEBuild::set_uninstall_mode(int un)
|
void CEXEBuild::set_uninstall_mode(int un)
|
||||||
|
@ -3379,6 +3360,46 @@ void CEXEBuild::VerifyDeclaredUserVarRefs(UserVarsStringList *pVarsStringList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CEXEBuild::set_compressor(const string& compressor, const bool solid) {
|
||||||
|
string stub = stubs_dir + PLATFORM_PATH_SEPARATOR_STR + compressor;
|
||||||
|
if (solid)
|
||||||
|
stub += "_solid";
|
||||||
|
|
||||||
|
return update_exehead(stub, &m_exehead_original_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CEXEBuild::update_exehead(const string& file, size_t *size/*=NULL*/) {
|
||||||
|
FILE *tmpfile = fopen(file.c_str(), "rb");
|
||||||
|
if (!tmpfile)
|
||||||
|
{
|
||||||
|
ERROR_MSG("Error: opening stub \"%s\"\n", file.c_str());
|
||||||
|
return PS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
fseek(tmpfile, 0, SEEK_END);
|
||||||
|
size_t exehead_size = ftell(tmpfile);
|
||||||
|
|
||||||
|
unsigned char *exehead = new unsigned char[exehead_size];
|
||||||
|
fseek(tmpfile, 0, SEEK_SET);
|
||||||
|
if (fread(exehead, 1, exehead_size, tmpfile) != exehead_size)
|
||||||
|
{
|
||||||
|
ERROR_MSG("Error: reading stub \"%s\"\n", file.c_str());
|
||||||
|
fclose(tmpfile);
|
||||||
|
delete [] exehead;
|
||||||
|
return PS_ERROR;
|
||||||
|
}
|
||||||
|
fclose(tmpfile);
|
||||||
|
|
||||||
|
update_exehead(exehead, exehead_size);
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
*size = exehead_size;
|
||||||
|
|
||||||
|
delete [] exehead;
|
||||||
|
|
||||||
|
return PS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
void CEXEBuild::update_exehead(const unsigned char *new_exehead, size_t new_size) {
|
void CEXEBuild::update_exehead(const unsigned char *new_exehead, size_t new_size) {
|
||||||
assert(m_exehead != new_exehead);
|
assert(m_exehead != new_exehead);
|
||||||
|
|
||||||
|
@ -3394,3 +3415,4 @@ void CEXEBuild::update_exehead(const unsigned char *new_exehead, size_t new_size
|
||||||
// zero rest of exehead
|
// zero rest of exehead
|
||||||
memset(m_exehead + new_size, 0, m_exehead_size - new_size);
|
memset(m_exehead + new_size, 0, m_exehead_size - new_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ enum notify_e {
|
||||||
class CEXEBuild {
|
class CEXEBuild {
|
||||||
public:
|
public:
|
||||||
CEXEBuild();
|
CEXEBuild();
|
||||||
void setdirs(const char *argv0);
|
void initialize(const char *makensis_path);
|
||||||
~CEXEBuild();
|
~CEXEBuild();
|
||||||
|
|
||||||
// to add a warning to the compiler's warning list.
|
// to add a warning to the compiler's warning list.
|
||||||
|
@ -116,6 +116,8 @@ class CEXEBuild {
|
||||||
int prepare_uninstaller();
|
int prepare_uninstaller();
|
||||||
int pack_exe_header();
|
int pack_exe_header();
|
||||||
|
|
||||||
|
int set_compressor(const std::string& compressor, const bool solid);
|
||||||
|
int update_exehead(const std::string& 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);
|
||||||
|
|
||||||
// tokens.cpp
|
// tokens.cpp
|
||||||
|
@ -281,6 +283,8 @@ class CEXEBuild {
|
||||||
|
|
||||||
// a whole bunch O data.
|
// a whole bunch O data.
|
||||||
|
|
||||||
|
std::string stubs_dir;
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
||||||
ICompressor *compressor;
|
ICompressor *compressor;
|
||||||
CZlib zlib_compressor;
|
CZlib zlib_compressor;
|
||||||
|
@ -361,11 +365,12 @@ class CEXEBuild {
|
||||||
|
|
||||||
unsigned char *m_exehead;
|
unsigned char *m_exehead;
|
||||||
size_t m_exehead_size;
|
size_t m_exehead_size;
|
||||||
|
size_t m_exehead_original_size;
|
||||||
|
|
||||||
int icon_offset;
|
|
||||||
bool branding_image_found;
|
bool branding_image_found;
|
||||||
WORD branding_image_id;
|
WORD branding_image_id;
|
||||||
unsigned char *m_unicon_data;
|
unsigned char *m_unicon_data;
|
||||||
|
size_t m_unicon_size;
|
||||||
|
|
||||||
#ifdef NSIS_SUPPORT_BGBG
|
#ifdef NSIS_SUPPORT_BGBG
|
||||||
LOGFONT bg_font;
|
LOGFONT bg_font;
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
#include "exedata.h"
|
|
||||||
|
|
||||||
//#ifndef _DEBUG
|
|
||||||
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
|
||||||
#include "exehead/Release-zlib/bitmap1.h"
|
|
||||||
#endif
|
|
||||||
#include "exehead/Release-zlib/icon.h"
|
|
||||||
#include "exehead/Release-zlib/unicon.h"
|
|
||||||
#include "exehead/Release-zlib/exehead_zlib.h"
|
|
||||||
#include "exehead/Release-bzip2/exehead_bzip2.h"
|
|
||||||
#include "exehead/Release-lzma/exehead_lzma.h"
|
|
||||||
/*#else
|
|
||||||
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
|
||||||
#include "exehead/Debug-zlib/bitmap1.h"
|
|
||||||
#endif
|
|
||||||
#include "exehead/Debug-zlib/icon.h"
|
|
||||||
#include "exehead/Debug-zlib/unicon.h"
|
|
||||||
#include "exehead/Debug-zlib/exehead_zlib.h"
|
|
||||||
#include "exehead/Debug-bzip2/exehead_bzip2.h"
|
|
||||||
#include "exehead/Debug-lzma/exehead_lzma.h"
|
|
||||||
#endif*/
|
|
||||||
|
|
||||||
size_t zlib_exehead_size=sizeof(zlib_exehead);
|
|
||||||
size_t bzip2_exehead_size=sizeof(bzip2_exehead);
|
|
||||||
size_t lzma_exehead_size=sizeof(lzma_exehead);
|
|
||||||
size_t exehead_original_size=0;
|
|
||||||
|
|
||||||
size_t icondata_size=sizeof(icon_data)-22;
|
|
||||||
size_t unicondata_size=sizeof(unicon_data)-22;
|
|
|
@ -1,21 +0,0 @@
|
||||||
#ifndef _EXEDATA_H_
|
|
||||||
#define _EXEDATA_H_
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
// TODO: these should live in a singleton
|
|
||||||
extern size_t zlib_exehead_size;
|
|
||||||
extern size_t bzip2_exehead_size;
|
|
||||||
extern size_t lzma_exehead_size;
|
|
||||||
extern size_t exehead_original_size;
|
|
||||||
extern size_t icondata_size;
|
|
||||||
extern size_t unicondata_size;
|
|
||||||
|
|
||||||
extern unsigned char zlib_exehead[];
|
|
||||||
extern unsigned char bzip2_exehead[];
|
|
||||||
extern unsigned char lzma_exehead[];
|
|
||||||
extern unsigned char icon_data[];
|
|
||||||
extern unsigned char unicon_data[];
|
|
||||||
extern unsigned char bitmap1_data[630];
|
|
||||||
|
|
||||||
#endif //_EXEDATA_H_
|
|
|
@ -58,27 +58,6 @@
|
||||||
#define NSIS_CONFIG_COMPRESSION_SUPPORT
|
#define NSIS_CONFIG_COMPRESSION_SUPPORT
|
||||||
// compression specific options
|
// compression specific options
|
||||||
|
|
||||||
// NSIS_ZLIB_COMPRESS_WHOLE makes all install data in zlib installers
|
|
||||||
// compressed together. Runtime requirements are increased, but potential
|
|
||||||
// for compression is as well. Requires that the installer create a
|
|
||||||
// (potentially large) temporary file in the temp directory.
|
|
||||||
// not recommended for zlib installers, since bzip2 performs much better
|
|
||||||
// than zlib in whole mode usually.
|
|
||||||
// #define NSIS_ZLIB_COMPRESS_WHOLE
|
|
||||||
|
|
||||||
// NSIS_LZMA_COMPRESS_WHOLE makes all install data in lzma installers
|
|
||||||
// compressed together. Runtime requirements are increased, but potential
|
|
||||||
// for compression is as well. Requires that the installer create a
|
|
||||||
// (potentially large) temporary file in the temp directory.
|
|
||||||
#define NSIS_LZMA_COMPRESS_WHOLE
|
|
||||||
|
|
||||||
// NSIS_BZIP2_COMPRESS_WHOLE makes all install data in bzip2 installers
|
|
||||||
// compressed together. Runtime requirements are increased, but potential
|
|
||||||
// for compression is as well. Requires that the installer create a
|
|
||||||
// (potentially large) temporary file in the temp directory.
|
|
||||||
// recommended for bzip2, since bzip2 really shines in this mode
|
|
||||||
#define NSIS_BZIP2_COMPRESS_WHOLE
|
|
||||||
|
|
||||||
// if NSIS_COMPRESS_BZIP2_SMALLMODE is defined, bzip2's decompressor uses
|
// if NSIS_COMPRESS_BZIP2_SMALLMODE is defined, bzip2's decompressor uses
|
||||||
// bzip2's alternative decompression method that uses less runtime
|
// bzip2's alternative decompression method that uses less runtime
|
||||||
// memory, at the expense of speed (and executable size). not recommended.
|
// memory, at the expense of speed (and executable size). not recommended.
|
||||||
|
@ -309,24 +288,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
||||||
#ifdef NSIS_COMPRESS_USE_ZLIB
|
|
||||||
#ifdef NSIS_ZLIB_COMPRESS_WHOLE
|
|
||||||
#define NSIS_COMPRESS_WHOLE
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NSIS_COMPRESS_USE_BZIP2
|
|
||||||
#ifdef NSIS_BZIP2_COMPRESS_WHOLE
|
|
||||||
#define NSIS_COMPRESS_WHOLE
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NSIS_COMPRESS_USE_LZMA
|
|
||||||
#ifdef NSIS_LZMA_COMPRESS_WHOLE
|
|
||||||
#define NSIS_COMPRESS_WHOLE
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NSIS_COMPRESS_WHOLE
|
#ifdef NSIS_COMPRESS_WHOLE
|
||||||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||||
#ifndef _NSIS_CONFIG_VERIFYDIALOG
|
#ifndef _NSIS_CONFIG_VERIFYDIALOG
|
||||||
|
|
|
@ -45,7 +45,6 @@ const char *NSIS_VERSION="v2.06";
|
||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "exedata.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -96,7 +95,16 @@ int main(int argc, char **argv)
|
||||||
int in_files=0;
|
int in_files=0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
build.setdirs(argv[0]);
|
try
|
||||||
|
{
|
||||||
|
build.initialize(argv[0]);
|
||||||
|
}
|
||||||
|
catch (exception& err)
|
||||||
|
{
|
||||||
|
fprintf(g_output, "Error initalizing CEXEBuild: %s\n", err.what());
|
||||||
|
fflush(g_output);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc > 1 && !stricmp(argv[1], OPT_STR "VERSION"))
|
if (argc > 1 && !stricmp(argv[1], OPT_STR "VERSION"))
|
||||||
{
|
{
|
||||||
|
@ -243,9 +251,6 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (build.display_info)
|
if (build.display_info)
|
||||||
{
|
{
|
||||||
fprintf(g_output,"Size of zlib EXE header is %d bytes.\n",zlib_exehead_size);
|
|
||||||
fprintf(g_output,"Size of bzip2 EXE header is %d bytes.\n",bzip2_exehead_size);
|
|
||||||
fprintf(g_output,"Size of lzma EXE header is %d bytes.\n",lzma_exehead_size);
|
|
||||||
fprintf(g_output,"Size of first header is %d bytes.\n",sizeof(firstheader));
|
fprintf(g_output,"Size of first header is %d bytes.\n",sizeof(firstheader));
|
||||||
fprintf(g_output,"Size of main header is %d bytes.\n",sizeof(header));
|
fprintf(g_output,"Size of main header is %d bytes.\n",sizeof(header));
|
||||||
fprintf(g_output,"Size of each section is %d bytes.\n",sizeof(section));
|
fprintf(g_output,"Size of each section is %d bytes.\n",sizeof(section));
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "tokens.h"
|
#include "tokens.h"
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "exedata.h"
|
|
||||||
#include "ResourceEditor.h"
|
#include "ResourceEditor.h"
|
||||||
#include "DialogTemplate.h"
|
#include "DialogTemplate.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
@ -12,6 +11,8 @@
|
||||||
#include "exehead/resource.h"
|
#include "exehead/resource.h"
|
||||||
#include <cassert> // for assert(3)
|
#include <cassert> // for assert(3)
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -1421,7 +1422,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
SCRIPT_MSG("Icon: \"%s\"\n",line.gettoken_str(1));
|
SCRIPT_MSG("Icon: \"%s\"\n",line.gettoken_str(1));
|
||||||
try {
|
try {
|
||||||
init_res_editor();
|
init_res_editor();
|
||||||
if (replace_icon(res_editor, IDI_ICON2, line.gettoken_str(1))) {
|
if (replace_icon(res_editor, IDI_ICON2, line.gettoken_str(1)) < 0) {
|
||||||
ERROR_MSG("Error: File doesn't exist or is an invalid icon file\n");
|
ERROR_MSG("Error: File doesn't exist or is an invalid icon file\n");
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -2445,60 +2446,65 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
ERROR_MSG("Error: can't change compressor after data already got compressed or header already changed!\n");
|
ERROR_MSG("Error: can't change compressor after data already got compressed or header already changed!\n");
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
if (!build_compressor_final)
|
|
||||||
|
if (build_compressor_final)
|
||||||
{
|
{
|
||||||
|
warning_fl("SetCompressor ignored due to previous call with the /FINAL switch");
|
||||||
|
return PS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
int a = 1;
|
int a = 1;
|
||||||
|
|
||||||
|
build_compress_whole = false;
|
||||||
|
|
||||||
|
while (line.gettoken_str(a)[0] == '/')
|
||||||
|
{
|
||||||
if (!strcmpi(line.gettoken_str(1),"/FINAL"))
|
if (!strcmpi(line.gettoken_str(1),"/FINAL"))
|
||||||
{
|
{
|
||||||
build_compressor_final = true;
|
build_compressor_final = true;
|
||||||
a++;
|
a++;
|
||||||
}
|
}
|
||||||
else if (line.getnumtokens() == 3)
|
else if (!strcmpi(line.gettoken_str(1),"/SOLID"))
|
||||||
{
|
{
|
||||||
ERROR_MSG("%s expects 2 parameters, got 3.\n",line.gettoken_str(0));
|
build_compress_whole = true;
|
||||||
|
a++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a != line.getnumtokens() - 1)
|
||||||
|
{
|
||||||
|
ERROR_MSG("%s expects %d parameters, got %d.\n", line.gettoken_str(0), a + 1, line.getnumtokens());
|
||||||
PRINTHELP();
|
PRINTHELP();
|
||||||
}
|
}
|
||||||
int k=line.gettoken_enum(a,"zlib\0bzip2\0lzma\0");
|
|
||||||
|
int k=line.gettoken_enum(a, "zlib\0bzip2\0lzma\0");
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case 0: // JF> should handle the state of going from bzip2 back to zlib:
|
case 0:
|
||||||
compressor = &zlib_compressor;
|
compressor = &zlib_compressor;
|
||||||
update_exehead(zlib_exehead, zlib_exehead_size);
|
|
||||||
#ifdef NSIS_ZLIB_COMPRESS_WHOLE
|
|
||||||
build_compress_whole=true;
|
|
||||||
#else
|
|
||||||
build_compress_whole=false;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
compressor=&bzip2_compressor;
|
compressor = &bzip2_compressor;
|
||||||
update_exehead(bzip2_exehead, bzip2_exehead_size);
|
|
||||||
#ifdef NSIS_BZIP2_COMPRESS_WHOLE
|
|
||||||
build_compress_whole=true;
|
|
||||||
#else
|
|
||||||
build_compress_whole=false;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
compressor = &lzma_compressor;
|
compressor = &lzma_compressor;
|
||||||
update_exehead(lzma_exehead, lzma_exehead_size);
|
|
||||||
#ifdef NSIS_LZMA_COMPRESS_WHOLE
|
|
||||||
build_compress_whole=true;
|
|
||||||
#else
|
|
||||||
build_compress_whole=false;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PRINTHELP();
|
PRINTHELP();
|
||||||
}
|
}
|
||||||
SCRIPT_MSG("SetCompressor: %s%s\n", build_compressor_final? "/FINAL " : "", line.gettoken_str(a));
|
|
||||||
}
|
string compressor_name = line.gettoken_str(a);
|
||||||
else
|
transform(compressor_name.begin(), compressor_name.end(), compressor_name.begin(), tolower);
|
||||||
|
|
||||||
|
if (set_compressor(compressor_name, build_compress_whole) != PS_OK)
|
||||||
{
|
{
|
||||||
warning_fl("SetCompressor ignored due to previous call with the /FINAL switch");
|
SCRIPT_MSG("SetCompressor: error loading stub for \"%s\" compressor.\n", compressor_name.c_str());
|
||||||
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCRIPT_MSG("SetCompressor: %s%s%s\n", build_compressor_final ? "/FINAL " : "", build_compress_whole ? "/SOLID " : "", line.gettoken_str(a));
|
||||||
}
|
}
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
#else//NSIS_CONFIG_COMPRESSION_SUPPORT
|
#else//NSIS_CONFIG_COMPRESSION_SUPPORT
|
||||||
|
@ -2837,7 +2843,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
SCRIPT_MSG("UninstallIcon: \"%s\"\n",line.gettoken_str(1));
|
SCRIPT_MSG("UninstallIcon: \"%s\"\n",line.gettoken_str(1));
|
||||||
try {
|
try {
|
||||||
free(m_unicon_data);
|
free(m_unicon_data);
|
||||||
m_unicon_data = generate_uninstall_icon_data(line.gettoken_str(1));
|
m_unicon_data = generate_uninstall_icon_data(line.gettoken_str(1), m_unicon_size);
|
||||||
if (!m_unicon_data) {
|
if (!m_unicon_data) {
|
||||||
ERROR_MSG("Error: File doesn't exist or is an invalid icon file\n");
|
ERROR_MSG("Error: File doesn't exist or is an invalid icon file\n");
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
|
|
|
@ -172,7 +172,7 @@ static tokenType tokenlist[TOK__LAST] =
|
||||||
{TOK_SETCTLCOLORS,"SetCtlColors",2,2,"hwnd [/BRANDING] [text_color] [transparent|bg_color]",TP_CODE},
|
{TOK_SETCTLCOLORS,"SetCtlColors",2,2,"hwnd [/BRANDING] [text_color] [transparent|bg_color]",TP_CODE},
|
||||||
{TOK_SETBRANDINGIMAGE,"SetBrandingImage",1,2,"[/IMGID=image_item_id_in_dialog] [/RESIZETOFIT] bitmap.bmp",TP_CODE},
|
{TOK_SETBRANDINGIMAGE,"SetBrandingImage",1,2,"[/IMGID=image_item_id_in_dialog] [/RESIZETOFIT] bitmap.bmp",TP_CODE},
|
||||||
{TOK_SETCOMPRESS,"SetCompress",1,0,"(off|auto|force)",TP_ALL},
|
{TOK_SETCOMPRESS,"SetCompress",1,0,"(off|auto|force)",TP_ALL},
|
||||||
{TOK_SETCOMPRESSOR,"SetCompressor",1,1,"[/FINAL] (zlib|bzip2|lzma)",TP_GLOBAL},
|
{TOK_SETCOMPRESSOR,"SetCompressor",1,2,"[/FINAL] [/SOLID] (zlib|bzip2|lzma)",TP_GLOBAL},
|
||||||
{TOK_SETCOMPRESSORDICTSIZE,"SetCompressorDictSize",1,0,"dict_size_mb",TP_ALL},
|
{TOK_SETCOMPRESSORDICTSIZE,"SetCompressorDictSize",1,0,"dict_size_mb",TP_ALL},
|
||||||
{TOK_SETCOMPRESSIONLEVEL,"SetCompressionLevel",1,0,"level_0-9",TP_ALL},
|
{TOK_SETCOMPRESSIONLEVEL,"SetCompressionLevel",1,0,"level_0-9",TP_ALL},
|
||||||
{TOK_SETDATESAVE,"SetDateSave",1,0,"(off|on)",TP_ALL},
|
{TOK_SETDATESAVE,"SetDateSave",1,0,"(off|on)",TP_ALL},
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "exedata.h"
|
|
||||||
#include "exehead/fileform.h"
|
#include "exehead/fileform.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
|
@ -39,7 +38,7 @@ void dopause(void)
|
||||||
// Returns -2 if the file is an invalid bitmap
|
// Returns -2 if the file is an invalid bitmap
|
||||||
// Returns -3 if the size doesn't match
|
// Returns -3 if the size doesn't match
|
||||||
// Returns -4 if the bpp doesn't match
|
// Returns -4 if the bpp doesn't match
|
||||||
int update_bitmap(CResourceEditor* re, WORD id, char* filename, int width/*=0*/, int height/*=0*/, int maxbpp/*=0*/) {
|
int update_bitmap(CResourceEditor* re, WORD id, const char* filename, int width/*=0*/, int height/*=0*/, int maxbpp/*=0*/) {
|
||||||
FILE *f = FOPEN(filename, "rb");
|
FILE *f = FOPEN(filename, "rb");
|
||||||
if (!f) return -1;
|
if (!f) return -1;
|
||||||
|
|
||||||
|
@ -138,7 +137,7 @@ typedef struct {
|
||||||
// return values:
|
// return values:
|
||||||
// 0 - All OK
|
// 0 - All OK
|
||||||
// -1 - Bad icon file
|
// -1 - Bad icon file
|
||||||
int replace_icon(CResourceEditor* re, WORD wIconId, char* filename)
|
int replace_icon(CResourceEditor* re, WORD wIconId, const char* filename)
|
||||||
{
|
{
|
||||||
FILE* f = FOPEN(filename, "rb");
|
FILE* f = FOPEN(filename, "rb");
|
||||||
if (!f) return -1;
|
if (!f) return -1;
|
||||||
|
@ -201,8 +200,6 @@ int replace_icon(CResourceEditor* re, WORD wIconId, char* filename)
|
||||||
|
|
||||||
free(rsrcIconGroup);
|
free(rsrcIconGroup);
|
||||||
|
|
||||||
icondata_size = iNewIconSize;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +209,7 @@ int replace_icon(CResourceEditor* re, WORD wIconId, char* filename)
|
||||||
// return values:
|
// return values:
|
||||||
// 0 - Bad icon file
|
// 0 - Bad icon file
|
||||||
// Anything else - Pointer to the uninstaller icon data
|
// Anything else - Pointer to the uninstaller icon data
|
||||||
unsigned char* generate_uninstall_icon_data(char* filename)
|
unsigned char* generate_uninstall_icon_data(const char* filename, size_t &size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -263,7 +260,7 @@ unsigned char* generate_uninstall_icon_data(char* filename)
|
||||||
free(offsets);
|
free(offsets);
|
||||||
free(rawSizes);
|
free(rawSizes);
|
||||||
|
|
||||||
unicondata_size = iNewIconSize;
|
size = iNewIconSize;
|
||||||
|
|
||||||
return pbUninstIcon;
|
return pbUninstIcon;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +278,7 @@ int find_in_dir(PRESOURCE_DIRECTORY rd, WORD id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill the array of icons for uninstall with their offsets
|
// Fill the array of icons for uninstall with their offsets
|
||||||
// Returns 0 if failed, anything else is icon_offset.
|
// Returns 0 if failed, anything else is the icon offset in the PE.
|
||||||
int generate_unicons_offsets(unsigned char* exeHeader, unsigned char* uninstIconData) {
|
int generate_unicons_offsets(unsigned char* exeHeader, unsigned char* uninstIconData) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@ extern void dopause(void);
|
||||||
|
|
||||||
// Adds the bitmap in filename using resource editor re as id id.
|
// Adds the bitmap in filename using resource editor re as id id.
|
||||||
// If width or height are specified it will also make sure the bitmap is in that size
|
// If width or height are specified it will also make sure the bitmap is in that size
|
||||||
int update_bitmap(CResourceEditor* re, WORD id, char* filename, int width=0, int height=0, int maxbpp=0);
|
int update_bitmap(CResourceEditor* re, WORD id, const char* filename, int width=0, int height=0, int maxbpp=0);
|
||||||
|
|
||||||
// reads icon file filename and places its icons in the resource wIconId using resource editor re. Also updates icondata_size.
|
// reads icon file filename and places its icons in the resource wIconId using resource editor re
|
||||||
int replace_icon(CResourceEditor* re, WORD wIconId, char* filename);
|
int replace_icon(CResourceEditor* re, WORD wIconId, const char* filename);
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
// returns the data of the uninstaller icon (inside filename) that should replace the installer icon data
|
// returns the data of the uninstaller icon (inside filename) that should replace the installer icon data
|
||||||
unsigned char* generate_uninstall_icon_data(char* filename);
|
unsigned char* generate_uninstall_icon_data(const char* filename, size_t &size);
|
||||||
// Fill the array of icons for uninstall with their offsets
|
// Fill the array of icons for uninstall with their offsets
|
||||||
int generate_unicons_offsets(unsigned char* exeHeader, unsigned char* uninstIconData);
|
int generate_unicons_offsets(unsigned char* exeHeader, unsigned char* uninstIconData);
|
||||||
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue