Build hunspell via self-generated CMake file on linux too

This commit is contained in:
Gres 2020-07-18 12:28:43 +03:00
parent 0920ed1f40
commit ac1c598953

View File

@ -30,15 +30,13 @@ def check_existing():
if not os.path.exists(dll) or not os.path.exists(lib): if not os.path.exists(dll) or not os.path.exists(lib):
return False return False
elif platform.system() == "Darwin": elif platform.system() == "Darwin":
lib = install_dir + '/lib/libhunspell.1.7.0.dylib' lib = install_dir + '/lib/libhunspell.dylib'
if not os.path.exists(lib): if not os.path.exists(lib):
return False return False
c.symlink(lib, install_dir + '/lib/libhunspell.dylib')
else: else:
lib = install_dir + '/lib/libhunspell-1.7.so' lib = install_dir + '/lib/libhunspell.so'
if not os.path.exists(lib): if not os.path.exists(lib):
return False return False
c.symlink(lib, install_dir + '/lib/libhunspell.so')
includes_path = install_dir + '/include/hunspell' includes_path = install_dir + '/include/hunspell'
if len(c.get_folder_files(includes_path)) == 0: if len(c.get_folder_files(includes_path)) == 0:
@ -78,12 +76,6 @@ os.chdir(build_dir)
c.set_make_threaded() c.set_make_threaded()
if platform.system() != "Windows":
c.run('autoreconf -i {}'.format(src_dir))
c.run('{}/configure --prefix={}'.format(src_dir, install_dir))
c.run('make')
c.run('make install')
else:
lib_src = os.path.join(src_dir, 'src', 'hunspell') lib_src = os.path.join(src_dir, 'src', 'hunspell')
sources = [] sources = []
with os.scandir(lib_src) as it: with os.scandir(lib_src) as it:
@ -91,10 +83,8 @@ else:
if not f.is_file() or not f.name.endswith('.cxx'): if not f.is_file() or not f.name.endswith('.cxx'):
continue continue
sources.append('${SRC_DIR}/' + f.name) sources.append('${SRC_DIR}/' + f.name)
headers = ['${SRC_DIR}/atypes.hxx', '${SRC_DIR}/hunspell.h', '${SRC_DIR}/hunspell.hxx', headers = ['${SRC_DIR}/atypes.hxx', '${SRC_DIR}/hunspell.h', '${SRC_DIR}/hunspell.hxx',
'${SRC_DIR}/hunvisapi.h', '${SRC_DIR}/w_char.hxx'] '${SRC_DIR}/hunvisapi.h', '${SRC_DIR}/w_char.hxx']
cmake_file = os.path.join(build_dir, 'CMakeLists.txt') cmake_file = os.path.join(build_dir, 'CMakeLists.txt')
with open(cmake_file, 'w') as f: with open(cmake_file, 'w') as f:
f.write('project(hunspell)\n') f.write('project(hunspell)\n')
@ -103,7 +93,9 @@ else:
f.write('\n') f.write('\n')
f.write('add_library(hunspell SHARED {})\n'.format(' '.join(sources))) f.write('add_library(hunspell SHARED {})\n'.format(' '.join(sources)))
f.write('\n') f.write('\n')
f.write('add_compile_definitions(HAVE_CONFIG_H _WIN32 BUILDING_LIBHUNSPELL)\n') f.write('add_compile_definitions(HAVE_CONFIG_H BUILDING_LIBHUNSPELL)\n')
if platform.system() == "Windows":
f.write('add_compile_definitions(_WIN32)\n')
f.write('\n') f.write('\n')
f.write('install(FILES {} \ f.write('install(FILES {} \
DESTINATION include/hunspell)\n'.format(' '.join(headers))) DESTINATION include/hunspell)\n'.format(' '.join(headers)))
@ -118,10 +110,15 @@ ${{CMAKE_CURRENT_BINARY_DIR}}/hunspell.pc @ONLY)\n'.format(src_dir.replace('\\',
f.write('install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hunspell.pc \ f.write('install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hunspell.pc \
DESTINATION lib/pkgconfig)\n') DESTINATION lib/pkgconfig)\n')
env_cmd = c.get_msvc_env_cmd(bitness=bitness, msvc_version=msvc_version)
c.apply_cmd_env(env_cmd)
cmake_args = '"{}" -DCMAKE_INSTALL_PREFIX="{}" {}'.format( cmake_args = '"{}" -DCMAKE_INSTALL_PREFIX="{}" {}'.format(
build_dir, install_dir, c.get_cmake_arch_args(bitness=bitness)) build_dir, install_dir, c.get_cmake_arch_args(bitness=bitness))
if platform.system() == "Windows":
env_cmd = c.get_msvc_env_cmd(bitness=bitness, msvc_version=msvc_version)
c.apply_cmd_env(env_cmd)
cmake_args += ' ' + c.get_cmake_arch_args(bitness=bitness)
c.set_make_threaded()
c.run('cmake {}'.format(cmake_args)) c.run('cmake {}'.format(cmake_args))
build_type_flag = 'Debug' if build_type == 'debug' else 'Release' build_type_flag = 'Debug' if build_type == 'debug' else 'Release'
c.run('cmake --build . --config {}'.format(build_type_flag)) c.run('cmake --build . --config {}'.format(build_type_flag))