]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tools/tinyos/ncc/ncc.in
Allow custom platform families
[tinyos-2.x.git] / tools / tinyos / ncc / ncc.in
index 7ae3c0a21309b8790bd5ab106d054955ffe8de51..2f61d921400ce5f896b6b7aeb4f5d6b2b6e3db80 100644 (file)
@@ -14,15 +14,21 @@ $TOSDIR = "@TOSDIR@";
 $TOSDIR = $ENV{"TOSDIR"} if defined($ENV{"TOSDIR"});
 $nescc = "@nescc_prefix@/bin/nescc";
 $tossim = 0;
+$is_tos_1 = 0;
+$with_scheduler_flag = 1;
 
 # Support platform directory renaming for 2.x
 if (-d "$TOSDIR/platform") {
     $platform = "platform";
+    $is_tos_1 = 1;
 }
 else {
     $platform = "platforms";
 }
 
+my $exeflag=0;
+my $libs = "";
+
 # Have fun with the arguments
 
 for ($i = 0; $i <= $#ARGV; $i++) {
@@ -38,6 +44,10 @@ for ($i = 0; $i <= $#ARGV; $i++) {
            $TOSDIR = $1;
            $strip = 1;
        }
+       elsif (/^-tosscheduler=(.*)/) {
+           $scheduler = $1;
+           $strip = 1;
+       }
        elsif (/^-nostdinc$/) {
            $nostdinc = 1;
        }
@@ -72,10 +82,22 @@ for ($i = 0; $i <= $#ARGV; $i++) {
            $strip = 1;
            push @includes, $file;
        }
+       elsif (/^-fnesc-cfile=(.*)/){
+           $appfilename=$1;
+       }
+       elsif (/^-o$/){
+           $exeflag=1;
+       }
+        elsif (/^-l/) {
+            $libs = $libs . " " . $_;
+        } 
        elsif (/^--version$/) {
            $print_version = 1;
        }
-    } 
+    } elsif ($exeflag) {
+       $exefilename =$_;
+       $exeflag=0;
+    }
 
     push @new_args, $_ if !$strip;
 }
@@ -113,6 +135,10 @@ if (!defined $target) {
     }
 }
 
+if (!defined $scheduler && !$is_tos_1) {
+       $scheduler = "TinySchedulerC,TinySchedulerC.TaskBasic,TaskBasic,TaskBasic,runTask,postTask";
+}
+
 if ($print_target) {
     print $target, "\n";
     exit 0;
@@ -122,6 +148,15 @@ if ($print_target) {
 foreach $dir (@includes) {
     if ($dir =~ m!/$target/?$! && -f "$dir/.platform") {
        $platform_def = "$dir/.platform";
+       # Check to see if the platform is a member of a family
+       if (-f "$dir/.family") {
+           $family_def = "$dir/.family";
+       }
+       else {
+           if (-f "$dir/../.family") {
+               $family_def = "$dir/../.family";
+           }
+       }
        last;
     }
 }
@@ -202,6 +237,9 @@ do $family_def if -f $family_def;
 unshift @new_args, "-DPLATFORM_\U$target";
 
 push @new_args, @opts;
+if(!$is_tos_1) {
+  unshift @new_args, "-fnesc-scheduler=$scheduler";
+}
 
 # old nesdoc: set the default topdir based on TOSDIR
 my ($tosparent) = ($TOSDIR =~ m!^(.*)/.*?$!);
@@ -235,7 +273,6 @@ foreach $idir (@includes) {
 
 
 print STDERR join(' ', @new_args), "\n" if $verbose;
-
 exec @new_args;
 print STDERR "Couldn't execute nescc\n";
 exit 2;
@@ -262,6 +299,7 @@ sub idir_subst {
        $rep = "%" if $char eq "%";
        $rep = $TOSDIR if $char eq "T";
        $rep = $target if $char eq "p";
+       $rep = $platform_dir if $char eq "P";
        &fail("unknown include-path substitution %" . $char) if !$rep;
        substr($idir, $idx, 2) = $rep;
        $idx += length $rep;