aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2008-10-02 21:15:05 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2008-10-02 21:15:05 +0000
commite4a5ea3130129124a9d88e5e27d8bcf26f147fa0 (patch)
treed6e05c63cbcdec28213f5462d45b770dfa5cfcda
parent88ab90b4757e481b627bb61b0eaca5ed2aa22b4d (diff)
Build system tweaks to make it more convenient for the plugin authors.
Plugins can be now compiled in with a slight Makefile change. For example, to compile the new Clang driver, use: cd $LLVMC2_DIR make TOOLNAME=ccc2 BUILTIN_PLUGINS=Clang git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56967 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CompilerDriver/Common.td (renamed from tools/llvmc2/Common.td)0
-rw-r--r--include/llvm/CompilerDriver/Tools.td (renamed from tools/llvmc2/Tools.td)0
-rw-r--r--tools/llvmc2/AutoGenerated.cpp15
-rw-r--r--tools/llvmc2/Makefile39
-rw-r--r--tools/llvmc2/plugins/Base/AutoGenerated.cpp1
-rw-r--r--tools/llvmc2/plugins/Base/Base.td (renamed from tools/llvmc2/Graph.td)4
-rw-r--r--tools/llvmc2/plugins/Base/Makefile12
-rw-r--r--tools/llvmc2/plugins/Clang/AutoGenerated.cpp1
-rw-r--r--tools/llvmc2/plugins/Clang/Clang.td (renamed from tools/llvmc2/examples/Clang.td)6
-rw-r--r--tools/llvmc2/plugins/Clang/Makefile13
-rw-r--r--tools/llvmc2/plugins/Hello/Makefile11
11 files changed, 62 insertions, 40 deletions
diff --git a/tools/llvmc2/Common.td b/include/llvm/CompilerDriver/Common.td
index 45518385e4..45518385e4 100644
--- a/tools/llvmc2/Common.td
+++ b/include/llvm/CompilerDriver/Common.td
diff --git a/tools/llvmc2/Tools.td b/include/llvm/CompilerDriver/Tools.td
index 1a466a2735..1a466a2735 100644
--- a/tools/llvmc2/Tools.td
+++ b/include/llvm/CompilerDriver/Tools.td
diff --git a/tools/llvmc2/AutoGenerated.cpp b/tools/llvmc2/AutoGenerated.cpp
deleted file mode 100644
index 9f34e58b14..0000000000
--- a/tools/llvmc2/AutoGenerated.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===--- AutoGenerated.cpp - The LLVM Compiler Driver -----------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open
-// Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Auto-generated tool descriptions - implementation.
-//
-//===----------------------------------------------------------------------===//
-
-// The auto-generated file
-#include "AutoGenerated.inc"
diff --git a/tools/llvmc2/Makefile b/tools/llvmc2/Makefile
index 0d64088ced..93501657fb 100644
--- a/tools/llvmc2/Makefile
+++ b/tools/llvmc2/Makefile
@@ -6,24 +6,39 @@
# Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
+
+# Compiled-in plugins
+BUILTIN_PLUGINS = Base
+
LEVEL = ../..
TOOLNAME = llvmc2
-BUILT_SOURCES = AutoGenerated.inc
LINK_COMPONENTS = support system
REQUIRES_EH := 1
+ifneq ($(BUILTIN_PLUGINS),)
+
+export BUILTIN_LLVMC_PLUGIN=1
+USEDLIBS = $(patsubst %,LLVMC%,$(BUILTIN_PLUGINS))
+
+endif
+
include $(LEVEL)/Makefile.common
-GRAPH=Graph.td
-$(GRAPH) : Common.td
-Graph.td : Tools.td
-TOOLS_SOURCE=$(GRAPH)
+TD_COMMON = $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td)
+
+# There is probably a better way to do this: currently we enter the
+# subdirectory 2 times - the second time is not needed.
+# This probably also needs to be integrated into Makefile.rules.
+define PLUGIN_template
+PLUGIN_$(1)_SOURCES=$$(wildcard plugins/$(1)/*.cpp)
+PLUGIN_$(1)_TD_SOURCES=$$(wildcard plugins/$(1)/*.cpp)
+
+$$(LibDir)/LLVMC$(1).o: $$(PLUGIN_$(1)_SOURCES) $$(PLUGIN_$(1)_TD_SOURCES) \
+ $$(TD_COMMON)
+ @$$(MAKE) -C plugins/$(1)
-# TOFIX: integrate this part into Makefile.rules?
-# The degree of horrorshowness in that file is too much for me atm.
-$(ObjDir)/AutoGenerated.inc.tmp: $(TOOLS_SOURCE) $(ObjDir)/.dir $(TBLGEN)
- $(Echo) "Building LLVMC configuration library with tblgen"
- $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
+$$(RecursiveTargets) ::
+ @$$(MAKE) -C plugins/$(1) $$@
+endef
-AutoGenerated.inc : $(ObjDir)/AutoGenerated.inc.tmp
- $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
+$(foreach plugin,$(BUILTIN_PLUGINS),$(eval $(call PLUGIN_template,$(plugin))))
diff --git a/tools/llvmc2/plugins/Base/AutoGenerated.cpp b/tools/llvmc2/plugins/Base/AutoGenerated.cpp
new file mode 100644
index 0000000000..add8acb4a5
--- /dev/null
+++ b/tools/llvmc2/plugins/Base/AutoGenerated.cpp
@@ -0,0 +1 @@
+#include "AutoGenerated.inc"
diff --git a/tools/llvmc2/Graph.td b/tools/llvmc2/plugins/Base/Base.td
index b09d8cefdc..bc40dd56ed 100644
--- a/tools/llvmc2/Graph.td
+++ b/tools/llvmc2/plugins/Base/Base.td
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-include "Common.td"
-include "Tools.td"
+include "llvm/CompilerDriver/Common.td"
+include "llvm/CompilerDriver/Tools.td"
// Toolchains
diff --git a/tools/llvmc2/plugins/Base/Makefile b/tools/llvmc2/plugins/Base/Makefile
new file mode 100644
index 0000000000..e72f4fe38e
--- /dev/null
+++ b/tools/llvmc2/plugins/Base/Makefile
@@ -0,0 +1,12 @@
+##===- tools/llvmc2/plugins/Base/Makefile ------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLVMC_PLUGIN = Base
+
+include ../Makefile.common
diff --git a/tools/llvmc2/plugins/Clang/AutoGenerated.cpp b/tools/llvmc2/plugins/Clang/AutoGenerated.cpp
new file mode 100644
index 0000000000..add8acb4a5
--- /dev/null
+++ b/tools/llvmc2/plugins/Clang/AutoGenerated.cpp
@@ -0,0 +1 @@
+#include "AutoGenerated.inc"
diff --git a/tools/llvmc2/examples/Clang.td b/tools/llvmc2/plugins/Clang/Clang.td
index 383984a0bf..9985d70cda 100644
--- a/tools/llvmc2/examples/Clang.td
+++ b/tools/llvmc2/plugins/Clang/Clang.td
@@ -1,11 +1,11 @@
// A (first stab at a) replacement for the Clang's ccc script.
// To compile, use this command:
-// make TOOLNAME=ccc2 GRAPH=examples/Clang.td
+// cd $LLVMC2_DIR
+// make TOOLNAME=ccc2 BUILTIN_PLUGINS=Clang
-include "Common.td"
+include "llvm/CompilerDriver/Common.td"
-// TOFIX: Add an explicit option list for aliases and things like this.
def Options : OptionList<[
(switch_option "E",
(help "Stop after the preprocessing stage, do not run the compiler"))
diff --git a/tools/llvmc2/plugins/Clang/Makefile b/tools/llvmc2/plugins/Clang/Makefile
new file mode 100644
index 0000000000..8904588222
--- /dev/null
+++ b/tools/llvmc2/plugins/Clang/Makefile
@@ -0,0 +1,13 @@
+##===- tools/llvmc2/plugins/Clang/Makefile -----------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLVMC_PLUGIN = Clang
+
+include ../Makefile.common
+
diff --git a/tools/llvmc2/plugins/Hello/Makefile b/tools/llvmc2/plugins/Hello/Makefile
index 3aeef24eea..8cd0b57a00 100644
--- a/tools/llvmc2/plugins/Hello/Makefile
+++ b/tools/llvmc2/plugins/Hello/Makefile
@@ -1,4 +1,4 @@
-##===- lib/Transforms/Hello/Makefile -----------------------*- Makefile -*-===##
+##===- tools/llvmc2/plugins/Hello/Makefile -----------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
@@ -7,11 +7,6 @@
#
##===----------------------------------------------------------------------===##
-LEVEL = ../../../..
-LIBRARYNAME = LLVMCHello
-LOADABLE_MODULE = 1
-REQUIRES_EH = 1
-USEDLIBS =
-
-include $(LEVEL)/Makefile.common
+LLVMC_PLUGIN = Hello
+include ../Makefile.common