Esempio n. 1
0
bool MComponent::addFromFilename( WFileName& filename, WString& err )
{
    if( filename.isMask() ) {
        return( addFromMask( filename, err ) );
    }

    MRule* rule = _config->findMatchingRule( filename, _target->rule(), _mask );
    if( rule ) {
        if( rule == _config->nilRule() ) {
            unsigned    cnt;

            cnt = _items.count();
            for( ; cnt > 0; cnt-- ) {
                if( *(MItem *)_items[cnt - 1] == filename ) break;
            }
            if( cnt == 0 ) {
                MItem* item = new MItem( filename, this, rule );
                newItem( item );
            } else {
                return( false );
            }
        } else {
            MItem* item = new MItem( filename, this, rule );
            MComponent* comp = NULL;
            MItem* m = _project->findSameResult( item, &comp );
            if( !m ) {
                newItem( item );
            } else {
                delete item;
                if( comp != this ) {
                    err.printf( "Conflicting file '%s' found in target '%s'",
                        (const char*)*m, (const char*)*comp->target() );
                    return( false );
                }
            }
        }
        return( true );
    }
    return( false );
}
Esempio n. 2
0
void VCompDialog::browseButton( WWindow* )
{
    WWindow *old = WWindow::hasFocus();
//    NYI - let the user enter lists of targets to add
//    WFileNameList     fn_list;
//    if( _browseDialog->getOpenFileName( fn_list, "", "Enter target filename", WFOpenNew ) ) {
//      WFileName fn( fn_list.cString( 0, -1 ) );
    WFileName fn;
    fn = _browseDialog->getOpenFileName( NULL, "Enter target filename",
                                         WFOpenNew );
        if( fn.size() > 0 ) {
            WFileName cwd; cwd.getCWD( TRUE );
            int len = cwd.size();
            if( len > 0 ) {
                if( strnicmp( cwd, fn, len ) == 0 ) {
                    fn.chop( len );
                }
            }
            _eName->setText( fn );
        }
    old->setFocus();
}
Esempio n. 3
0
void MComponent::writeRule( ContFile& mak )
{
    if( !_target->ismakeable() ) return;

    WFileName tgt;
    _target->absName( tgt );

    for( int i=0; i<_workFiles.count(); i++ ) {
        MWorkFile* w = (MWorkFile*)_workFiles[i];
        MItem* m = w->item();
        if( !m->isMask() && m->ismakeable() ) {
            WFileName r;
            m->absResult( r );
            if( r.needQuotes() ) {
                r.addQuotes();
            }
            if( w->needQuotes() ) {
                w->addQuotes();
            }
            mak.printf( "%s : %s", (const char*)r, (const char*)*w );
            r.removeQuotes();
            w->removeQuotes();
            if( _autodepend ) mak.puts( " .AUTODEPEND" );
            mak.puts( "\n" );
            WString c;
            w->makeCommand( c, NULL );
            writeTargetCD( mak );
            mak.puts( c );
            mak.puts( "\n" );
            w->puts( r );       //setup for later use by target-maker
        }
    }
    if( tgt.needQuotes() ) {
        tgt.addQuotes();
    }
    mak.printf( "%s :", (const char*)tgt );
    tgt.removeQuotes();
    int jcount = _workFiles.count();
    for( int j=0; j<jcount; j++ ) {
        MWorkFile* w = (MWorkFile*)_workFiles[j];
        if( !w->isMask() ) {
            if( w->needQuotes() ) {
                w->addQuotes();
            }
            mak.printf( " %s", (const char*)*w );
            w->removeQuotes();
            w->relativeTo( _filename );
        }
    }
    if( _autodepend ) mak.puts( " .AUTODEPEND" );
    mak.puts( "\n" );
    bool browseable = writeCBR();
    if( _target->ismakeable() ) {
        WFileName fn; _target->absName( fn );
        MWorkFile w( fn, _mode, _target, this );
        WString c;
        if( browseable && _config->browseMerge().size() > 0 ) {
            MCommand cmd;
            cmd.concatf( " %s @$*.cbr", (const char*)_config->browseMerge() );
            expand( c, cmd );
        }
        expand( c, _before );
        w.makeCommand( c, &_workFiles );
        expand( c, _after );
        writeTargetCD( mak );
        mak.puts( c );
        mak.puts( "\n" );
    }
}
Esempio n. 4
0
void EdModule::addButton( WWindow * )
//-----------------------------------
{
    int             i;
    int             fileIdx;
    WFileNameList   files;
    WFileDialog     fileSelect( this, EdModuleFilter );
    bool            result;
    WFileName *     file;
    bool            found;

    result = fileSelect.getOpenFileName( files, NULL,
                                        "Select Module File(s)",
                                        WFOpenNew );

    if( result ) {
        for( fileIdx = 0; fileIdx < files.count(); fileIdx += 1 ) {
            file = new WFileName( files.cStringAt( fileIdx ) );

            if( *( file->ext() ) == '\0' ) {
                file->setExt("mbr");
            }
            file->absoluteTo();
            file->toLower();

            found = false;

            if( !file->attribs() ) {
                errMessage( "Module %s%s does not exist", file->fName(), file->ext() );
                found = true;
            }

            for( i = 0; i < _moduleBox->count() && !found; i += 1 ) {
                WString * str = (*_moduleBox)[ i ]->_str;

                if( *str == *file ) {
                    errMessage( "Module %s%s already in project", file->fName(), file->ext() );
                    found = true;
                }
            }

            for( int i = 0; i < _removedModuleItems->entries() && !found; i++ ) {
                WString * str = (*_removedModuleItems)[ i ]->_str;

                if( *str == *file ) {
                    ModuleItem * item = _removedModuleItems->removeAt( i ) ;
                    item->_enabled = true;
                    _moduleBox->insert( item );

                    found = true;
                }
            }

            if( !found ) {
                ModuleItem * item = new ModuleItem( file, true );
                _moduleBox->insert( item );
            }

        } /* for( i < files.count() ) */

    } /* if( result ) */
    _moduleBox->reset();

}
Esempio n. 5
0
void MItem::absName( WFileName& fn )
{
    fn.puts( *this );
    fn.absoluteTo( _component->filename() );
}