Converted teststrings into a tool
Monotone-Parent: ae0c0cd3dbc947562a3dbd28f513f46bcd28a5b4 Monotone-Revision: f6ec5191473f90384de5c3301569150128a2ae63 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2011-10-07T15:27:41 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
b85b885608
commit
f045996ac6
|
@ -10,6 +10,7 @@ SUBPROJECTS = \
|
||||||
SoObjects \
|
SoObjects \
|
||||||
Main \
|
Main \
|
||||||
UI \
|
UI \
|
||||||
Tools
|
Tools \
|
||||||
|
Bundles/Sample
|
||||||
|
|
||||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||||
|
|
|
@ -4,9 +4,10 @@ include ../config.make
|
||||||
include $(GNUSTEP_MAKEFILES)/common.make
|
include $(GNUSTEP_MAKEFILES)/common.make
|
||||||
include ../Version
|
include ../Version
|
||||||
|
|
||||||
ADDITIONAL_INCLUDE_DIRS +=
|
ADDITIONAL_INCLUDE_DIRS += -I/usr/include/python2.6/
|
||||||
ADDITIONAL_LIB_DIRS += -L../SOPE/GDLContentStore/obj/
|
ADDITIONAL_LIB_DIRS += -L../SOPE/GDLContentStore/obj/
|
||||||
ADDITIONAL_LDFLAGS += -Wl,--no-as-needed
|
ADDITIONAL_LDFLAGS += -Wl,--no-as-needed
|
||||||
|
ADDITIONAL_LDFLAGS += -lpython2.6
|
||||||
|
|
||||||
SOGOD = sogod
|
SOGOD = sogod
|
||||||
TOOL_NAME = $(SOGOD)
|
TOOL_NAME = $(SOGOD)
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
@interface SOGo : SoApplication
|
@interface SOGo : SoApplication
|
||||||
{
|
{
|
||||||
|
NSMutableArray *bundles;
|
||||||
SOGoCache *cache;
|
SOGoCache *cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
117
Main/SOGo.m
117
Main/SOGo.m
|
@ -25,6 +25,8 @@
|
||||||
#import <Foundation/NSData.h>
|
#import <Foundation/NSData.h>
|
||||||
#import <Foundation/NSDate.h>
|
#import <Foundation/NSDate.h>
|
||||||
#import <Foundation/NSEnumerator.h>
|
#import <Foundation/NSEnumerator.h>
|
||||||
|
#import <Foundation/NSFileManager.h>
|
||||||
|
#import <Foundation/NSPathUtilities.h>
|
||||||
#import <Foundation/NSProcessInfo.h>
|
#import <Foundation/NSProcessInfo.h>
|
||||||
#import <Foundation/NSRunLoop.h>
|
#import <Foundation/NSRunLoop.h>
|
||||||
#import <Foundation/NSURL.h>
|
#import <Foundation/NSURL.h>
|
||||||
|
@ -65,6 +67,8 @@
|
||||||
#import <SOGo/WOResourceManager+SOGo.h>
|
#import <SOGo/WOResourceManager+SOGo.h>
|
||||||
#import <SOGo/NSObject+DAV.h>
|
#import <SOGo/NSObject+DAV.h>
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
#import "NSException+Stacktrace.h"
|
#import "NSException+Stacktrace.h"
|
||||||
|
|
||||||
#import "SOGo.h"
|
#import "SOGo.h"
|
||||||
|
@ -147,6 +151,116 @@ static BOOL debugLeaks;
|
||||||
[[SOGoProductLoader productLoader] loadAllProducts];
|
[[SOGoProductLoader productLoader] loadAllProducts];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _loadBundles
|
||||||
|
{
|
||||||
|
NSFileManager *aFileManager;
|
||||||
|
NSMutableArray *allPaths;
|
||||||
|
NSArray *allFiles;
|
||||||
|
NSString *aPath;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
bundles = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
|
aFileManager = [NSFileManager defaultManager];
|
||||||
|
allPaths = [[NSMutableArray alloc] initWithArray: NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
|
||||||
|
NSLocalDomainMask|
|
||||||
|
NSNetworkDomainMask|
|
||||||
|
NSSystemDomainMask|
|
||||||
|
NSUserDomainMask,
|
||||||
|
YES)];
|
||||||
|
for (i = 0; i < [allPaths count]; i++)
|
||||||
|
{
|
||||||
|
// We remove any potential duplicate paths in our allPaths array.
|
||||||
|
[allPaths removeObject: [allPaths objectAtIndex: i] inRange: NSMakeRange(i+1, [allPaths count]-i-1)];
|
||||||
|
|
||||||
|
aPath = [NSString stringWithFormat: @"%@/SOGo", [allPaths objectAtIndex: i]];
|
||||||
|
allFiles = [aFileManager directoryContentsAtPath: aPath];
|
||||||
|
|
||||||
|
for (j = 0; j < [allFiles count]; j++)
|
||||||
|
{
|
||||||
|
NSString *aString;
|
||||||
|
|
||||||
|
aString = [allFiles objectAtIndex: j];
|
||||||
|
|
||||||
|
// If we found a bundle, let's load it!
|
||||||
|
if ([[aString pathExtension] isEqualToString: @"bundle"])
|
||||||
|
{
|
||||||
|
NSBundle *aBundle;
|
||||||
|
NSString *path;
|
||||||
|
|
||||||
|
path = [NSString stringWithFormat: @"%@/%@", aPath, aString];
|
||||||
|
aBundle = [NSBundle bundleWithPath: path];
|
||||||
|
|
||||||
|
if (aBundle)
|
||||||
|
{
|
||||||
|
PyObject *pName, *pModule;
|
||||||
|
NSString *ppath;
|
||||||
|
|
||||||
|
NSLog(@"Loaded bundle at path %@ successfully...", path);
|
||||||
|
|
||||||
|
// We add that path to the PYTHONPATH environment
|
||||||
|
ppath = [NSString stringWithFormat: @"%@/Resources/:%s", path, getenv("PYTHONPATH")];
|
||||||
|
NSLog(@"Setting environment to %@", ppath);
|
||||||
|
setenv("PYTHONPATH", [ppath UTF8String], 1);
|
||||||
|
NSLog(@"New environment: %s", getenv("PYTHONPATH"));
|
||||||
|
|
||||||
|
Py_Initialize();
|
||||||
|
pName = PyString_FromString("main");
|
||||||
|
|
||||||
|
if (pName)
|
||||||
|
{
|
||||||
|
NSLog(@"Trying to initialize module...");
|
||||||
|
pModule = PyImport_Import(pName);
|
||||||
|
Py_DECREF(pName);
|
||||||
|
|
||||||
|
if (pModule != NULL)
|
||||||
|
{
|
||||||
|
id aModule;
|
||||||
|
Class c;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
NSLog(@"Loaded main Python file at path %@", path);
|
||||||
|
|
||||||
|
len = [aString length];
|
||||||
|
|
||||||
|
c = NSClassFromString([aString substringToIndex: (len-7)]);
|
||||||
|
aModule = [c new];
|
||||||
|
|
||||||
|
if (aModule)
|
||||||
|
{
|
||||||
|
[bundles addObject: aModule];
|
||||||
|
RELEASE(aModule);
|
||||||
|
|
||||||
|
NSLog(@"Successfully instanciated Sample");
|
||||||
|
|
||||||
|
if ([aModule respondsToSelector: @selector(userWasCreated:atDate:)])
|
||||||
|
{
|
||||||
|
[aModule userWasCreated: @"foo" atDate: @"bar"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Failed to instanciate Sample");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Failed to load module.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Failed to load module. You MUST have main.py in your SOGo Python bundle.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
|
@ -157,6 +271,9 @@ static BOOL debugLeaks;
|
||||||
rm = [[WEResourceManager alloc] init];
|
rm = [[WEResourceManager alloc] init];
|
||||||
[self setResourceManager:rm];
|
[self setResourceManager:rm];
|
||||||
[rm release];
|
[rm release];
|
||||||
|
|
||||||
|
/* load all bundles */
|
||||||
|
[self _loadBundles];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
PROGRAM=teststrings
|
|
||||||
|
|
||||||
SRCS=teststrings.m
|
|
||||||
OBJS=$(SRCS:.m=.o)
|
|
||||||
|
|
||||||
teststrings: $(OBJS)
|
|
||||||
$(CC) -o $@ $< $(GNUSTEP_LIBRARIES_FLAGS) -lgnustep-base -L../../SoObjects/SOGo/SOGo.framework -lSOGo -lobjc
|
|
||||||
|
|
||||||
include $(GNUSTEP_MAKEFILES)/common.make
|
include $(GNUSTEP_MAKEFILES)/common.make
|
||||||
|
|
||||||
all: $(PROGRAM)
|
TOOL_NAME = teststrings
|
||||||
|
teststrings_OBJC_FILES += \
|
||||||
|
teststrings.m
|
||||||
|
|
||||||
clean:
|
-include GNUmakefile.preamble
|
||||||
rm -f $(PROGRAM) $(OBJS) *~
|
include $(GNUSTEP_MAKEFILES)/tool.make
|
||||||
|
|
||||||
.m.o:
|
|
||||||
$(CC) -o $@ -c $(GNUSTEP_HEADERS_FLAGS) $(AUXILIARY_OBJCFLAGS) $(OBJCFLAGS) $(CPPFLAGS) -I../../SoObjects $<
|
|
||||||
|
|
||||||
.SUFFIXES: .m .o
|
|
||||||
|
|
|
@ -5,12 +5,12 @@ RC=0
|
||||||
|
|
||||||
if [ ! -f teststrings ]
|
if [ ! -f teststrings ]
|
||||||
then
|
then
|
||||||
make teststrings
|
make
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for stringfile in ${TOPDIR}/*/*/*.lproj/Localizable.strings
|
for stringfile in ${TOPDIR}/*/*/*.lproj/Localizable.strings
|
||||||
do
|
do
|
||||||
./teststrings "$stringfile" > /dev/null
|
./obj/teststrings "$stringfile" > /dev/null
|
||||||
code=$?
|
code=$?
|
||||||
if test $code -eq 0;
|
if test $code -eq 0;
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in New Issue