Make lldb build with Makefiles on OS X.

This change does the following:

* Adds Makefile build scripts to debug server.

* Fixes a few small mistakes in the other makefiles.

* Modifies generate-vers.pl slightly to also work for debugserver.

* Changes the OS X, non-framework python search path from libdir to
  libdir/python2.X/site-packages where it is installed by the build
  system (also where it is installed on other operating systems).

Patch by Keno Fischer.

llvm-svn: 199543
This commit is contained in:
Todd Fiala 2014-01-18 08:05:32 +00:00
parent 7132122196
commit 5000e28a5e
15 changed files with 215 additions and 19 deletions
lldb
lib
scripts
source
CMakeLists.txt
Host/common
Makefile
Plugins
Makefile
SystemRuntime/MacOSX
tools

View File

@ -96,7 +96,8 @@ ifeq ($(HOST_OS),Darwin)
lldbPluginObjectFileMachO.a \
lldbPluginSymbolVendorMacOSX.a \
lldbPluginProcessDarwin.a \
lldbPluginProcessMachCore.a
lldbPluginProcessMachCore.a \
lldbPluginSystemRuntimeMacOSX.a
endif
ifeq ($(HOST_OS),Linux)

View File

@ -2,11 +2,11 @@
sub usage()
{
print "Usage: generate-vers.pl /path/toproject.pbxproj";
print "Usage: generate-vers.pl /path/toproject.pbxproj program_name";
exit(0);
}
(scalar @ARGV == 1) or usage();
(scalar @ARGV == 2) or usage();
open $pbxproj, $ARGV[0] or die "Couldn't open ".$ARGV[0];
@ -51,6 +51,6 @@ $lowercase_name = lc $product_name;
close $pbxproj;
$file_string = " const unsigned char liblldb_coreVersionString[] __attribute__ ((used)) = \"@(#)PROGRAM:".$uppercase_name." PROJECT:".$lowercase_name."-".$lldb_version_string."\" \"\\n\"; const double liblldb_coreVersionNumber __attribute__ ((used)) = (double)".$lldb_version.".".$lldb_train.";\n";
$file_string = " const unsigned char ".$ARGV[1]."VersionString[] __attribute__ ((used)) = \"@(#)PROGRAM:".$uppercase_name." PROJECT:".$lowercase_name."-".$lldb_version_string."\" \"\\n\"; const double ".$ARGV[1]."VersionNumber __attribute__ ((used)) = (double)".$lldb_version.".".$lldb_train.";\n";
print $file_string;

View File

