mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use only win32 functions in the launcher, no CRT functions
Reduces the size of the executables a little
This commit is contained in:
parent
9a49104dac
commit
ab3e048a95
@ -575,7 +575,7 @@ class Win32Freeze(Command, WixMixIn):
|
|||||||
dll = self.j(self.obj_dir, 'calibre-launcher.dll')
|
dll = self.j(self.obj_dir, 'calibre-launcher.dll')
|
||||||
ver = '.'.join(__version__.split('.')[:2])
|
ver = '.'.join(__version__.split('.')[:2])
|
||||||
if self.newer(dll, objects):
|
if self.newer(dll, objects):
|
||||||
cmd = [msvc.linker, '/DLL', '/VERSION:'+ver, '/OUT:'+dll,
|
cmd = [msvc.linker, '/DLL', '/VERSION:'+ver, '/LTCG', '/OUT:'+dll,
|
||||||
'/nologo', '/MACHINE:'+machine] + dlflags + objects + \
|
'/nologo', '/MACHINE:'+machine] + dlflags + objects + \
|
||||||
[self.embed_resources(dll),
|
[self.embed_resources(dll),
|
||||||
'/LIBPATH:%s/libs'%self.python_base,
|
'/LIBPATH:%s/libs'%self.python_base,
|
||||||
@ -605,10 +605,10 @@ class Win32Freeze(Command, WixMixIn):
|
|||||||
self.run_builder(cmd)
|
self.run_builder(cmd)
|
||||||
exe = self.j(self.base, bname+'.exe')
|
exe = self.j(self.base, bname+'.exe')
|
||||||
lib = dll.replace('.dll', '.lib')
|
lib = dll.replace('.dll', '.lib')
|
||||||
u32 = ['user32.lib'] if typ == 'gui' else []
|
u32 = ['user32.lib']
|
||||||
if self.newer(exe, [dest, lib, self.rc_template, __file__]):
|
if self.newer(exe, [dest, lib, self.rc_template, __file__]):
|
||||||
self.info('Linking', bname)
|
self.info('Linking', bname)
|
||||||
cmd = [msvc.linker] + ['/MACHINE:'+machine,
|
cmd = [msvc.linker] + ['/MACHINE:'+machine, '/LTCG',
|
||||||
'/LIBPATH:'+self.obj_dir, '/SUBSYSTEM:'+subsys,
|
'/LIBPATH:'+self.obj_dir, '/SUBSYSTEM:'+subsys,
|
||||||
'/LIBPATH:%s/libs'%self.python_base, '/RELEASE',
|
'/LIBPATH:%s/libs'%self.python_base, '/RELEASE',
|
||||||
'/OUT:'+exe] + u32 + dlflags + [self.embed_resources(exe),
|
'/OUT:'+exe] + u32 + dlflags + [self.embed_resources(exe),
|
||||||
|
@ -5,24 +5,28 @@
|
|||||||
#define UNICODE
|
#define UNICODE
|
||||||
#define WINDOWS_LEAN_AND_MEAN
|
#define WINDOWS_LEAN_AND_MEAN
|
||||||
#include<windows.h>
|
#include<windows.h>
|
||||||
#include<stdio.h>
|
#include<strsafe.h>
|
||||||
|
|
||||||
|
size_t mystrlen(const wchar_t *buf) {
|
||||||
|
size_t ans = 0;
|
||||||
|
if (FAILED(StringCbLengthW(buf, 500, &ans))) return 0;
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
static int show_error(const wchar_t *preamble, const wchar_t *msg, const int code) {
|
static int show_error(const wchar_t *preamble, const wchar_t *msg, const int code) {
|
||||||
wchar_t *buf;
|
wchar_t *buf;
|
||||||
buf = (wchar_t*)LocalAlloc(LMEM_ZEROINIT, sizeof(wchar_t)*
|
buf = (wchar_t*)LocalAlloc(LMEM_ZEROINIT, sizeof(wchar_t)*
|
||||||
(wcslen(msg) + wcslen(preamble) + 80));
|
(mystrlen(msg) + mystrlen(preamble) + 80));
|
||||||
|
if (!buf) {
|
||||||
|
MessageBox(NULL, preamble, NULL, MB_OK|MB_ICONERROR);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
_snwprintf_s(buf,
|
|
||||||
LocalSize(buf) / sizeof(wchar_t), _TRUNCATE,
|
|
||||||
L"%s\r\n %s (Error Code: %d)\r\n",
|
|
||||||
preamble, msg, code);
|
|
||||||
|
|
||||||
#ifdef GUI_APP
|
|
||||||
MessageBeep(MB_ICONERROR);
|
MessageBeep(MB_ICONERROR);
|
||||||
MessageBox(NULL, buf, NULL, MB_OK|MB_ICONERROR);
|
if (FAILED(StringCbPrintfW(buf, LocalSize(buf), L"%s\r\n %s (Error Code: %d)\r\n", preamble, msg, code)))
|
||||||
#else
|
MessageBox(NULL, preamble, NULL, MB_OK|MB_ICONERROR);
|
||||||
wprintf_s(L"%s\n", buf);
|
else
|
||||||
#endif
|
MessageBox(NULL, buf, NULL, MB_OK|MB_ICONERROR);
|
||||||
LocalFree(buf);
|
LocalFree(buf);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user