コード例 #1
0
def load_win_x64_win_x64_vs2015_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all win_x64_win_x64 configurations
    """
    v = conf.env

    global PLATFORM

    # Add defines to indicate a win64 build
    v['DEFINES'] += ['_WIN32', '_WIN64', 'NOMINMAX']

    # Make sure this is a supported platform
    if PLATFORM not in conf.get_supported_platforms():
        return

    # Attempt to detect the C++ compiler for VS 2015 ( msvs version 14.0 )
    windows_kit = conf.options.win_vs2015_winkit
    try:
        conf.auto_detect_msvc_compiler('msvc 14.0', 'x64', windows_kit)
    except:
        Logs.warn(
            'Unable to find Visual Studio 2015 C++ compiler and/or Windows Kit {}, removing build target'
            .format(windows_kit))
        conf.mark_supported_platform_for_removal(PLATFORM)
        return

    # Detect the QT binaries
    conf.find_qt5_binaries(PLATFORM)

    # Introduce the linker to generate 64 bit code
    v['LINKFLAGS'] += ['/MACHINE:X64']
    v['ARFLAGS'] += ['/MACHINE:X64']

    VS2015_FLAGS = [
        '/FS',  # Fix for issue writing to pdb files
        '/Wv:18'  # Stick with 2013 warnings for the time being...
    ]

    v['CFLAGS'] += VS2015_FLAGS
    v['CXXFLAGS'] += VS2015_FLAGS

    if conf.options.use_uber_files:
        v['CFLAGS'] += ['/bigobj']
        v['CXXFLAGS'] += ['/bigobj']

    azcg_dir = conf.Path('Tools/AzCodeGenerator/bin/vc140')
    if not os.path.exists(azcg_dir):
        conf.fatal(
            'Unable to locate the AzCodeGenerator subfolder.  Make sure that you have VS2015 AzCodeGenerator binaries available'
        )
    v['CODE_GENERATOR_PATH'] = [azcg_dir]

    crcfix_dir = conf.Path('Tools/crcfix/bin/vc140')
    if not os.path.exists(crcfix_dir):
        Logs.warn(
            'Unable to locate the crcfix subfolder.  Make sure that you have VS2015 crcfix binaries available'
        )
    v['CRCFIX_PATH'] = [crcfix_dir]

    conf.find_dx12(windows_kit)
コード例 #2
0
def load_win_x64_win_x64_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all win_x64_win_x64 configurations
    """
    v = conf.env

    # Add defines to indicate a win64 build
    v['DEFINES'] += ['_WIN32', '_WIN64', 'NOMINMAX']

    # currently only the Visual Studio 2013 tool chain can build the win x64 target platform
    # Once we can compile across multiple ranges, enable the min and max versions properly
    try:
        conf.auto_detect_msvc_compiler('msvc 12.0', 'x64')
    except:
        if 'win_x64' in conf.get_supported_platforms():
            Logs.warn(
                'Unable to find Visual Studio 2013 for win_x64, removing build target'
            )
            conf.mark_supported_platform_for_removal('win_x64')
        return

    # Introduce the linker to generate 64 bit code
    v['LINKFLAGS'] += ['/MACHINE:X64']
    v['ARFLAGS'] += ['/MACHINE:X64']

    VS2013_FLAGS = [
        '/FS'  # Fix for issue writing to pdb files
    ]

    v['CFLAGS'] += VS2013_FLAGS
    v['CXXFLAGS'] += VS2013_FLAGS

    if conf.options.use_uber_files:
        v['CFLAGS'] += ['/bigobj']
        v['CXXFLAGS'] += ['/bigobj']
