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

Added Support for Shared Items Projects #6286

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

DevFelixFaber
Copy link

@DevFelixFaber DevFelixFaber commented Apr 12, 2024

At work (Areus Gmbh), we use Shared Items Projects in order to deduplicate code. In contrast to conventional project files (.vcxproj), the compilation configuration is set by the "includee", which makes the code-reuse of the project more flexible.

This pull-request adds support for Shared Items Projects (.vcxitems) in Visual studio projects / solutions.

The idea is that for each .vcxproj, we check for referenced shared items projects. When all the source files and include paths are build, we add the ones defined in the referenced .vcxitems.
The implementation probably isn't 100% robust, but this works for our projects and could serve as a starting point :)

I apologize for the commit history - it's a bit wonky as we currently still use 2.11. I tried to merge the changes to the main branch so other could benefit from these changes as well, but seems like the git history looks a bit weird as a result.

lib/importproject.cpp Outdated Show resolved Hide resolved
lib/importproject.cpp Outdated Show resolved Hide resolved
lib/importproject.cpp Outdated Show resolved Hide resolved
@firewave
Copy link
Collaborator

Thanks for a contribution. I will take a closer look in the next few days.

Please add a test with an example project to test/cli/more-projects.py.

Also some initial comments inline.

@firewave
Copy link
Collaborator

I apologize for the commit history - it's a bit wonky as we currently still use 2.11. I tried to merge the changes to the main branch so other could benefit from these changes as well, but seems like the git history looks a bit weird as a result.

That can be resolved by re-basing the branch on the latest head.

@DevFelixFaber
Copy link
Author

Thank you for the feedback, I'll try to implement it this week.

@DevFelixFaber
Copy link
Author

DevFelixFaber commented Apr 19, 2024

I apologize for the commit history - it's a bit wonky as we currently still use 2.11. I tried to merge the changes to the main branch so other could benefit from these changes as well, but seems like the git history looks a bit weird as a result.

That can be resolved by re-basing the branch on the latest head.

I had the same issue as my merge, but my oversight was that my initial changes came from the 2.11 release branch, meaning it includes the few commits made for the official release.
I re-based this once more, removed the release commits and force-pushed this to my branch. Seems more correct now.

Still working on adding tests.

@firewave
Copy link
Collaborator

Thanks for adding the project. This will help understanding things. It is probably sufficient to have only a single configuration in it. That should make things easier to read as well.

@DevFelixFaber
Copy link
Author

DevFelixFaber commented Apr 30, 2024

Thanks for adding the project. This will help understanding things. It is probably sufficient to have only a single configuration in it. That should make things easier to read as well.

Fixed in 10fb4e5

I also added a (crude) test in d34d14c. Seems to run fine on my machine, but I'm not sure I set it up correctly.

I seem to have broken the "changes requested" with my rebase + force push. Sorry!

@firewave
Copy link
Collaborator

Sorry for the late reply.

Please fix the CI and I will finally have a proper look.

@DevFelixFaber DevFelixFaber marked this pull request as draft June 5, 2024 10:57
@DevFelixFaber DevFelixFaber marked this pull request as ready for review June 5, 2024 10:57
@DevFelixFaber
Copy link
Author

My apologies, I borked the pipeline with the code removed in a00dd2a.
That was some special code which (should be) unrelated to the shared items support.
I fixed some more formatting issues (thanks Visual Studio) and adjusted the assertion on the new shared items project test.

@firewave
Copy link
Collaborator

firewave commented Jun 5, 2024

My apologies, I borked the pipeline with the code removed in [a00dd2a]

It happens.

As the CI seems to be happy now, I hope to finish up the review this week.

@danmar
Copy link
Owner

danmar commented Jun 9, 2024

At a glance this looks very interesting. Please make the CI happy. 👍

Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits

@@ -203,7 +203,8 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings
}
} else if (endsWith(filename, ".vcxproj")) {
std::map<std::string, std::string, cppcheck::stricmp> variables;
if (importVcxproj(filename, variables, emptyString, fileFilters)) {
std::vector<SharedItemsProject> sharedItemsProjects{};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we skip the redundant {}

@@ -698,14 +699,15 @@ static void loadVisualStudioProperties(const std::string &props, std::map<std::s
}
}

bool ImportProject::importVcxproj(const std::string &filename, std::map<std::string, std::string, cppcheck::stricmp> &variables, const std::string &additionalIncludeDirectories, const std::vector<std::string> &fileFilters)
bool ImportProject::importVcxproj(const std::string &filename, std::map<std::string, std::string, cppcheck::stricmp> &variables, const std::string &additionalIncludeDirectories, const std::vector<std::string> &fileFilters, std::vector<SharedItemsProject> &cache)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm the name cache is short. I feel like 50/50 if I think the name is fine or not.

}
if (!simplifyPathWithVariables(pathToSharedItemsFile, variables)) {
printError("Could not simplify path to referenced shared items project");
exit(-1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you return false here?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For information I fear that in the GUI this would mean that the whole program would just terminate without any indication to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants