how to apply a patch after building blender.

Hi all i am really interested about this patch https://developer.blender.org/D1985.

I builded blender with the help of this nice guide http://blog.machinimatrix.org/building-blender/

Blender seams to work (ok i got 2 errors from some cuda files so gpu isnt working for cycles )

A good step by step guide for a ultimate newbie how to apply a patch would be awesome.

Do i have to download the diff file or can i use the url derectly?
What is the repository root directory?
The dev/docs are not really helpful.

Thanks in advanced

You can’t apply a patch after building. You’ll need to use the git patching tool (or git bash) to apply the patch to the downloaded master code base and then rebuild Blender.

So:

Download the diff

Put it in the root folder of the Blender code

Navigate there with Git Bash

type ‘git apply --ignore-space-change <patchFileNameGoesHere>’ (without the quotes) and hit enter

If there are no errors, do a clean project build.

Thanks for your help,

so i started the Rawdiff download and put it in the root folder (i guess its the root folder)



i navigated with gitBash to the folder and used the ’ patch -p1 < difffile’ but no file to patch was found at line 5.


I was looking in line 5 and was thinking maybe i have to put the diff file in the ‘intern’ folder because to patch works only in one folder…i navigated git bash again to te intern folder and try to patch and this time he find some code to change…but not all and he ask again to skip the not founded code …now my original source code is changed and works no more …i think i have make a copy first before i try to patch.

Ok after skipping some lines i realysed some files are not included in the source code so maybe the patch is written for another blender version…just guessing.

How do i know which patch belongs to which blender source version?

Patching will create files where it needs to. Don’t use the patch command. Use the apply command from within the git bash prompt.

Thanks for all your help i have to learn more about the git concept and how it works

Also, consider that this patch is from May, which means that it may not apply correctly anymore. Commit 98e2135a2 looks like a decent candidate.

So, I’d recommend the following:

  • “git stash” to get rid of local changes
  • “git checkout 98e2135a2” to go back to the version for which this patch was made
  • “git apply D1985.diff” to apply the patch
  • Build Blender
  • “git stash”, “git checkout origin/master” to return to the current Blender version

lukas thanks a lot.

-“git stash”(in master folder) all changes gone.
-“git checkout 98e2135a2” master switched to 98e2135a2 …how the heck you know which blender version belongs to which patch?.
-“git apply D1985.diff” I put the raw diff in the root folder


and after the apply command i get a lot of errors “No such files or directory”
But in version 98e2135 all files and directories are there so i dont know why git dont find these files and directory…maybe i but the .diff file not in right folder?



-build blender works…also the new cuda 7.5 (befor i used 7.0 and get 2 build errors) works…so cycles with gpu works.

-root folder back to master works.

I opened blender but unfortunatly i find no light links option…in addition i have no idea where i have to search in blender.

maybe you have a idea.

Anyway you helped me a lot to get further…thanks.

Right!, Im on the Verge of randomly smacking someone in the face on the street.

First the whole Blender patch situation is as clear as mud, All docs are out of date and just drive you nuts.

Im on windows 10, Can compile blender fine but ive tried 50,000 different ways to patch code with RAW .diffs and nothings worked.

Download diff, released today. Update blender master from today. git console into directory of master blender-git/blender. Copy patch there. Git apply patch xxxxxx.diff

C:\blender-git\blender [master ≡]> git apply D2341.diff
error: patch failed: intern/cycles/kernel/svm/svm.h:332
error: intern/cycles/kernel/svm/svm.h: patch does not apply
error: patch failed: intern/cycles/render/nodes.h:462
error: intern/cycles/render/nodes.h: patch does not apply
C:\blender-git\blender [master ≡]> git apply --ignore-space-change D2341.diff
error: patch failed: intern/cycles/kernel/svm/svm.h:332
error: intern/cycles/kernel/svm/svm.h: patch does not apply
error: patch failed: intern/cycles/render/nodes.h:462
error: intern/cycles/render/nodes.h: patch does not apply
C:\blender-git\blender [master ≡]>

Tried in blender directory, tried in source directory as other docs online say, it’s such a confused subject that has no real decent help or information on.

So tried git stash then the above again with same problems. Ive tried git add in many different ways. AGHHHHHHHH!

I get this with every single diff downloaded from the dev page, WTF is going on.

There has to be a blender dev running windows and applying patches, for once could devs actually help new comers who are just trying to pitch in, why is it such a hassle for devs to help new comers. And sort out the Bloody Docs related to this ASAP.

wait,wait, think im having a stroke :mad:

1 Like

@3DLuver, I use Linux so I do not have much idea about how to patch on Windows. But that seems like you’re trying to patch versions of Blender that do not match the patch date. Have you done what Lukas explain in message #7?

Edit:
Sorry, I did not pay attention. You said today…

Edit 2:
Ok, analyzing the D2341.
I am not coder or any of that. Not sure of anything, but I think you have to see if the patch has “Parent Revisions”. You have to progressively open each parent for each patch and patch from the last one of them. I have patched in this order in Linux:
https://developer.blender.org/D2339
https://developer.blender.org/D2340
https://developer.blender.org/D2341

Thank you Yafu, Your a diamond mate. Again no where in docs did it explain you have to apply patches in number order.

Now works.

Im going to write a start to finish explanation of compiling blender on windows and apply dev patches / creating dev patches as the docs are shamefully wrong and out of date on this. Makes you wonder how many devs wanted to get involved with blender code just to loose interest because the lac of documentation on this subject.

Cheers J

3 Likes