Allow to pass additional options into generator's clang::tooling
In my macOS build, that clang::tooling::runToolOnCodeWithArgs invocation failed to find headers like cassert and assert.h, which works now with COMPILER_PLUGINS_TOOLING_ARGS=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -isystem /Users/stephan/Software/llvm/inst/include/c++/v1 added to my autogen.input (I build against my Clang trunk libc++ whose headers are at /Users/stephan/Software/llvm/inst/include/c++/v1). Change-Id: Idbffa39c9fd4a88743fd498b8f7b6c9c56d7630d Reviewed-on: https://gerrit.libreoffice.org/69538 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
cb54bb8949
commit
ad7e2af4ed
@ -175,7 +175,9 @@ ifdef LO_CLANG_SHARED_PLUGINS
|
|||||||
$(CLANGINDIR)/sharedvisitor/sharedvisitor.cxx: $(shell grep -l "LO_CLANG_SHARED_PLUGINS" $(CLANGINDIR)/*.cxx)
|
$(CLANGINDIR)/sharedvisitor/sharedvisitor.cxx: $(shell grep -l "LO_CLANG_SHARED_PLUGINS" $(CLANGINDIR)/*.cxx)
|
||||||
$(CLANGINDIR)/sharedvisitor/sharedvisitor.cxx: $(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT)
|
$(CLANGINDIR)/sharedvisitor/sharedvisitor.cxx: $(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT)
|
||||||
$(call gb_Output_announce,$(subst $(SRCDIR)/,,$@),$(true),GEN,1)
|
$(call gb_Output_announce,$(subst $(SRCDIR)/,,$@),$(true),GEN,1)
|
||||||
$(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT) $(shell grep -l "LO_CLANG_SHARED_PLUGINS" $(CLANGINDIR)/*.cxx) \
|
$(CLANGOUTDIR)/sharedvisitor/generator$(CLANG_EXE_EXT) \
|
||||||
|
$(COMPILER_PLUGINS_TOOLING_ARGS:%=-arg=%) \
|
||||||
|
$(shell grep -l "LO_CLANG_SHARED_PLUGINS" $(CLANGINDIR)/*.cxx) \
|
||||||
> $(CLANGINDIR)/sharedvisitor/sharedvisitor.cxx
|
> $(CLANGINDIR)/sharedvisitor/sharedvisitor.cxx
|
||||||
|
|
||||||
CLANGTOOLLIBS = -lclangTooling -lclangDriver -lclangFrontend -lclangParse -lclangSema -lclangEdit -lclangAnalysis \
|
CLANGTOOLLIBS = -lclangTooling -lclangDriver -lclangFrontend -lclangParse -lclangSema -lclangEdit -lclangAnalysis \
|
||||||
|
@ -56,6 +56,8 @@ TODO:
|
|||||||
#include "clang/Frontend/FrontendAction.h"
|
#include "clang/Frontend/FrontendAction.h"
|
||||||
#include "clang/Tooling/Tooling.h"
|
#include "clang/Tooling/Tooling.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -534,14 +536,21 @@ string readSourceFile( const char* filename )
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
for( int i = 1; i < argc; ++ i )
|
vector< string > args;
|
||||||
|
int i = 1;
|
||||||
|
for( ; i < argc; ++ i )
|
||||||
{
|
{
|
||||||
string contents = readSourceFile(argv[i]);
|
constexpr std::size_t prefixlen = 5; // strlen("-arg=");
|
||||||
if( contents.empty())
|
if (std::strncmp(argv[i], "-arg=", prefixlen) != 0)
|
||||||
continue;
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
args.push_back(argv[i] + prefixlen);
|
||||||
|
}
|
||||||
#define STRINGIFY2(a) #a
|
#define STRINGIFY2(a) #a
|
||||||
#define STRINGIFY(a) STRINGIFY2(a)
|
#define STRINGIFY(a) STRINGIFY2(a)
|
||||||
vector< string > args =
|
args.insert(
|
||||||
|
args.end(),
|
||||||
{
|
{
|
||||||
"-I" STRINGIFY(BUILDDIR) "/config_host", // plugin sources use e.g. config_global.h
|
"-I" STRINGIFY(BUILDDIR) "/config_host", // plugin sources use e.g. config_global.h
|
||||||
"-I" STRINGIFY(CLANGDIR) "/include", // clang's headers
|
"-I" STRINGIFY(CLANGDIR) "/include", // clang's headers
|
||||||
@ -550,7 +559,12 @@ int main(int argc, char** argv)
|
|||||||
"-D__STDC_CONSTANT_MACROS", // Clang headers require these.
|
"-D__STDC_CONSTANT_MACROS", // Clang headers require these.
|
||||||
"-D__STDC_FORMAT_MACROS",
|
"-D__STDC_FORMAT_MACROS",
|
||||||
"-D__STDC_LIMIT_MACROS",
|
"-D__STDC_LIMIT_MACROS",
|
||||||
};
|
});
|
||||||
|
for( ; i < argc; ++ i )
|
||||||
|
{
|
||||||
|
string contents = readSourceFile(argv[i]);
|
||||||
|
if( contents.empty())
|
||||||
|
continue;
|
||||||
foundSomething = false;
|
foundSomething = false;
|
||||||
if( !clang::tooling::runToolOnCodeWithArgs( new FindNamedClassAction, contents, args, argv[ i ] ))
|
if( !clang::tooling::runToolOnCodeWithArgs( new FindNamedClassAction, contents, args, argv[ i ] ))
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,7 @@ export COMPILER_PLUGINS=@COMPILER_PLUGINS@
|
|||||||
export COMPILER_PLUGINS_CXX=@COMPILER_PLUGINS_CXX@
|
export COMPILER_PLUGINS_CXX=@COMPILER_PLUGINS_CXX@
|
||||||
export COMPILER_PLUGINS_CXX_LINKFLAGS=@COMPILER_PLUGINS_CXX_LINKFLAGS@
|
export COMPILER_PLUGINS_CXX_LINKFLAGS=@COMPILER_PLUGINS_CXX_LINKFLAGS@
|
||||||
export COMPILER_PLUGINS_DEBUG=@COMPILER_PLUGINS_DEBUG@
|
export COMPILER_PLUGINS_DEBUG=@COMPILER_PLUGINS_DEBUG@
|
||||||
|
export COMPILER_PLUGINS_TOOLING_ARGS=@COMPILER_PLUGINS_TOOLING_ARGS@
|
||||||
export COM_IS_CLANG=@COM_IS_CLANG@
|
export COM_IS_CLANG=@COM_IS_CLANG@
|
||||||
export CPPUNIT_CFLAGS=$(gb_SPACE)@CPPUNIT_CFLAGS@
|
export CPPUNIT_CFLAGS=$(gb_SPACE)@CPPUNIT_CFLAGS@
|
||||||
export CPPUNIT_LIBS=$(gb_SPACE)@CPPUNIT_LIBS@
|
export CPPUNIT_LIBS=$(gb_SPACE)@CPPUNIT_LIBS@
|
||||||
|
@ -6917,6 +6917,7 @@ AC_SUBST(COMPILER_PLUGINS)
|
|||||||
AC_SUBST(COMPILER_PLUGINS_CXX)
|
AC_SUBST(COMPILER_PLUGINS_CXX)
|
||||||
AC_SUBST(COMPILER_PLUGINS_CXX_LINKFLAGS)
|
AC_SUBST(COMPILER_PLUGINS_CXX_LINKFLAGS)
|
||||||
AC_SUBST(COMPILER_PLUGINS_DEBUG)
|
AC_SUBST(COMPILER_PLUGINS_DEBUG)
|
||||||
|
AC_SUBST(COMPILER_PLUGINS_TOOLING_ARGS)
|
||||||
AC_SUBST(CLANGDIR)
|
AC_SUBST(CLANGDIR)
|
||||||
AC_SUBST(CLANGLIBDIR)
|
AC_SUBST(CLANGLIBDIR)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user