Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid adding .conan folder to projects that may not want to use Conan #256

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions BuildEventsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,22 @@ public BuildEventsHandler(DTE dte)
_buildEvents.OnBuildProjConfigDone += OnBuildProjConfigDone;
}

private bool IsConanEnabledForProject(string projectName)
{
ThreadHelper.ThrowIfNotOnUIThread();
var project = ProjectConfigurationManager.GetProjectByName(_dte, projectName);
return project != null && ProjectConfigurationManager.conandataFileExists(project);
}

private void OnBuildProjConfigBegin(string Project, string ProjectConfig, string Platform, string SolutionConfig)
{
ThreadHelper.ThrowIfNotOnUIThread();
// here we generate profiles for all projects but we probably should only generate profiles for
// the project marked as startup project

if (!IsConanEnabledForProject(Project))
{
return;
}

Project invokedProject = ProjectConfigurationManager.GetProjectByName(_dte, Project);
_profiles_manager.GenerateProfilesForProject(invokedProject);

Expand All @@ -40,8 +51,12 @@ private void OnBuildProjConfigBegin(string Project, string ProjectConfig, string
private void OnBuildProjConfigDone(string Project, string ProjectConfig, string Platform, string SolutionConfig, bool Success)
{
ThreadHelper.ThrowIfNotOnUIThread();
var message = "OnBuildProjConfigDone";
System.Diagnostics.Debug.WriteLine(message);

if (!IsConanEnabledForProject(Project))
{
return;
}

Project invokedProject = ProjectConfigurationManager.GetProjectByName(_dte, Project);
VCConfiguration config = ProjectConfigurationManager.GetVCConfig(invokedProject, ProjectConfig, Platform);
// FIXME: the problem with this is that the first time you build
Expand Down
5 changes: 3 additions & 2 deletions ProjectConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ProjectConfigurationManager()
{
}

static private bool conandataFileExists(Project project)
public static bool conandataFileExists(Project project)
{
ThreadHelper.ThrowIfNotOnUIThread();
string projectDirectory = System.IO.Path.GetDirectoryName(project.FullName);
Expand Down Expand Up @@ -214,14 +214,15 @@ private static async Task SaveConanPrebuildEventAsync(Project project, VCConfigu
public static async Task SaveConanPrebuildEventsAllConfigAsync(Project project)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
await GenerateConanInstallScriptAsync(project); // all the config share the same script

if (!conandataFileExists(project))
{
System.Diagnostics.Debug.WriteLine("conandata.yml not found. Skipping Conan PreBuildEvent.");
return;
}

await GenerateConanInstallScriptAsync(project); // all the config share the same script

VCProject vcProject = project.Object as VCProject;
foreach (VCConfiguration vcConfig in (IEnumerable)vcProject.Configurations)
{
Expand Down
Loading