From 72ae1b0e0bbd7cca3d6fc6e896589054dab84bae Mon Sep 17 00:00:00 2001 From: Uleat Date: Mon, 22 Jul 2019 23:05:33 -0400 Subject: [PATCH 1/5] Added 'vcxproj_dependencies.py' --- changelog.txt | 3 + utils/scripts/.gitignore | 3 +- utils/scripts/vcxproj_dependencies.py | 735 ++++++++++++++++++++++++++ 3 files changed, 740 insertions(+), 1 deletion(-) create mode 100644 utils/scripts/vcxproj_dependencies.py diff --git a/changelog.txt b/changelog.txt index dc9d0f16c..6b9d00a80 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 7/22/2019 == +Uleat: Added script 'vcxproj_dependencies.py' - a script to help determine conflicting project dependencies (alpha-stage) + == 7/10/2019 == Akkadius: Add #npcedit flymode [0 = ground, 1 = flying, 2 = levitate, 3 = water, 4 = floating] diff --git a/utils/scripts/.gitignore b/utils/scripts/.gitignore index eba9f59cb..76f70485c 100644 --- a/utils/scripts/.gitignore +++ b/utils/scripts/.gitignore @@ -1 +1,2 @@ -opcode_handlers_output \ No newline at end of file +opcode_handlers_output +vcxproj_dependencies_output diff --git a/utils/scripts/vcxproj_dependencies.py b/utils/scripts/vcxproj_dependencies.py new file mode 100644 index 000000000..581103506 --- /dev/null +++ b/utils/scripts/vcxproj_dependencies.py @@ -0,0 +1,735 @@ +#! /usr/bin/env python +# + +""" +'VCXProj-Dependencies' for EQEmulator + +This script locates external dependency paths and generates lists for each +project. In addition, it will cross-check these lists to determine if any +discrepancies exist for any dependencies globally and across all projects. + +""" + + +import sys +import os +import fnmatch + +try: + import xml.etree.cElementTree as ElementTree +except ImportError: + import xml.etree.ElementTree as ElementTree + +from time import time, ctime + + +QUIET_REPORT = True + +include_projects = [] +exclude_projects = ['VCTargetsPath', 'CompilerIdC', 'CompilerIdCXX'] # these three should be left in by default + +base_path = os.getcwd()[:-14] # '/utils/scripts' +base_path = base_path.replace('\\', '/') + +file_extensions = ['vcxproj'] +project_paths = [] +master_dependencies = [] +# {[project]:{[build]:{[resource]:{[reference]:[paths]}}}} +project_dependencies = {} + +out_files = {} + +col1 = '{0}'.format(' ' * 0) +col2 = '{0}'.format(' ' * 2) +col3 = '{0}'.format(' ' * 4) +col4 = '{0}'.format(' ' * 6) +col5 = '{0}'.format(' ' * 8) + + +def main(): + """ main """ + + if not create_output_directory(): + exit() + + if not open_output_files(): + exit() + + print 'Locating project paths...' + locate_project_paths() + print '..project count: {0}'.format(len(project_paths)) + print 'Parsing project files...' + parse_project_files() + print 'Building master dependencies...' + build_master_dependencies() + print '..dependency count: {0}'.format(len(master_dependencies)) + print 'Checking for version discrepancies...' + check_for_version_discrepancies() + close_output_files() + print '\n..fin' + + return + + +def create_output_directory(): + """ Check for output directory - create if does not exist """ + + try: + output_path = '{0}/utils/scripts/vcxproj_dependencies_output'.format(base_path) + if not os.path.exists(output_path): + os.mkdir(output_path) + + return True + + except IOError: + print('(Exception Error: {0}) create_output_directory()'.format(sys.exc_info()[0])) + + return False + + +def open_output_files(): + """ Open all output files """ + + try: + file_name = '{0}/utils/scripts/vcxproj_dependencies_output/ProjectPaths.txt'.format(base_path) + out_files['ProjectPaths'] = open(file_name, 'w') + file_name = '{0}/utils/scripts/vcxproj_dependencies_output/MasterDependencies.txt'.format(base_path) + out_files['MasterDependencies'] = open(file_name, 'w') + file_name = '{0}/utils/scripts/vcxproj_dependencies_output/ProjectDependencies.txt'.format(base_path) + out_files['ProjectDependencies'] = open(file_name, 'w') + file_name = '{0}/utils/scripts/vcxproj_dependencies_output/ContextTree.txt'.format(base_path) + out_files['ContextTree'] = open(file_name, 'w') + file_name = '{0}/utils/scripts/vcxproj_dependencies_output/DiscrepancyReport.txt'.format(base_path) + out_files['DiscrepancyReport'] = open(file_name, 'w') + for file in out_files: + out_files[file].write('>> \'VCXProj-Dependencies\' {0} file\n'.format(file)) + out_files[file].write('>> file generated @ {0}\n\n'.format(ctime(time()))) + + return True + + except IOError: + print('(Exception Error: {0}) open_output_files()'.format(sys.exc_info()[0])) + close_output_files() + + return False + + +def locate_project_paths(): + """ Locate vcxproj files in the build folder """ + + for root, dirs, files in os.walk('{0}/build'.format(base_path)): + for name in files: + project = name.split('.')[0] + if not len(include_projects) == 0 and project not in include_projects: + continue + if not len(exclude_projects) == 0 and project in exclude_projects: + continue + for extension in file_extensions: + if fnmatch.fnmatch(name, '*.{0}'.format(extension)): + project_paths.append(os.path.join(root, name).replace('\\', '/').lower()) + for path in project_paths: + out_files['ProjectPaths'].write('{0};\n'.format(path)) + + return + + +def fixup_path(project_path, dependency_path): + """ Fix-up malformed dependency paths """ + + trailing = dependency_path.replace('\\', '/') + if '../' in trailing: + if trailing[:3] == '../': # windows + leading = project_path[:project_path.rfind('/')] + while trailing[:3] == '../': + leading = leading[:leading.rfind('/')] + trailing = trailing[3:] + trailing = trailing.lower() + trailing = '{0}/{1};'.format(leading, trailing) + else: # unix + print '..processing unix-style path fix-up' + while '../' in trailing: + backout = trailing.find('../') + backdir = trailing.rfind('/', 0, backout - 1) + trailing = trailing.replace(trailing[backdir:backout + 2], '', 1) + trailing = trailing.lower() + else: + trailing = trailing.lower() + + return trailing + + +def parse_project_files(): + """ Parse each vcxproj file's xml data """ + + for key1 in project_paths: + with open(key1, 'r') as vcxproj_file: + project_dependencies[key1] = {} + xml_tree = ElementTree.ElementTree(file=vcxproj_file) + for element1 in xml_tree.getroot(): + if not element1.tag[-19:] == 'ItemDefinitionGroup': + continue + # add '.split('|')[0]' to remove the '|Win##' attribute + key2 = element1.attrib['Condition'].split('==')[1][1:-1] + project_dependencies[key1][key2] = {} + for element2 in element1.getiterator(): + if element2.tag[-9:] == 'ClCompile': + key3 = element2.tag[-9:] + project_dependencies[key1][key2][key3] = {} + for element3 in element2.getiterator(): + if element3.tag[-28:] == 'AdditionalIncludeDirectories': + key4 = element3.tag[-28:] + project_dependencies[key1][key2][key3][key4] = [] + paths = element3.text.split(';') + for path in paths: + project_dependencies[key1][key2][key3][key4].append(fixup_path(key1, path)) + elif element2.tag[-15:] == 'ResourceCompile': + key3 = element2.tag[-15:] + project_dependencies[key1][key2][key3] = {} + for element3 in element2.getiterator(): + if element3.tag[-28:] == 'AdditionalIncludeDirectories': + key4 = element3.tag[-28:] + project_dependencies[key1][key2][key3][key4] = [] + paths = element3.text.split(';') + for path in paths: + project_dependencies[key1][key2][key3][key4].append(fixup_path(key1, path)) + elif element2.tag[-4:] == 'Midl': + key3 = element2.tag[-4:] + project_dependencies[key1][key2][key3] = {} + for element3 in element2.getiterator(): + if element3.tag[-28:] == 'AdditionalIncludeDirectories': + key4 = element3.tag[-28:] + project_dependencies[key1][key2][key3][key4] = [] + paths = element3.text.split(';') + for path in paths: + project_dependencies[key1][key2][key3][key4].append(fixup_path(key1, path)) + elif element2.tag[-4:] == 'Link': + key3 = element2.tag[-4:] + project_dependencies[key1][key2][key3] = {} + for element3 in element2.getiterator(): + if element3.tag[-22:] == 'AdditionalDependencies': + key4 = element3.tag[-22:] + project_dependencies[key1][key2][key3][key4] = [] + paths = element3.text.split(';') + for path in paths: + project_dependencies[key1][key2][key3][key4].append(fixup_path(key1, path)) + if element3.tag[-28:] == 'AdditionalLibraryDirectories': + key4 = element3.tag[-28:] + project_dependencies[key1][key2][key3][key4] = [] + paths = element3.text.split(';') + for path in paths: + project_dependencies[key1][key2][key3][key4].append(fixup_path(key1, path)) + vcxproj_file.close() + + return + + +def build_master_dependencies(): + """ Build master dependencies list """ + + def write(message): + """ internal 'ProjectDependencies' write method - performed here so processing takes place after fix-up """ + + out_files['ProjectDependencies'].write('{0}\n'.format(message)) + + return + + for key1 in project_dependencies: + write('{0}'.format(col1, key1)) + for key2 in project_dependencies[key1]: + write('{0}'.format(col2, key2)) + for key3 in project_dependencies[key1][key2]: + write('{0}'.format(col3, key3)) + for key4 in project_dependencies[key1][key2][key3]: + write('{0}'.format(col4, key4)) + for path in project_dependencies[key1][key2][key3][key4]: + write('{0}{1}'.format(col4, path)) + if path not in master_dependencies: + master_dependencies.append(path) + write('{0}'.format(col4)) + write('{0}'.format(col3)) + write('{0}'.format(col2)) + write('{0}'.format(col1)) + master_dependencies.sort() + for path in master_dependencies: + out_files['MasterDependencies'].write('{0}\n'.format(path)) + + return + + +def check_for_version_discrepancies(): + """ Check for dependency version discrepancies """ + + def twrite(message): + """ internal 'ContextTree' write method """ + + out_files['ContextTree'].write('{0}\n'.format(message)) + + return + + def rwrite(message): + """ internal 'DiscrepancyReport' write method """ + + out_files['DiscrepancyReport'].write('{0}\n'.format(message)) + + return + + libraries = [ + 'mysql', + 'zlib', + 'perl', + 'lua', + 'boost', + 'sodium', + 'openssl' + ] + references = [ + 'include', + 'source', + 'library' + ] + priorities = { + 0: 'NOT FOUND', + 1: 'install', + 2: 'dependencies', + 3: 'libs', + 4: 'vcpkg', + 5: 'static', + 6: 'submodule' + } + # use all lowercase for path description + # use forward slash ('/') for directory name breaks + # use '|' token for multiple hints ('my_file_path_1|my_file_path_2') + # use '##' token for joined hints ('my_file_##_1') + # use '&&' and '^' tokens for multiple argument hints ('my_file_&&path_1^path_2') + # joined hints may be nested until the multiple argument token is used.. + # ..then, only argument separators ('^') may be used + # (i.e., 'my_file_path_1|my_file_##_2|my_##_##&&_3^_4') + # {[library]:{[reference]:[[priority]:hint]}} + hints = { + # Notes: + 'mysql': { + 'include': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/mysql_##/include', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'source': [ + '', # 'NOT FOUND' + '', # 'install' + '', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'library': [ + '', # 'NOT FOUND' + '', # 'install' + 'dependencies/mysql_##/lib', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ] + }, + 'zlib': { + 'include': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/zlib_x##/include', # 'dependencies' + # not sure if this should be '/libs/zlibng' or '/build/libs/zlibng' based on cmake behavior + '/build/libs/zlibng', # 'libs' + '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '/build/libs/zlibng', # 'static' + '' # 'submodule' + ], + 'source': [ + '', # 'NOT FOUND' + '', # 'install' + '', # 'dependencies' + '/libs/zlibng', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'library': [ + '', # 'NOT FOUND' + '', # 'install' + 'dependencies/zlib_x##/lib/zdll.lib', # 'dependencies' + '', # 'libs' + '/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/zlib.lib^debug/lib/zlibd.lib', # 'vcpkg' + '/build/libs/zlibng/##&&zlibstatic.lib^zlibstaticd.lib', # 'static' + '' # 'submodule' + ] + }, + 'perl': { + 'include': [ + '', # 'NOT FOUND' + '/perl/lib/core', # 'install' + '', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'source': [ + '', # 'NOT FOUND' + '', # 'install' + '', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'library': [ + '', # 'NOT FOUND' + '/perl/lib/core/perl51##.lib', # 'install' + '', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ] + }, + 'lua': { + 'include': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/luaj_x##/src', # 'dependencies' + '', # 'libs' + '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'source': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/luaj_x##/src', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'library': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/luaj_x##/bin/lua51.lib', # 'dependencies' + '', # 'libs' + # debug lua package likely incorrect..should be 'lua51d.lib' - or whatever debug version is + '/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/lua51.lib^debug/lib/lua51.lib', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ] + }, + 'boost': { + 'include': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/boost', # 'dependencies' + '', # 'libs' + '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'source': [ + '', # 'NOT FOUND' + '', # 'install' + '', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'library': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/boost', # 'dependencies' + '', # 'libs' + '/vcpkg/vcpkg-export', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ] + }, + 'sodium': { + 'include': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/libsodium/include', # 'dependencies' + '', # 'libs' + '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'source': [ + '', # 'NOT FOUND' + '', # 'install' + '', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'library': [ + '', # 'NOT FOUND' + '', # 'install' + 'dependencies/libsodium/##/dynamic/libsodium.lib', # 'dependencies' + '', # 'libs' + # debug libsodium package likely incorrect..should be 'libsodiumd.lib' - or whatever debug version is + '/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/libsodium.lib^debug/lib/libsodium.lib', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ] + }, + 'openssl': { + 'include': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/openssl_x##/include', # 'dependencies' + '', # 'libs' + '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'source': [ + '', # 'NOT FOUND' + '', # 'install' + '', # 'dependencies' + '', # 'libs' + '', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ], + 'library': [ + '', # 'NOT FOUND' + '', # 'install' + '/dependencies/openssl_x##/lib/VC/&&libeay32MD.lib^libeay32MDd.lib^' + 'ssleay32MD.lib^ssleay32MDd.lib', # 'dependencies' + '', # 'libs' + # debug openssl package likely incorrect..should be + # 'libeay32d.lib' and 'ssleay32d.lib' - or whatever debug versions are + '/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/libeay32.lib^' + 'lib/ssleay32.lib^debug/lib/libeay32.lib^debug/lib/ssleay32.lib', # 'vcpkg' + '', # 'static' + '' # 'submodule' + ] + } + } + # {[project]:{[build]:{[resource]:{[library]:{[reference]:priority}}}}} + context_tree = {} + # {[library]:priority} + global_priorities = { + 'mysql': 0, + 'zlib': 0, + 'perl': 0, + 'lua': 0, + 'boost': 0, + 'sodium': 0, + 'openssl': 0 + } + # loop for discovering first occurence dependency sources (assumes same search precedence as compiler includes) + for key1 in project_dependencies: + if key1 not in context_tree.keys(): + context_tree[key1] = {} + for key2 in project_dependencies[key1]: + if key2 not in context_tree[key1].keys(): + context_tree[key1][key2] = {} + for key3 in project_dependencies[key1][key2]: + if key3 not in context_tree[key1][key2].keys(): + context_tree[key1][key2][key3] = {} + for key4 in project_dependencies[key1][key2][key3]: + for path in project_dependencies[key1][key2][key3][key4]: + for library in libraries: + if library not in context_tree[key1][key2][key3].keys(): + context_tree[key1][key2][key3][library] = {} + for reference in references: + if reference not in context_tree[key1][key2][key3][library].keys(): + context_tree[key1][key2][key3][library][reference] = 0 + elif not context_tree[key1][key2][key3][library][reference] == 0: + continue + for priority in priorities: + if hints[library][reference][priority] == '': + continue + for hint in hints[library][reference][priority].split('|'): + if is_hint_in_path(hint, path): + context_tree[key1][key2][key3][library][reference] = priority + if context_tree[key1][key2][key3][library][reference] >\ + global_priorities[library]: + global_priorities[library] =\ + context_tree[key1][key2][key3][library][reference] + twrite('{0}'.format(col1)) + for library in libraries: + twrite('{0}{2}'.format(col2, library, global_priorities[library])) + twrite('{0}'.format(col1)) + twrite('') + # loop for dumping 'ConflictTree' + for project in context_tree: + twrite('{0}'.format(col1, project)) + for build in context_tree[project]: + twrite('{0}'.format(col2, build)) + for resource in context_tree[project][build]: + twrite('{0}'.format(col3, resource)) + for library in context_tree[project][build][resource]: + twrite('{0}'.format(col4, library)) + for reference in context_tree[project][build][resource][library]: + twrite( + '{0}{2}'.format( + col5, + reference, + context_tree[project][build][resource][library][reference] + ) + ) + twrite('{0}'.format(col4)) + twrite('{0}'.format(col3)) + twrite('{0}'.format(col2)) + twrite('{0}'.format(col1)) + if QUIET_REPORT is False: + for library in libraries: + rwrite( + '> Global Library \'{0}\' status: \'{1}\' ({2})'.format( + library, + priorities[global_priorities[library]], + global_priorities[library] + ) + ) + # loop for identifying dependency discrepancies + for project in context_tree: + for build in context_tree[project]: + for resource in context_tree[project][build]: + for library in context_tree[project][build][resource]: + if global_priorities[library] == 0: + if QUIET_REPORT is False: + rwrite( + '> No Global Library \'{0}\' .. skipping Project:Build:Resource' + ' "{1}":"{2}":"{3}"'.format( + library, + project, + build, + resource + ) + ) + continue + r_flag = False + for reference in context_tree[project][build][resource][library]: + if context_tree[project][build][resource][library][reference] == 0: + continue + r_flag = True + if not global_priorities[library] == context_tree[project][build][resource][library][reference]: + rwrite( + '> Global-Project Library \'{0}\' mis-match \'{1}!={2}\'' + ' ({3}!={4}) Project:Build:Resource "{5}":"{6}":"{7}"'.format( + library, + priorities[global_priorities[library]], + priorities[context_tree[project][build][resource][library][reference]], + global_priorities[library], + context_tree[project][build][resource][library][reference], + project, + build, + resource + ) + ) + for cross_resource in context_tree[project][build]: + for cross_reference in context_tree[project][build][cross_resource][library]: + if cross_resource == resource and cross_reference == reference: + continue + if context_tree[project][build][cross_resource][library][cross_reference] == 0: + continue + if QUIET_REPORT is False and\ + not context_tree[project][build][cross_resource][library][cross_reference] ==\ + context_tree[project][build][resource][library][reference]: + rwrite( + '> Project Library \'{0}\' mis-match \'{1}:{2}:{3}!={4}:{5}:{6}\'' + ' ({7}!={8}) Project:Build "{9}":"{10}"'.format( + library, + resource, + reference, + priorities[context_tree[project][build][resource][library][reference]], + cross_resource, + cross_reference, + priorities[context_tree[project][build][cross_resource][library] + [cross_reference]], + context_tree[project][build][resource][library][reference], + context_tree[project][build][cross_resource][library][cross_reference], + project, + build + ) + ) + if r_flag is False and QUIET_REPORT is False: + rwrite( + '> No References found for Library \'{0}\' in Project "{1}":"{2}"'.format( + library, + project, + resource + ) + ) + + return + + +def is_hint_in_path(hint, path): + """ + Helper function for parsing and checking for hints in paths + + Hints strings should be split ('|') and passed as a singular hint into this function + + A re-write could allow for nested split models + + """ + + if hint == '' or path == '': + return False + + joined_index = hint.find('##') + pretext_index = hint.find('&&') + if joined_index == -1 and pretext_index == -1: + return hint in path + + elif (not joined_index == -1 and pretext_index == -1) or\ + (not joined_index == -1 and not pretext_index == -1 and joined_index < pretext_index): + start_index = 0 + for partial_hint in hint.split('##', 1): + if partial_hint == '': + continue + if not is_hint_in_path(partial_hint, path[start_index:]): + return False + + start_index = path.find(partial_hint, start_index) + len(partial_hint) + + return True + + elif (joined_index == -1 and not pretext_index == -1) or\ + (not joined_index == -1 and not pretext_index == -1 and joined_index > pretext_index): + partial_hints = hint.split('&&', 1) + found_index = path.find(partial_hints[0]) + if found_index == -1: + return False + + start_index = found_index + len(partial_hints[0]) + for alt_hint in partial_hints[1].split('^'): + if alt_hint == '': + continue + if path[start_index:].find(alt_hint) == 0: + return True + + return False + + else: + return False + + +def close_output_files(): + """ Close all output files """ + + while not len(out_files) == 0: + key = out_files.keys()[0] + out_files[key].close() + del out_files[key] + + return + + +if __name__ == '__main__': + main() From f5da6e18fcd18c2ba24dd8eeb3dd48cb1d9f7746 Mon Sep 17 00:00:00 2001 From: Uleat Date: Mon, 22 Jul 2019 23:27:38 -0400 Subject: [PATCH 2/5] Changed 'vcxproj_dependencies.py' script criteria to allow zero-length pretext headers in multiple-argument hints [skip ci] --- utils/scripts/vcxproj_dependencies.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/scripts/vcxproj_dependencies.py b/utils/scripts/vcxproj_dependencies.py index 581103506..6c0453f4a 100644 --- a/utils/scripts/vcxproj_dependencies.py +++ b/utils/scripts/vcxproj_dependencies.py @@ -703,9 +703,11 @@ def is_hint_in_path(hint, path): elif (joined_index == -1 and not pretext_index == -1) or\ (not joined_index == -1 and not pretext_index == -1 and joined_index > pretext_index): partial_hints = hint.split('&&', 1) - found_index = path.find(partial_hints[0]) - if found_index == -1: - return False + found_index = 0 + if not partial_hints[0] == '': + found_index = path.find(partial_hints[0]) + if found_index == -1: + return False start_index = found_index + len(partial_hints[0]) for alt_hint in partial_hints[1].split('^'): From 53ec007459e8d839a07bab997e43eb855c894c48 Mon Sep 17 00:00:00 2001 From: Uleat Date: Tue, 23 Jul 2019 19:34:35 -0400 Subject: [PATCH 3/5] Fixes and tweaks for 'vcxproj' script [skip ci] (zlib still needs some work) --- utils/scripts/vcxproj_dependencies.py | 144 ++++++++++++++------------ 1 file changed, 79 insertions(+), 65 deletions(-) diff --git a/utils/scripts/vcxproj_dependencies.py b/utils/scripts/vcxproj_dependencies.py index 6c0453f4a..fd018991b 100644 --- a/utils/scripts/vcxproj_dependencies.py +++ b/utils/scripts/vcxproj_dependencies.py @@ -340,18 +340,18 @@ def check_for_version_discrepancies(): 'include': [ '', # 'NOT FOUND' '', # 'install' - '/dependencies/zlib_x##/include', # 'dependencies' + '/server/dependencies/zlib_x##/include', # 'dependencies' # not sure if this should be '/libs/zlibng' or '/build/libs/zlibng' based on cmake behavior - '/build/libs/zlibng', # 'libs' - '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' - '/build/libs/zlibng', # 'static' + '/server/libs/zlibng', # 'libs' + '/server/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '/server/build/libs/zlibng', # 'static' '' # 'submodule' ], 'source': [ '', # 'NOT FOUND' '', # 'install' '', # 'dependencies' - '/libs/zlibng', # 'libs' + '/server/libs/zlibng', # 'libs' '', # 'vcpkg' '', # 'static' '' # 'submodule' @@ -359,10 +359,10 @@ def check_for_version_discrepancies(): 'library': [ '', # 'NOT FOUND' '', # 'install' - 'dependencies/zlib_x##/lib/zdll.lib', # 'dependencies' + '/server/dependencies/zlib_x##/lib/zdll.lib', # 'dependencies' '', # 'libs' - '/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/zlib.lib^debug/lib/zlibd.lib', # 'vcpkg' - '/build/libs/zlibng/##&&zlibstatic.lib^zlibstaticd.lib', # 'static' + '/server/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/zlib.lib^debug/lib/zlibd.lib', # 'vcpkg' + '/server/build/libs/zlibng/##&&zlibstatic.lib^zlibstaticd.lib', # 'static' '' # 'submodule' ] }, @@ -399,16 +399,16 @@ def check_for_version_discrepancies(): 'include': [ '', # 'NOT FOUND' '', # 'install' - '/dependencies/luaj_x##/src', # 'dependencies' + '/server/dependencies/luaj_x##/src', # 'dependencies' '', # 'libs' - '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '/server/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' '', # 'static' '' # 'submodule' ], 'source': [ '', # 'NOT FOUND' '', # 'install' - '/dependencies/luaj_x##/src', # 'dependencies' + '/server/dependencies/luaj_x##/src', # 'dependencies' '', # 'libs' '', # 'vcpkg' '', # 'static' @@ -417,10 +417,10 @@ def check_for_version_discrepancies(): 'library': [ '', # 'NOT FOUND' '', # 'install' - '/dependencies/luaj_x##/bin/lua51.lib', # 'dependencies' + '/server/dependencies/luaj_x##/bin/lua51.lib', # 'dependencies' '', # 'libs' # debug lua package likely incorrect..should be 'lua51d.lib' - or whatever debug version is - '/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/lua51.lib^debug/lib/lua51.lib', # 'vcpkg' + '/server/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/lua51.lib^debug/lib/lua51.lib', # 'vcpkg' '', # 'static' '' # 'submodule' ] @@ -429,9 +429,9 @@ def check_for_version_discrepancies(): 'include': [ '', # 'NOT FOUND' '', # 'install' - '/dependencies/boost', # 'dependencies' + '/server/dependencies/boost', # 'dependencies' '', # 'libs' - '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '/server/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' '', # 'static' '' # 'submodule' ], @@ -447,9 +447,9 @@ def check_for_version_discrepancies(): 'library': [ '', # 'NOT FOUND' '', # 'install' - '/dependencies/boost', # 'dependencies' + '/server/dependencies/boost', # 'dependencies' '', # 'libs' - '/vcpkg/vcpkg-export', # 'vcpkg' + '/server/vcpkg/vcpkg-export', # 'vcpkg' '', # 'static' '' # 'submodule' ] @@ -458,9 +458,9 @@ def check_for_version_discrepancies(): 'include': [ '', # 'NOT FOUND' '', # 'install' - '/dependencies/libsodium/include', # 'dependencies' + '/server/dependencies/libsodium/include', # 'dependencies' '', # 'libs' - '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '/server/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' '', # 'static' '' # 'submodule' ], @@ -476,10 +476,11 @@ def check_for_version_discrepancies(): 'library': [ '', # 'NOT FOUND' '', # 'install' - 'dependencies/libsodium/##/dynamic/libsodium.lib', # 'dependencies' + '/server/dependencies/libsodium/##/dynamic/libsodium.lib', # 'dependencies' '', # 'libs' # debug libsodium package likely incorrect..should be 'libsodiumd.lib' - or whatever debug version is - '/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/libsodium.lib^debug/lib/libsodium.lib', # 'vcpkg' + '/server/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/libsodium.lib^' + 'debug/lib/libsodium.lib', # 'vcpkg' '', # 'static' '' # 'submodule' ] @@ -488,9 +489,9 @@ def check_for_version_discrepancies(): 'include': [ '', # 'NOT FOUND' '', # 'install' - '/dependencies/openssl_x##/include', # 'dependencies' + '/server/dependencies/openssl_x##/include', # 'dependencies' '', # 'libs' - '/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' + '/server/vcpkg/vcpkg-export-##/installed/x##-windows/include', # 'vcpkg' '', # 'static' '' # 'submodule' ], @@ -506,12 +507,12 @@ def check_for_version_discrepancies(): 'library': [ '', # 'NOT FOUND' '', # 'install' - '/dependencies/openssl_x##/lib/VC/&&libeay32MD.lib^libeay32MDd.lib^' + '/server/dependencies/openssl_x##/lib/VC/&&libeay32MD.lib^libeay32MDd.lib^' 'ssleay32MD.lib^ssleay32MDd.lib', # 'dependencies' '', # 'libs' # debug openssl package likely incorrect..should be # 'libeay32d.lib' and 'ssleay32d.lib' - or whatever debug versions are - '/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/libeay32.lib^' + '/server/vcpkg/vcpkg-export-##/installed/x##-windows/&&lib/libeay32.lib^' 'lib/ssleay32.lib^debug/lib/libeay32.lib^debug/lib/ssleay32.lib', # 'vcpkg' '', # 'static' '' # 'submodule' @@ -521,51 +522,61 @@ def check_for_version_discrepancies(): # {[project]:{[build]:{[resource]:{[library]:{[reference]:priority}}}}} context_tree = {} # {[library]:priority} - global_priorities = { - 'mysql': 0, - 'zlib': 0, - 'perl': 0, - 'lua': 0, - 'boost': 0, - 'sodium': 0, - 'openssl': 0 - } + global_priorities = {} + # {[build]:{[library]:priority}} + build_priorities = {} # loop for discovering first occurence dependency sources (assumes same search precedence as compiler includes) - for key1 in project_dependencies: - if key1 not in context_tree.keys(): - context_tree[key1] = {} - for key2 in project_dependencies[key1]: - if key2 not in context_tree[key1].keys(): - context_tree[key1][key2] = {} - for key3 in project_dependencies[key1][key2]: - if key3 not in context_tree[key1][key2].keys(): - context_tree[key1][key2][key3] = {} - for key4 in project_dependencies[key1][key2][key3]: - for path in project_dependencies[key1][key2][key3][key4]: + for project in project_dependencies: + if project not in context_tree.keys(): + context_tree[project] = {} + for build in project_dependencies[project]: + if build not in context_tree[project].keys(): + context_tree[project][build] = {} + if build not in build_priorities.keys(): + build_priorities[build] = {} + for resource in project_dependencies[project][build]: + if resource not in context_tree[project][build].keys(): + context_tree[project][build][resource] = {} + for reference_project in project_dependencies[project][build][resource]: + for path in project_dependencies[project][build][resource][reference_project]: for library in libraries: - if library not in context_tree[key1][key2][key3].keys(): - context_tree[key1][key2][key3][library] = {} + if library not in context_tree[project][build][resource].keys(): + context_tree[project][build][resource][library] = {} + if library not in build_priorities[build].keys(): + build_priorities[build][library] = 0 + if library not in global_priorities.keys(): + global_priorities[library] = 0 for reference in references: - if reference not in context_tree[key1][key2][key3][library].keys(): - context_tree[key1][key2][key3][library][reference] = 0 - elif not context_tree[key1][key2][key3][library][reference] == 0: + if reference not in context_tree[project][build][resource][library].keys(): + context_tree[project][build][resource][library][reference] = 0 + elif not context_tree[project][build][resource][library][reference] == 0: continue for priority in priorities: if hints[library][reference][priority] == '': continue for hint in hints[library][reference][priority].split('|'): if is_hint_in_path(hint, path): - context_tree[key1][key2][key3][library][reference] = priority - if context_tree[key1][key2][key3][library][reference] >\ + context_tree[project][build][resource][library][reference] = priority + if context_tree[project][build][resource][library][reference] >\ + build_priorities[build][library]: + build_priorities[build][library] =\ + context_tree[project][build][resource][library][reference] + if context_tree[project][build][resource][library][reference] >\ global_priorities[library]: global_priorities[library] =\ - context_tree[key1][key2][key3][library][reference] + context_tree[project][build][resource][library][reference] twrite('{0}'.format(col1)) for library in libraries: twrite('{0}{2}'.format(col2, library, global_priorities[library])) twrite('{0}'.format(col1)) twrite('') - # loop for dumping 'ConflictTree' + for build in build_priorities.keys(): + twrite('{0}'.format(col1, build)) + for library in libraries: + twrite('{0}{2}'.format(col2, library, build_priorities[build][library])) + twrite('{0}'.format(col1)) + twrite('') + # loop for dumping 'ContextTree' for project in context_tree: twrite('{0}'.format(col1, project)) for build in context_tree[project]: @@ -612,11 +623,21 @@ def check_for_version_discrepancies(): ) ) continue - r_flag = False + if build_priorities[build][library] == 0: + if QUIET_REPORT is False: + rwrite( + '> No Build Library \'{0}\' .. skipping Project:Build:Resource' + ' "{1}":"{2}":"{3}"'.format( + library, + project, + build, + resource + ) + ) + continue for reference in context_tree[project][build][resource][library]: if context_tree[project][build][resource][library][reference] == 0: continue - r_flag = True if not global_priorities[library] == context_tree[project][build][resource][library][reference]: rwrite( '> Global-Project Library \'{0}\' mis-match \'{1}!={2}\'' @@ -631,6 +652,7 @@ def check_for_version_discrepancies(): resource ) ) + # 'builds' are allowed to have different dependencies..so, we'll start crossing at 'resource' for cross_resource in context_tree[project][build]: for cross_reference in context_tree[project][build][cross_resource][library]: if cross_resource == resource and cross_reference == reference: @@ -657,14 +679,6 @@ def check_for_version_discrepancies(): build ) ) - if r_flag is False and QUIET_REPORT is False: - rwrite( - '> No References found for Library \'{0}\' in Project "{1}":"{2}"'.format( - library, - project, - resource - ) - ) return @@ -716,7 +730,7 @@ def is_hint_in_path(hint, path): if path[start_index:].find(alt_hint) == 0: return True - return False + return False else: return False From 9c9615e8bb3184bc111e0d7807f6271bdfad7163 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Tue, 23 Jul 2019 19:06:11 -0500 Subject: [PATCH 4/5] Fix the manifest [skip ci] --- utils/sql/db_update_manifest.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index 92bcfd260..4addfe6ce 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -393,7 +393,7 @@ 9137|2018_12_12_client_faction_tables.sql|SHOW TABLES LIKE 'faction_base_data'|empty| 9138|2018_12_12_convert_to_client_functions.sql|SELECT `id` FROM `faction_list` WHERE `id` > 4999|empty| 9139|2019_03_25_optional_npc_model.sql|SHOW COLUMNS FROM `npc_types` LIKE 'model'|empty| -9140|2019_07_03_update_range.sql|SHOW COLUMNS FROM `npc_types` LIKE 'max_movement_update_range'|empty| +9140|2019_07_03_update_range.sql|SHOW COLUMNS FROM `zone` LIKE 'max_movement_update_range'|empty| 9141|2019_07_10_npc_flymode.sql|SHOW COLUMNS FROM `npc_types` LIKE 'flymode'|empty| # Upgrade conditions: From debc2644b11e5697e17843b7994f00f6624a8bfe Mon Sep 17 00:00:00 2001 From: Uleat Date: Tue, 23 Jul 2019 21:11:30 -0400 Subject: [PATCH 5/5] Tweaked CMakeLists.txt so CMake will play nicer with 'vcpkg' dependencies [skip ci] --- CMakeLists.txt | 62 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be92c7d0d..d58e2bd1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,8 @@ #EQEMU_BUILD_CLIENT_FILES #EQEMU_USE_MAP_MMFS #EQEMU_MAP_DIR +#EQEMU_ARCH +#EQEMU_ARCH_ALT CMAKE_MINIMUM_REQUIRED(VERSION 2.8) IF(POLICY CMP0074) @@ -57,33 +59,37 @@ ENDIF(MSVC OR MINGW) IF(MSVC) IF(CMAKE_CL_64) - SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64") - SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64") - SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_x64") - SET(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/openssl_x64") - SET(SODIUM_INCLUDE_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/include") - IF(MSVC_VERSION GREATER 1800) - SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/x64/Release/v140/dynamic") - ELSEIF(MSVC_VERSION EQUAL 1800) - SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/x64/Release/v120/dynamic") - ELSE() - SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/x64/Release/v110/dynamic") - ENDIF() + SET(EQEMU_ARCH "x64") + SET(EQEMU_ARCH_ALT "x64") ELSE(CMAKE_CL_64) - SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86") - SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86") - SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_x86") - SET(SODIUM_INCLUDE_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/include") - SET(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/openssl_x86") - IF(MSVC_VERSION GREATER 1800) - SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/Win32/Release/v140/dynamic") - ELSEIF(MSVC_VERSION EQUAL 1800) - SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/Win32/Release/v120/dynamic") - ELSE() - SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/Win32/Release/v110/dynamic") - ENDIF() + SET(EQEMU_ARCH "x86") + SET(EQEMU_ARCH_ALT "Win32") ENDIF(CMAKE_CL_64) - + + SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_${EQEMU_ARCH}") + + IF(VCPKG_TOOLCHAIN) + IF(NOT MSVC_VERSION GREATER 1800) + SET(SODIUM_INCLUDE_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/include") + ENDIF() + ELSE(VCPKG_TOOLCHAIN) + SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_${EQEMU_ARCH}") + SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_${EQEMU_ARCH}") + SET(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/openssl_${EQEMU_ARCH}") + + SET(SODIUM_INCLUDE_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/include") + ENDIF(VCPKG_TOOLCHAIN) + + IF(SODIUM_INCLUDE_HINTS) + IF(MSVC_VERSION GREATER 1800) + SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/${EQEMU_ARCH_ALT}/Release/v140/dynamic") + ELSEIF(MSVC_VERSION EQUAL 1800) + SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/${EQEMU_ARCH_ALT}/Release/v120/dynamic") + ELSE() + SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/${EQEMU_ARCH_ALT}/Release/v110/dynamic") + ENDIF() + ENDIF(SODIUM_INCLUDE_HINTS) + #disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON) IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS) @@ -320,8 +326,14 @@ IF(ZLIB_FOUND) SET(SERVER_LIBS ${SERVER_LIBS} ${ZLIB_LIBRARY}) ENDIF() ELSE() + # NOTE: This processing chain is broken. + # Path "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng" is added to ${SERVER_LIBS}..but, the current CMake process does not + # generate the "${CMAKE_CURRENT_SOURCE_DIR}/build/lib/zlibng" and create the required "zconf.h" file. A path to + # a valid ZLIB package is required to trigger this process. "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng/zconf.h" is not + # valid due to the extension name change to "../zlibng/zconf.h.in" during the ZLIB project creation process. INCLUDE_DIRECTORIES(BEFORE SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng" "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng") SET(SERVER_LIBS ${SERVER_LIBS} "zlibstatic") + MESSAGE(STATUS "Could NOT find ZLIB - using ZLIBSTATIC package.") ENDIF() IF(WIN32)