Skip to content
Snippets Groups Projects

L2 sdp 185

Merged Pieter Donker requested to merge L2SDP-185 into master
2 files
+ 79
2
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -49,8 +49,8 @@
import sys
import fnmatch
from os import listdir, walk, getenv
from os.path import expandvars, isabs, join, isfile
from os import listdir, walk, getenv, stat
from os.path import expandvars, isabs, join, isfile, basename, exists
import shutil
from distutils.dir_util import copy_tree
from argparse import ArgumentParser
@@ -567,6 +567,82 @@ class HdlLibrariesWizard:
print("Could not copy source {} to desination {}".format(sourcePathName,destinationPath))
print("Copied {} files and {} directories for {} libraries".format(file_count, dir_count, lib_count))
def check_for_build_changes(self, build_type, lib_names=None):
"""
Check all source directories and source files listed at the <tool_name>_copy_files key, if the file in
the build dir is younger than in the source dir, a warning is print on the screen and the script is stopped.
The build_type selects the <tool_name>_copy_files key using the <build_type>_tool_name key value
from the hdl_buildset_<buildset>.cfg.
The <tool_name>_copy_files key expects a source and a destination pair per listed directory or file:
- The sources need to be specified with absolute path or relative to the HDL library source directory
where the hdllib.cfg is stored
- The destinations need to be specified with absolute path or relative to HDL library build directory
where the project file (e.g. mpf, qpf) gets stored
Arguments:
- lib_names : zero or more HDL libraries
"""
if lib_names is None:
lib_names = self.lib_names
lib_dicts = self.libs.get_configfiles(key='hdl_lib_name', values=lib_names)
tool_name_key = build_type + '_tool_name'
tool_name_value = self.buildset[tool_name_key]
tool_name_copy_key = tool_name_value + '_copy_files'
build_file_newer = []
for lib_dict in lib_dicts:
if tool_name_copy_key in lib_dict.content:
lib_path = lib_dict.location
build_dir_path = self.get_lib_build_dirs(build_type, lib_dicts=lib_dict)
cm.mkdir(build_dir_path)
key_values = lib_dict[tool_name_copy_key].split()
sources = key_values[0::2]
destinations = key_values[1::2]
file_io = list(zip(sources, destinations))
for fpn_io in file_io:
try:
sourcePathName = cm.expand_file_path_name(fpn_io[0], lib_path)
destinationPath = cm.expand_file_path_name(fpn_io[1], build_dir_path)
if sourcePathName.endswith('./'):
sourcePathName = sourcePathName[:-3]
if destinationPath.endswith('.'):
destinationPath = destinationPath[:-2]
if isfile(sourcePathName):
destinationPath = join(destinationPath, basename(sourcePathName))
if exists(destinationPath):
_stat = [stat(sourcePathName), stat(destinationPath)]
if _stat[1].st_mtime > _stat[0].st_mtime:
build_file_newer.append(destinationPath)
else:
if exists(destinationPath):
for root, dirs, files in walk(sourcePathName):
for file in files:
_src_file = join(root, file)
_dst_file = destinationPath + _src_file[len(sourcePathName):]
if exists(_src_file) and exists(_dst_file):
#_stat = [stat(_src_file), stat(_dst_file)]
if stat(_dst_file).st_mtime > stat(_src_file).st_mtime:
build_file_newer.append(_dst_file)
except:
print("Could not check for changes for {}".format(sourcePathName))
if len(build_file_newer) > 0:
print("")
print("########################################################################" )
print("")
#print(" ********************************************************************")
print(" ERROR, some destination files are younger than source files")
print(" ------------------------------------------------------------")
print("")
print("The following files are newer in the destination(build) dir:")
for file in build_file_newer:
print(" {}".format(file))
print("")
print("- Copy changed files to source dir or remove the files in the build dir.")
print("- If done run this script again.")
print("")
sys.exit("Stopped quartus_config")
if __name__ == '__main__':
# Parse command line arguments
Loading