def get_environment(): from setuptools.msvc import (msvc9_query_vcvarsall, EnvironmentInfo, msvc14_get_vc_env) py_version = sys.version_info[:2] if py_version >= (3, 5): env = msvc14_get_vc_env(ARCH) msbuild_version = 14.0 env_info = EnvironmentInfo(ARCH) msbuild_path = _find_file('MSBuild.exe', env_info.MSBuild[0])[0] sdks = ('10.0', '8.1', '8.1A', '8.0', '8.0A') solution_dest = 'vs2015' elif (3, 5) > py_version >= (3, 3): env = msvc9_query_vcvarsall(10.0, ARCH) msbuild_version = 4.0 msbuild_path = _get_reg_value('MSBuild\\4.0', 'MSBuildOverrideTasksPath') if msbuild_path: msbuild_path = _find_file('MSBuild.exe', msbuild_path)[0] sdks = ('7.1', '7.0A') solution_dest = 'vs2010' elif (3, 3) > py_version >= (2, 6): env = msvc9_query_vcvarsall(9.0, ARCH) msbuild_version = 4.0 msbuild_path = _get_reg_value('MSBuild\\4.0', 'MSBuildOverrideTasksPath') if msbuild_path: msbuild_path = _find_file('MSBuild.exe', msbuild_path)[0] sdks = ('6.1', '6.1A', '6.0A') solution_dest = 'vs2008' else: raise RuntimeError( 'This library does not support python versions < 2.6') for sdk in sdks: sdk_version = _get_reg_value('Microsoft SDKs\\Windows\\v' + sdk, 'ProductVersion') if sdk_version: sdk_installation_folder = _get_reg_value( 'Microsoft SDKs\\Windows\\v' + sdk, 'InstallationFolder') target_platform = sdk_version os.environ['WindowsSdkDir'] = sdk_installation_folder break else: raise RuntimeError('Unable to locate suitable SDK %s' % (sdks, )) platform_toolset, tools_version = TOOLSETS[msbuild_version] return (env, msbuild_version, msbuild_path, sdk_installation_folder, target_platform, platform_toolset, tools_version, solution_dest)
def build_wrapper_library_windows(runtime_library, msvs, vcvars): # When building library cmake variables file is being modified # for the /MD build. If the build fails and variables aren't # restored then the next /MT build would be broken. Make sure # that original contents of cmake variables files is always # restored. fix_cmake_variables_for_MD_library(try_undo=True) # Command to build libcef_dll_wrapper cmake_wrapper = prepare_build_command(build_lib=True, vcvars=vcvars) cmake_wrapper.extend(["cmake", "-G", "Ninja", "-DCMAKE_BUILD_TYPE="+Options.build_type, ".."]) # Build directory and library path build_wrapper_dir = os.path.join( Options.cef_binary, "build_wrapper_{runtime_library}_VS{msvs}" .format(runtime_library=runtime_library, msvs=msvs)) wrapper_lib = os.path.join(build_wrapper_dir, "libcef_dll_wrapper", "libcef_dll_wrapper{ext}".format(ext=LIB_EXT)) # Check whether library is already built mt_already_built = False if os.path.exists(wrapper_lib): mt_already_built = True elif os.path.exists(build_wrapper_dir): # Last build failed, clean directory assert build_wrapper_dir shutil.rmtree(build_wrapper_dir) os.makedirs(build_wrapper_dir) else: os.makedirs(build_wrapper_dir) # Build library if mt_already_built: print("[automate.py] Already built: libcef_dll_wrapper" " /{runtime_library} for VS{msvs}" .format(runtime_library=runtime_library, msvs=msvs)) else: print("[automate.py] Build libcef_dll_wrapper" " /{runtime_library} for VS{msvs}" .format(runtime_library=runtime_library, msvs=msvs)) # Run cmake old_gyp_msvs_version = Options.gyp_msvs_version Options.gyp_msvs_version = msvs if runtime_library == RUNTIME_MD: fix_cmake_variables_for_MD_library() env = getenv() if msvs == "2010": # When Using WinSDK 7.1 vcvarsall.bat doesn't work. Use # setuptools.msvc.msvc9_query_vcvarsall to query env vars. env.update(msvc9_query_vcvarsall(10.0, arch=VS_PLATFORM_ARG)) # On Python 2.7 env values returned by both distutils # and setuptools are unicode, but Python expects env # dict values as strings. for env_key in env: env_value = env[env_key] if type(env_value) != str: env[env_key] = env_value.encode("utf-8") run_command(cmake_wrapper, working_dir=build_wrapper_dir, env=env) Options.gyp_msvs_version = old_gyp_msvs_version if runtime_library == RUNTIME_MD: fix_cmake_variables_for_MD_library(undo=True) print("[automate.py] cmake OK") # Run ninja ninja_wrapper = prepare_build_command(build_lib=True, vcvars=vcvars) ninja_wrapper.extend(["ninja", "-j", Options.ninja_jobs, "libcef_dll_wrapper"]) run_command(ninja_wrapper, working_dir=build_wrapper_dir) print("[automate.py] ninja OK") assert os.path.exists(wrapper_lib)
def build_wrapper_library_windows(runtime_library, msvs, vcvars): # When building library cmake variables file is being modified # for the /MD build. If the build fails and variables aren't # restored then the next /MT build would be broken. Make sure # that original contents of cmake variables files is always # restored. fix_cmake_variables_for_MD_library(try_undo=True) # Command to build libcef_dll_wrapper cmake_wrapper = prepare_build_command(build_lib=True, vcvars=vcvars) cmake_wrapper.extend([ "cmake", "-G", "Ninja", "-DCMAKE_BUILD_TYPE=" + Options.build_type, ".." ]) # Build directory and library path build_wrapper_dir = os.path.join( Options.cef_binary, "build_wrapper_{runtime_library}_VS{msvs}".format( runtime_library=runtime_library, msvs=msvs)) wrapper_lib = os.path.join(build_wrapper_dir, "libcef_dll_wrapper", "libcef_dll_wrapper{ext}".format(ext=LIB_EXT)) # Check whether library is already built mt_already_built = False if os.path.exists(wrapper_lib): mt_already_built = True elif os.path.exists(build_wrapper_dir): # Last build failed, clean directory assert build_wrapper_dir shutil.rmtree(build_wrapper_dir) os.makedirs(build_wrapper_dir) else: os.makedirs(build_wrapper_dir) # Build library if mt_already_built: print("[automate.py] Already built: libcef_dll_wrapper" " /{runtime_library} for VS{msvs}".format( runtime_library=runtime_library, msvs=msvs)) else: print("[automate.py] Build libcef_dll_wrapper" " /{runtime_library} for VS{msvs}".format( runtime_library=runtime_library, msvs=msvs)) # Run cmake old_gyp_msvs_version = Options.gyp_msvs_version Options.gyp_msvs_version = msvs if runtime_library == RUNTIME_MD: fix_cmake_variables_for_MD_library() env = getenv() if msvs == "2010": # When Using WinSDK 7.1 vcvarsall.bat doesn't work. Use # setuptools.msvc.msvc9_query_vcvarsall to query env vars. env.update(msvc9_query_vcvarsall(10.0, arch=VS_PLATFORM_ARG)) # On Python 2.7 64-bit env values returned by setuptools # are unicode. On 32-bit they are strings. for env_key in env: env_value = env[env_key] if type(env_value) != str: env[env_key] = env_value.encode("utf-8") run_command(cmake_wrapper, working_dir=build_wrapper_dir, env=env) Options.gyp_msvs_version = old_gyp_msvs_version if runtime_library == RUNTIME_MD: fix_cmake_variables_for_MD_library(undo=True) print("[automate.py] cmake OK") # Run ninja ninja_wrapper = prepare_build_command(build_lib=True, vcvars=vcvars) ninja_wrapper.extend(["ninja", "libcef_dll_wrapper"]) run_command(ninja_wrapper, working_dir=build_wrapper_dir) print("[automate.py] ninja OK") assert os.path.exists(wrapper_lib)
if OS_X_ver > 7: path = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/' + \ 'SDKs/MacOSX10.%d.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers/' % OS_X_ver CyOpenGL_includes += [path] CyOpenGL_includes += ['/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers/'] CyOpenGL_extra_link_args = ['-framework', 'OpenGL'] CyOpenGL_extra_link_args += macOS_link_args elif sys.platform == 'linux2' or sys.platform == 'linux': CyOpenGL_includes += ['/usr/include/GL'] CyOpenGL_libs += ['GL'] elif sys.platform == 'win32': if cc == 'msvc': include_dirs = [] if sys.version_info.major == 2: from setuptools.msvc import msvc9_query_vcvarsall includes = msvc9_query_vcvarsall(9.0)['include'].split(';') include_dirs += includes include_dirs += [os.path.join(path, 'gl') for path in includes] elif sys.version_info.major == 3 and sys.version_info.minor == 4: from distutils.msvc9compiler import query_vcvarsall includes = query_vcvarsall(10.0)['include'].split(';') include_dirs += includes if sys.maxsize <= 2**32: include_dirs += [os.path.join(path, 'gl') for path in includes] elif sys.version_info.major == 3 and sys.version_info.minor > 4: from distutils.msvc9compiler import query_vcvarsall includes = query_vcvarsall(14.0)['include'].split(';') include_dirs += includes include_dirs += [os.path.join(path, 'gl') for path in includes] CyOpenGL_includes += include_dirs CyOpenGL_extras += ['opengl32.lib']