Makefile.in | 2 +- bin/gbuild-to-ide | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-)
New commits: commit 785024705dc50d60247458003197e4b8e38e90a3 Author: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> AuthorDate: Thu Jun 26 11:09:24 2025 +0200 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Thu Jun 26 12:59:03 2025 +0200 vim/vscode/compile_commands.json: add objective-c/cxx and c-files and use the real compiler command instead of hardcoding "clang++" Change-Id: I9126771a646de4648a9cf24ceda4b984f1634da8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187028 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/Makefile.in b/Makefile.in index 55d27282feef..6b167dfec6a0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -528,7 +528,7 @@ clang-format-check: define gb_Top_GbuildToIdeIntegration $(1)-ide-integration: gbuildtojson $(if $(filter MACOSX,$(OS_FOR_BUILD)),python3.allbuild) - cd $(SRCDIR) && \ + cd $(SRCDIR) && CC="$(filter-out %ccache,$(CC))" CXX="$(filter-out %ccache,$(CXX))" \ $(if $(filter MACOSX,$(OS_FOR_BUILD)),PATH="$(INSTROOT_FOR_BUILD)/Frameworks/LibreOfficePython.framework/Versions/Current/bin:$(PATH)") \ $(if $(filter WNT,$(OS_FOR_BUILD)$(PYTHON_FOR_BUILD)),$(INSTROOT_FOR_BUILD)/program/python.exe) \ bin/gbuild-to-ide --ide $(1) --make $(MAKE) diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide index b3f8b9fbd371..b9e93690c337 100755 --- a/bin/gbuild-to-ide +++ b/bin/gbuild-to-ide @@ -64,7 +64,7 @@ class GbuildLinkTarget: def __init__(self, json): (foundincludes, foundisystem) = GbuildLinkTarget.__split_includes(json['INCLUDE']) - (self.name, self.location, self.include, self.include_sys, self.defs, self.cxxobjects, self.objcxxobjects, self.cxxflags, self.cobjects, self.cflags, self.cxxclrobjects, self.cxxclrflags, self.linked_libs, self.linked_static_libs, self.link_target) = ( + (self.name, self.location, self.include, self.include_sys, self.defs, self.cxxobjects, self.objcxxobjects, self.cxxflags, self.objcxxflags, self.cobjects, self.objcobjects, self.cflags, self.objcflags, self.cxxclrobjects, self.cxxclrflags, self.linked_libs, self.linked_static_libs, self.link_target) = ( type(self).targetpattern.match(os.path.basename(json['MAKEFILE'])).group(1), os.path.dirname(json['MAKEFILE']), foundincludes, @@ -73,8 +73,11 @@ class GbuildLinkTarget: GbuildLinkTarget.__split_objs(json['CXXOBJECTS']), GbuildLinkTarget.__split_objs(json['OBJCXXOBJECTS']), GbuildLinkTarget.__split_flags(json['CXXFLAGS'], json['CXXFLAGSAPPEND']), + GbuildLinkTarget.__split_flags(json['OBJCXXFLAGS'], json['OBJCXXFLAGSAPPEND']), GbuildLinkTarget.__split_objs(json['COBJECTS']), + GbuildLinkTarget.__split_objs(json['OBJCOBJECTS']), GbuildLinkTarget.__split_flags(json['CFLAGS'], json['CFLAGSAPPEND']), + GbuildLinkTarget.__split_flags(json['OBJCFLAGS'], json['OBJCFLAGSAPPEND']), GbuildLinkTarget.__split_objs(json['CXXCLROBJECTS']), GbuildLinkTarget.__split_flags(json['CXXCLRFLAGS'], json['CXXCLRFLAGSAPPEND']), json['LINKED_LIBS'].strip().split(' '), @@ -497,11 +500,32 @@ class VimIntegrationGenerator(IdeIntegrationGenerator): entry = {'directory': lib.location, 'file': filePath, 'command': self.generateCommand(lib, filePath)} entries.append(entry) global_list.extend(entries) + entries = [] + for file in lib.objcxxobjects: + filePath = os.path.join(self.gbuildparser.srcdir, file) + ".mm" + entry = {'directory': lib.location, 'file': filePath, 'command': self.generateCommand(lib, filePath)} + entries.append(entry) + global_list.extend(entries) + entries = [] + for file in lib.cobjects: + filePath = os.path.join(self.gbuildparser.srcdir, file) + ".c" + entry = {'directory': lib.location, 'file': filePath, 'command': self.generateCommand(lib, filePath)} + entries.append(entry) + global_list.extend(entries) + entries = [] + for file in lib.objcobjects: + filePath = os.path.join(self.gbuildparser.srcdir, file) + ".m" + entry = {'directory': lib.location, 'file': filePath, 'command': self.generateCommand(lib, filePath)} + entries.append(entry) + global_list.extend(entries) with open(os.path.join(self.gbuildparser.builddir, 'compile_commands.json'), 'w') as export_file: json.dump(global_list, export_file) def generateCommand(self, lib, file): - command = 'clang++ -Wall' + command = os.environ.get('CXX') + if file.endswith('.c') or file.endswith('.m'): + command = os.environ.get('CC') + command += ' -Wall' for key, value in lib.defs.items(): command += ' -D' command += key @@ -515,7 +539,14 @@ class VimIntegrationGenerator(IdeIntegrationGenerator): for isystem in lib.include_sys: command += ' -isystem ' command += isystem - for cxxflag in lib.cxxflags: + flags = lib.cxxflags + if file.endswith('.mm'): + flags = lib.objcxxflags + elif file.endswith('.c'): + flags = lib.cflags + elif file.endswith('.m'): + flags = lib.objcflags + for cxxflag in flags: command += ' ' command += cxxflag command += ' -c '