コード例 #3
0
def load_win_x64_win_x64_vs2013_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all win_x64_win_x64 configurations
    """
    v = conf.env

    global PLATFORM

    # Add defines to indicate a win64 build
    v['DEFINES'] += ['_WIN32', '_WIN64', 'NOMINMAX']

    # Make sure this is a supported platform
    if PLATFORM not in conf.get_supported_platforms():
        return

    # Attempt to detect the C++ compiler for VS 2013 ( msvs version 12.0 )
    try:
        conf.auto_detect_msvc_compiler('msvc 12.0', 'x64')
    except:
        Logs.warn(
            'Unable to detect find the C++ compiler for Visual Studio 2013, removing build target'
        )
        conf.mark_supported_platform_for_removal(PLATFORM)
        return

    # Detect the QT binaries
    conf.find_qt5_binaries(PLATFORM)

    # Introduce the linker to generate 64 bit code
    v['LINKFLAGS'] += ['/MACHINE:X64']
    v['ARFLAGS'] += ['/MACHINE:X64']

    VS2013_FLAGS = [
        '/FS',  # Fix for issue writing to pdb files
        '/Zo'  # Enhanced optimized debugging (increases pdb size but has no effect on code size and improves debugging) - this is enabled by default for vs2015.
    ]

    v['CFLAGS'] += VS2013_FLAGS
    v['CXXFLAGS'] += VS2013_FLAGS

    if conf.options.use_uber_files:
        v['CFLAGS'] += ['/bigobj']
        v['CXXFLAGS'] += ['/bigobj']

    azcg_dir = conf.srcnode.make_node(
        'Tools/AzCodeGenerator/bin/vc120').abspath()
    if not os.path.exists(azcg_dir):
        conf.fatal(
            'Unable to locate the AzCodeGenerator subfolder.  Make sure that you have VS2013 AzCodeGenerator binaries available'
        )
    v['CODE_GENERATOR_PATH'] = [azcg_dir]

    crcfix_dir = conf.srcnode.make_node('Tools/crcfix/bin/vc120').abspath()
    if not os.path.exists(crcfix_dir):
        Logs.warn(
            'Unable to locate the crcfix subfolder.  Make sure that you have VS2013 crcfix binaries available'
        )
    v['CRCFIX_PATH'] = [crcfix_dir]
コード例 #4
0
def load_win_x64_win_x64_vs2015_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all win_x64_win_x64 configurations
    """
    v = conf.env

    global PLATFORM

    # Add defines to indicate a win64 build
    v['DEFINES'] += ['_WIN32', '_WIN64', 'NOMINMAX']

    restricted_tool_list_macro_header = 'AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS='
    restricted_tool_list_macro = restricted_tool_list_macro_header
    if len(restricted_tool_list_macro) > len(restricted_tool_list_macro_header):
        v['DEFINES'] += [ restricted_tool_list_macro ]

    # Make sure this is a supported platform
    if PLATFORM not in conf.get_supported_platforms():
        return

    # Attempt to detect the C++ compiler for VS 2015 ( msvs version 14.0 )
    windows_kit = conf.options.win_vs2015_winkit
    try:
        conf.auto_detect_msvc_compiler('msvc 14.0', 'x64', windows_kit)
    except:
        Logs.warn('Unable to find Visual Studio 2015 C++ compiler and/or Windows Kit {}, removing build target'.format(windows_kit))
        conf.mark_supported_platform_for_removal(PLATFORM)
        return

    # Detect the QT binaries, if the current capabilities selected requires it.
    _, enabled, _, _ = conf.tp.get_third_party_path(PLATFORM, 'qt')
    if enabled:
        conf.find_qt5_binaries(PLATFORM)

    # Introduce the linker to generate 64 bit code
    v['LINKFLAGS'] += ['/MACHINE:X64']
    v['ARFLAGS'] += ['/MACHINE:X64']

    VS2015_FLAGS = [
        '/FS'  # Fix for issue writing to pdb files
    ]

    v['CFLAGS'] += VS2015_FLAGS
    v['CXXFLAGS'] += VS2015_FLAGS

    if conf.options.use_uber_files:
        v['CFLAGS'] += ['/bigobj']
        v['CXXFLAGS'] += ['/bigobj']

    crcfix_dir = conf.Path('Tools/crcfix/bin/vc140')
    if not os.path.exists(crcfix_dir):
        Logs.warn('Unable to locate the crcfix subfolder.  Make sure that you have VS2015 crcfix binaries available')
    v['CRCFIX_PATH'] = [crcfix_dir]

    conf.find_dx12(windows_kit)
コード例 #5
0
ファイル: lumberyard_sdks.py プロジェクト: xxyzfd/lumberyard
def copy_local_python_to_target(task, source_python_dll_path):
    """
    Perform a quick simple copy of python.dll from a local python folder

    :param task:                    The current running task
    :param source_python_dll_path:  The source python path
    """
    current_platform = task.env['PLATFORM'].lower()
    current_configuration = task.env['CONFIGURATION'].lower()

    # Determine the target folder(s)
    output_sub_folder = getattr(task, 'output_sub_folder', None)

    # If we have a custom output folder, then make a list of nodes from it
    target_folders = getattr(task, 'output_folder', [])
    if len(target_folders) > 0:
        target_folders = [
            task.bld.path.make_node(node) if isinstance(node, str) else node
            for node in target_folders
        ]
    else:
        target_folders = task.bld.get_output_folders(current_platform,
                                                     current_configuration)

    python_name = os.path.basename(source_python_dll_path)

    # Copy to each output folder target node
    for target_node in target_folders:

        python_dll_target_path = os.path.join(target_node.abspath(),
                                              python_name)
        if output_sub_folder:
            python_dll_target_path = os.path.join(
                target_node.make_node(output_sub_folder).abspath(),
                python_name)
        if should_overwrite_file(source_python_dll_path,
                                 python_dll_target_path):
            try:
                # In case the file is readonly, we'll remove the existing file first
                if os.path.exists(python_dll_target_path):
                    os.chmod(python_dll_target_path, stat.S_IWRITE)
                fast_copy2(source_python_dll_path, python_dll_target_path)
            except Exception as e:
                Logs.warn(
                    '[WARN] Unable to copy {} to destination {} ({}).  '
                    'Check the file permissions or any process that may be locking it.'
                    .format(python_dll_target_path, python_dll_target_path,
                            e.message))
コード例 #6
0
def load_win_x64_win_x64_vs2010_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all win_x64_win_x64_vs2010 configurations
    """
    try:
        conf.auto_detect_msvc_compiler('msvc 10.0', 'x64')
    except:
        if 'win_x64_vs2010' in conf.get_supported_platforms():
            Logs.warn(
                'Unable to find Visual Studio 2010, removing build target')
            conf.mark_supported_platform_for_removal('win_x64_vs2010')
        return

    v = conf.env

    # Add defines to indicate a win64 build
    v['DEFINES'] += ['_WIN32', '_WIN64', 'NOMINMAX']

    # Introduce the linker to generate 64 bit code
    v['LINKFLAGS'] += ['/MACHINE:X64']
    v['ARFLAGS'] += ['/MACHINE:X64']
コード例 #7
0
    def sync_3rd_party(self, third_party_subpath):

        Logs.info("[INFO] Syncing library {} from perforce...".format(
            third_party_subpath))
        try:
            timer = Utils.Timer()

            sync_proc = subprocess.Popen([
                self.p4_exe, '-p', self.p4_port, '-c', self.p4_workspace,
                'sync', '-f', "{}/{}/...".format(
                    self.p4_repo, third_party_subpath.rstrip('/'))
            ],
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE)
            sync_out, sync_err = sync_proc.communicate()
            if not sync_err:
                Logs.info("[INFO] Library {} synced.  ({})".format(
                    third_party_subpath, str(timer)))

        except OSError as err:
            Logs.warn("[WARN] Unable to sync 3rd party path {}: {}".format(
                third_party_subpath, str(err)))
コード例 #8
0
    def __init__(self, local_3rd_party_root, config_file):
        """
        Initialize the sync settings object to a config file.  This will also attempt to connect to the perforce host
        via the settings if any to determine the local workspace root as well.  If all goes well, then the object
        will be marked as valid (see is_valid())
        """
        self.valid = False

        if not os.path.exists(config_file):
            return

        try:
            config_parser = ConfigParser.ConfigParser()
            config_parser.read(config_file)

            self.p4_exe = config_parser.get(P4_SYNC_CONFIG_SECTION,
                                            P4_SYNC_CONFIG_EXECUTABLE)
            self.p4_port = config_parser.get(P4_SYNC_CONFIG_SECTION,
                                             P4_SYNC_CONFIG_HOST_PORT)
            self.p4_workspace = config_parser.get(P4_SYNC_CONFIG_SECTION,
                                                  P4_SYNC_CONFIG_WORKSPACE)
            self.p4_repo = config_parser.get(P4_SYNC_CONFIG_SECTION,
                                             P4_SYNC_CONFIG_REPOSITORY)
        except ConfigParser.Error as err:
            Logs.warn(
                '[WARN] Error reading p4 sync settings file {}.  ({}).  '
                'Missing 3rd party libraries will not be synced from perforce'.
                format(config_file, str(err)))
            return

        try:
            proc = subprocess.Popen([
                self.p4_exe, '-p', self.p4_port, 'client', '-o',
                self.p4_workspace
            ],
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
            for line in iter(proc.stdout.readline, b''):
                if line.startswith("Root:"):
                    self.client_root = line.replace("Root:", "").strip()
                    break
        except OSError as err:
            Logs.warn(
                '[WARN] Invalid values in the p4 sync settings file {}.  ({}).  '
                'Missing 3rd party libraries will not be synced from perforce'.
                format(config_file, str(err)))
            return

        normalized_client_root = os.path.normcase(self.client_root)
        normalized_3rd_party_root = os.path.normcase(local_3rd_party_root)
        if not normalized_3rd_party_root.startswith(normalized_client_root):
            Logs.warn(
                '[WARN] Local 3rd Party root ({}) does not match the root from workspace "{}" ({})'
                'Missing 3rd party libraries will not be synced from perforce'.
                format(local_3rd_party_root, self.p4_workspace,
                       self.client_root))
            return
        self.valid = True
コード例 #9
0
def find_dx12(conf, windows_kit):
    global DX12_INCLUDE_DIR
    global DX12_LIB_DIR
    if not windows_kit in DX12_INCLUDE_DIR:
        DX12_INCLUDE_DIR[windows_kit] = None
    if not windows_kit in DX12_LIB_DIR:
        DX12_LIB_DIR[windows_kit] = None
    if (DX12_INCLUDE_DIR[windows_kit] is None) or (DX12_LIB_DIR[windows_kit] is None):
        DX12_INCLUDE_DIR[windows_kit] = []   # set to empty, will prevent this part of the function from running more than once even if nothing is found
        DX12_LIB_DIR[windows_kit] = []
        v = conf.env
        includes = v['INCLUDES']
        libs = v['LIBPATH']

        for path in includes:
            if windows_kit in path:
                for root, dirs, files in os.walk(path):
                    if 'd3d12.h' in files:
                        DX12_INCLUDE_DIR[windows_kit] = root
                        break
                if DX12_INCLUDE_DIR[windows_kit]:
                    break

        # this is expensive, so only do it if the include was also found
        if DX12_INCLUDE_DIR[windows_kit]:
            for path in libs:
                if windows_kit in path:
                    for root, dirs, files in os.walk(path):
                        if 'd3d12.lib' in files:
                            Logs.warn('[DX12] libraries found, can compile for DX12')
                            DX12_LIB_DIR[windows_kit] = root
                            break
                    if DX12_LIB_DIR[windows_kit]:
                        break
    conf.env['DX12_INCLUDES'] = DX12_INCLUDE_DIR[windows_kit]
    conf.env['DX12_LIBPATH'] = DX12_LIB_DIR[windows_kit]
コード例 #10
0
def enable_embedded_python(self):
    # Only win_x64 builds support embedding Python.
    #
    # We assume 'project_generator' (the result of doing a lmbr_waf configure) is
    # also for a win_x64 build so that the include directory is configured property
    # for Visual Studio.

    platform = self.env['PLATFORM'].lower()
    config = self.env['CONFIGURATION'].lower()

    if platform in ['win_x64_vs2013', 'win_x64_vs2015', 'win_x64_test', 'linux_x64', 'project_generator']:

        # Set the USE_DEBUG_PYTHON environment variable to the location of
        # a debug build of python if you want to use one for debug builds.
        #
        # This does NOT work with the boost python helpers, which are used
        # by the Editor, since the boost headers always undef _DEBUG before
        # including the python headers.
        #
        # Any code that includes python headers directly should also undef
        # _DEBUG before including those headers except for when USE_DEBUG_PYTHON
        # is defined.

        if 'debug' in config and 'USE_DEBUG_PYTHON' in os.environ:

            python_home = os.environ['USE_DEBUG_PYTHON']
            python_dll = '{}/python27_d.dll'.format(python_home)

            self.env['DEFINES'] += ['USE_DEBUG_PYTHON']

        else:
            python_home, python_include_dir, python_libs_dir, python_dll = get_python_home_lib_and_dll(self.bld,
                                                                                                       platform)

        self.includes += [python_include_dir]
        self.env['LIBPATH'] += [python_libs_dir]

        # Save off the python home for use from within code (BoostPythonHelpers.cpp).  This allows us to control exactly which version of
        # python the editor uses.
        # Also, standardize on forward-slash through the entire path.  We specifically don't use backslashes to avoid an interaction with compiler
        # response-file generation in msvcdeps.py and mscv_helper.py that "fixes up" all the compiler flags, in part by replacing backslashes
        # with double-backslashes.  If we tried to replace backslashes with double-backslashes here to make it a valid C++ string, it would
        # get double-fixed-up in the case that a response file gets used (long directory path names).
        # Side note - BoostPythonHelpers.cpp, which uses this define, apparently goes through and replaces forward-slashes with backslashes anyways.
        if python_home.startswith(self.bld.engine_path):
            python_home_define = '@root@{}'.format(python_home[len(self.bld.engine_path):])
        else:
            python_home_define = python_home

        self.env['DEFINES'] += ['DEFAULT_LY_PYTHONHOME="{}"'.format(python_home_define.replace('\\', '/'))]
        if 'LIBPATH_BOOSTPYTHON' in self.env:
            self.env['LIBPATH'] += self.env['LIBPATH_BOOSTPYTHON']
        elif self.env['PLATFORM'] != 'project_generator':
            Logs.warn(
                '[WARN] Required 3rd party boostpython not detected.  This may cause a link error in project {}.'.format(
                    self.name))

    if platform in ['darwin_x64']:
        _, python_include_dir, python_libs_dir, _ = get_python_home_lib_and_dll(self.bld, platform)

        # TODO: figure out what needs to be set for OSX builds.
        self.includes += [python_include_dir]
        self.env['LIBPATH'] += [python_libs_dir]
コード例 #11
0
def load_win_x64_win_x64_clang_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all win_x64_win_x64 configurations
    """
    v = conf.env

    global PLATFORM

    # Load MSVC settings for non-build stuff (AzCG, CrcFix, etc)
    load_win_x64_win_x64_vs2015_common_settings(conf)

    windows_kit = conf.options.win_vs2015_winkit
    try:
        _, _, _, system_includes, _, _ = conf.detect_msvc(windows_kit, True)
    except:
        Logs.warn(
            'Unable to find Windows Kit {}, removing build target'.format(
                windows_kit))
        conf.mark_supported_platform_for_removal(PLATFORM)
        return

    restricted_tool_list_macro_header = 'AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS='
    restricted_tool_list_macro = restricted_tool_list_macro_header

    # Start with a blank platform slate
    conf.undefine('AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS')
    if len(restricted_tool_list_macro) > len(
            restricted_tool_list_macro_header):
        v['DEFINES'] += [restricted_tool_list_macro]

    # Remove MSVC/clang specific settings
    v['CFLAGS'] = []
    v['CXXFLAGS'] = []
    v['LINKFLAGS'] = []

    # Linker
    v['CCLNK_SRC_F'] = v['CXXLNK_SRC_F'] = []
    v['CCLNK_TGT_F'] = v['CXXLNK_TGT_F'] = '/OUT:'

    v['LIB_ST'] = '%s.lib'
    v['LIBPATH_ST'] = '/LIBPATH:%s'
    v['STLIB_ST'] = '%s.lib'
    v['STLIBPATH_ST'] = '/LIBPATH:%s'

    v['cprogram_PATTERN'] = '%s.exe'
    v['cxxprogram_PATTERN'] = '%s.exe'

    v['cstlib_PATTERN'] = '%s.lib'
    v['cxxstlib_PATTERN'] = '%s.lib'

    v['cshlib_PATTERN'] = '%s.dll'
    v['cxxshlib_PATTERN'] = '%s.dll'

    v['LINKFLAGS_cshlib'] = ['/DLL']
    v['LINKFLAGS_cxxshlib'] = ['/DLL']

    # AR Tools
    v['ARFLAGS'] = ['/NOLOGO']
    v['AR_TGT_F'] = '/OUT:'

    # Delete the env variables so that they can be replaced with the clang versions
    del v['AR']
    del v['CC']
    del v['CXX']
    del v['LINK']
    conf.find_program('clang', var='CC', mandatory=False, silent_output=True)

    if not v['CC']:
        conf.mark_supported_platform_for_removal(PLATFORM)
        Logs.warn('clang executable not found, removing platform {}'.format(
            PLATFORM))
        return

    conf.find_program('clang++', var='CXX', silent_output=True)
    conf.find_program('llvm-lib', var='AR', silent_output=True)
    conf.find_program('lld-link', var='LINK', silent_output=True)

    v['LINK_CC'] = v['LINK_CXX'] = v['LINK']

    clang_FLAGS = [
        '-mcx16',
        '-msse3',
        '-Wno-macro-redefined',
        '-Wno-nonportable-include-path',
        '-Wno-microsoft-cast',
        '-Wno-ignored-pragma-intrinsic',  # Clang doens't need #pragma intrinsic anyway, so don't whine when one isn't recognized
    ]

    # Path to clang.exe is [clang]/bin/clang.exe, but the include path is [clang]/lib/clang/6.0.0/include
    clang_include_path = os.path.join(
        os.path.dirname(os.path.dirname(v['CXX'])), 'lib', 'clang', '6.0.0',
        'include')

    system_includes = [clang_include_path] + system_includes

    # Treat all MSVC include paths as system headers
    for include in system_includes:
        clang_FLAGS += ['-isystem', include]

    v['CFLAGS'] += clang_FLAGS
    v['CXXFLAGS'] += clang_FLAGS
    v['DEFINES'] += [
        '_CRT_SECURE_NO_WARNINGS',
        '_CRT_NONSTDC_NO_WARNINGS',
    ]
    v['LINKFLAGS'] += [
        '/MACHINE:x64',
        '/MANIFEST',  # Create a manifest file
        '/OPT:REF',
        '/OPT:ICF',  # Always optimize for size, there's no reason not to
        '/LARGEADDRESSAWARE',  # tell the linker that the application can handle addresses larger than 2 gigabytes.
    ]
