From a37c14499ca3358b50427eec71b2ff399a7031ba Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 16 Jun 2021 17:14:31 +0530 Subject: [PATCH] Fix building of sqlite_extension on ancient Linux --- setup/build.py | 16 +++++++++++----- setup/extensions.json | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/setup/build.py b/setup/build.py index 0561d52a5a..ce0a585996 100644 --- a/setup/build.py +++ b/setup/build.py @@ -5,7 +5,7 @@ __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import textwrap, os, shlex, subprocess, glob, shutil, sys, json +import textwrap, os, shlex, subprocess, glob, shutil, sys, json, errno from collections import namedtuple from setup import Command, islinux, isbsd, isfreebsd, ismacos, ishaiku, SRC, iswindows @@ -279,6 +279,14 @@ class Build(Command): parser.add_option('--sanitize', default=False, action='store_true', help='Build with sanitization support. Run with LD_PRELOAD=$(gcc -print-file-name=libasan.so)') + def dump_db(self, name, db): + try: + with open(f'{name}_commands.json', 'w') as f: + json.dump(db, f, indent=2) + except OSError as err: + if err.errno != errno.EROFS: + raise + def run(self, opts): from setup.parallel_build import parallel_build, create_job if opts.no_compile: @@ -314,8 +322,7 @@ class Build(Command): objects_map[id(ext)] = objects for cmd in cmds: jobs.append(create_job(cmd.cmd)) - with open('compile_commands.json', 'w') as f: - json.dump(ccdb, f, indent=2) + self.dump_db('compile', ccdb) if jobs: self.info(f'Compiling {len(jobs)} files...') if not parallel_build(jobs, self.info): @@ -327,8 +334,7 @@ class Build(Command): if cmd is not None: link_commands.append(cmd) jobs.append(create_job(cmd.cmd)) - with open('link_commands.json', 'w') as f: - json.dump(lddb, f, indent=2) + self.dump_db('link', lddb) if jobs: self.info(f'Linking {len(jobs)} files...') if not parallel_build(jobs, self.info): diff --git a/setup/extensions.json b/setup/extensions.json index 511898196a..4c84c6a866 100644 --- a/setup/extensions.json +++ b/setup/extensions.json @@ -74,6 +74,7 @@ { "name": "sqlite_extension", "sources": "calibre/db/sqlite_extension.cpp", + "needs_c++11": true, "libraries": "icudata icui18n icuuc icuio", "windows_libraries": "icudt icuin icuuc icuio", "lib_dirs": "!icu_lib_dirs",