diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 49c73b718fc..4269ae842be 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -19,6 +19,7 @@ if( NOT WIN32 OR MSYS OR CYGWIN ) add_subdirectory(llvm-config) endif() +add_subdirectory(llvm-config-2) add_subdirectory(opt) add_subdirectory(llvm-as) add_subdirectory(llvm-dis) diff --git a/tools/Makefile b/tools/Makefile index 2da39177815..278546bc162 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -34,7 +34,7 @@ PARALLEL_DIRS := opt llvm-as llvm-dis \ bugpoint llvm-bcanalyzer llvm-stub \ llvm-diff macho-dump llvm-objdump \ llvm-rtdyld llvm-dwarfdump llvm-cov \ - llvm-size + llvm-size llvm-config-2 # Let users override the set of tools to build from the command line. ifdef ONLY_TOOLS diff --git a/tools/llvm-config-2/CMakeLists.txt b/tools/llvm-config-2/CMakeLists.txt new file mode 100644 index 00000000000..a1e083df08a --- /dev/null +++ b/tools/llvm-config-2/CMakeLists.txt @@ -0,0 +1,5 @@ +set(LLVM_LINK_COMPONENTS support) + +add_llvm_tool(llvm-config-2 + llvm-config.cpp + ) diff --git a/tools/llvm-config-2/Makefile b/tools/llvm-config-2/Makefile new file mode 100644 index 00000000000..e0036a40622 --- /dev/null +++ b/tools/llvm-config-2/Makefile @@ -0,0 +1,17 @@ +##===- tools/llvm-config/Makefile---------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL := ../.. +TOOLNAME := llvm-config-2 +LINK_COMPONENTS := support + +# This tool has no plugins, optimize startup time. +TOOL_NO_EXPORTS := 1 + +include $(LEVEL)/Makefile.common diff --git a/tools/llvm-config-2/llvm-config.cpp b/tools/llvm-config-2/llvm-config.cpp new file mode 100644 index 00000000000..35bda5026f0 --- /dev/null +++ b/tools/llvm-config-2/llvm-config.cpp @@ -0,0 +1,259 @@ +//===-- llvm-config.cpp - LLVM project configuration utility --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This tool encapsulates information about an LLVM project configuration for +// use by other project's build environments (to determine installed path, +// available features, required libraries, etc.). +// +// Note that although this tool *may* be used by some parts of LLVM's build +// itself (i.e., the Makefiles use it to compute required libraries when linking +// tools), this tool is primarily designed to support external projects. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" +#include "llvm/Config/config.h" +#include "llvm/Config/llvm-config.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/raw_ostream.h" +#include +#include + +using namespace llvm; + +// FIXME: Need to get various bits of build time information. +const char LLVM_SRC_ROOT[] = "FIXME"; +const char LLVM_OBJ_ROOT[] = "FIXME"; +const char LLVM_CPPFLAGS[] = "FIXME"; +const char LLVM_CFLAGS[] = "FIXME"; +const char LLVM_LDFLAGS[] = "FIXME"; +const char LLVM_CXXFLAGS[] = "FIXME"; +const char LLVM_BUILDMODE[] = "FIXME"; +const char LLVM_SYSTEM_LIBS[] = "FIXME"; + +// FIXME: Include component table. +struct AvailableComponent { + const char *Name; +} AvailableComponents[1] = {}; +unsigned NumAvailableComponents = 0; + +void ComputeLibsForComponents(const std::vector &Components, + std::vector &RequiredLibs) { + // FIXME: Implement. + RequiredLibs = Components; +} + +/* *** */ + +void usage() { + errs() << "\ +usage: llvm-config