Skip to content
Open
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
122 changes: 102 additions & 20 deletions build_files/utils/make_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def parse_arguments() -> argparse.Namespace:
parser.add_argument("--git-command", default="git")
parser.add_argument("--use-linux-libraries", action="store_true")
parser.add_argument("--architecture", type=str, choices=("x86_64", "amd64", "arm64",))
parser.add_argument("--windows-vc-version", type=str, choices=("vc15", "vc17"), default="vc17", help="Visual C++ version for Windows precompiled libraries (default: vc17 for VS2022)")
parser.add_argument("--addons-repo-name", default="blender-addons", help="Name of the addons repository (e.g., blender-addons or custom-fork-name)")
parser.add_argument("--addons-contrib-repo-name", default="blender-addons-contrib", help="Name of the addons_contrib repository (e.g., blender-addons-contrib or custom-fork-name)")
return parser.parse_args()


Expand All @@ -82,9 +85,26 @@ def get_effective_architecture(args: argparse.Namespace) -> str:
def svn_update(args: argparse.Namespace, release_version: Optional[str]) -> None:
svn_non_interactive = [args.svn_command, '--non-interactive']

lib_dirpath = os.path.join(get_blender_git_root(), '..', 'lib')
# Get the base SVN URL for libraries from make_utils
# This URL is expected to point to the 'lib' directory for the given version/branch.
# e.g., https://svn.blender.org/svnroot/bf-blender/tags/blender-4.1-release/lib/
svn_url = make_utils.svn_libraries_base_url(release_version, args.svn_branch)

# Correct svn_url if args.svn_branch is a tag and make_utils incorrectly prepended "branches/"
if args.svn_branch and args.svn_branch.startswith("tags/"):
# Define the expected correct base and the faulty segment
correct_base_url_prefix = "https://svn.blender.org/svnroot/bf-blender/"
faulty_path_segment_in_url = "/branches/" + args.svn_branch # e.g., /branches/tags/blender-4.1-release
correct_path_segment_for_tag = "/" + args.svn_branch # e.g., /tags/blender-4.1-release

if faulty_path_segment_in_url in svn_url:
print(f"---- DEBUG make_update.py: Correcting SVN URL for tag-based lib ----")
print(f"---- Original svn_url: {svn_url}")
svn_url = svn_url.replace(faulty_path_segment_in_url, correct_path_segment_for_tag)
print(f"---- Corrected svn_url: {svn_url}")

lib_dirpath = os.path.join(get_blender_git_root(), '..', 'lib')

# Checkout precompiled libraries
architecture = get_effective_architecture(args)
if sys.platform == 'darwin':
Expand All @@ -98,7 +118,10 @@ def svn_update(args: argparse.Namespace, release_version: Optional[str]) -> None
# Windows checkout is usually handled by bat scripts since python3 to run
# this script is bundled as part of the precompiled libraries. However it
# is used by the buildbot.
lib_platform = "win64_vc15"
if args.windows_vc_version == "vc15":
lib_platform = "win64_vc15" # For VS2017
else: # vc17 (default)
lib_platform = "win64_vc17" # For VS2022
elif args.use_linux_libraries:
lib_platform = "linux_x86_64_glibc_228"
else:
Expand Down Expand Up @@ -299,14 +322,14 @@ def external_script_copy_old_submodule_over(args: argparse.Namespace, directory_


def external_script_initialize_if_needed(args: argparse.Namespace,
repo_name: str,
actual_repo_name: str,
directory_name: str) -> None:
"""Initialize checkout of an external repository scripts directory"""

blender_git_root = Path(get_blender_git_root())
blender_dot_git = blender_git_root / ".git"
scripts_dir = blender_git_root / "scripts"
external_dir = scripts_dir / directory_name
external_dir: Path = scripts_dir / directory_name

if external_dir.exists():
return
Expand All @@ -318,20 +341,57 @@ def external_script_initialize_if_needed(args: argparse.Namespace,
external_script_copy_old_submodule_over(args, directory_name)
return

origin_name = "upstream" if use_upstream_workflow(args) else "origin"
blender_url = make_utils.git_get_remote_url(args.git_command, origin_name)
external_url = resolve_external_url(blender_url, repo_name)
# Determine the primary remote of the main Blender repository and its URL.
# This remote's URL will be used as the base to resolve the external script's repository URL.
main_blender_repo_primary_remote_name = "upstream" if use_upstream_workflow(args) else "origin"
main_blender_repo_url = make_utils.git_get_remote_url(args.git_command, main_blender_repo_primary_remote_name)

# Special handling for 'addons_contrib' if using the default name, to always point to official GitHub.
if directory_name == "addons_contrib" and actual_repo_name == "blender-addons-contrib":
print(f"Forcing 'scripts/{directory_name}' to use official GitHub repository: blender/{actual_repo_name}")
external_repo_url_to_clone = f"https://github.com/blender/{actual_repo_name}"
# When using a forced official URL, typically name the remote 'upstream'.
remote_name_for_clone = "upstream"
else:
# Default URL resolution:
# URL for the external script's repository, derived from the main Blender repo's URL and the actual_repo_name.
external_repo_url_to_clone = resolve_external_url(main_blender_repo_url, actual_repo_name)
remote_name_for_clone = main_blender_repo_primary_remote_name

# When running `make update` from a freshly cloned fork check whether the fork of the submodule is
# available, If not, switch to the submodule relative to the main blender repository.
if origin_name == "origin" and not make_utils.git_is_remote_repository(args.git_command, external_url):
external_url = resolve_external_url("https://projects.blender.org/blender/blender", repo_name)

call((args.git_command, "clone", "--origin", origin_name, external_url, str(external_dir)))
# available. If not, switch to the submodule relative to the main blender repository.
# This fallback is triggered if:
# 1. The main Blender repo's primary remote is 'origin' (i.e., likely a fork, and not using 'upstream' as primary).
# 2. The derived URL for the external script's repository (e.g., user_fork/actual_repo_name) is not found.
if main_blender_repo_primary_remote_name == "origin" and \
not (directory_name == "addons_contrib" and actual_repo_name == "blender-addons-contrib") and \
not make_utils.git_is_remote_repository(args.git_command, external_repo_url_to_clone):
standard_official_repo_name = ""
if directory_name == "addons":
standard_official_repo_name = "blender-addons"
elif directory_name == "addons_contrib":
standard_official_repo_name = "blender-addons-contrib"
# This case implies actual_repo_name was something other than "blender-addons-contrib"
# (e.g. a custom fork name that wasn't found).

if standard_official_repo_name:
print(f"Forked repository {external_repo_url_to_clone} (derived from your 'origin' remote and repo name '{actual_repo_name}') not found.")
print(f"Falling back to official Blender repository for {directory_name}: {standard_official_repo_name}.")
if directory_name == "addons_contrib" and standard_official_repo_name == "blender-addons-contrib":
external_repo_url_to_clone = "https://github.com/blender/blender-addons-contrib"
else:
official_blender_base_url = "https://projects.blender.org/blender/blender"
external_repo_url_to_clone = resolve_external_url(official_blender_base_url, standard_official_repo_name)
# When cloning the official repo as a fallback, name the remote 'upstream' in the sub-repo.
# This helps 'external_script_add_origin_if_needed' to correctly set up 'origin' for the user's fork later.
remote_name_for_clone = "upstream"
else:
sys.stderr.write(f"Warning: Could not determine standard repo name for {directory_name} during fallback. Will attempt to clone {external_repo_url_to_clone} as is.\n")
call((args.git_command, "clone", "--origin", remote_name_for_clone, external_repo_url_to_clone, str(external_dir)))


def external_script_add_origin_if_needed(args: argparse.Namespace,
repo_name: str,
actual_repo_name: str,
directory_name: str) -> None:
"""
Add remote called 'origin' if there is a fork of the external repository available
Expand All @@ -349,7 +409,7 @@ def external_script_add_origin_if_needed(args: argparse.Namespace,
external_dir = scripts_dir / directory_name

origin_blender_url = make_utils.git_get_remote_url(args.git_command, "origin")
origin_external_url = resolve_external_url(origin_blender_url, repo_name)
origin_external_url = resolve_external_url(origin_blender_url, actual_repo_name)

try:
os.chdir(external_dir)
Expand Down Expand Up @@ -391,15 +451,15 @@ def external_script_add_origin_if_needed(args: argparse.Namespace,


def external_scripts_update(args: argparse.Namespace,
repo_name: str,
actual_repo_name: str,
directory_name: str,
branch: Optional[str]) -> str:
"""Update a single external checkout with the given name in the scripts folder"""

external_script_initialize_if_needed(args, repo_name, directory_name)
external_script_add_origin_if_needed(args, repo_name, directory_name)
external_script_initialize_if_needed(args, actual_repo_name, directory_name)
external_script_add_origin_if_needed(args, actual_repo_name, directory_name)

print(f"Updating scripts/{directory_name} ...")
print(f"Updating scripts/{directory_name} (from repository '{actual_repo_name}')...")

cwd = os.getcwd()

Expand Down Expand Up @@ -469,8 +529,12 @@ def scripts_submodules_update(args: argparse.Namespace, branch: Optional[str]) -
"""Update working trees of addons and addons_contrib within the scripts/ directory"""
msg = ""

msg += external_scripts_update(args, "blender-addons", "addons", branch)
msg += external_scripts_update(args, "blender-addons-contrib", "addons_contrib", branch)
# Use the repository names provided by arguments or their defaults.
addons_repo_name = args.addons_repo_name
addons_contrib_repo_name = args.addons_contrib_repo_name

msg += external_scripts_update(args, addons_repo_name, "addons", branch)
msg += external_scripts_update(args, addons_contrib_repo_name, "addons_contrib", branch)

return msg

Expand All @@ -486,6 +550,24 @@ def submodules_update(args: argparse.Namespace, branch: Optional[str]) -> str:

if __name__ == "__main__":
args = parse_arguments()
# ---- ADD DEBUG PRINT ----
print("---- DEBUG make_update.py: Raw sys.argv ----")
print(sys.argv)
print("---- DEBUG make_update.py: Parsed arguments ----")
print(f"args.no_libraries: {args.no_libraries}")
print(f"args.no_blender: {args.no_blender}")
print(f"args.no_submodules: {args.no_submodules}")
print(f"args.use_tests: {args.use_tests}")
print(f"args.svn_command: {args.svn_command}")
print(f"args.svn_branch: {args.svn_branch}") # This is the crucial one
print(f"args.git_command: {args.git_command}")
print(f"args.use_linux_libraries: {args.use_linux_libraries}")
print(f"args.architecture: {args.architecture}")
print(f"args.windows_vc_version: {args.windows_vc_version}")
print(f"args.addons_repo_name: {args.addons_repo_name}")
print(f"args.addons_contrib_repo_name: {args.addons_contrib_repo_name}")
print("---- /DEBUG ----")
# ---- END DEBUG PRINT ----
blender_skip_msg = ""
submodules_skip_msg = ""

Expand Down
25 changes: 18 additions & 7 deletions build_files/utils/make_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,25 @@ def git_branch_release_version(branch: str, tag: Optional[str]) -> Optional[str]
return release_version


def svn_libraries_base_url(release_version: Optional[str], branch: Optional[str] = None) -> str:
if release_version:
svn_branch = "tags/blender-" + release_version + "-release"
elif branch:
svn_branch = "branches/" + branch
def svn_libraries_base_url(release_version: Optional[str], branch_override: Optional[str] = None) -> str:
# Determine the final segment of the SVN path (e.g., "trunk", "tags/blender-4.1-release", "branches/my-feature")
final_branch_segment = ""
if branch_override:
# If a specific branch/tag path is provided, use it directly.
# Assumes branch_override is a full path like "tags/..." or "branches/..." or "trunk".
if branch_override.startswith("tags/") or branch_override.startswith("branches/") or branch_override == "trunk":
final_branch_segment = branch_override
else:
# If it's a simple name, assume it's a feature branch under "branches/".
# This might need refinement if simple names can also be tags not following the full path.
final_branch_segment = "branches/" + branch_override
elif release_version:
# If no override, but a release version is known, construct the tag path.
final_branch_segment = "tags/blender-" + release_version + "-release"
else:
svn_branch = "trunk"
return "https://svn.blender.org/svnroot/bf-blender/" + svn_branch + "/lib/"
# Default to trunk if no override and no release version.
final_branch_segment = "trunk"
return "https://svn.blender.org/svnroot/bf-blender/" + final_branch_segment + "/lib/"


def command_missing(command: str) -> bool:
Expand Down
69 changes: 46 additions & 23 deletions build_files/windows/check_libraries.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
if "%BUILD_VS_YEAR%"=="2019" set BUILD_VS_LIBDIRPOST=vc15
if "%BUILD_VS_YEAR%"=="2022" set BUILD_VS_LIBDIRPOST=vc15
REM Goo Engine is based on Blender 4.1, which uses vc15 libraries for Windows.
REM This should be set regardless of the BUILD_VS_YEAR (host compiler).
echo Note: Forcing library type to vc15 for Goo Engine (Blender 4.1 base).
set BUILD_VS_LIBDIRPOST=vc15

set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%"
Expand All @@ -10,35 +12,56 @@ if NOT "%verbose%" == "" (
if NOT EXIST %BUILD_VS_LIBDIR% (
rem libs not found, but svn is on the system
if not "%SVN%"=="" (
echo.
echo The required external libraries in %BUILD_VS_LIBDIR% are missing
echo.
set /p GetLibs= "Would you like to download them? (y/n)"
if /I "!GetLibs!"=="Y" (
if "%BUILD_UPDATE%" == "1" (
echo.
echo Downloading %BUILD_VS_SVNDIR% libraries, please wait.
echo The required external libraries in %BUILD_VS_LIBDIR% are missing.
echo The 'make update' process will attempt to download/update them shortly.
echo.
:RETRY
"%SVN%" checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/%BUILD_VS_SVNDIR% %BUILD_VS_LIBDIR%
if errorlevel 1 (
set /p LibRetry= "Error during download, retry? y/n"
if /I "!LibRetry!"=="Y" (
cd %BUILD_VS_LIBDIR%
"%SVN%" cleanup
cd %BLENDER_DIR%
goto RETRY
)
REM Do not exit with an error; let make_update.py handle it by exiting this script successfully.
goto :EOF
) else (
echo.
echo The required external libraries in %BUILD_VS_LIBDIR% are missing.
echo.
set /p GetLibs= "Would you like to download them now? (y/n) "
if /I "!GetLibs!"=="Y" (
echo.
echo Error: Download of external libraries failed.
echo This is needed for building, please manually run 'svn cleanup' and 'svn update' in
echo %BUILD_VS_LIBDIR% , until this is resolved you CANNOT make a successful blender build
echo Downloading %BUILD_VS_SVNDIR% libraries from SVN TRUNK, please wait.
echo Note: If your current Blender source is a release version, this might fetch libraries
echo from an incorrect location. For robust library fetching, especially for
echo release versions, prefer using 'make update'.
echo.
exit /b 1
:RETRY
REM Ensure the parent directory for libs exists
if NOT EXIST "%BLENDER_DIR%..\lib" mkdir "%BLENDER_DIR%..\lib"
"%SVN%" checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/%BUILD_VS_SVNDIR% %BUILD_VS_LIBDIR%
if errorlevel 1 (
set /p LibRetry= "Error during download, retry? (y/n) "
if /I "!LibRetry!"=="Y" (
if EXIST %BUILD_VS_LIBDIR% (
echo Trying to cleanup %BUILD_VS_LIBDIR% ...
pushd %BUILD_VS_LIBDIR%
"%SVN%" cleanup
popd
echo Removing potentially incomplete directory %BUILD_VS_LIBDIR% for fresh checkout attempt.
rd /s /q %BUILD_VS_LIBDIR%
) else (
echo Target directory %BUILD_VS_LIBDIR% was not created.
)
goto RETRY
)
echo.
echo Error: Download of external libraries failed.
echo This is needed for building. Please ensure SVN is configured correctly
echo and you have network access to the Blender SVN repository.
echo.
exit /b 1
)
)
)
)
) else (
if NOT EXIST %PYTHON% (
if NOT EXIST "%PYTHON%" (
if not "%SVN%"=="" (
echo.
echo Python not found in external libraries, updating to latest version
Expand Down
10 changes: 9 additions & 1 deletion build_files/windows/update_sources.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ if NOT EXIST %PYTHON% (
:detect_python_done

REM Use -B to avoid writing __pycache__ in lib directory and causing update conflicts.
%PYTHON% -B %BLENDER_DIR%\build_files\utils\make_update.py --git-command "%GIT%" --svn-command "%SVN%" %BUILD_UPDATE_ARGS%
echo ---- DEBUG update_sources.cmd: Arguments being passed to make_update.py ----
echo Python exe: %PYTHON%
echo Script: %BLENDER_DIR%\build_files\utils\make_update.py
echo Fixed Args: --git-command "%GIT%" --svn-command "%SVN%"
echo BUILD_UPDATE_ARGS: %BUILD_UPDATE_ARGS%
echo Star Args (from make.bat call to this script): %*
echo Full command to python: %PYTHON% -B %BLENDER_DIR%\build_files\utils\make_update.py --git-command "%GIT%" --svn-command "%SVN%" %BUILD_UPDATE_ARGS% %*
echo ---- /DEBUG ----
%PYTHON% -B %BLENDER_DIR%\build_files\utils\make_update.py --git-command "%GIT%" --svn-command "%SVN%" %BUILD_UPDATE_ARGS% %*

:EOF
23 changes: 10 additions & 13 deletions intern/cycles/scene/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "util/task.h"
#include "util/texture.h"
#include "util/unique_ptr.h"
#include <cmath>


#ifdef WITH_OSL
# include <OSL/oslexec.h>
Expand All @@ -28,19 +30,14 @@ CCL_NAMESPACE_BEGIN

namespace {

/* Some helpers to silence warning in templated function. */
bool isfinite(uchar /*value*/)
{
return true;
}
bool isfinite(half /*value*/)
{
return true;
}
bool isfinite(uint16_t /*value*/)
{
return true;
}
// Do NOT add 'using std::isfinite;' here!

// Only keep the overloads that are needed and the template for integrals.
bool isfinite(half /*value*/) { return true; }
inline bool isfinite(float value) { return std::isfinite(value); }
inline bool isfinite(double value) { return std::isfinite(value); }
template<typename T>
inline std::enable_if_t<std::is_integral_v<T>, bool> isfinite(T) { return true; }

const char *name_from_type(ImageDataType type)
{
Expand Down
Loading