} else
found = false;
break;
+ case 'b':
+ if (*PI == "%bindir%") {
+ std::string tmp(*PI);
+ tmp.replace(0,8,LLVM_BINDIR);
+ action->args.push_back(tmp);
+ } else
+ found = false;
+ break;
case 'd':
if (*PI == "%defs%") {
StringVector::iterator I = Defines.begin();
found = false;
break;
case 'l':
- if (*PI == "%libs%") {
+ if ((*PI)[1] == 'l') {
+ std::string tmp(*PI);
+ if (*PI == "%llvmgccdir%")
+ tmp.replace(0,12,LLVMGCCDIR);
+ else if (*PI == "%llvmgccarch%")
+ tmp.replace(0,13,LLVMGCCARCH);
+ else if (*PI == "%llvmgcc%")
+ tmp.replace(0,9,LLVMGCC);
+ else if (*PI == "%llvmgxx%")
+ tmp.replace(0,9,LLVMGXX);
+ else if (*PI == "%llvmcc1%")
+ tmp.replace(0,9,LLVMCC1);
+ else if (*PI == "%llvmcc1plus%")
+ tmp.replace(0,9,LLVMCC1);
+ else
+ found = false;
+ if (found)
+ action->args.push_back(tmp);
+ } else if (*PI == "%libs%") {
PathVector::iterator I = LibraryPaths.begin();
PathVector::iterator E = LibraryPaths.end();
while (I != E) {
action->args.push_back( std::string("-L") + I->toString() );
++I;
}
+ } else if (*PI == "%libdir%") {
+ std::string tmp(*PI);
+ tmp.replace(0,8,LLVM_LIBDIR);
+ action->args.push_back(tmp);
} else
found = false;
break;
CompilerDriver::~CompilerDriver() {
}
+CompilerDriver::ConfigDataProvider::~ConfigDataProvider() {}
+
CompilerDriver*
CompilerDriver::Get(ConfigDataProvider& CDP) {
return new CompilerDriverImpl(CDP);
/// @brief Configuration Data Provider interface
class ConfigDataProvider {
public:
+ virtual ~ConfigDataProvider();
virtual ConfigData* ProvideConfigData(const std::string& filetype) = 0;
virtual void setConfigDir(const sys::Path& dirName) = 0;
};
extern InputProvider* ConfigLexerInput;
enum ConfigLexerTokens {
- EOFTOK = 0, ///< Returned by Configlex when we hit end of file
- EOLTOK, ///< End of line
- ERRORTOK, ///< Error token
- ARGS_SUBST, ///< THe substitution item %args%
- ASSEMBLY, ///< The value "assembly" (and variants)
- ASSEMBLER, ///< The name "assembler" (and variants)
- BYTECODE, ///< The value "bytecode" (and variants)
- COMMAND, ///< The name "command" (and variants)
- DEFS_SUBST, ///< The substitution item %defs%
- EQUALS, ///< The equals sign, =
- FALSETOK, ///< A boolean false value (false/no/off)
- FOPTS_SUBST, ///< The substitution item %fOpts%
- IN_SUBST, ///< The substitution item %in%
- INCLS_SUBST, ///< The substitution item %incls%
- INTEGER, ///< An integer
- LANG, ///< The name "lang" (and variants)
- LIBPATHS, ///< The name "libpaths" (and variants)
- LIBS, ///< The name "libs" (and variants)
- LIBS_SUBST, ///< The substitution item %libs%
- LINKER, ///< The name "linker" (and variants)
- MOPTS_SUBST, ///< The substitution item %Mopts%
- NAME, ///< The name "name" (and variants)
- OPT_SUBST, ///< The substitution item %opt%
- OPTIMIZER, ///< The name "optimizer" (and variants)
- OPTION, ///< A command line option
- OPT1, ///< The name "opt1" (and variants)
- OPT2, ///< The name "opt2" (and variants)
- OPT3, ///< The name "opt3" (and variants)
- OPT4, ///< The name "opt4" (and variants)
- OPT5, ///< The name "opt5" (and variants)
- OUT_SUBST, ///< The output substitution item %out%
- OUTPUT, ///< The name "output" (and variants)
- PREPROCESSES, ///< The name "preprocesses" (and variants)
- PREPROCESSOR, ///< The name "preprocessor" (and variants)
- REQUIRED, ///< The name "required" (and variants)
- SEPARATOR, ///< A configuration item separator
- SPACE, ///< Space between options
- STATS_SUBST, ///< The stats substitution item %stats%
- STRING, ///< A quoted string
- TARGET_SUBST, ///< The substitition item %target%
- TIME_SUBST, ///< The substitution item %time%
- TRANSLATES, ///< The name "translates" (and variants)
- TRANSLATOR, ///< The name "translator" (and variants)
- TRUETOK, ///< A boolean true value (true/yes/on)
- VERBOSE_SUBST,///< The substitution item %verbose%
- VERSION_TOK, ///< The name "version" (and variants)
- WOPTS_SUBST, ///< The %WOpts% substitution
+ EOFTOK = 0, ///< Returned by Configlex when we hit end of file
+ EOLTOK, ///< End of line
+ ERRORTOK, ///< Error token
+ ARGS_SUBST, ///< The substitution item %args%
+ BINDIR_SUBST, ///< The substitution item %bindir%
+ ASSEMBLY, ///< The value "assembly" (and variants)
+ ASSEMBLER, ///< The name "assembler" (and variants)
+ BYTECODE, ///< The value "bytecode" (and variants)
+ COMMAND, ///< The name "command" (and variants)
+ DEFS_SUBST, ///< The substitution item %defs%
+ EQUALS, ///< The equals sign, =
+ FALSETOK, ///< A boolean false value (false/no/off)
+ FOPTS_SUBST, ///< The substitution item %fOpts%
+ IN_SUBST, ///< The substitution item %in%
+ INCLS_SUBST, ///< The substitution item %incls%
+ INTEGER, ///< An integer
+ LANG, ///< The name "lang" (and variants)
+ LIBDIR_SUBST, ///< The substitution item %libdir%
+ LIBPATHS, ///< The name "libpaths" (and variants)
+ LIBS, ///< The name "libs" (and variants)
+ LIBS_SUBST, ///< The substitution item %libs%
+ LINKER, ///< The name "linker" (and variants)
+ LLVMGCCDIR_SUBST, ///< The substitution item %llvmgccdir%
+ LLVMGCCARCH_SUBST, ///< The substitution item %llvmgccarch%
+ LLVMGCC_SUBST, ///< The substitution item %llvmgcc%
+ LLVMGXX_SUBST, ///< The substitution item %llvmgxx%
+ LLVMCC1_SUBST, ///< The substitution item %llvmcc1%
+ LLVMCC1PLUS_SUBST, ///< The substitution item %llvmcc1plus%
+ MOPTS_SUBST, ///< The substitution item %Mopts%
+ NAME, ///< The name "name" (and variants)
+ OPT_SUBST, ///< The substitution item %opt%
+ OPTIMIZER, ///< The name "optimizer" (and variants)
+ OPTION, ///< A command line option
+ OPT1, ///< The name "opt1" (and variants)
+ OPT2, ///< The name "opt2" (and variants)
+ OPT3, ///< The name "opt3" (and variants)
+ OPT4, ///< The name "opt4" (and variants)
+ OPT5, ///< The name "opt5" (and variants)
+ OUT_SUBST, ///< The output substitution item %out%
+ OUTPUT, ///< The name "output" (and variants)
+ PREPROCESSES, ///< The name "preprocesses" (and variants)
+ PREPROCESSOR, ///< The name "preprocessor" (and variants)
+ REQUIRED, ///< The name "required" (and variants)
+ SEPARATOR, ///< A configuration item separator
+ SPACE, ///< Space between options
+ STATS_SUBST, ///< The stats substitution item %stats%
+ STRING, ///< A quoted string
+ TARGET_SUBST, ///< The substitition item %target%
+ TIME_SUBST, ///< The substitution item %time%
+ TRANSLATES, ///< The name "translates" (and variants)
+ TRANSLATOR, ///< The name "translator" (and variants)
+ TRUETOK, ///< A boolean true value (true/yes/on)
+ VERBOSE_SUBST, ///< The substitution item %verbose%
+ VERSION_TOK, ///< The name "version" (and variants)
+ WOPTS_SUBST, ///< The %WOpts% substitution
};
extern ConfigLexerTokens Configlex();
{LINKER} { return handleNameContext(LINKER); }
%args% { return handleSubstitution(ARGS_SUBST); }
+%bindir% { return handleSubstitution(BINDIR_SUBST); }
%defs% { return handleSubstitution(DEFS_SUBST); }
%in% { return handleSubstitution(IN_SUBST); }
%incls% { return handleSubstitution(INCLS_SUBST); }
+%libdir% { return handleSubstitution(LIBDIR_SUBST); }
%libs% { return handleSubstitution(LIBS_SUBST); }
+%llvmgccdir% { return handleSubstitution(LLVMGCCDIR_SUBST); }
+%llvmgccarch% { return handleSubstitution(LLVMGCCARCH_SUBST); }
+%llvmgcc% { return handleSubstitution(LLVMGCC_SUBST); }
+%llvmgxx% { return handleSubstitution(LLVMGXX_SUBST); }
+%llvmcc1% { return handleSubstitution(LLVMCC1_SUBST); }
+%llvmcc1plus% { return handleSubstitution(LLVMCC1PLUS_SUBST); }
%opt% { return handleSubstitution(OPT_SUBST); }
%out% { return handleSubstitution(OUT_SUBST); }
%stats% { return handleSubstitution(STATS_SUBST); }
bool parseSubstitution(CompilerDriver::StringVector& optList) {
switch (token) {
case ARGS_SUBST: optList.push_back("%args%"); break;
+ case BINDIR_SUBST: optList.push_back("%bindir%"); break;
case DEFS_SUBST: optList.push_back("%defs%"); break;
case IN_SUBST: optList.push_back("%in%"); break;
case INCLS_SUBST: optList.push_back("%incls%"); break;
+ case LIBDIR_SUBST: optList.push_back("%libdir%"); break;
case LIBS_SUBST: optList.push_back("%libs%"); break;
case OPT_SUBST: optList.push_back("%opt%"); break;
case OUT_SUBST: optList.push_back("%out%"); break;
LEVEL = ../..
TOOLNAME = llvmc
USEDLIBS = LLVMBCReader LLVMCore LLVMSupport.a LLVMbzip2 LLVMSystem.a
-CONFIG_FILES = c cpp ll st
-EXTRA_DIST = c cpp ll st
+CONFIG_FILES = c cpp ll
+EXTRA_DIST = c cpp ll
+
+# The CompilerDriver needs to know the locations of several configured
+# directories and paths. We define these as preprocessor symbols so they can
+# be hard coded into the process based on the configuration. Only those
+# configuration values not available in llvm/include/Config/config.h need to be
+# specified here. These values are used as the replacements for the
+# configuration file substitution variables such as %llvmgccdir%
+CPPFLAGS = -DLLVMGCCDIR="\"$(LLVMGCCDIR)\"" \
+ -DLLVMGCCARCH="\"$(LLVMGCCARCH)\"" \
+ -DLLVMGCC="\"$(LLVMGCC)\"" \
+ -DLLVMGXX="\"$(LLVMGXX)\"" \
+ -DLLVMCC1="\"$(LLVMCC1)\"" \
+ -DLLVMCC1PLUS="$(LLVMCC1PLUS)"
include $(LEVEL)/Makefile.common
install::
$(Echo) Installing additional C++ configuration clones
- $(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/cc
- $(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/c++
- $(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/cxx
- $(Verb)$(DataInstall) $(PROJ_OBJ_DIR)/cpp $(PROJ_etcdir)/C
+ $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/cc
+ $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/c++
+ $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/cxx
+ $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/C
--- /dev/null
+# C configuration file for llvmc
+
+##########################################################
+# Language definitions
+##########################################################
+ lang.name=C
+ lang.opt1=-O1
+ lang.opt2=-O2
+ lang.opt3=-O3
+ lang.opt4=-O3
+ lang.opt5=-O3
+ lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib \
+ %llvmgccdir%/lib/gcc/%llvmgccarch%
+
+##########################################################
+# Pre-processor definitions
+##########################################################
+
+ # We use gcc as our pre-processor
+ preprocessor.command=gcc -E %in% -o %out% %incls% %defs%
+ preprocessor.required=true
+
+##########################################################
+# Translator definitions
+##########################################################
+
+ # To compile C source, just use llvm-gcc's cc1
+ translator.command=%llvmcc1% -quiet %in% -o %out% \
+ %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
+ -D_GNU_SOURCE
+
+ # llvm-gcc does not pre-process
+ translator.preprocesses=false
+
+ # The translator is required to run.
+ translator.required=true
+
+ # Output of the translator is assembly
+ translator.output=assembly
+
+##########################################################
+# Optimizer definitions
+##########################################################
+
+ # Use gccas to clean up the generated code
+ optimizer.command=%bindir%/gccas %in% -o %out% %args%
+ optimizer.required = true
+
+ # gccas doesn't translate
+ optimizer.translates = false
+
+ # gccas doesn't preprocess
+ optimizer.preprocesses=false
+
+ # gccas produces bytecode
+ optimizer.output = bytecode
+
+##########################################################
+# Assembler definitions
+##########################################################
+ assembler.command=%bindir%/llc %in% -o %out% %target% %time% %stats%
+++ /dev/null
-# C configuration file for llvmc
-
-##########################################################
-# Language definitions
-##########################################################
- lang.name=C
- lang.opt1=-O1
- lang.opt2=-O2
- lang.opt3=-O3
- lang.opt4=-O3
- lang.opt5=-O3
- lang.libs=@LLVMGCCDIR@/lib @LLVMGCCDIR@/lib \
- @LLVMGCCDIR@/lib/gcc/@LLVMGCCARCH@
-
-##########################################################
-# Pre-processor definitions
-##########################################################
-
- # We use gcc as our pre-processor
- preprocessor.command=gcc -E %in% -o %out% %incls% %defs%
- preprocessor.required=true
-
-##########################################################
-# Translator definitions
-##########################################################
-
- # To compile C source, just use llvm-gcc's cc1
- translator.command=@LLVMCC1@ -quiet %in% -o %out% \
- %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
- -D_GNU_SOURCE
-
- # llvm-gcc does not pre-process
- translator.preprocesses=false
-
- # The translator is required to run.
- translator.required=true
-
- # Output of the translator is assembly
- translator.output=assembly
-
-##########################################################
-# Optimizer definitions
-##########################################################
-
- # Use gccas to clean up the generated code
- optimizer.command=@LLVM_BINDIR@/gccas %in% -o %out% %args%
- optimizer.required = true
-
- # gccas doesn't translate
- optimizer.translates = false
-
- # gccas doesn't preprocess
- optimizer.preprocesses=false
-
- # gccas produces bytecode
- optimizer.output = bytecode
-
-##########################################################
-# Assembler definitions
-##########################################################
- assembler.command=@LLVM_BINDIR@/llc %in% -o %out% %target% %time% %stats%
--- /dev/null
+# C++ configuration file for llvmc
+
+##########################################################
+# Language definitions
+##########################################################
+ lang.name=C++
+ lang.opt1=-O1
+ lang.opt2=-O2
+ lang.opt3=-O3
+ lang.opt4=-O3
+ lang.opt5=-O3
+ lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib \
+ %llvmgccdir%/lib/gcc/%llvmgccarch%
+
+##########################################################
+# Pre-processor definitions
+##########################################################
+
+ # We use g++ as our pre-processor
+ preprocessor.command=g++ -E %in% -o %out% %incls% %defs%
+ preprocessor.required=true
+
+##########################################################
+# Translator definitions
+##########################################################
+
+ # To compile C++ source, just use llvm-g++'s cc1
+ translator.command=%llvmcc1plus% -quiet %in% -o %out% \
+ %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
+ -D_GNU_SOURCE
+
+ # llvm-g++ does not pre-process
+ translator.preprocesses=false
+
+ # The translator is required to run.
+ translator.required=true
+
+ # Output of translator is assembly
+ translator.output=assembly
+
+##########################################################
+# Optimizer definitions
+##########################################################
+
+ # Use gccas to clean up the generated code
+ optimizer.command=%bindir%/gccas %in% -o %out% %args%
+ optimizer.required = true
+
+ # gccas doesn't translate
+ optimizer.translates = false
+
+ # gccas doesn't preprocess
+ optimizer.preprocesses=false
+
+ # gccas produces bytecode
+ optimizer.output = bytecode
+
+##########################################################
+# Assembler definitions
+##########################################################
+ assembler.command=%bindir%/llc %in% -o %out% %target% %time% %stats%
+++ /dev/null
-# C++ configuration file for llvmc
-
-##########################################################
-# Language definitions
-##########################################################
- lang.name=C++
- lang.opt1=-O1
- lang.opt2=-O2
- lang.opt3=-O3
- lang.opt4=-O3
- lang.opt5=-O3
- lang.libs=@LLVMGCCDIR@/lib @LLVMGCCDIR@/lib \
- @LLVMGCCDIR@/lib/gcc/@LLVMGCCARCH@
-
-##########################################################
-# Pre-processor definitions
-##########################################################
-
- # We use g++ as our pre-processor
- preprocessor.command=g++ -E %in% -o %out% %incls% %defs%
- preprocessor.required=true
-
-##########################################################
-# Translator definitions
-##########################################################
-
- # To compile C++ source, just use llvm-g++'s cc1
- translator.command=@LLVMCC1PLUS@ -quiet %in% -o %out% \
- %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \
- -D_GNU_SOURCE
-
- # llvm-g++ does not pre-process
- translator.preprocesses=false
-
- # The translator is required to run.
- translator.required=true
-
- # Output of translator is assembly
- translator.output=assembly
-
-##########################################################
-# Optimizer definitions
-##########################################################
-
- # Use gccas to clean up the generated code
- optimizer.command=@LLVM_BINDIR@/gccas %in% -o %out% %args%
- optimizer.required = true
-
- # gccas doesn't translate
- optimizer.translates = false
-
- # gccas doesn't preprocess
- optimizer.preprocesses=false
-
- # gccas produces bytecode
- optimizer.output = bytecode
-
-##########################################################
-# Assembler definitions
-##########################################################
- assembler.command=@LLVM_BINDIR@/llc %in% -o %out% %target% %time% %stats%
--- /dev/null
+# LLVM Assembly Config File For llvmc
+ version="1.0"
+ lang.name=LLVM Assembly
+ preprocessor.command=
+ preprocessor.required=false
+ translator.command=%bindir%/llvm-as %in% -o %out%
+ translator.optimizes=no
+ translator.preprocesses=true
+ translator.required=TRUE
+ optimizer.command=%bindir%/opt %in% -o %out% %opt% %args%
+ optimizer.translates=no
+ assembler.command=%bindir%/llc %in% -o %out%
+++ /dev/null
-# LLVM Assembly Config File For llvmc
- version="1.0"
- lang.name=LLVM Assembly
- preprocessor.command=
- preprocessor.required=false
- translator.command=@bindir@/llvm-as %in% -o %out%
- translator.optimizes=no
- translator.preprocesses=true
- translator.required=TRUE
- optimizer.command=@bindir@/opt %in% -o %out% %opt% %args%
- optimizer.translates=no
- assembler.command=@bindir@/llc %in% -o %out%