Show
Ignore:
Timestamp:
08/09/08 21:44:20 (5 months ago)
Author:
liamstask
Message:

- a few tests for the Builder class: creating a Makefile properly and loading in the requisite libraries
- update the AinToServo? example's project file format

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • mcbuilder/trunk/src/Builder.cpp

    r797 r799  
    2323#include "ConsoleItem.h" 
    2424 
     25#define LIBRARIES_DIR "cores/makecontroller/libraries" 
     26 
    2527/* 
    2628  Builder takes a project and turns it into a binary executable. 
     
    2830  and Properties for this project. 
    2931*/ 
    30 Builder::Builder(MainWindow *mainWindow, ProjectInfo *projInfo, BuildLog *buildLog) : QProcess( 0 ) 
     32Builder::Builder( MainWindow *mainWindow, ProjectInfo *projInfo, BuildLog *buildLog ) : QProcess( 0 ) 
    3133{ 
    3234  this->mainWindow = mainWindow; 
    3335  this->projInfo = projInfo; 
    3436  this->buildLog = buildLog; 
     37   
    3538  connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(filterOutput())); 
    3639  connect(this, SIGNAL(readyReadStandardError()), this, SLOT(filterErrorOutput())); 
     
    5457  } 
    5558  currentProjectPath = projectName; 
    56   ensureBuildDirExists(currentProjectPath);  // make sure we have a build dir 
    5759  setWorkingDirectory(QDir(currentProjectPath).filePath("build")); 
    58   loadDependencies(currentProjectPath);      // this loads up the list of libraries this project depends on 
     60  loadDependencies(LIBRARIES_DIR, currentProjectPath);      // this loads up the list of libraries this project depends on 
    5961  createMakefile(currentProjectPath);        // create a Makefile for this project, given the dependencies 
    6062  createConfigFile(currentProjectPath);      // create a config file based on the Properties for this project 
     
    107109/* 
    108110  If there's no build directory within a project, create one. 
    109 */ 
    110 void Builder::ensureBuildDirExists(QString projPath) 
     111  Return the build dir's path. 
     112*/ 
     113QString Builder::ensureBuildDirExists(QString projPath) 
    111114{ 
    112115  QDir dir(projPath); 
    113116  if(!dir.exists("build")) 
    114117    dir.mkdir("build"); 
     118  return dir.filePath("build"); 
    115119} 
    116120 
     
    184188{ 
    185189  bool retval = true; 
    186   QDir buildDir(projectPath + "/build"); 
     190  QDir buildDir( ensureBuildDirExists(projectPath) ); 
    187191  QFile makefile(buildDir.filePath("Makefile")); 
    188192  if(makefile.open(QIODevice::WriteOnly | QFile::Text)) 
     
    250254           
    251255          // add in the directories for the required libraries 
    252           QDir libdir(QDir::current().filePath("cores/makecontroller/libraries")); 
     256          QDir libdir(QDir::current().filePath(LIBRARIES_DIR)); 
    253257          foreach(Library lib, libraries) 
    254258            tofile << "  -I" << filteredPath(libdir.filePath(lib.name)) << " \\" << endl; 
     
    484488      while(!outline.isNull()) 
    485489      { 
    486         qDebug("msg: %s", qPrintable(outline)); 
     490        //qDebug("msg: %s", qPrintable(outline)); 
    487491        QStringList sl = outline.split(" "); 
    488492        if(sl.first().endsWith("arm-elf-gcc") && sl.at(1) == "-c") 
     
    522526      while(!outline.isNull()) 
    523527      { 
    524         qDebug("err: %s", qPrintable(outline)); 
     528        //qDebug("err: %s", qPrintable(outline)); 
    525529        QString line = outline; 
    526530        outline = outstream.readLine(); 
     
    648652  Create a Library structure for each library and store it in our class member "libraries" 
    649653*/ 
    650 void Builder::loadDependencies(QString project) 
     654void Builder::loadDependencies(QString libsDir, QString project) 
    651655{ 
    652656  QDir projDir(project); 
    653657  QStringList srcFiles = projDir.entryList(QStringList() << "*.c" << "*.h"); 
    654   QDir libDir(QDir::current().filePath("cores/makecontroller/libraries")); 
     658  QDir libDir(QDir::current().filePath(libsDir)); 
    655659  QStringList libDirs = libDir.entryList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot); 
    656660