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

Proposal: Require ninja when building with MSVC #47

Merged
merged 1 commit into from
Apr 12, 2019

Conversation

djcsdy
Copy link
Contributor

@djcsdy djcsdy commented Apr 8, 2019

This PR is a proposal to make ninja a hard requirement when building with MSVC. It remains optional in all other cases.

The motivation for this change is that, if building with MSVC but without ninja, shaderc builds with msbuild, which often causes the build to fail due to the excessively long path names generated by the msbuild project generator. This is especially true when shaderc is built as a dependency of another project, since in that case it will build in a nested subdirectory.

The best solution to this problem is to build with ninja instead, but this solution is not obvious especially for users of downstream projects, who are unlikely to have read the shaderc README, or think of reading it as their first action to try to solve the problem.

With this change, if ninja is not available and the user is compiling with MSVC, the build will fail with:

couldn't find required command: "ninja"'

This at least points the user in the right direction, at the IMHO very minor cost of requiring ninja in some cases where it is not absolutely necessary.

By comparison, if the build fails due to long path names (without this change), the relevant error message looks like:

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(321,5): error MSB3491: Could not write lines to file "x64\Release\spirv-tools-spv-amd-shader-explicit-vertex-parameter\spirv-to.1662915F.tlog\spirv-tools-spv-amd-shader-explicit-vertex-parameter.lastbuildstate". The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. [C:\Users\travis\build\djcsdy\gfx\target\debug\build\shaderc-65c2fb29275ff843\out\build\spirv-tools\source\spirv-tools-spv-amd-shader-explicit-vertex-parameter.vcxproj]

Although this a very well-written error message and thoroughly describes the underlying problem, it doesn’t do anything to point the user in the right direction and can lead to hours of confused searching and experimentation. I know this because it happened to me :-).

If you like this change and want to merge it then I will also update the documentation to reflect this change.

By default shaderc is built with msbuild when building with MSVC.
Unfortunately this often causes the build to fail due to excessively
long path names created by the msbuild project generator. This is
especially true when shaderc is built as a dependency of another
project, since in that case it will build in a nested subdirectory.

The best solution to this problem is to build with ninja instead, but
this solution is not obvious especially for users of downstream
projects, who are unlikely to have read the shaderc README.

To avoid this problem, we make ninja a hard requirement when building
with MSVC. This causes the build to fail with 'couldn't find required
command: "ninja"' when ninja is not available. This at least points the
user in the right direction.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@djcsdy
Copy link
Contributor Author

djcsdy commented Apr 8, 2019

I signed the CLA.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Collaborator

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

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

I think this is reasonable analysis and solution.

@antiagainst
Copy link
Collaborator

Thanks, @djcsdy! :)

@antiagainst antiagainst merged commit 367a4dd into google:master Apr 12, 2019
@antiagainst
Copy link
Collaborator

I just merged this PR. Please update the doc in another PR. Thanks! :)

knappador added a commit to e-nguyen/shaderc-rs that referenced this pull request Apr 17, 2019
Original PR: google#47

To merge master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants