Changeset 205

Show
Ignore:
Timestamp:
12/26/06 14:42:18 (2 years ago)
Author:
Ant
Message:

Project dependences

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/leds/Project.d

    r204 r205  
    1818 
    1919module leds.Project; 
     20 
     21//debug = dependences; 
    2022 
    2123//version(Win32) 
     
    526528        version(compd) 
    527529        { 
     530            buildDependences(target.dependences); 
    528531            new TargetBuilder_compd(this, target); 
    529532        } 
     
    847850} // end of compd version? 
    848851     
    849   static class TargetBuilder : AbstractTargetBuilder 
    850   { 
    851  
    852       this(Project project, ProjectTarget target) 
    853       { 
    854           super(project, target); 
    855  
    856           buildTarget(); 
    857       } 
    858        
    859       ~this() 
    860       { 
    861           writefln("closing down target builder"); 
    862       } 
    863        
    864       /** 
    865        * build a target 
    866        */ 
    867       private void buildTarget() 
    868       { 
    869           if ( target !is null ) 
    870           { 
    871               project.lastBuildTarget = target; 
    872               project.workspace.setLastBuildProject(project); 
    873                
    874               String compCom = target.getCompilerCommand(); 
    875    
    876               buildConsole.exec( 
    877                   target.getBaseDirSrc(),  
    878                   compCom, 
    879                   true,   //   async 
    880                   &linkTarget, 
    881                   &compOutputReader, 
    882                   &compErrorReader 
    883               ); 
    884           } 
    885       } 
    886        
    887       /** 
    888        * links the target. 
    889        * This is called from the Compile spawned command. 
    890        * Params: 
    891        *      spawn =      
    892        * Returns: true 
    893        */ 
    894       bool linkTarget(Spawn spawn) 
    895       { 
    896           gdkThreadsEnter(); 
    897            
    898           if ( spawn.exitStatus == 0 ) 
    899           { 
    900               String linkCom = target.getLinkCommand(); 
    901 //                if ( Leds.leds.getPropValue("popupBuildOutput",true) ) 
    902 //                { 
    903 //                    compilerBox.addLinkerCommand(linkCom); 
    904 //                } 
    905               Path.chdir(project.getBaseDir()); 
    906               buildConsole.exec(target.getBaseDirObj(), linkCom, 
    907                   true, 
    908                   &endLink, 
    909                   &linkOutputReader, 
    910                   &linkErrorReader 
    911                   ); 
    912               //buildConsole.exec(new String("."), linkCom, true); 
    913           } 
    914           //if ( lastP_OpenExitStatus != 0 ) 
    915           { 
    916               project.workspace.refreshDockableLabel(buildConsole); 
    917               project.workspace.getProjectView().setProjectStatus(project); 
    918           } 
    919            
    920           Gdk.flush(); 
    921           gdkThreadsLeave(); 
    922           return true; 
    923       } 
    924  
    925       bool endLink(Spawn spawn) 
    926       { 
    927           if ( target.isNativeTargetPlatform()  
    928               && target.crossWindows 
    929               ) 
    930           { 
    931               target.setTargetPlatform(ProjectTarget.Platform.WINDOWS32); 
    932               buildTarget(); 
    933           } 
    934           else 
    935           { 
    936               gdkThreadsEnter(); 
    937               project.compileEnd(); 
    938               Gdk.flush(); 
    939               gdkThreadsLeave(); 
    940           } 
    941           return true; // consume 
    942       } 
    943  
    944   } 
     852//    static class TargetBuilder : AbstractTargetBuilder 
     853//    { 
     854// 
     855//        this(Project project, ProjectTarget target) 
     856//        { 
     857//            super(project, target); 
     858// 
     859//            buildTarget(); 
     860//        } 
     861//         
     862//        ~this() 
     863//        { 
     864//            writefln("closing down target builder"); 
     865//        } 
     866//         
     867//        /** 
     868//         * build a target 
     869//         */ 
     870//        private void buildTarget() 
     871//        { 
     872//            if ( target !is null ) 
     873//            { 
     874//                project.lastBuildTarget = target; 
     875//                project.workspace.setLastBuildProject(project); 
     876//                 
     877//                String compCom = target.getCompilerCommand(); 
     878//     
     879//                buildConsole.exec( 
     880//                    target.getBaseDirSrc(),  
     881//                    compCom, 
     882//                    true,   //   async 
     883//                    &linkTarget, 
     884//                    &compOutputReader, 
     885//                    &compErrorReader 
     886//                ); 
     887//            } 
     888//        } 
     889//         
     890//        /** 
     891//         * links the target. 
     892//         * This is called from the Compile spawned command. 
     893//         * Params: 
     894//         *      spawn =      
     895//         * Returns: true 
     896//         */ 
     897//        bool linkTarget(Spawn spawn) 
     898//        { 
     899//            gdkThreadsEnter(); 
     900//             
     901//            if ( spawn.exitStatus == 0 ) 
     902//            { 
     903//                String linkCom = target.getLinkCommand(); 
     904////              if ( Leds.leds.getPropValue("popupBuildOutput",true) ) 
     905////              { 
     906////                  compilerBox.addLinkerCommand(linkCom); 
     907////              } 
     908//                Path.chdir(project.getBaseDir()); 
     909//                buildConsole.exec(target.getBaseDirObj(), linkCom, 
     910//                    true, 
     911//                    &endLink, 
     912//                    &linkOutputReader, 
     913//                    &linkErrorReader 
     914//                    ); 
     915//                //buildConsole.exec(new String("."), linkCom, true); 
     916//            } 
     917//            //if ( lastP_OpenExitStatus != 0 ) 
     918//            { 
     919//                project.workspace.refreshDockableLabel(buildConsole); 
     920//                project.workspace.getProjectView().setProjectStatus(project); 
     921//            } 
     922//             
     923//            Gdk.flush(); 
     924//            gdkThreadsLeave(); 
     925//            return true; 
     926//        } 
     927// 
     928//        bool endLink(Spawn spawn) 
     929//        { 
     930//            if ( target.isNativeTargetPlatform()  
     931//                && target.crossWindows 
     932//                ) 
     933//            { 
     934//                target.setTargetPlatform(ProjectTarget.Platform.WINDOWS32); 
     935//                buildTarget(); 
     936//            } 
     937//            else 
     938//            { 
     939//                gdkThreadsEnter(); 
     940//                project.compileEnd(); 
     941//                Gdk.flush(); 
     942//                gdkThreadsLeave(); 
     943//            } 
     944//            return true; // consume 
     945//        } 
     946// 
     947//    } 
    945948 
    946949    /** 
     
    11681171    } 
    11691172     
    1170     private bool buildDependences() 
    1171     { 
    1172         String[] depend = getPropValue("dependencies","").split(); 
     1173    private bool buildDependences(String[] dependences) 
     1174    { 
     1175        //String[] depend = getPropValue("dependencies","").split(); 
     1176        writefln("Project.buildDependences: depend = %s", dependences); 
     1177        debug(dependences) 
     1178        { 
     1179            foreach ( String str ; dependences) 
     1180            { 
     1181                writefln("Project.buildDependences: %s", str); 
     1182            } 
     1183        } 
    11731184        bit failed = false; 
    1174         int i = 0; 
    1175         while ( !failed && i<depend.length ) 
    1176         { 
    1177             Project project = workspace.getProjectView().getProject(depend[i]); 
    1178             if ( project !is null ) 
    1179             { 
    1180                 if ( project.getNeedsRecompile() ) 
     1185 
     1186        foreach ( String depend ; dependences ) 
     1187        { 
     1188            String[] dependSplit = depend.split("."); 
     1189            if ( dependSplit.length == 2 ) 
     1190            { 
     1191                debug(dependences)writefln("- Project.build dependSplit = %s", dependSplit); 
     1192 
     1193                Project project = workspace.getProjectView().getProject(dependSplit[0]); 
     1194                ProjectTarget target = project.getCurrTarget(dependSplit[1]); 
     1195                 
     1196                if ( project !is null  
     1197                    && target !is null 
     1198                    ) 
    11811199                { 
    1182                     project.build(true); 
    1183                     failed = project.getCompileErrors(); 
    1184                     if ( failed
     1200                    debug(dependences)writefln("- Project.build project = %s", project); 
     1201                    debug(dependences)writefln("- Project.build target = %s", target); 
     1202                    if ( project.getNeedsRecompile()
    11851203                    { 
    1186                         failedDependency = project.getName(); 
     1204                        project.build(true, target); 
     1205                        failed = project.getCompileErrors(); 
     1206                        if ( failed ) 
     1207                        { 
     1208                            failedDependency = project.getName(); 
     1209                            break; 
     1210                        } 
    11871211                    } 
    11881212                } 
    11891213            } 
    1190             i++; 
    11911214        } 
    11921215        return !failed; 
     
    11961219     * executes the build command for this project 
    11971220     */ 
    1198     public void build(bit newConsole) 
    1199     { 
    1200          
     1221    public void build(bit newConsole, ProjectTarget target=null) 
     1222    { 
     1223         
     1224        if ( target is null ) 
     1225        { 
     1226            target = getLastBuildTarget(); 
     1227        } 
    12011228        writefln("- Project.build"); 
    1202         //if ( getCurrTarget(props.get("lastTarget","")) !is null ) 
    1203         //{ 
    1204         //  printf("compiler command = %.*s\n", currTarget.getCompilerCommand()); 
    1205         //  printf("link command = %.*s\n", currTarget.getLinkCommand()); 
    1206         //  currTarget.generateMakefile(); 
    1207         //} 
    1208          
    1209         // first build dependencies 
    1210         bool failed = buildDependences(); 
    1211          
    1212         if ( !failed ) 
    1213         { 
    1214             String buildCommand = getPropValue("makeCommand",""); 
    1215             // \todo how do we clear an associative array? 
    1216             ProjectError[][String] t; 
    1217             projectErrors = t; 
    1218              
    1219             baseSrcPath = getSrcPath(); 
    1220              
    1221             if ( buildCommand.length > 0 ) 
    1222             { 
    1223                 clearFileViews(); 
    1224                 setCompiling(true); 
    1225                 String grabOutput = new String(); 
    1226                 String grabError = new String(); 
    1227                 int exitStatus; 
    1228                 //workspace.getErrorPane().drawNow(); 
    1229 //              if ( Leds.leds.getPropValue("popupBuildOutput",true) ) 
     1229        writefln("- Project.build target = %s", target); 
     1230         
     1231        new TargetBuilder_compd(this, target); 
     1232         
     1233//      //if ( getCurrTarget(props.get("lastTarget","")) !is null ) 
     1234//      //{ 
     1235//      //  printf("compiler command = %.*s\n", currTarget.getCompilerCommand()); 
     1236//      //  printf("link command = %.*s\n", currTarget.getLinkCommand()); 
     1237//      //  currTarget.generateMakefile(); 
     1238//      //} 
     1239//       
     1240//      // first build dependencies 
     1241//      bool failed = buildDependences(target.dependences); 
     1242//       
     1243//      if ( !failed ) 
     1244//      { 
     1245//          String buildCommand = getPropValue("makeCommand",""); 
     1246//          // \todo how do we clear an associative array? 
     1247//          ProjectError[][String] t; 
     1248//          projectErrors = t; 
     1249//           
     1250//          baseSrcPath = getSrcPath(); 
     1251//           
     1252//          if ( buildCommand.length > 0 ) 
     1253//          { 
     1254//              clearFileViews(); 
     1255//              setCompiling(true); 
     1256//              String grabOutput = new String(); 
     1257//              String grabError = new String(); 
     1258//              int exitStatus; 
     1259//              //workspace.getErrorPane().drawNow(); 
     1260////                if ( Leds.leds.getPropValue("popupBuildOutput",true) ) 
     1261////                { 
     1262////                    compilerWindow = workspace.getCompilerWindow(); 
     1263////                    CompilerBox compilerBox = compilerWindow.getCompilerBox(); 
     1264////                    compilerBox.clearAll(); 
     1265////                    compilerBox.addCompilerCommand(buildCommand); 
     1266////                } 
     1267//              if ( newConsole ) 
    12301268//              { 
    1231 //                  compilerWindow = workspace.getCompilerWindow(); 
    1232 //                  CompilerBox compilerBox = compilerWindow.getCompilerBox(); 
    1233 //                  compilerBox.clearAll(); 
    1234 //                  compilerBox.addCompilerCommand(buildCommand); 
     1269//                  BuildConsole buildConsole = new BuildConsole(workspace,this, buildCommand); 
     1270//                  workspace.addConsole(buildConsole); 
     1271//                  buildConsole.exec( 
     1272//                      getBaseDir(), 
     1273//                      buildCommand 
     1274//                      //grabOutput, grabError, exitStatus, null 
     1275//                      ); 
    12351276//              } 
    1236                 if ( newConsole ) 
    1237                 { 
    1238                     BuildConsole buildConsole = new BuildConsole(workspace,this, buildCommand); 
    1239                     workspace.addConsole(buildConsole); 
    1240                     buildConsole.exec( 
    1241                         getBaseDir(), 
    1242                         buildCommand 
    1243                         //grabOutput, grabError, exitStatus, null 
    1244                         ); 
    1245                 } 
    1246                 else 
    1247                 { 
    1248                     workspace.getSystemConsole().exec( 
    1249                         getBaseDir(), 
    1250                         buildCommand 
    1251                         //grabOutput, grabError, exitStatus, null 
    1252                         ); 
    1253                 } 
    1254  
    1255                 //if ( exitStatus != 0 ) 
    1256                 { 
    1257                     processBuildOutput(grabOutput, grabError); 
    1258                 } 
    1259             } 
    1260         } 
    1261         workspace.getErrorPane().refresh(); 
     1277//              else 
     1278//              { 
     1279//                  workspace.getSystemConsole().exec( 
     1280//                      getBaseDir(), 
     1281//                      buildCommand 
     1282//                      //grabOutput, grabError, exitStatus, null 
     1283//                      ); 
     1284//              } 
     1285// 
     1286//              //if ( exitStatus != 0 ) 
     1287//              { 
     1288//                  processBuildOutput(grabOutput, grabError); 
     1289//              } 
     1290//          } 
     1291//      } 
     1292//      workspace.getErrorPane().refresh(); 
    12621293    } 
    12631294 
  • trunk/src/leds/SystemConsole.d

    r204 r205  
    359359    { 
    360360        setExecuting(true); 
     361        //Gdk.flush(); 
    361362        //writefln("\n> ("~Path.getcwd()~") Executing >(befor)>\n"~command~"\n"); 
    362363        String oldDir = Path.getcwd();