Status DeleterTest::MultipleFilesDeletionFunc() { UnixCommand command(INSTALL_PREFIX"/bin/MultipleFilesDeletion.sh"); std::auto_ptr<ProcessResult> result(command.Execute(CreateArguments())); cerr << result->GetOutput() << " "; return (Status)result->GetStatus(); }
void CMakePlugin::OnExportMakefile(clBuildEvent& event) { const wxString project = event.GetProjectName(); const wxString config = event.GetConfigurationName(); // Get settings const CMakeProjectSettings* settings = GetSettingsManager()->GetProjectSettings(project, config); // Doesn't exists or not enabled if (!settings || !settings->enabled) { // Unable to export makefile event.Skip(); return; } // Get project directory - this is directory where the makefile is stored const wxFileName projectDir = GetProjectDirectory(project); // Targets forward inspired by // https://gist.github.com/doitian/4978329 // Content of the generated makefile wxString content = wxString() << "# Generated by CMakePlugin\n" ".PHONY: all clean $(MAKECMDGOALS)\n" "\n" ; // Parent project is set if (!settings->parentProject.IsEmpty()) { // Configure parent project instead const wxString& parentProject = settings->parentProject; settings = GetSettingsManager()->GetProjectSettings(parentProject, config); // Parent project not found if (!settings || !settings->enabled) { CL_ERROR("Unable to find or not enabled parent project " "'" + parentProject + "' for project '" + project + "'"); return; } // Get parent project directory wxFileName parentProjectDir = GetProjectDirectory(parentProject); parentProjectDir.MakeRelativeTo(projectDir.GetFullPath()); // Path is relative so UNIX path system can be used const wxString parentProjectDirEsc = parentProjectDir.GetPath(wxPATH_NO_SEPARATOR, wxPATH_UNIX); // Redirect make to the parent project content << "# Parent project\n" "PARENT := " << parentProjectDirEsc << "\n" "PARENT_MAKEFILE := " << parentProject << ".mk\n" "\n" "all:\n" "\t$(MAKE) -C \"$(PARENT)\" -f \"$(PARENT_MAKEFILE)\" " << project << "\n" "\n" "clean:\n" "\t$(MAKE) -C \"$(PARENT)\" -f \"$(PARENT_MAKEFILE)\" " << project << " clean\n" "\n" ; } else { // Macro expander // FIXME use IMacroManager (unable to find it yet) MacroManager* macro = MacroManager::Instance(); wxASSERT(macro); // Get variables // Expand variables for final project const wxString cmake = GetConfiguration()->GetProgramPath(); wxFileName sourceDir = wxFileName::DirName(macro->Expand(settings->sourceDirectory, GetManager(), project, config)); wxFileName buildDir = wxFileName::DirName(macro->Expand(settings->buildDirectory, GetManager(), project, config)); // Source dir must be relative to build directory (here is cmake called) sourceDir.MakeRelativeTo(buildDir.GetFullPath()); // Build dir must be relative to project directory buildDir.MakeRelativeTo(projectDir.GetFullPath()); // Relative paths const wxString sourceDirEsc = sourceDir.GetPath(wxPATH_NO_SEPARATOR, wxPATH_UNIX); const wxString buildDirEsc = buildDir.GetPath(wxPATH_NO_SEPARATOR, wxPATH_UNIX); // Generated makefile content << "CMAKE := \"" << cmake << "\"\n" "BUILD_DIR := " << buildDirEsc << "\n" "SOURCE_DIR := " << sourceDirEsc << "\n" "CMAKE_ARGS := " << CreateArguments(*settings, *m_configuration.get()) << "\n" "\n" "# Building project(s)\n" "$(or $(lastword $(MAKECMDGOALS)), all): $(BUILD_DIR)/Makefile\n" "\t$(MAKE) -C \"$(BUILD_DIR)\" $(MAKECMDGOALS)\n" "\n" "# Building directory\n" "$(BUILD_DIR):\n" "\t$(CMAKE) -E make_directory \"$(BUILD_DIR)\"\n" "\n" "# Rule that detects if cmake is called\n" "$(BUILD_DIR)/Makefile: .cmake_dirty | $(BUILD_DIR)\n" "\tcd \"$(BUILD_DIR)\" && $(CMAKE) $(CMAKE_ARGS) \"$(SOURCE_DIR)\"\n" "\n" "# This rule / file allows force cmake run\n" ".cmake_dirty:\n" "\t@echo '' > .cmake_dirty\n" "\n" ; } // Path to makefile - called project directory required wxFileName makefile = projectDir; makefile.SetName(project); makefile.SetExt("mk"); // Read old content from disk wxString oldContent; bool ok = ReadFileWithConversion(makefile.GetFullPath(), oldContent); // Write only if there are some changes if (!ok || content != oldContent) { // Write make file content wxFile file(makefile.GetFullPath(), wxFile::write); if (!file.Write(content)) { CL_ERROR("Unable to write custom makefile (CMakePlugin): " + makefile.GetFullPath()); } } }