Пример #1
0
bool Builder::BuildCoreLib(void)
{
    if (QFileInfo(coreLib).exists()) {
        return true;
    }

    map <QString, BoardDef>::const_iterator board = config.boards.find(project->boardName);
    map <QString, BuildDef>::const_iterator bld = config.builds.find(board->second.build_core);

    if (bld == config.builds.end()) {
        msg.Add("Error getting build configuration for board " + project->boardName, mtError);
        return false;
    }

    //buildType = 1;
    progress->SetPhase(BuildWindowTypes::linkingCore);
    int oldPercent = GetPercentage();
    SetPercentage(0);

    QString linkerPath = config.avrPath + "/avr-ar";

    msg.AddOutput("Linking core lib for board :" + project->boardName, false);

    QStringList coreFiles = bld->second.coreLibs.split(";");
    qDebug() << "Core Libs:" << bld->second.coreLibs;
    bool ok = true;

    for (int i=0; i < coreFiles.size(); i++) {
        coreFiles[i] = coreFiles[i].trimmed();
        if (coreFiles[i] == "") {
            continue;
        }
        QString inputFile = config.DecodeMacros(coreFiles.at(i), project);

        if (GetCancel()) {
            msg.Add("Build cancelled by the user!", mtRegular);
            ok = false;
            break;
        }
        ok = ok && CompileFile (inputFile, false, false);//, true);
        if (ok) {
            QString outputFile = MangleFileName(inputFile);
            QStringList arguments;
            arguments << "rcs" << coreLib;
            arguments << outputFile;
            msg.buildStage = 2;
            ok = launcher->RunCommand(linkerPath, arguments);
        }
        SetPercentage(100 * i / coreFiles.size());
    }

    SetPercentage(oldPercent);
    progress->SetPhase(BuildWindowTypes::compiling);
    //buildType = 0;
    return ok;
}
void AColorDialogForm::ConnectEvent()
{
	EVENT_CONNECT(GetButtonsPanel(),OnMouseDown,TitleBackDoMouseDown);
	EVENT_CONNECT(GetButtonsPanel(),OnMouseMove,TitleBackDoMouseMove);
	EVENT_CONNECT(GetOK(),OnClick,OnOKClick);
	EVENT_CONNECT(GetCancel(),OnClick,OnCancelClick);
	EVENT_CONNECT(GetColorSelector(),OnPaint,OnColorSelectorPaint);
	EVENT_CONNECT(GetColorSelector(),OnMouseDown,OnColorSelectorMouseDown);
	EVENT_CONNECT(GetSLSelector(),OnPaint,OnSLPaint);
	EVENT_CONNECT(GetSLSelector(),OnMouseDown,OnSLMouseDown);
	EVENT_CONNECT(GetColorSelector(),OnScroll,OnColorScroll);
	EVENT_CONNECT(GetSLSelector(),OnMouseMove,OnSLMouseMove);
}
Пример #3
0
//-----------------------------------------------------------------------------
int Builder::Build(bool upload)
{
    config.avrPath = config.arduinoInstall + "/hardware/tools/avr/bin";
    msg.ClearOutput();
    msg.ClearBuildMessages();

    progress = new BuildWindow((QWidget *)(this->parent())); //"Task in progress...", "Cancel", 0, 100, (QWidget *)this->parent());
    progress->setWindowModality(Qt::WindowModal);
    progress->SetPhase(BuildWindowTypes::compiling);
    SetPercentage(0);
    progress->show();
    qApp->processEvents();
    running = true;

    project = workspace.GetCurrentProject();
    if (project == NULL) {
        return -1;
    }

    if (project->rebuild) {
        if (Clean()) {
            project->rebuild = false;
        }
    }

    map <QString, BoardDef>::const_iterator board = config.boards.find(project->boardName);
    if (board == config.boards.end()) {
        msg.Add("Could not find board configuration for project: " + project->name, mtError);
        return false;
    }

    // Create the build directory
    buildPath = config.workspace + "/" + project->name + "/build"; //QDir().tempPath() + "/mariamole/build/" + project->name;
    QDir().mkpath(buildPath);

    // Get core lib filename
    coreLib = buildPath + "/arduino_core_" + board->second.build_variant+".a";

    msg.ClearBuildInfo();

    msg.AddOutput("Detecting undeclared functions in main project file: " + project->name + ".cpp...", false);

    if (config.useAutoGeneratedFile) {
        ImportDeclarations();
    }
    bool ok = true;
    for (unsigned int i=0; i < project->files.size(); i++) {
        QString ext = QFileInfo(project->files.at(i).name).suffix().toUpper();
        if ((ext == "CPP") || (ext == "C")) {
            ok = ok & Compile(i);
            if (GetCancel()) {
                msg.Add("Build cancelled by the user!", mtRegular);
                ok = false;
                break;
            }
            SetPercentage(40 * i / project->files.size());
            //SleepEx(1500, true);
        }
    }

    //QThread::sleep(5);

    if (GetCancel()) {
        msg.Add("Build cancelled by the user!", mtRegular);
        ok = false;
    }

    if (ok) {
        ok = Link();
        if (ok) {
            msg.Add("Project " + project->name + " successfully built!", mtSuccess);
            GetBinarySize();
        } else {
            msg.Add("Error linking project " + project->name, mtError);
        }
    } else {
        msg.Add("Error while building project " + project->name + ".", mtError);
    }

    if(ok && upload) {
        ok = Upload();
        if (ok) {
            msg.Add("Project " + project->name + " binaries successfully uploaded to board", mtSuccess);
        } else {
            if (project->programmer != "") {
                msg.Add("Error while uploading program to " + project->boardName
                        + " using programmer " +  project->programmer + ". Please check the output window for details", mtError);
            } else {
                msg.Add("Error while uploading program to " + project->boardName
                        + " via USB cable. Please check the output window for details", mtError);
            }
        }

        if (GetCancel()) {
            msg.Add("Build cancelled by the user!", mtRegular);
            ok = false;
        }
    }
    if (ok) {
        lastBuildStatus = 2;
    } else {
        lastBuildStatus = 1;
    }

    running = false;
    progress->hide();
    delete progress;
    return ok;
}
Пример #4
0
QString Builder::GetLeonardoSerialPort(QString defaultPort)
{
    QStringList before, after;
    QSerialPortInfo serialList;
    QSerialPort port;

    SetPercentage(100);

    for (int i=0; i < serialList.availablePorts().count(); i++) {
        before.append(serialList.availablePorts().at(i).portName());
    }

    /*#ifdef Q_OS_WIN
       	PrepareSerialPort(project->serialPort, "1200");
    #endif*/
    port.setPortName(project->serialPort);
    port.setFlowControl(QSerialPort::NoFlowControl);
    port.setBaudRate(QSerialPort::Baud1200);
    port.setParity(QSerialPort::NoParity);
    port.setStopBits(QSerialPort::OneStop);
    port.setDataBits(QSerialPort::Data8);
    bool open = port.open (QIODevice::ReadWrite);
//#endif
    if (open == false) {
        progress->SetPhase(BuildWindowTypes::detectingLeonardo2);
        msg.Add("Could not reset board automatically via serial port " + project->serialPort + "! Press RESET button at your board NOW!", mtWarning);
    }
    /*char buffer[20] = "Hello!\r\n";
    port.write ((const char *)buffer);*/
    //QThread::msleep(10);
    port.close();

    QThread::msleep(100);

    int counter = 50;
    after.clear();
    bool warningMessage = true;
    while (counter > 0) {
        QSerialPortInfo newSerialList;
        for (int i=0; i < newSerialList.availablePorts().count(); i++) {
            after.append(newSerialList.availablePorts().at(i).portName());
        }

        for (int i=0; i < after.count(); i++) {
            if (before.indexOf(after.at(i)) < 0) {
                return after.at(i);
            }
        }
        QThread::msleep(120);
        counter--;

        if ( (progress->value() > 40) && warningMessage) {
            warningMessage = false;
            progress->SetPhase(BuildWindowTypes::detectingLeonardo2);
            msg.Add("Could not reset board automatically via serial port " + project->serialPort + "! Press RESET button at your board NOW!", mtWarning);
        }

        SetPercentage(100 - counter * 2);
        if (GetCancel()) {
            counter = 0;
            break;
        }
    }

    msg.Add("Could not detect Leonardo serial port for programming. Please try pressing the RESET button at your board when you see the dialog message 'Detecting Leonardo port...'!", mtError);
    return "";
}