@ -110,7 +110,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set(LLDB_VERS_GENERATED_FILE ${LLDB_BINARY_DIR}/source/LLDB_vers.c)
add_custom_command(OUTPUT ${LLDB_VERS_GENERATED_FILE}
COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj liblldb_core
> ${LLDB_VERS_GENERATED_FILE})
set_source_files_properties(${LLDB_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)

View File

@ -1118,19 +1118,23 @@ Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
{
framework_pos += strlen("LLDB.framework");
::strncpy (framework_pos, "/Resources/Python", PATH_MAX - (framework_pos - raw_path));
}
else
{
#endif
llvm::SmallString<256> python_version_dir;
llvm::raw_svector_ostream os(python_version_dir);
os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << "/site-packages";
os.flush();
// We may get our string truncated. Should we protect
// this with an assert?
::strncat(raw_path, python_version_dir.c_str(),
sizeof(raw_path) - strlen(raw_path) - 1);
#if defined (__APPLE__)
}
#else
llvm::SmallString<256> python_version_dir;
llvm::raw_svector_ostream os(python_version_dir);
os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << "/site-packages";
os.flush();
// We may get our string truncated. Should we protect
// this with an assert?
::strncat(raw_path, python_version_dir.c_str(),
sizeof(raw_path) - strlen(raw_path) - 1);
#endif
FileSpec::Resolve (raw_path, resolved_path, sizeof(resolved_path));
g_lldb_python_dir.SetCString(resolved_path);

View File

@ -25,7 +25,7 @@ include $(LLDB_LEVEL)/Makefile
ifeq ($(HOST_OS),Darwin)
LLDB_vers.c: $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/generate-vers.pl $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/lldb.xcodeproj/project.pbxproj
"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/generate-vers.pl" "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/lldb.xcodeproj/project.pbxproj" > LLDB_vers.c
"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/generate-vers.pl" "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/lldb.xcodeproj/project.pbxproj" liblldb_core > LLDB_vers.c
else
LLDB_REVISION := $(strip \
$(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(LLVM_SRC_ROOT)/tools/lldb))

View File

@ -30,6 +30,7 @@ DIRS += ObjectContainer/Universal-Mach-O ObjectFile/Mach-O
DIRS += SymbolVendor/MacOSX
#DIRS += Process/MacOSX-User
DIRS += Process/mach-core
DIRS += SystemRuntime/MacOSX
endif
ifeq ($(HOST_OS),Linux)

View File

@ -0,0 +1,14 @@
##===- source/Plugins/SystemRuntime/MacOSX ----*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../../../..
LIBRARYNAME := lldbPluginSystemRuntimeMacOSX
BUILD_ARCHIVE = 1
include $(LLDB_LEVEL)/Makefile

View File

@ -24,4 +24,8 @@ ifneq ($(HOST_OS),MingW)
DIRS += driver lldb-platform
endif
ifeq ($(HOST_OS),Darwin)
DIRS += debugserver
endif
include $(LLDB_LEVEL)/Makefile

View File

@ -0,0 +1,13 @@
##===- tools/debugserver/Makefile --------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../..
DIRS := scripts source
include $(LLDB_LEVEL)/Makefile

View File

@ -0,0 +1,21 @@
##===- tools/debugserver/scripts/Makefile ------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../../..
include $(LLDB_LEVEL)/Makefile
DBCONFIG_FILE = "$(PROJ_OBJ_DIR)/../DNBConfig.h"
$(DBCONFIG_FILE):
SCRIPT_OUTPUT_FILE_0=$(DBCONFIG_FILE) perl $(PROJ_SRC_DIR)/dbgnub-config.pl
all:: $(DBCONFIG_FILE)
.PHONY: all

View File

@ -33,7 +33,7 @@ my $key;
my $val;
while (($key, $val) = each %ENV)
{
$val =~ s/\n/\n\/\/ /;
$val =~ s/\n/\n\/\/ /g;
printf CONFIG "// %s = %s\n", $key, $val;
}
print CONFIG "//" . "-" x 72 . "\n";

View File

@ -0,0 +1,54 @@
##===- tools/debugserver/source/MacOSX/Makefile ------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../../../..
DIRS := i386 x86_64
TOOLNAME = debugserver
CODESIGN_TOOLS := 1
TOOL_CODESIGN_IDENTITY := lldb_codesign
LLVMLibsOptions += -llldbDebugserverCommon -llldbUtility -llldbDebugserverMacOSX_I386 -llldbDebugserverMacOSX_X86_64 \
-framework Foundation -framework CoreFoundation
GENERATED_MACH_SOURCES = $(PROJ_OBJ_DIR)/mach_excServer.c $(PROJ_OBJ_DIR)/mach_excUser.c
SOURCES := CFBundle.cpp \
CFData.cpp \
CFString.cpp \
MachException.cpp \
MachProcess.cpp \
MachTask.cpp \
MachThread.cpp \
MachThreadList.cpp \
MachVMMemory.cpp \
MachVMRegion.cpp
BUILT_SOURCES = $(GENERATED_MACH_SOURCES) $(PROJ_OBJ_DIR)/HasAVX.o
CPP.Flags += -I$(PROJ_OBJ_DIR)/../.. -I$(PROJ_SRC_DIR)/..
LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(PROJ_SRC_DIR)/../../resources/lldb-debugserver-Info.plist
include $(LLDB_LEVEL)/Makefile
ObjectsO += $(PROJ_OBJ_DIR)/HasAVX.o
$(PROJ_OBJ_DIR)/HasAVX.o: $(PROJ_SRC_DIR)/HasAVX.s
$(Echo) "Compiling HasAVX.s for $(BuildMode) build" $(PIC_FLAG)
$(CC) $(TargetCommonOpts) $(CompileCommonOpts) -c $< -o $@
ifeq ($(HOST_OS),Darwin)
LLVMLibsOptions += -Wl,-rpath,@loader_path/../lib/
endif
$(GENERATED_MACH_SOURCES):
mig -I$(PROJ_OBJ_DIR)/../.. $(PROJ_SRC_DIR)/dbgnub-mig.defs

View File

@ -0,0 +1,19 @@
##===- tools/debugserver/source/MacOSX/i386/Makefile -------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../../../../..
LIBRARYNAME := lldbDebugserverMacOSX_I386
BUILD_ARCHIVE = 1
SOURCES := DNBArchImplI386.cpp
include $(LLDB_LEVEL)/Makefile
CPP.Flags += -I$(PROJ_SRC_DIR)/.. -I$(PROJ_SRC_DIR)/../.. -I$(PROJ_OBJ_DIR)/../../..

View File

@ -0,0 +1,19 @@
##===- tools/debugserver/source/MacOSX/i386/Makefile -------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../../../../..
LIBRARYNAME := lldbDebugserverMacOSX_X86_64
BUILD_ARCHIVE = 1
SOURCES := DNBArchImplX86_64.cpp
include $(LLDB_LEVEL)/Makefile
CPP.Flags += -I$(PROJ_SRC_DIR)/.. -I$(PROJ_SRC_DIR)/../.. -I$(PROJ_OBJ_DIR)/../../..

View File

@ -0,0 +1,46 @@
##===- tools/debugserver/source/Makefile -------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../../..
LIBRARYNAME := lldbDebugserverCommon
BUILD_ARCHIVE = 1
SOURCES := debugserver.cpp \
DNBArch.cpp \
DNBBreakpoint.cpp \
DNB.cpp \
DNBDataRef.cpp \
DNBError.cpp \
DNBLog.cpp \
DNBRegisterInfo.cpp \
DNBThreadResumeActions.cpp \
libdebugserver.cpp \
PseudoTerminal.cpp \
PThreadEvent.cpp \
PThreadMutex.cpp \
RNBContext.cpp \
RNBRemote.cpp \
RNBServices.cpp \
RNBSocket.cpp \
SysSignal.cpp \
TTYState.cpp
include $(LLDB_LEVEL)/Makefile
ifeq ($(HOST_OS),Darwin)
DIRS := MacOSX/i386 MacOSX/x86_64 MacOSX
CPP.Flags += -I$(PROJ_SRC_DIR)/MacOSX
CPP.Flags += -I$(PROJ_OBJ_DIR)/..
BUILT_SOURCES = debugserver_vers.c
endif
ifeq ($(HOST_OS),Darwin)
debugserver_vers.c: $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/generate-vers.pl $(PROJ_SRC_DIR)/../debugserver.xcodeproj/project.pbxproj
"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/generate-vers.pl" "$(PROJ_SRC_DIR)/../debugserver.xcodeproj/project.pbxproj" debugserver > debugserver_vers.c
endif