⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctcommondoc.cpp

📁 eCos1.31版
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  if (vitem->get_name () == "CYGHWR_MEMORY_LAYOUT")  {    ASSERT (m_strMemoryLayoutFolder.IsEmpty ());    m_strMemoryLayoutFolder = vitem->get_owner ()->get_directory().c_str ();    m_strMemoryLayoutFolder.Replace(_TCHAR('/'),_TCHAR('\\'));    TRACE (_T("Found memory layout folder: %s\n"), m_strMemoryLayoutFolder);  }    if (vitem->get_name () == "CYGBLD_LINKER_SCRIPT")  {    ASSERT (m_strLinkerScriptFolder.IsEmpty ());    m_strLinkerScriptFolder = vitem->get_owner ()->get_directory().c_str ();    m_strLinkerScriptFolder.Replace(_TCHAR('/'),_TCHAR('\\'));    TRACE (_T("Found linker script folder: %s\n"), m_strLinkerScriptFolder);        // the CDL hardware template name will eventually become the target name,    // but for now we must deduce the target name from the linker script file name        const CdlValuable valuable = dynamic_cast<CdlValuable> (vitem);    CFileName strLinkerScript (m_strPackagesDir, m_strLinkerScriptFolder, CString (valuable->get_value ().c_str ()));    strLinkerScript.Replace (_TCHAR('/'), _TCHAR('\\'));    if(!strLinkerScript.Exists ()){        CConfigTool::Log(_T("%s does not exist\n"),strLinkerScript);    }    TRACE (_T("Target '%s' selected\n"), strLinkerScript.Tail ().Root (), pItem->Macro());    //CFileName strBinDir = AfxGetApp () -> GetProfileString (CUtils::LoadString (IDS_KEY_TOOLS_DIR), pTarget->Name (), _T(""));    //if (! strBinDir.IsEmpty () && strBinDir.IsDir ())    //{    //  pTarget->SetBinDir (strBinDir);    //}  }	    //TRACE(_T("Created new item from cdl: "));  //pItem->DumpItem();  return pItem;}void CConfigToolDoc::AddAllItems (){  // remove any old items and packages  DeleteContents ();  if(NULL!=CConfigTool::GetControlView()){ // may not be the case for plugin    // add the root item    CConfigItem * pItem = new CConfigItem (NULL, NULL);    m_arItem.Add(pItem);    pItem->m_strDesc = _T("The root node for all configurable items");      // add the remaining items using their CDL descriptions    m_strMemoryLayoutFolder = _T("");    m_strLinkerScriptFolder = _T("");    AddContents (m_CdlConfig, FirstItem ());      // check that exactly one radio button in each group is enabled    CheckRadios ();      // update the rules (conflicts) view    UpdateFailingRuleCount ();      if(NULL==CConfigTool::GetRulesView() || !CConfigTool::GetRulesView()->IsWindowVisible()){      // log all conflicts      //	LogConflicts (m_CdlConfig->get_structural_conflicts ()); // relating to package availability - ignore for now      LogConflicts (m_CdlConfig->get_all_conflicts ());    }    CConfigTool::GetControlView()->SelectItem(Item(0));    UpdateAllViews (NULL, SelChanged, (CObject *)Item(0)); // refresh the display    if(ItemCount()>0){      CConfigTool::GetControlView()->GetTreeCtrl().Expand(Item(0)->HItem(),TVE_EXPAND);    }    CConfigTool::GetControlView()->SetFocus();  }}const CFileName CConfigToolDoc::CurrentLinkerScript(){  const CConfigItem * pItem = Find (_T("CYGBLD_LINKER_SCRIPT"));  return pItem ? CFileName (m_strPackagesDir, m_strLinkerScriptFolder, pItem->StringValue ()) : _T("");}bool CConfigToolDoc::GenerateHeaders(){// Copy non-config header files from the repository to the// install tree for plugin only. The make system used by// the standalone config tool does this for us.#ifdef PLUGIN  typedef std::vector<CdlBuildInfo_Loadable> EntriesArray;  const EntriesArray &arEntries=BuildInfo().entries;  typedef std::vector<CdlBuildInfo_Header> HeaderArray;  for(EntriesArray::size_type j=0;j<arEntries.size();j++){    const CdlBuildInfo_Loadable &e=arEntries[j];    const CFileName strDir(CUtils::WPath(e.directory));    const HeaderArray &arHeaders=e.headers;    for(HeaderArray::size_type i=0;i<arHeaders.size();i++){      const CdlBuildInfo_Header &h=arHeaders[i];      const CFileName strSource(PackagesDir()+strDir+CUtils::WPath(h.source));      const CFileName strDest(HeadersDir()/*+CUtils::WPath(e.directory)*/+CUtils::WPath(h.destination));          if(!strDest.Head().CreateDirectory(true)){        CUtils::MessageBoxF(_T("Failed to create %s - %s"),strDest.Head(),CUtils::GetLastErrorMessageString());        return false;      }      if(!CUtils::CopyFile(strSource,strDest)){         return false; // message already emitted      }    }  }#endif  // Generate headers  try {    CFileName strPkfConfDir(InstallTree()+_T("include\\pkgconf"));    if(!strPkfConfDir.CreateDirectory()){      CUtils::MessageBoxF(_T("Failed to create %s - %s"),strPkfConfDir,CUtils::GetLastErrorMessageString());      return false;    }    GetCdlConfig()->generate_config_headers(CUtils::UnicodeToStdStr(strPkfConfDir.ShortName()));  }  catch (CdlInputOutputException e) {    const CString strMsg(e.get_message().c_str());    TRACE(_T("!!! Exception thrown calling generate_config_headers - %s"),strMsg);    CUtils::MessageBoxF(_T("Failed to generate header files - %s"),strMsg);    return false;  }  return true;}const CFileName CConfigToolDoc::MLTDir (){	CString strPathName (GetPathName ());	ASSERT (! strPathName.IsEmpty ());	return strPathName.Left (strPathName.ReverseFind (_TCHAR('.'))) + _T("_mlt");}bool CConfigToolDoc::UpdateBuildInfo(bool bFirstTime){  try {    GetCdlConfig()->get_build_info(m_BuildInfo);    #ifdef PLUGIN    // FIXME: this means anything not mentioned by AddFile in our scan below will be removed - including user-added items    m_peCosProject->ClearItemFlags();        m_peCosProject->UpdateeCosProject(bFirstTime);    m_peCosProject->RemoveAllUnflaggedItems();    #else    UNUSED_ALWAYS(bFirstTime);    generate_build_tree (GetCdlConfig(), CUtils::UnicodeToStdStr(BuildTree()), CUtils::UnicodeToStdStr(InstallTree()));    #endif    return true;  }  catch(...){    return false;  }}void CConfigToolDoc::RemoveAllItems(){  for(int nItem=0;nItem<ItemCount();nItem++){    CConfigItem *pItem=Item(nItem);    deleteZ(pItem);  }  m_arItem.RemoveAll();  UpdateAllViews(NULL,Clear,0);}void CConfigToolDoc::EnableCallbacks (bool bEnable/*=true*/){  CdlTransactionCallback::set_callback_fn(bEnable?&CdlTransactionHandler:0);  CdlTransactionBody::set_inference_callback_fn(bEnable?&CdlInferenceHandler:0);  CdlTransactionBody::set_inference_override(CdlValueSource_Invalid);}int CConfigToolDoc::GetTestExeNames (CFileNameArray &arTestExes,CFileNameArray &arMissing){  arTestExes.RemoveAll();  arMissing.RemoveAll();    typedef std::vector<CdlBuildInfo_Loadable> EntriesArray;  const EntriesArray &arEntries=BuildInfo().entries;  for(EntriesArray::size_type j=0;j<arEntries.size();j++){    const CdlBuildInfo_Loadable &e=arEntries[j];    CStringArray ar;    int n=CUtils::Chop(CString(get_tests(GetCdlConfig(),e).c_str()),ar);    for(int i=0;i<n;i++){      CFileName strFile;      strFile.Format(_T("%s\\tests\\%s\\%s.exe"),InstallTree(),CString(e.directory.c_str()),ar[i]);       strFile.Replace(_TCHAR('/'),_TCHAR('\\'));      if(strFile.Exists()){        arTestExes.Add(strFile);      } else {        arMissing.Add(strFile);      }    }  }  return arTestExes.GetSize();}CConfigToolDoc::GlobalConflictOutcome CConfigToolDoc::ResolveGlobalConflicts(CPtrArray *parConflictsOfInterest){  m_ConflictsOutcome=NotDone;  m_arConflictsOfInterest.RemoveAll();  if(parConflictsOfInterest){    m_arConflictsOfInterest.Copy(*parConflictsOfInterest);  }  CdlInferenceCallback fn=CdlTransactionBody::get_inference_callback_fn();  CdlTransactionBody::set_inference_callback_fn(CdlGlobalInferenceHandler);  GetCdlInterpreter()->get_toplevel()->resolve_all_conflicts();  CdlTransactionBody::set_inference_callback_fn(fn);  if(NotDone==m_ConflictsOutcome){    // No solutions were available, but we'll run the dialog anyway    const std::list<CdlConflict>& conflicts=GetCdlConfig()->get_all_conflicts();      CFailingRulesDialog dlg(conflicts,NULL,&m_arConflictsOfInterest);    m_ConflictsOutcome=(IDOK==dlg.DoModal())?OK:Cancel;  }  return m_ConflictsOutcome;}bool CConfigToolDoc::CheckConflictsBeforeSave(){  if(GetCdlInterpreter()->get_toplevel()->get_all_conflicts().size()>0){    if(Deferred&m_nRuleChecking){      if((SuggestFixes&m_nRuleChecking)&&(Cancel==ResolveGlobalConflicts())){        return false;      }      int nConflicts=GetCdlInterpreter()->get_toplevel()->get_all_conflicts().size();      switch(nConflicts){      case 0:        break;      case 1:        if(IDNO==CUtils::MessageBoxFT(MB_YESNO|MB_DEFBUTTON2,_T("There is 1 unresolved conflict.  Save anyway?"))){          return false;        }      default:        if(IDNO==CUtils::MessageBoxFT(MB_YESNO|MB_DEFBUTTON2,_T("There are %d unresolved conflicts.  Save anyway?"),nConflicts)){          return false;        }      }    }  }  return true;}BOOL CConfigToolDoc::IsModified() {   return m_bModified || MemoryMap.map_modified();}void CConfigToolDoc::OnFileExport(){  CFileDialog dlg (FALSE, _T("ecm"), NULL, OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, _T("eCos Minimal Configuration (*.ecm)|*.ecm||"), AfxGetMainWnd ());  TCHAR szBuffer [MAX_PATH * 16] = _T("");  dlg.m_ofn.lpstrFile = szBuffer;  dlg.m_ofn.nMaxFile = MAX_PATH * 16;  dlg.m_ofn.lpstrTitle = _T("Export eCos Minimal Configuration");  if (IDOK == dlg.DoModal ()) {    try {      TRACE (_T("Exporting eCos minimal configuration '%s'\n"), dlg.GetPathName ());      m_CdlConfig->save (CUtils::UnicodeToStdStr (dlg.GetPathName ()), /* minimal = */ true);    }    catch (CdlStringException exception) {      CUtils::MessageBoxF (_T("Error exporting eCos minimal configuration:\n\n%s"), CString (exception.get_message ().c_str ()));    }    catch (...) {      CUtils::MessageBoxF (_T("Error exporting eCos minimal configuration."));    }  }}void CConfigToolDoc::OnFileImport(){  CFileDialog dlg (TRUE, NULL, NULL, OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, _T("eCos Minimal Configurations (*.ecm)|*.ecm||"), AfxGetMainWnd ());  TCHAR szBuffer [MAX_PATH * 16] = _T("");  dlg.m_ofn.lpstrFile = szBuffer;  dlg.m_ofn.nMaxFile = MAX_PATH * 16;  dlg.m_ofn.lpstrTitle = _T("Import eCos Minimal Configuration");  if (IDOK == dlg.DoModal ()) {    try {      TRACE (_T("Importing eCos minimal configuration '%s'\n"), dlg.GetPathName ());      m_CdlConfig->add (CUtils::UnicodeToStdStr (dlg.GetPathName ()), CConfigToolDoc::CdlParseErrorHandler, CConfigToolDoc::CdlParseWarningHandler);    }    catch (CdlStringException exception) {      CUtils::MessageBoxF (_T("Error importing eCos minimal configuration:\n\n%s"), CString (exception.get_message ().c_str ()));    }    catch (...) {      CUtils::MessageBoxF (_T("Error importing eCos minimal configuration."));    }    CWaitCursor wait;    AddAllItems (); // regenerate all the config items since the topology may have changed    if (m_strLinkerScriptFolder.IsEmpty ()) {      CUtils::MessageBoxF (_T("The eCos linker script macro CYGBLD_LINKER_SCRIPT is not defined."));    }    if (m_strMemoryLayoutFolder.IsEmpty ()) {      CUtils::MessageBoxF (_T("The eCos memory layout macro CYGHWR_MEMORY_LAYOUT is not defined."));    }    SwitchMemoryLayout (true); // the hardware template may have changed    UpdateBuildInfo ();    CConfigTool::GetControlView()->SelectItem (Item (0));    SetModifiedFlag ();  }}bool CConfigToolDoc::QualifyDocURL(CString &strURL){  if(-1==strURL.Find(_T("://"))){    // Relative URL - qualify it as a file URL    strURL=DocBase()+CFileName(strURL);    strURL.Replace(_TCHAR('/'),_TCHAR('\\'));    strURL=_T("file://")+strURL;  }  if(0==strURL.Find(_T("file://"))){    CFileName strFile(strURL.Right(strURL.GetLength()-7));    int nIndex=strFile.ReverseFind(_TCHAR('#'));    if(-1!=nIndex){      strFile=strFile.Left(nIndex);    }    strFile.Replace(_TCHAR('/'),_TCHAR('\\'));    if(!strFile.Exists()){      CUtils::MessageBoxF(_T("Cannot locate the file %s"),strFile);      return false;    }  }  return true;}bool CConfigToolDoc::NewMemoryLayout (const CString &strPrefix){  CFileName strFileName = CurrentLinkerScript ();  TRACE(_T("Reading linker-defined memory sections from %s\n"), strFileName);  MemoryMap.new_memory_layout (); // delete the old memory layout regardless  if (! strFileName.IsEmpty ())    MemoryMap.import_linker_defined_sections (strFileName); // read the linker-defined section names from the repository (failure is silent)  CString strMemoryLayoutFileName = strPrefix + _T("\\mlt_") + CurrentMemoryLayout () + _T(".mlt");  TRACE(_T("Reading memory layout from %s\n"), strMemoryLayoutFileName);  MemoryMap.load_memory_layout (strMemoryLayoutFileName); // load the new memory layout (failure is silent)  strSelectedSection = _T("");  strSelectedRegion = _T("");  UpdateAllViews (NULL, MemLayoutChanged);  return true; // FIXME}void CConfigToolDoc::SetPathName( LPCTSTR pszPath, BOOL bAddToMRU /*= TRUE*/ ){  if(_TCHAR('\0')==*pszPath){ // called like this after failed saves to put things back as they were	  // CDocument::SetPathName would assert given an empty string	  m_strPathName = _T("");#ifndef PLUGIN    SetTitle(_T("Untitled"));#endif    m_strBuildTree   = _T("");    m_strInstallTree = _T("");  } else {#ifdef PLUGIN    m_strPathNa

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -