Permalink
Browse files

Add -f to specify a device family. Remove WaxSim specific code.

  • Loading branch information...
1 parent 0ec2f09 commit a13bcd053e0b95b4e4486fe2c07ceeba8dc8dd63 Rob Holland committed Jun 24, 2010
Showing with 23 additions and 29 deletions.
  1. +1 −0 .gitignore
  2. +3 −2 Simulator.h
  3. +9 −2 Simulator.m
  4. +10 −25 WaxSim.m
View
@@ -0,0 +1 @@
+build
View
@@ -13,7 +13,8 @@
@interface Simulator : NSObject <DTiPhoneSimulatorSessionDelegate> {
NSString *_appPath;
- DTiPhoneSimulatorSystemRoot *_sdk;
+ DTiPhoneSimulatorSystemRoot *_sdk;
+ NSNumber *_family;
DTiPhoneSimulatorSession* _session;
NSArray *_args;
}
@@ -22,7 +23,7 @@
+ (NSArray *)availableSDKs;
-- (id)initWithAppPath:(NSString *)appPath sdk:(NSString *)sdk args:(NSArray *)args;
+- (id)initWithAppPath:(NSString *)appPath sdk:(NSString *)sdk family:(NSString *)family args:(NSArray *)args;
- (int)launch;
- (void)end;
View
@@ -18,7 +18,7 @@ @implementation Simulator
@synthesize session=_session;
-- (id)initWithAppPath:(NSString *)appPath sdk:(NSString *)sdk args:(NSArray *)args {
+- (id)initWithAppPath:(NSString *)appPath sdk:(NSString *)sdk family:(NSString *)family args:(NSArray *)args {
self = [super init];
NSFileManager *fileManager = [NSFileManager defaultManager];
@@ -48,6 +48,12 @@ - (id)initWithAppPath:(NSString *)appPath sdk:(NSString *)sdk args:(NSArray *)ar
exit(EXIT_FAILURE);
}
+ if ([family isEqualToString: @"ipad"]) {
+ _family = [NSNumber numberWithInt: 2];
+ } else {
+ _family = [NSNumber numberWithInt: 1];
+ }
+
_args = [args retain];
return self;
@@ -76,10 +82,11 @@ - (int)launch {
DTiPhoneSimulatorSessionConfig *config = [[DTiPhoneSimulatorSessionConfig alloc] init];
[config setApplicationToSimulateOnStart:appSpec];
[config setSimulatedSystemRoot:sdkRoot];
+ [config setSimulatedDeviceFamily:_family];
[config setSimulatedApplicationShouldWaitForDebugger:NO];
[config setSimulatedApplicationLaunchArgs:_args];
[config setSimulatedApplicationLaunchEnvironment:[[NSProcessInfo processInfo] environment]];
- [config setLocalizedClientName:@"WaxSim"];
+ [config setLocalizedClientName:@"iCuke"];
// Make the simulator output to the current STDOUT & STDERR
char path[MAXPATHLEN];
View
@@ -6,23 +6,26 @@
static BOOL gReset = false;
void printUsage();
-void simulate(NSString *sdk, NSString *appPath, NSMutableArray *additionalArgs);
+void simulate(NSString *sdk, NSString *family, NSString *appPath, NSMutableArray *additionalArgs);
void resetSignal(int sig);
int main(int argc, char *argv[]) {
signal(SIGQUIT, resetSignal);
int c;
char *sdk = nil;
+ char *family = nil;
char *appPath = nil;
- char *buildPath = nil;
NSMutableArray *additionalArgs = [NSMutableArray array];
while ((c = getopt(argc, argv, "s:ah")) != -1) {
switch(c) {
case 's':
sdk = optarg;
break;
+ case 'f':
+ family = optarg;
+ break;
case 'a':
fprintf(stdout, "Available SDK Versions.\n", optopt);
for (NSString *sdkVersion in [Simulator availableSDKs]) {
@@ -33,7 +36,7 @@ int main(int argc, char *argv[]) {
printUsage();
return 1;
case '?':
- if (optopt == 's') {
+ if (optopt == 's' || optopt == 'f') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
printUsage();
}
@@ -52,10 +55,6 @@ int main(int argc, char *argv[]) {
if (argc > optind) {
appPath = argv[optind++];
- if (argc > optind) {
- buildPath = argv[optind++];
- }
-
// Additional args are sent to app
for (int i = optind; i < argc; i++) {
[additionalArgs addObject:[NSString stringWithUTF8String:argv[i]]];
@@ -69,35 +68,21 @@ int main(int argc, char *argv[]) {
NSString *sdkString = sdk ? [NSString stringWithUTF8String:sdk] : nil;
+ NSString *familyString = family ? [NSString stringWithUTF8String:family] : nil;
NSString *appPathString = [NSString stringWithUTF8String:appPath];
- NSString *buildPathString = buildPath ? [NSString stringWithUTF8String:buildPath] : nil;
while (true) {
gReset = false;
- // Move scripts over!
- if (buildPathString) {
- NSFileManager *fm = [NSFileManager defaultManager];
- NSString *appDataPath = [appPathString stringByAppendingPathComponent:@"data"];
- NSString *buildDataPath = [buildPathString stringByAppendingPathComponent:@"data"];
- NSError *error = nil;
- [fm removeItemAtPath:appDataPath error:&error];
- [fm copyItemAtPath:buildDataPath toPath:appDataPath error:&error];
- [fm copyItemAtPath:[buildPathString stringByAppendingPathComponent:@"wax/lib/wax-scripts"]
- toPath:[appDataPath stringByAppendingPathComponent:@"scripts/wax"]
- error:&error];
-
- }
-
- simulate(sdkString, appPathString, additionalArgs);
+ simulate(sdkString, familyString, appPathString, additionalArgs);
printf("\n\nREBOOT\n", appPath);
}
return 0;
}
-void simulate(NSString *sdk, NSString *appPath, NSMutableArray *additionalArgs) {
- Simulator *simulator = [[Simulator alloc] initWithAppPath:appPath sdk:sdk args:additionalArgs];
+void simulate(NSString *sdk, NSString *family, NSString *appPath, NSMutableArray *additionalArgs) {
+ Simulator *simulator = [[Simulator alloc] initWithAppPath:appPath sdk:sdk family:family args:additionalArgs];
[simulator launch];
while (!gReset && [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:-1]]) ;

0 comments on commit a13bcd0

Please sign in to comment.