mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Clean up C/C++ std specifications
This commit is contained in:
parent
58c9ca9519
commit
d6a0f4bb9d
@ -49,10 +49,12 @@ class Extension:
|
||||
self.libraries = d['libraries'] = kwargs.get('libraries', [])
|
||||
self.cflags = d['cflags'] = kwargs.get('cflags', [])
|
||||
self.uses_icu = 'icuuc' in self.libraries
|
||||
if self.needs_cxx and kwargs.get('needs_c++'):
|
||||
std_prefix = '/std:' if iswindows else '-std='
|
||||
self.cflags.insert(0, std_prefix + 'c++' + kwargs['needs_c++'])
|
||||
|
||||
if iswindows:
|
||||
self.cflags.append('/DCALIBRE_MODINIT_FUNC=PyMODINIT_FUNC')
|
||||
if self.needs_cxx and kwargs.get('needs_c++14'):
|
||||
self.cflags.insert(0, '/std:c++14')
|
||||
else:
|
||||
return_type = 'PyObject*'
|
||||
extern_decl = 'extern "C"' if self.needs_cxx else ''
|
||||
@ -61,14 +63,8 @@ class Extension:
|
||||
'-DCALIBRE_MODINIT_FUNC='
|
||||
'{} __attribute__ ((visibility ("default"))) {}'.format(extern_decl, return_type))
|
||||
|
||||
if self.needs_cxx:
|
||||
if kwargs.get('needs_c++11'):
|
||||
self.cflags.insert(0, '-std=c++11')
|
||||
elif kwargs.get('needs_c++14'):
|
||||
self.cflags.insert(0, '-std=c++14')
|
||||
else:
|
||||
if kwargs.get('needs_c99'):
|
||||
self.cflags.insert(0, '-std=c99')
|
||||
if kwargs.get('needs_c'):
|
||||
self.cflags.insert(0, '-std=c' + kwargs['needs_c'])
|
||||
|
||||
self.ldflags = d['ldflags'] = kwargs.get('ldflags', [])
|
||||
self.optional = d['options'] = kwargs.get('optional', False)
|
||||
@ -182,6 +178,20 @@ def get_python_include_paths():
|
||||
is_macos_universal_build = ismacos and 'universal2' in sysconfig.get_platform()
|
||||
|
||||
|
||||
def basic_windows_flags(debug=False):
|
||||
cflags = '/c /nologo /W3 /EHsc /utf-8'.split()
|
||||
cflags.append('/Zi' if debug else '/DNDEBUG')
|
||||
suffix = ('d' if debug else '')
|
||||
cflags.append('/MD' + suffix)
|
||||
ldflags = f'/DLL /nologo /INCREMENTAL:NO /NODEFAULTLIB:libcmt{suffix}.lib'.split()
|
||||
if debug:
|
||||
ldflags.append('/DEBUG')
|
||||
# cflags = '/c /nologo /Ox /MD /W3 /EHsc /Zi'.split()
|
||||
# ldflags = '/DLL /nologo /INCREMENTAL:NO /DEBUG'.split()
|
||||
cflags.append('/GS-')
|
||||
return cflags, ldflags
|
||||
|
||||
|
||||
def init_env(debug=False, sanitize=False):
|
||||
from setup.build_environment import win_ld, win_inc, win_lib, NMAKE, win_cc
|
||||
linker = None
|
||||
@ -236,17 +246,7 @@ def init_env(debug=False, sanitize=False):
|
||||
|
||||
if iswindows:
|
||||
cc = cxx = win_cc
|
||||
cflags = '/c /nologo /W3 /EHsc /utf-8'.split()
|
||||
cflags.append('/Zi' if debug else '/DNDEBUG')
|
||||
suffix = ('d' if debug else '')
|
||||
cflags.append('/MD' + suffix)
|
||||
ldflags = f'/DLL /nologo /INCREMENTAL:NO /NODEFAULTLIB:libcmt{suffix}.lib'.split()
|
||||
if debug:
|
||||
ldflags.append('/DEBUG')
|
||||
# cflags = '/c /nologo /Ox /MD /W3 /EHsc /Zi'.split()
|
||||
# ldflags = '/DLL /nologo /INCREMENTAL:NO /DEBUG'.split()
|
||||
cflags.append('/GS-')
|
||||
|
||||
cflags, ldflags = basic_windows_flags(debug)
|
||||
for p in win_inc:
|
||||
cflags.append('-I'+p)
|
||||
for p in win_lib:
|
||||
|
@ -6,7 +6,7 @@
|
||||
"lib_dirs": "!hunspell_lib_dirs",
|
||||
"libraries": "hunspell-1.7",
|
||||
"windows_libraries": "libhunspell",
|
||||
"needs_c++11": true
|
||||
"needs_c++": "11"
|
||||
},
|
||||
{
|
||||
"name": "hyphen",
|
||||
@ -14,7 +14,7 @@
|
||||
"libraries": "hyphen",
|
||||
"inc_dirs": "!hyphen_inc_dirs",
|
||||
"lib_dirs": "!hyphen_lib_dirs",
|
||||
"needs_c99": true
|
||||
"needs_c": "99"
|
||||
},
|
||||
{
|
||||
"name": "uchardet",
|
||||
@ -27,7 +27,7 @@
|
||||
"name": "unicode_names",
|
||||
"headers": "unicode_names/names.h unicode_names/data-types.h",
|
||||
"sources": "unicode_names/unicode_names.c",
|
||||
"needs_c99": true
|
||||
"needs_c": "99"
|
||||
},
|
||||
{
|
||||
"name": "speedup",
|
||||
@ -82,7 +82,7 @@
|
||||
"name": "sqlite_extension",
|
||||
"headers": "calibre/utils/cpp_binding.h",
|
||||
"sources": "calibre/db/sqlite_extension.cpp",
|
||||
"needs_c++14": true,
|
||||
"needs_c++": "14",
|
||||
"libraries": "icudata icui18n icuuc icuio stemmer",
|
||||
"windows_libraries": "icudt icuin icuuc icuio libstemmer",
|
||||
"lib_dirs": "!icu_lib_dirs",
|
||||
@ -124,19 +124,19 @@
|
||||
"lib_dirs": "!podofo_lib",
|
||||
"inc_dirs": "!podofo_inc",
|
||||
"error": "!podofo_error",
|
||||
"needs_c++11": true
|
||||
"needs_c++": "11"
|
||||
},
|
||||
{
|
||||
"name": "html_as_json",
|
||||
"sources": "calibre/srv/html_as_json.cpp",
|
||||
"needs_c++11": true
|
||||
"needs_c++": "11"
|
||||
},
|
||||
{
|
||||
"name": "fast_css_transform",
|
||||
"headers": "calibre/utils/cpp_binding.h calibre/utils/stb_sprintf.h",
|
||||
"sources": "calibre/srv/fast_css_transform.cpp",
|
||||
"inc_dirs": "perfect-hashing",
|
||||
"needs_c++14": true
|
||||
"needs_c++": "14"
|
||||
},
|
||||
{
|
||||
"name": "rcc_backend",
|
||||
@ -190,7 +190,8 @@
|
||||
"headers": "calibre/utils/cpp_binding.h calibre/utils/windows/common.h",
|
||||
"sources": "calibre/utils/windows/winspeech.cpp",
|
||||
"libraries": "WindowsApp",
|
||||
"cflags": "/X /std:c++17 /Zc:__cplusplus /bigobj /await /permissive- /WX /Zc:twoPhase-"
|
||||
"needs_c++": "17",
|
||||
"cflags": "/X /Zc:__cplusplus /bigobj /await /permissive- /WX /Zc:twoPhase-"
|
||||
},
|
||||
{
|
||||
"name": "wpd",
|
||||
|
Loading…
x
Reference in New Issue
Block a user