Kaydet (Commit) 38da1ed9 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Make plugin rewriting work on Windows too

...in a somewhat hacked-up way for now (see the TODO comment)

Change-Id: Ida89fb8257b876cfca05b3048ce15996091c5703
üst b61214c9
......@@ -191,6 +191,11 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
if( plugins[ i ].object != NULL )
plugins[ i ].object->run();
}
#if defined _WIN32
//TODO: make the call to 'rename' work on Windows (where the renamed-to
// original file is probably still held open somehow):
rewriter.overwriteChangedFiles();
#else
for( Rewriter::buffer_iterator it = rewriter.buffer_begin();
it != rewriter.buffer_end();
++it )
......@@ -256,6 +261,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
report( DiagnosticsEngine::Error, "cannot write modified source to %0 (%1)" ) << modifyFile << error;
delete[] filename;
}
#endif
}
#if CLANG_VERSION >= 30600
......
......@@ -73,6 +73,85 @@ gb_LinkTarget_LAYER_LINKPATHS := \
NONE:URELIB+OOO+NONE. \
# Used to run a compiler plugin tool.
#
# At least for now, these definitions are generic enough so that they can be
# shared across all current use cases (COMPILER_EXTERNAL_TOOL,
# COMPILER_PLUGIN_TOOL) on all relevant toolchains (GCC?, Clang, clang-cl). If
# it ever becomes necessary, they can be moved to e.g.
# platform/com_{GCC,MSC}_class.mk and made different there.
#
# $(call gb_CObject__tool_command,relative-source,source)
define gb_CObject__tool_command
$(call gb_Output_announce,$(1).c,$(true),C ,3)
$(call gb_Helper_abbreviate_dirs,\
ICECC=no CCACHE_DISABLE=1 \
$(gb_CC) \
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
$(gb_COMPILER_PLUGINS) \
$(T_CFLAGS) $(T_CFLAGS_APPEND) \
$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
-c $(2) \
-I$(dir $(2)) \
$(INCLUDE) \
)
endef
define gb_ObjCObject__tool_command
$(call gb_Output_announce,$(1).m,$(true),OCC,3)
$(call gb_Helper_abbreviate_dirs,\
ICECC=no CCACHE_DISABLE=1 \
$(gb_CC) \
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
$(gb_COMPILER_PLUGINS) \
$(T_OBJCFLAGS) $(T_OBJCFLAGS_APPEND) \
$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
-c $(2) \
-I$(dir $(2)) \
$(INCLUDE) \
)
endef
define gb_CxxObject__tool_command
$(call gb_Output_announce,$(1).cxx,$(true),CXX,3)
$(call gb_Helper_abbreviate_dirs,\
ICECC=no CCACHE_DISABLE=1 \
$(gb_CXX) \
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
$(gb_COMPILER_PLUGINS) \
$(T_CXXFLAGS) $(T_CXXFLAGS_APPEND) \
$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
-c $(2) \
-I$(dir $(2)) \
$(INCLUDE) \
)
endef
define gb_ObjCxxObject__tool_command
$(call gb_Output_announce,$(1).mm,$(true),OCX,3)
$(call gb_Helper_abbreviate_dirs,\
ICECC=no CCACHE_DISABLE=1 \
$(gb_CXX) \
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
$(gb_COMPILER_PLUGINS) \
$(T_OBJCXXFLAGS) $(T_OBJCXXFLAGS_APPEND) \
$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
-c $(2) \
-I$(dir $(2)) \
$(INCLUDE) \
)
endef
# Overview of dependencies and tasks of LinkTarget
#
# target task depends on
......
......@@ -67,80 +67,6 @@ $(call gb_Helper_abbreviate_dirs,\
)
endef
# Used to run a compiler plugin tool.
# $(call gb_CObject__tool_command,relative-source,source)
define gb_CObject__tool_command
$(call gb_Output_announce,$(1).c,$(true),C ,3)
$(call gb_Helper_abbreviate_dirs,\
ICECC=no CCACHE_DISABLE=1 \
$(gb_CC) \
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
$(gb_COMPILER_PLUGINS) \
$(T_CFLAGS) $(T_CFLAGS_APPEND) \
$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
-c $(2) \
-I$(dir $(2)) \
$(INCLUDE) \
)
endef
define gb_ObjCObject__tool_command
$(call gb_Output_announce,$(1).m,$(true),OCC,3)
$(call gb_Helper_abbreviate_dirs,\
ICECC=no CCACHE_DISABLE=1 \
$(gb_CC) \
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
$(gb_COMPILER_PLUGINS) \
$(T_OBJCFLAGS) $(T_OBJCFLAGS_APPEND) \
$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
-c $(2) \
-I$(dir $(2)) \
$(INCLUDE) \
)
endef
# Used to run a compiler plugin tool.
# $(call gb_CxxObject__tool_command,relative-source,source)
define gb_CxxObject__tool_command
$(call gb_Output_announce,$(1).cxx,$(true),CXX,3)
$(call gb_Helper_abbreviate_dirs,\
ICECC=no CCACHE_DISABLE=1 \
$(gb_CXX) \
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
$(gb_COMPILER_PLUGINS) \
$(T_CXXFLAGS) $(T_CXXFLAGS_APPEND) \
$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
-c $(2) \
-I$(dir $(2)) \
$(INCLUDE) \
)
endef
define gb_ObjCxxObject__tool_command
$(call gb_Output_announce,$(1).mm,$(true),OCX,3)
$(call gb_Helper_abbreviate_dirs,\
ICECC=no CCACHE_DISABLE=1 \
$(gb_CXX) \
$(DEFS) \
$(gb_LTOFLAGS) \
$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
$(gb_COMPILER_PLUGINS) \
$(T_OBJCXXFLAGS) $(T_OBJCXXFLAGS_APPEND) \
$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
-c $(2) \
-I$(dir $(2)) \
$(INCLUDE) \
)
endef
define gb_SrsPartTarget__command_dep
$(call gb_Helper_abbreviate_dirs,\
mkdir -p $(dir $(call gb_SrsPartTarget_get_dep_target,$(1))) && cd $(SRCDIR) && \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment