bool cbMGMakefile::SaveAllRules( wxTextFile& pFile )
{
    bool lRet = false;

    size_t num = m_Rules.GetCount();
    unsigned long i;
    unsigned long k;

    for ( i = 0; i < num; i++ )
    {
        cbMGRule& lRule = m_Rules.Item( i );
        pFile.AddLine( lRule.GetTarget() + _T( ": " ) + lRule.GetPrerequisites() );
        for ( k = 0; k < lRule.GetCommands().GetCount(); k++ )
        {
            if ( m_IsSilence )
            {
                pFile.AddLine( GetCommandPrefix() + _T( "@" ) + lRule.GetCommands()[ k ] );
            }
            else
            {
                pFile.AddLine( GetCommandPrefix() + lRule.GetCommands()[ k ] );
            }
        }
        pFile.AddLine( wxEmptyString );
    }
    lRet = true;
    return lRet;
}
Esempio n. 2
0
bool STISpectrumExports::SaveToFile(wxTextFile& wxtfSplData)
{
    const wxChar* awxpchNoiseCaption[]  = { wxT("---BACKGROUND NOISE LEFT (dB)--- "), 
                                            wxT("---BACKGROUND NOISE RIGHT (dB)---") };
    const wxChar* awxpchSignalCaption[] = { wxT("---SIGNAL LEVEL LEFT (dB)---     "),
                                            wxT("---SIGNAL LEVEL RIGHT (dB)---    ") };
    wxString wxszLine;

    int nBand;
    for(int nCh = 0; nCh < 2; nCh++)
    {
        wxszLine = awxpchNoiseCaption[nCh];
        wxtfSplData.AddLine(wxszLine, wxTextFileType_Dos);
        for(nBand = 2; nBand < 9; nBand++) // 125 Hz -> 8 kHz
        {
            wxszLine.Printf(wxT("%.1f"), m_pAs->GetNoiseLevel(nBand, nCh));
            wxtfSplData.AddLine(wxszLine, wxTextFileType_Dos);
        }
        wxszLine = awxpchSignalCaption[nCh];
        wxtfSplData.AddLine(wxszLine, wxTextFileType_Dos);
        for(nBand = 2; nBand < 9; nBand++) // 125 Hz -> 8 kHz
        {
            wxszLine.Printf(wxT("%.1f"), m_pAs->GetSignalLevel(nBand, nCh));
            wxtfSplData.AddLine(wxszLine, wxTextFileType_Dos);
        }
    }
    return wxtfSplData.Write(wxTextFileType_Dos);
}
Esempio n. 3
0
void LabelTrack::Export(wxTextFile & f)
{
   for (int i = 0; i < (int)mLabels.Count(); i++) {
      f.AddLine(wxString::Format("%lf\t%s",
                                 mLabels[i]->t,
                                 (const char *) (mLabels[i]->title)));
   }
}
bool cbMGMakefile::SaveAllRules( wxTextFile& pFile )
{
    bool lRet = false;

    size_t num = m_Rules.GetCount();
    unsigned long i;
    unsigned long k;
    wxString l_CommandPrefix = GetCommandPrefix();
    wxString l_Prefix;

    for ( i = 0; i < num; i++ )
    {
        cbMGRule& lRule = m_Rules.Item( i );
        pFile.AddLine( lRule.GetTarget() + _T( ": " ) + lRule.GetPrerequisites() );
        for ( k = 0; k < lRule.GetCommands().GetCount(); k++ )
        {
            l_Prefix = l_CommandPrefix;
            wxString l_Cmd = lRule.GetCommands()[ k ];
            if ( _T('-') == l_Cmd[ 0 ] )
            {
                l_Cmd = l_Cmd.SubString( 1, l_Cmd.size() );
                l_Prefix += _T('-');
            }
            if ( m_IsSilence )
            {
                pFile.AddLine( l_Prefix + _T( "@" ) + l_Cmd );
            }
            else
            {
                pFile.AddLine( l_Prefix + l_Cmd );
            }
        }
        pFile.AddLine( wxEmptyString );
    }
    lRet = true;
    return lRet;
}
Esempio n. 5
0
    void writeInfoPlistFile(wxTextFile& file)
    {
        if(not file.Exists()) {
            wxMessageBox(_("Cannot access or create file!"));
            return;
        }

        file.AddLine(wxT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
        file.AddLine(wxT("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" "
                         "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"));
        file.AddLine(wxT("<plist version=\"1.0\">"));
        file.AddLine(wxT("<dict>\n"));
        file.AddLine(wxT("    <key>CFBundleExecutable</key>"));
        file.AddLine(wxT("    <string>") + m_project_name + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleGetInfoString</key>"));
        file.AddLine(wxT("    <string>") + m_get_info_string->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleIconFile</key>"));
        file.AddLine(wxT("    <string>") + m_icon_file->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleIdentifier</key>"));
        file.AddLine(wxT("    <string>") + m_identifier->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleSignature</key>"));
        file.AddLine(wxT("    <string>") + m_signature->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleVersion</key>"));
        file.AddLine(wxT("    <string>") + m_version->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleInfoDictionaryVersion</key>"));
        file.AddLine(wxT("    <string>6.0</string>\n"));
        file.AddLine(wxT("    <key>CFBundleDevelopmentRegion</key>"));
        file.AddLine(wxT("    <string>English</string>\n"));
        file.AddLine(wxT("    <key>CFBundlePackageType</key>"));
        file.AddLine(wxT("    <string>APPL</string>\n"));
        file.AddLine(wxT("    <key>CFBundleShortVersionString</key>"));
        file.AddLine(wxT("    <string>") + m_version->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("</dict>"));
        file.AddLine(wxT("</plist>"));

        if(not file.Write()) {
            wxMessageBox(_("Failed to write Info.plist file!"));
            return;
        }
    }
bool cbMGMakefile::formFileForTarget( ProjectBuildTarget *p_BuildTarget, wxTextFile &p_File )
{
    bool l_Ret = false;
    if ( !p_BuildTarget )
    {
        wxString l_Msg = _( "Can't found an active target!\n"
                            "C::B MakefileGen could not complete the operation." );
        cbMessageBox( l_Msg, _( "Error" ), wxICON_ERROR | wxOK, (wxWindow *)Manager::Get()->GetAppWindow() );
        Manager::Get()->GetMessageManager()->DebugLog( l_Msg );
        return l_Ret;
    }

    wxString l_TargetName = p_BuildTarget->GetTitle();

    wxString l_ObjsName = _T("OBJS_") + l_TargetName.Upper();
    wxString l_CmdBefore = cmdbefore + _T('_') + l_TargetName;
    wxString l_CmdAfter = cmdafter + _T('_') + l_TargetName;
    wxString l_CmdClean = cmdclean + _T('_') + l_TargetName;

    m_Rules.Clear();

    const wxString& l_CompilerId = p_BuildTarget->GetCompilerID();
    Compiler* l_pCompiler = CompilerFactory::GetCompiler( l_CompilerId );

    if( !l_pCompiler )
    {
        wxString l_Msg = _( "Can't found an compiler settings!\n"
                            "C::B MakefileGen could not complete the operation." );
        cbMessageBox( l_Msg, _( "Error" ), wxICON_ERROR | wxOK, (wxWindow *)Manager::Get()->GetAppWindow() );
        Manager::Get()->GetMessageManager()->DebugLog( l_Msg );
        return false;
    }

    if ( !getDependencies( p_BuildTarget, l_pCompiler ) ) return false;

    if ( !m_VariablesIsSaved )
    {
        m_Variables.AddVariable(_T("CPP"),l_pCompiler->GetPrograms().CPP);
        m_Variables.AddVariable(_T("CC"),l_pCompiler->GetPrograms().C);
        m_Variables.AddVariable(_T("LD"),l_pCompiler->GetPrograms().LD);
        m_Variables.AddVariable(_T("LIB"),l_pCompiler->GetPrograms().LIB);
        m_Variables.AddVariable(_T("WINDRES"),l_pCompiler->GetPrograms().WINDRES);
    }

    const wxArrayString& l_CommandsBeforeBuild = p_BuildTarget->GetCommandsBeforeBuild();
    const wxArrayString& l_CommandsAfterBuild = p_BuildTarget->GetCommandsAfterBuild();

    wxString l_TargetFileName = p_BuildTarget->GetOutputFilename();
    Manager::Get()->GetMacrosManager()->ReplaceMacros(l_TargetFileName, p_BuildTarget);
    wxFileName l_OutFileName = UnixFilename(l_TargetFileName);
    cbMGRule l_Rule;
    if ( 0 == l_TargetName.CmpNoCase( _T( "default" ) ) )
    {
        l_Rule.SetTarget( _T( "all" ) );
    }
    else
    {
        l_Rule.SetTarget( l_TargetName );
    }
    wxString l_Pre;
    if ( l_CommandsBeforeBuild.GetCount() > 0 )
    {
        l_Pre = l_CmdBefore;
    }
    l_Pre += l_OutFileName.GetFullPath();
    if ( l_CommandsAfterBuild.GetCount() > 0 )
    {
        l_Pre += _T(" ") + l_CmdAfter;
    }

    l_Rule.SetPrerequisites( l_Pre );
    m_Rules.Add( l_Rule );

    if ( l_CommandsBeforeBuild.GetCount() > 0 )
    {
        l_Rule.Clear();
        l_Rule.SetTarget( cmdphony );
        l_Rule.SetPrerequisites( l_CmdBefore );
        m_Rules.Add( l_Rule );
        l_Rule.Clear();
        l_Rule.SetTarget( l_CmdBefore );
        for ( unsigned long idx = 0; idx < l_CommandsBeforeBuild.GetCount(); idx ++ )
        {
            l_Rule.AddCommand( l_CommandsBeforeBuild[ idx ] );
        }
        m_Rules.Add( l_Rule );
    }
    if ( l_CommandsAfterBuild.GetCount() > 0 )
    {
        l_Rule.Clear();
        l_Rule.SetTarget( cmdphony );
        l_Rule.SetPrerequisites( l_CmdAfter );
        m_Rules.Add( l_Rule );
        l_Rule.Clear();
        l_Rule.SetTarget( l_CmdAfter );
        for ( unsigned long idx = 0; idx < l_CommandsAfterBuild.GetCount(); idx ++ )
        {
            l_Rule.AddCommand( l_CommandsAfterBuild[ idx ] );
        }
        m_Rules.Add( l_Rule );
    }
    l_Rule.Clear();
    l_Rule.SetTarget( l_OutFileName.GetFullPath() );
    l_Rule.SetPrerequisites( _T("$(") + l_ObjsName + _T(")") );

    wxString kind_of_output = _T( "unknown" );
    /* ctInvalid was deleted */
    /* FIXME (shl#1#): Wrongly used ctCompileObjectCmd. Can have problems . */
    CommandType ct = ctCompileObjectCmd; // get rid of compiler warning
    switch ( p_BuildTarget->GetTargetType() )
    {
    case ttConsoleOnly:
        ct = ctLinkConsoleExeCmd;
        kind_of_output = _T( "console executable" );
        break;

    case ttExecutable:
        ct = ctLinkExeCmd;
        kind_of_output = _T( "executable" );
        break;

    case ttDynamicLib:
        ct = ctLinkDynamicCmd;
        kind_of_output = _T( "dynamic library" );
        break;

    case ttStaticLib:
        ct = ctLinkStaticCmd;
        kind_of_output = _T( "static library" );
        break;

    case ttNative:
        ct = ctLinkNativeCmd;
        kind_of_output = _T( "native" );
        break;
    case ttCommandsOnly:
        ct = ctLinkConsoleExeCmd;
        kind_of_output = _T( "commands only" );
        break;

//      case ttCommandsOnly:
//          // add target post-build commands
//          ret.Clear();
//          AppendArray(GetPostBuildCommands(target), ret);
//          return ret;
//          break;
        break;
    }
    /*if(ttCommandsOnly == lTarget->GetTargetType())
    {
      GetPostBuildCommands(lTarget);
    }
    else*/
    {
        l_Rule.AddCommand( _T( "echo Building " ) + kind_of_output + _T( " " ) + l_OutFileName.GetFullPath() );
        wxString l_LinkerCmd = l_pCompiler->GetCommand( ct );


        Manager::Get()->GetMessageManager()->DebugLog(wxString::Format( _("LinkerCmd: %s"), l_LinkerCmd.c_str()) );
        l_pCompiler->GenerateCommandLine( l_LinkerCmd,
                                          p_BuildTarget,
                                          NULL,
                                          l_OutFileName.GetFullPath(),
                                          _T("$$(") + l_TargetName + _T(")"),
                                          wxEmptyString,
                                          wxEmptyString );
        l_Rule.AddCommand( l_LinkerCmd );
    }
    m_Rules.Add( l_Rule );

    // Form rules
    wxString l_Tmp;

    unsigned long ii;

    wxString macro;
    wxString file;
    wxString object;
    wxString FlatObject;
    wxString deps;

    cbMGSortFilesArray files = GetProjectFilesSortedByWeight(p_BuildTarget,true,false);
    unsigned long lnb_files = files.GetCount();
    for ( ii = 0; ii < lnb_files; ii++ )
    {
        l_Rule.Clear();
        ProjectFile* pf = files[ ii ];
        const pfDetails& pfd = pf->GetFileDetails( p_BuildTarget );
        wxString l_Object = ( l_pCompiler->GetSwitches().UseFlatObjects )?pfd.object_file_flat:pfd.object_file;
        wxString l_CompilerCmd;
        // lookup file's type
        FileType ft = FileTypeOf( pf->relativeFilename );
        bool isResource = ft == ftResource;
        bool isHeader = ft == ftHeader;
        if ( !isHeader || l_pCompiler->GetSwitches().supportsPCH )
        {
            pfCustomBuild& pcfb = pf->customBuild[l_pCompiler->GetID()];
            l_CompilerCmd = pcfb.useCustomBuildCommand
                            ? pcfb.buildCommand
                            : l_pCompiler->GetCommand( isResource ? ctCompileResourceCmd : ctCompileObjectCmd );
            wxString l_SourceFile;
            if ( l_pCompiler->GetSwitches().UseFullSourcePaths )
            {
                l_SourceFile = UnixFilename( pfd.source_file_absolute_native );
                // for resource files, use short from if path because if windres bug with spaces-in-paths
                if ( isResource )
                {
                    l_SourceFile = pf->file.GetShortPath();
                }
            }
            else
            {
                l_SourceFile = pfd.source_file;
            }
            QuoteStringIfNeeded( l_SourceFile );
            Manager::Get()->GetMessageManager()->DebugLog(wxString::Format( _("CompilerCmd: %s"), l_CompilerCmd.c_str()) );
            /* FIXME: traps after next command */
            l_pCompiler->GenerateCommandLine( l_CompilerCmd,
                                              p_BuildTarget,
                                              pf,
                                              l_SourceFile,
                                              l_Object,
                                              pfd.object_file_flat,
                                              pfd.dep_file );
            if ( m_Objs.size() )
            {
                m_Objs += _T(' ');
            }
            m_Objs += l_Object;
            l_Rule.SetTarget( l_Object );
            l_Rule.SetPrerequisites( l_SourceFile );
            l_Rule.AddCommand( _T( "echo Compiling: " ) + l_SourceFile );
            l_Rule.AddCommand( l_CompilerCmd );
            m_Rules.Add( l_Rule );
        }
    }
    for ( unsigned long i=0; i < m_Deps.Count(); i++ )
    {
        l_Rule.Clear();
        l_Rule.SetTarget( m_Deps.GetVarName( i ) );
        l_Rule.SetPrerequisites( m_Deps.GetVariable( i ) );
        m_Rules.Add( l_Rule );
    }

    l_Rule.Clear();
    l_Rule.SetTarget( cmdphony );
    l_Rule.SetPrerequisites( l_CmdClean );
    m_Rules.Add( l_Rule );
    l_Rule.Clear();
    l_Rule.SetTarget( l_CmdClean );
    l_Rule.AddCommand( _T( "echo Delete $(" ) + l_ObjsName + _T( ") " ) + l_OutFileName.GetFullPath() );
#ifdef __WXMSW__
    l_Rule.AddCommand( _T( "-del /f $(" ) + l_ObjsName + _T( ") " ) + l_OutFileName.GetFullPath() );
#else
    l_Rule.AddCommand( _T( "-rm -f $(" ) + l_ObjsName + _T( ") " ) + l_OutFileName.GetFullPath() );
#endif
    m_Rules.Add( l_Rule );

    if ( !m_VariablesIsSaved )
    {
        m_Variables.SaveAllVars( p_File );
        m_VariablesIsSaved = true;
    }
    p_File.AddLine( _T("# Target: ") + l_TargetName );
    p_File.AddLine( wxEmptyString );
    p_File.AddLine( l_ObjsName + _T("=") + m_Objs );
    p_File.AddLine( wxEmptyString );
    SaveAllRules( p_File );
    p_File.AddLine( wxEmptyString );
    p_File.AddLine( wxEmptyString );
    l_Ret = true;
    return l_Ret;
}