Build hunspell via self-generated CMake file on linux too
This commit is contained in:
parent
0920ed1f40
commit
ac1c598953
@ -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,54 +76,53 @@ os.chdir(build_dir)
|
|||||||
|
|
||||||
c.set_make_threaded()
|
c.set_make_threaded()
|
||||||
|
|
||||||
if platform.system() != "Windows":
|
lib_src = os.path.join(src_dir, 'src', 'hunspell')
|
||||||
c.run('autoreconf -i {}'.format(src_dir))
|
sources = []
|
||||||
c.run('{}/configure --prefix={}'.format(src_dir, install_dir))
|
with os.scandir(lib_src) as it:
|
||||||
c.run('make')
|
for f in it:
|
||||||
c.run('make install')
|
if not f.is_file() or not f.name.endswith('.cxx'):
|
||||||
else:
|
continue
|
||||||
lib_src = os.path.join(src_dir, 'src', 'hunspell')
|
sources.append('${SRC_DIR}/' + f.name)
|
||||||
sources = []
|
headers = ['${SRC_DIR}/atypes.hxx', '${SRC_DIR}/hunspell.h', '${SRC_DIR}/hunspell.hxx',
|
||||||
with os.scandir(lib_src) as it:
|
'${SRC_DIR}/hunvisapi.h', '${SRC_DIR}/w_char.hxx']
|
||||||
for f in it:
|
cmake_file = os.path.join(build_dir, 'CMakeLists.txt')
|
||||||
if not f.is_file() or not f.name.endswith('.cxx'):
|
with open(cmake_file, 'w') as f:
|
||||||
continue
|
f.write('project(hunspell)\n')
|
||||||
sources.append('${SRC_DIR}/' + f.name)
|
f.write('cmake_minimum_required(VERSION 3.11)\n')
|
||||||
|
f.write('set(SRC_DIR "{}")\n'.format(lib_src).replace('\\', '/'))
|
||||||
headers = ['${SRC_DIR}/atypes.hxx', '${SRC_DIR}/hunspell.h', '${SRC_DIR}/hunspell.hxx',
|
f.write('\n')
|
||||||
'${SRC_DIR}/hunvisapi.h', '${SRC_DIR}/w_char.hxx']
|
f.write('add_library(hunspell SHARED {})\n'.format(' '.join(sources)))
|
||||||
|
f.write('\n')
|
||||||
cmake_file = os.path.join(build_dir, 'CMakeLists.txt')
|
f.write('add_compile_definitions(HAVE_CONFIG_H BUILDING_LIBHUNSPELL)\n')
|
||||||
with open(cmake_file, 'w') as f:
|
if platform.system() == "Windows":
|
||||||
f.write('project(hunspell)\n')
|
f.write('add_compile_definitions(_WIN32)\n')
|
||||||
f.write('cmake_minimum_required(VERSION 3.11)\n')
|
f.write('\n')
|
||||||
f.write('set(SRC_DIR "{}")\n'.format(lib_src).replace('\\', '/'))
|
f.write('install(FILES {} \
|
||||||
f.write('\n')
|
|
||||||
f.write('add_library(hunspell SHARED {})\n'.format(' '.join(sources)))
|
|
||||||
f.write('\n')
|
|
||||||
f.write('add_compile_definitions(HAVE_CONFIG_H _WIN32 BUILDING_LIBHUNSPELL)\n')
|
|
||||||
f.write('\n')
|
|
||||||
f.write('install(FILES {} \
|
|
||||||
DESTINATION include/hunspell)\n'.format(' '.join(headers)))
|
DESTINATION include/hunspell)\n'.format(' '.join(headers)))
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
f.write('install(TARGETS hunspell \
|
f.write('install(TARGETS hunspell \
|
||||||
RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)\n')
|
RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)\n')
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
f.write('set(prefix "${CMAKE_INSTALL_PREFIX}")\n')
|
f.write('set(prefix "${CMAKE_INSTALL_PREFIX}")\n')
|
||||||
f.write('set(VERSION "{}")\n'.format(required_version))
|
f.write('set(VERSION "{}")\n'.format(required_version))
|
||||||
f.write('configure_file({}/hunspell.pc.in \
|
f.write('configure_file({}/hunspell.pc.in \
|
||||||
${{CMAKE_CURRENT_BINARY_DIR}}/hunspell.pc @ONLY)\n'.format(src_dir.replace('\\', '/')))
|
${{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')
|
||||||
|
|
||||||
|
cmake_args = '"{}" -DCMAKE_INSTALL_PREFIX="{}" {}'.format(
|
||||||
|
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)
|
env_cmd = c.get_msvc_env_cmd(bitness=bitness, msvc_version=msvc_version)
|
||||||
c.apply_cmd_env(env_cmd)
|
c.apply_cmd_env(env_cmd)
|
||||||
cmake_args = '"{}" -DCMAKE_INSTALL_PREFIX="{}" {}'.format(
|
cmake_args += ' ' + c.get_cmake_arch_args(bitness=bitness)
|
||||||
build_dir, install_dir, c.get_cmake_arch_args(bitness=bitness))
|
|
||||||
c.run('cmake {}'.format(cmake_args))
|
c.set_make_threaded()
|
||||||
build_type_flag = 'Debug' if build_type == 'debug' else 'Release'
|
c.run('cmake {}'.format(cmake_args))
|
||||||
c.run('cmake --build . --config {}'.format(build_type_flag))
|
build_type_flag = 'Debug' if build_type == 'debug' else 'Release'
|
||||||
c.run('cmake --build . --target install --config {}'.format(build_type_flag))
|
c.run('cmake --build . --config {}'.format(build_type_flag))
|
||||||
|
c.run('cmake --build . --target install --config {}'.format(build_type_flag))
|
||||||
|
|
||||||
with open(cache_file, 'w') as f:
|
with open(cache_file, 'w') as f:
|
||||||
f.write(cache_file_data)
|
f.write(cache_file_data)
|
||||||
|
Loading…
Reference in New Issue
Block a user