コード例 #12
0
def enable_embedded_python(self):

    # Only win_x64 builds support embedding Python.
    #
    # We assume 'project_generator' (the result of doing a lmbr_waf configure) is
    # also for a win_x64 build so that the include directory is configured property
    # for Visual Studio.

    platform = self.env['PLATFORM'].lower()
    config = self.env['CONFIGURATION'].lower()

    if platform in ['win_x64_vs2013', 'win_x64_vs2015', 'win_x64_test', 'linux_x64', 'project_generator']:

        # Set the USE_DEBUG_PYTHON environment variable to the location of 
        # a debug build of python if you want to use one for debug builds.
        #
        # This does NOT work with the boost python helpers, which are used
        # by the Editor, since the boost headers always undef _DEBUG before 
        # including the python headers.
        #
        # Any code that includes python headers directly should also undef 
        # _DEBUG before including those headers except for when USE_DEBUG_PYTHON 
        # is defined.

        if 'debug' in config and 'USE_DEBUG_PYTHON' in os.environ:
            
            python_home = os.environ['USE_DEBUG_PYTHON']
            python_dll = '{}/python27_d.dll'.format(python_home)

            self.env['DEFINES'] += ['USE_DEBUG_PYTHON']

        else:

            python_version = '2.7.12'
            if platform == 'linux_x64':
                python_variant = 'linux_x64'
                python_libs = 'lib'
                python_dll_name = 'lib/libpython2.7.so'
            else:
                python_variant = 'windows'
                python_libs = 'libs'
                python_dll_name = 'python27.dll'
            python_home = os.path.join('Tools', 'Python', python_version, python_variant)
            python_dll = os.path.join(python_home, python_dll_name)

        python_include_dir = os.path.join(python_home, 'include')

        if platform == 'linux_x64':
            python_include_dir = os.path.join(python_include_dir, 'python2.7')

        python_libs_dir = os.path.join(python_home, python_libs)

        self.includes += [self.bld.CreateRootRelativePath(python_include_dir)]
        self.env['LIBPATH'] += [self.bld.CreateRootRelativePath(python_libs_dir)]

        # Save off the python home for use from within code (BoostPythonHelpers.cpp).  This allows us to control exactly which version of
        # python the editor uses.
        # Also, standardize on forward-slash through the entire path.  We specifically don't use backslashes to avoid an interaction with compiler 
        # response-file generation in msvcdeps.py and mscv_helper.py that "fixes up" all the compiler flags, in part by replacing backslashes 
        # with double-backslashes.  If we tried to replace backslashes with double-backslashes here to make it a valid C++ string, it would
        # get double-fixed-up in the case that a response file gets used (long directory path names).  
        # Side note - BoostPythonHelpers.cpp, which uses this define, apparently goes through and replaces forward-slashes with backslashes anyways.
        self.env['DEFINES'] += ['DEFAULT_LY_PYTHONHOME="@root@/{}"'.format(python_home.replace('\\', '/'))] 
        if 'LIBPATH_BOOSTPYTHON' in self.env:
            self.env['LIBPATH'] += self.env['LIBPATH_BOOSTPYTHON']
        elif self.env['PLATFORM'] != 'project_generator':
            Logs.warn('[WARN] Required 3rd party boostpython not detected.  This may cause a link error in project {}.'.format(self.name))

        # Ideally we would load python27.dll from the python home directory. The best way
        # to do that may be to delay load python27.dll and use SetDllDirectory to insert
        # the python home directory into the DLL search path. However that doesn't work 
        # because the boost python helpers import a data symbol.
        self.source_artifacts_include = getattr(self, 'source_artifacts_include', []) + [python_dll]

    if platform in ['darwin_x64']:
        python_version = '2.7.13'
        python_variant = 'mac'
        python_home = 'Tools/Python/{}/{}/Python.framework'.format(python_version, python_variant)

        python_include_dir = '{}/Headers/'.format(python_home)
        python_lib_dir = '{}/Versions/Current/lib'.format(python_home)

        # TODO: figure out what needs to be set for OSX builds.
        self.includes += [self.bld.CreateRootRelativePath(python_include_dir)]
        self.env['LIBPATH'] += [self.bld.CreateRootRelativePath(python_lib_dir)]
コード例 #13
0
def load_win_x64_clang_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all win_x64_win_x64 configurations
    """
    v = conf.env

    if not conf.find_program('clang', mandatory=False, silent_output=True):
        raise Errors.WafError("Unable to detect Clang for windows")

    v['PLATFORM'] = PLATFORM

    # Load MSVC settings for non-build stuff (AzCG, CrcFix, etc)
    # load_win_x64_win_x64_vs2017_common_settings(conf)
    conf.load_windows_common_settings()

    conf.load_win_x64_vs2017_common_settings()

    windows_kit = conf.options.win_vs2017_winkit
    try:
        # Attempt to detect the C++ compiler for VS 2015 ( msvs version 14.0 )
        ctx.detect_visual_studio_2015(windows_kit)
        system_includes = []
    except:
        Logs.warn(
            'Unable to find Windows Kit {}, removing build target'.format(
                windows_kit))
        conf.disable_target_platform(PLATFORM)
        return

    # Remove MSVC/clang specific settings
    v['CFLAGS'] = []
    v['CXXFLAGS'] = []
    v['LINKFLAGS'] = []

    # Linker
    v['CCLNK_SRC_F'] = v['CXXLNK_SRC_F'] = []
    v['CCLNK_TGT_F'] = v['CXXLNK_TGT_F'] = '/OUT:'

    v['LIB_ST'] = '%s.lib'
    v['LIBPATH_ST'] = '/LIBPATH:%s'
    v['STLIB_ST'] = '%s.lib'
    v['STLIBPATH_ST'] = '/LIBPATH:%s'

    v['cprogram_PATTERN'] = '%s.exe'
    v['cxxprogram_PATTERN'] = '%s.exe'

    v['cstlib_PATTERN'] = '%s.lib'
    v['cxxstlib_PATTERN'] = '%s.lib'

    v['cshlib_PATTERN'] = '%s.dll'
    v['cxxshlib_PATTERN'] = '%s.dll'

    v['LINKFLAGS_cshlib'] = ['/DLL']
    v['LINKFLAGS_cxxshlib'] = ['/DLL']

    # AR Tools
    v['ARFLAGS'] = ['/NOLOGO']
    v['AR_TGT_F'] = '/OUT:'

    # Delete the env variables so that they can be replaced with the clang versions
    del v['AR']
    del v['CC']
    del v['CXX']
    del v['LINK']

    conf.find_program('clang', var='CC', silent_output=True)
    conf.find_program('clang++', var='CXX', silent_output=True)
    conf.find_program('llvm-lib', var='AR', silent_output=True)
    conf.find_program('lld-link', var='LINK', silent_output=True)

    v['LINK_CC'] = v['LINK_CXX'] = v['LINK']

    # Moved to platform.win_x64_clang.json
    """
    clang_FLAGS = [
        '-mcx16',
        '-msse3',
        
        '-Wno-macro-redefined',
        '-Wno-microsoft-cast',
        '-Wno-ignored-pragma-intrinsic',
        # Clang doens't need #pragma intrinsic anyway, so don't whine when one isn't recognized
    ]
    """
    clang_FLAGS = []

    # Path to clang.exe is [clang]/bin/clang.exe, but the include path is [clang]/lib/clang/7.0.0/include
    clang_include_path = os.path.join(
        os.path.dirname(os.path.dirname(v['CXX'])), 'lib', 'clang',
        CLANG_VERSION, 'include')

    system_includes = [clang_include_path] + system_includes

    # Treat all MSVC include paths as system headers
    for include in system_includes:
        clang_FLAGS += ['-isystem', include]

    v['CFLAGS'] += clang_FLAGS
    v['CXXFLAGS'] += clang_FLAGS
    # Moved to platform.win_x64_clang.json
    """
    v['DEFINES'] += [
        '_CRT_SECURE_NO_WARNINGS',
        '_CRT_NONSTDC_NO_WARNINGS',
    ]
    """

    # Moved to platform.win_x64_clang.json
    """
    v['LINKFLAGS'] += [
        '/MACHINE:x64',
        '/MANIFEST',  # Create a manifest file
        '/OPT:REF', '/OPT:ICF',  # Always optimize for size, there's no reason not to
        '/LARGEADDRESSAWARE',  # tell the linker that the application can handle addresses larger than 2 gigabytes.
    ]
    """
    v['WINDOWS_CLANG_SUPPORTED'] = True

    conf.load_clang_common_settings()

    conf.load_cryengine_common_settings()

    conf.register_win_x64_external_optional_cuda(PLATFORM)
コード例 #14
0
def load_win_x64_host_settings(conf):
    """
    Setup any environment settings you want to apply globally any time the host doing the building is win x64
    """
    v = conf.env

    # Setup the environment for the AZ Code Generator

    # Look for the most recent version of the code generator subfolder.  This should be either installed or built by the bootstrap process at this point
    global AZCG_VALIDATED_PATH
    if AZCG_VALIDATED_PATH is None:
        az_code_gen_subfolders = ['bin/windows']
        validated_azcg_dir = None
        for az_code_gen_subfolder in az_code_gen_subfolders:
            azcg_dir = conf.Path(
                'Tools/AzCodeGenerator/{}'.format(az_code_gen_subfolder))
            azcg_exe = os.path.join(azcg_dir, AZ_CODE_GEN_EXECUTABLE)
            if os.path.exists(azcg_exe):
                Logs.debug(
                    'lumberyard: Found AzCodeGenerator at {}'.format(azcg_dir))
                validated_azcg_dir = azcg_dir
                break
        AZCG_VALIDATED_PATH = validated_azcg_dir
        if validated_azcg_dir is None:
            conf.fatal(
                'Unable to locate the AzCodeGenerator subfolder.  Make sure that the Windows binaries are available'
            )

    v['CODE_GENERATOR_EXECUTABLE'] = AZ_CODE_GEN_EXECUTABLE
    v['CODE_GENERATOR_PATH'] = [AZCG_VALIDATED_PATH]
    v['CODE_GENERATOR_PYTHON_PATHS'] = [
        conf.Path('Tools/Python/3.7.10/windows/Lib'),
        conf.Path('Tools/Python/3.7.10/windows/libs'),
        conf.Path('Tools/Python/3.7.10/windows/DLLs'),
        conf.ThirdPartyPath('markupsafe', 'x64'),
        conf.ThirdPartyPath('jinja2', 'x64')
    ]
    v['CODE_GENERATOR_PYTHON_DEBUG_PATHS'] = [
        conf.Path('Tools/Python/3.7.10/windows/Lib'),
        conf.Path('Tools/Python/3.7.10/windows/libs'),
        conf.Path('Tools/Python/3.7.10/windows/DLLs'),
        conf.ThirdPartyPath('markupsafe', 'x64'),
        conf.ThirdPartyPath('jinja2', 'x64')
    ]
    v['EMBEDDED_PYTHON_HOME_RELATIVE_PATH'] = 'Tools/Python/3.7.10/windows'
    v['CODE_GENERATOR_PYTHON_HOME'] = conf.Path(
        v['EMBEDDED_PYTHON_HOME_RELATIVE_PATH'])
    v['CODE_GENERATOR_PYTHON_HOME_DEBUG'] = conf.Path(
        'Tools/Python/3.7.10/windows')
    v['CODE_GENERATOR_INCLUDE_PATHS'] = []

    v['EMBEDDED_PYTHON_HOME'] = v['CODE_GENERATOR_PYTHON_HOME']
    v['EMBEDDED_PYTHON_INCLUDE_PATH'] = os.path.join(v['EMBEDDED_PYTHON_HOME'],
                                                     'include')
    v['EMBEDDED_PYTHON_LIBPATH'] = os.path.join(v['EMBEDDED_PYTHON_HOME'],
                                                'libs')
    v['EMBEDDED_PYTHON_SHARED_OBJECT'] = os.path.join(
        v['EMBEDDED_PYTHON_HOME'], 'python37.dll')

    crcfix_dir = conf.Path('Tools/crcfix/bin/windows')
    if not os.path.exists(crcfix_dir):
        Logs.warn(
            'Unable to locate the crcfix subfolder.  Make sure that the Windows crcfix binaries are available'
        )
    v['CRCFIX_PATH'] = [crcfix_dir]
    v['CRCFIX_EXECUTABLE'] = 'crcfix.exe'
コード例 #15
0
def load_win_x64_win_x64_vs2017_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all win_x64_win_x64 configurations
    """
    v = conf.env

    global PLATFORM

    # Add defines to indicate a win64 build and configure VS2017 warnings
    v['DEFINES'] += [
        '_WIN32', '_WIN64', 'NOMINMAX',
        '_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING',
        '_ENABLE_EXTENDED_ALIGNED_STORAGE'
    ]

    restricted_tool_list_macro_header = 'AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS='
    restricted_tool_list_macro = restricted_tool_list_macro_header
    if len(restricted_tool_list_macro) > len(
            restricted_tool_list_macro_header):
        v['DEFINES'] += [restricted_tool_list_macro]

    # Make sure this is a supported platform
    if PLATFORM not in conf.get_supported_platforms():
        return

    # Attempt to detect the C++ compiler for VS 2017 ( msvs version 15.0 )
    windows_kit = conf.options.win_vs2017_winkit
    vcvarsall_args = windows_kit + ' ' + conf.options.win_vs2017_vcvarsall_args
    try:
        conf.auto_detect_msvc_compiler('msvc 15', 'x64', vcvarsall_args)
    except:
        Logs.warn(
            'MSVS 2017 will be removed as a build target. We were unable to find an installation of Visual Studio 2017 that matches win_vs2017_vswhere_args=({}), Windows Kit with win_vs2017_winkit=({}), and win_vs2017_vcvarsall_args=({}).'
            .format(conf.options.win_vs2017_vswhere_args, windows_kit,
                    conf.options.win_vs2017_vcvarsall_args))
        Logs.warn(
            'Lumberyard defaults use a known good set of options at the time of product release. If your project requires different configuration for MSVS 2017, you can modify these settings in _WAF_/user_settings.options under [Windows Options].'
        )
        conf.mark_supported_platform_for_removal(PLATFORM)
        return

    # Detect the QT binaries, if the current capabilities selected requires it.
    _, enabled, _, _ = conf.tp.get_third_party_path(PLATFORM, 'qt')
    if enabled:
        conf.find_qt5_binaries(PLATFORM)

    # Introduce the linker to generate 64 bit code
    v['LINKFLAGS'] += ['/MACHINE:X64']
    v['ARFLAGS'] += ['/MACHINE:X64']

    VS2017_FLAGS = [
        '/FS'  # Fix for issue writing to pdb files
    ]

    v['CFLAGS'] += VS2017_FLAGS
    v['CXXFLAGS'] += VS2017_FLAGS

    if conf.options.use_uber_files:
        v['CFLAGS'] += ['/bigobj']
        v['CXXFLAGS'] += ['/bigobj']

    azcg_dir = conf.Path('Tools/AzCodeGenerator/bin/vc141')
    if not os.path.exists(azcg_dir):
        azcg_dir = conf.Path('Tools/AzCodeGenerator/bin/vc140')
        if not os.path.exists(azcg_dir):
            conf.fatal(
                'Unable to locate the AzCodeGenerator subfolder.  Make sure that you have VS2017 AzCodeGenerator binaries available'
            )
    v['CODE_GENERATOR_PATH'] = [azcg_dir]

    crcfix_dir = conf.Path('Tools/crcfix/bin/vc141')
    if not os.path.exists(crcfix_dir):
        crcfix_dir = conf.Path('Tools/crcfix/bin/vc140')
        if not os.path.exists(crcfix_dir):
            Logs.warn(
                'Unable to locate the crcfix subfolder.  Make sure that you have VS2017 crcfix binaries available'
            )
    v['CRCFIX_PATH'] = [crcfix_dir]

    conf.find_dx12(windows_kit)
コード例 #16
0
def enable_embedded_python(self):
    # Only win_x64 builds support embedding Python.
    #
    # We assume 'project_generator' (the result of doing a lmbr_waf configure) is
    # using the host waf platform build so that the include directory is configured property
    # for that host platform.

    platform = self.env['PLATFORM'].lower()
    config = self.env['CONFIGURATION'].lower()

    if self.bld.is_windows_platform(platform) or self.bld.is_linux_platform(
            platform) or self.bld.is_mac_platform(
                platform) or platform == 'project_generator':

        env = self.bld.env
        # If the platform is project generator, the default environment will not have the EMBEDDED_PYTHON_*
        # env varaiable set. Therefore the first platform environment which contains the host_platform name is used instead
        if platform == 'project_generator':
            host_platform = self.bld.get_waf_host_platform()
            for platform_env in self.bld.all_envs:
                if host_platform in platform_env:
                    env = self.bld.all_envs[platform_env]
                    break

        # Set the USE_DEBUG_PYTHON environment variable to the location of
        # a debug build of python if you want to use one for debug builds.
        #
        # This does NOT work with the boost python helpers, which are used
        # by the Editor, since the boost headers always undef _DEBUG before
        # including the python headers.
        #
        # Any code that includes python headers directly should also undef
        # _DEBUG before including those headers except for when USE_DEBUG_PYTHON
        # is defined.

        if 'debug' in config and 'USE_DEBUG_PYTHON' in os.environ:

            python_home = os.environ['USE_DEBUG_PYTHON']
            python_dll = '{}/python37_d.dll'.format(python_home)

            self.env['DEFINES'] += ['USE_DEBUG_PYTHON']

        else:
            python_home, python_include_dir, python_libs_dir, python_dll, python_home_relative = get_python_home_lib_and_dll(
                self.bld, env)

        self.env['SYSTEM_INCLUDES'] += [python_include_dir]
        self.env['LIBPATH'] += [python_libs_dir]

        # Standardize on forward-slash through the entire path.  We specifically don't use backslashes to avoid an interaction with compiler
        # response-file generation in msvcdeps.py and msvc_helper.py that "fixes up" all the compiler flags, in part by replacing backslashes
        # with double-backslashes.  If we tried to replace backslashes with double-backslashes here to make it a valid C++ string, it would
        # get double-fixed-up in the case that a response file gets used (long directory path names).
        self.env['DEFINES'] += [
            'DEFAULT_LY_PYTHONHOME="{}"'.format(python_home.replace('\\', '/'))
        ]
        self.env['DEFINES'] += [
            'DEFAULT_LY_PYTHONHOME_RELATIVE="{}"'.format(
                python_home_relative.replace('\\', '/'))
        ]

        if 'LIBPATH_BOOSTPYTHON' in self.env:
            self.env['LIBPATH'] += self.env['LIBPATH_BOOSTPYTHON']
        elif 'STLIBPATH_BOOSTPYTHON' in self.env:
            self.env['LIBPATH'] += self.env['STLIBPATH_BOOSTPYTHON']
        elif self.env['PLATFORM'] != 'project_generator':
            Logs.warn(
                '[WARN] Required 3rd party boostpython not detected.  This may cause a link error in project {}.'
                .format(self.name))