[Lldb-commits] [lldb] r155501 - in /lldb/trunk/test: lang/objcxx/ lang/objcxx/sample/ lang/objcxx/sample/Makefile lang/objcxx/sample/main.mm make/Makefile.rules

Johnny Chen johnny.chen at apple.com
Tue Apr 24 16:05:08 PDT 2012


Author: johnny
Date: Tue Apr 24 18:05:07 2012
New Revision: 155501

URL: http://llvm.org/viewvc/llvm-project?rev=155501&view=rev
Log:
Add a suffix rule for compiling objc++ files and a sample directory under test/lang/objcxx.

Added:
    lldb/trunk/test/lang/objcxx/
    lldb/trunk/test/lang/objcxx/sample/
    lldb/trunk/test/lang/objcxx/sample/Makefile
    lldb/trunk/test/lang/objcxx/sample/main.mm
Modified:
    lldb/trunk/test/make/Makefile.rules

Added: lldb/trunk/test/lang/objcxx/sample/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objcxx/sample/Makefile?rev=155501&view=auto
==============================================================================
--- lldb/trunk/test/lang/objcxx/sample/Makefile (added)
+++ lldb/trunk/test/lang/objcxx/sample/Makefile Tue Apr 24 18:05:07 2012
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+OBJCXX_SOURCES := main.mm
+LDFLAGS = $(CFLAGS) -lobjc -framework Foundation
+
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/lang/objcxx/sample/main.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objcxx/sample/main.mm?rev=155501&view=auto
==============================================================================
--- lldb/trunk/test/lang/objcxx/sample/main.mm (added)
+++ lldb/trunk/test/lang/objcxx/sample/main.mm Tue Apr 24 18:05:07 2012
@@ -0,0 +1,71 @@
+#import <Foundation/Foundation.h>
+#include <iostream>
+
+ at interface MyString : NSObject {
+    NSString *_string;
+    NSDate *_date;
+}
+- (id)initWithNSString:(NSString *)string;
+
+ at property (copy) NSString *string;
+ at property (readonly,getter=getTheDate) NSDate *date;
+
+- (NSDate *) getTheDate;
+ at end
+
+ at implementation MyString
+
+ at synthesize string = _string;
+ at synthesize date = _date;
+
+- (id)initWithNSString:(NSString *)string
+{
+    if (self = [super init])
+    {
+        _string = [NSString stringWithString:string];
+        _date = [NSDate date];            
+    }
+    return self;
+}
+
+- (void) dealloc
+{
+    [_date release];
+    [_string release];
+    [super dealloc];
+}
+
+- (NSDate *) getTheDate
+{
+    return _date;
+}
+
+- (NSString *)description
+{
+    return [_string stringByAppendingFormat:@" with timestamp: %@", _date];
+}
+ at end
+
+int main (int argc, char const *argv[])
+{
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+    static NSString *g_global_nsstr = @"Howdy";
+    
+    MyString *myStr = [[MyString alloc] initWithNSString: [NSString stringWithFormat:@"string %i", 1]];
+    NSString *str1 = myStr.string;
+    NSString *str2 = [NSString stringWithFormat:@"string %i", 2];
+    NSString *str3 = [NSString stringWithFormat:@"string %i", 3];
+    NSArray *array = [NSArray arrayWithObjects: str1, str2, str3, nil];
+    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+                            str1, @"1", 
+                            str2, @"2", 
+                            str3, @"3", 
+                            myStr.date, @"date",
+                            nil];
+
+    id str_id = str1;
+    SEL sel = @selector(length);
+    [pool release];
+    std::cout << "Hello, objc++!\n";
+    return 0;
+}

Modified: lldb/trunk/test/make/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=155501&r1=155500&r2=155501&view=diff
==============================================================================
--- lldb/trunk/test/make/Makefile.rules (original)
+++ lldb/trunk/test/make/Makefile.rules Tue Apr 24 18:05:07 2012
@@ -136,7 +136,7 @@
 	OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))
 	CXX = $(call cxx_compiler,$(CC))
 	LD = $(call cxx_linker,$(CC))
-	ifeq $(findstring lobjc,$(LDFLAGS)) ""
+	ifeq "$(findstring lobjc,$(LDFLAGS))" ""
 		LDFLAGS +=-lobjc
 	endif
 endif
@@ -172,7 +172,7 @@
 	ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJCXX_SOURCES:.mm=.o))
 	CXX = $(call cxx_compiler,$(CC))
 	LD = $(call cxx_linker,$(CC))
-	ifeq $(findstring lobjc,$(LDFLAGS)) ""
+	ifeq "$(findstring lobjc,$(LDFLAGS))" ""
 		LDFLAGS +=-lobjc
 	endif
 endif
@@ -283,6 +283,11 @@
 	sinclude $(DYLIB_PREREQS)
 endif
 
+# Define a suffix rule for .mm -> .o
+.SUFFIXES: .mm .o
+.mm.o:
+	$(CXX) $(CXXFLAGS) -c $<
+
 .PHONY: clean
 dsym:	$(DSYM)
 all:	$(EXE) $(DSYM)





More information about the lldb-commits mailing list