mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix generation of compile_commands.json for windows specific extensions
This commit is contained in:
parent
39f5192c99
commit
e145f42fdc
@ -504,12 +504,15 @@ class Build(Command):
|
|||||||
def get_compile_commands(self, ext, db):
|
def get_compile_commands(self, ext, db):
|
||||||
obj_dir = self.j(self.obj_dir, ext.name)
|
obj_dir = self.j(self.obj_dir, ext.name)
|
||||||
|
|
||||||
def get(src: str, env: Environment) -> CompileCommand:
|
def get(src: str, env: Environment, for_tooling: bool = False) -> CompileCommand:
|
||||||
compiler = env.cxx if ext.needs_cxx else env.cc
|
compiler = env.cxx if ext.needs_cxx else env.cc
|
||||||
obj = self.j(obj_dir, os.path.splitext(self.b(src))[0]+env.obj_suffix)
|
obj = self.j(obj_dir, os.path.splitext(self.b(src))[0]+env.obj_suffix)
|
||||||
inf = env.cc_input_cpp_flag if src.endswith('.cpp') or src.endswith('.cxx') else env.cc_input_c_flag
|
inf = env.cc_input_cpp_flag if src.endswith('.cpp') or src.endswith('.cxx') else env.cc_input_c_flag
|
||||||
sinc = [inf, src]
|
sinc = [inf, src]
|
||||||
if env.cc_output_flag.startswith('/'):
|
if env.cc_output_flag.startswith('/'):
|
||||||
|
if for_tooling: # clangd gets confused by cl.exe style source and output flags
|
||||||
|
oinc = ['-o', obj]
|
||||||
|
else:
|
||||||
oinc = [env.cc_output_flag + obj]
|
oinc = [env.cc_output_flag + obj]
|
||||||
sinc = [inf + src]
|
sinc = [inf + src]
|
||||||
else:
|
else:
|
||||||
@ -545,8 +548,9 @@ class Build(Command):
|
|||||||
ans.append(cc)
|
ans.append(cc)
|
||||||
env = self.env_for_compilation_db(ext)
|
env = self.env_for_compilation_db(ext)
|
||||||
if env is not None:
|
if env is not None:
|
||||||
|
cc = get(src, env, for_tooling=True)
|
||||||
db.append({
|
db.append({
|
||||||
'arguments': get(src, env).cmd, 'directory': os.getcwd(), 'file': os.path.relpath(src, os.getcwd()),
|
'arguments': cc.cmd, 'directory': os.getcwd(), 'file': os.path.relpath(src, os.getcwd()),
|
||||||
'output': os.path.relpath(cc.dest, os.getcwd())})
|
'output': os.path.relpath(cc.dest, os.getcwd())})
|
||||||
return ans, objects
|
return ans, objects
|
||||||
|
|
||||||
@ -573,7 +577,7 @@ class Build(Command):
|
|||||||
env = self.env_for_compilation_db(ext)
|
env = self.env_for_compilation_db(ext)
|
||||||
if env is not None:
|
if env is not None:
|
||||||
ld = get(env)
|
ld = get(env)
|
||||||
lddb.append({'arguments': ld.cmd, 'directory': os.getcwd(), 'output': os.path.relpath(self.dest(ext, env), os.getcwd())})
|
lddb.append({'arguments': ld.cmd, 'directory': os.getcwd(), 'output': os.path.relpath(ld.dest, os.getcwd())})
|
||||||
|
|
||||||
env = self.windows_cross_env if self.compiling_for == 'windows' else self.env
|
env = self.windows_cross_env if self.compiling_for == 'windows' else self.env
|
||||||
lc = get(env)
|
lc = get(env)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user