logging_level = logging.INFO if args.debug: logging_level = logging.DEBUG logging_format = '%(levelname)s: %(message)s' fh = logging.StreamHandler() fh.setLevel(logging_level) formatter = logging.Formatter(logging_format) logger.setLevel(logging_level) fh.setFormatter(formatter) logger.addHandler(fh) file_provider = FileProvider(args.dir) logger.info("Checking path: " + os.path.abspath(args.dir)) hdk_file_path_list = file_provider.get_files() # Start with a simple string to check string_to_check = 'Amazon FPGA Hardware Development Kit' files_with_bad_headers = [] for file_path in hdk_file_path_list: f = open(file_path, 'r') lines = f.read() answer = lines.find(string_to_check) if answer == -1: files_with_bad_headers.append(file_path)
def check_headers(dir): logger.info("Checking path: " + dir) file_provider = FileProvider() os.chdir(file_provider.repo_dir) file_provider.set_exclude_files([ ".*\.css$", ".*\.csv$", ".*\.diff$", ".*\.f$", ".*\.JPG$", ".*\.jpg$", ".*\.md$", ".*\.patch$", ".*\.PNG$", ".*\.png$", ".*\.pdf$", ".*\.pptx$", ".*\.txt$", ".*\.xdc$", ".*\.xlsx$", ".*\.xml$", ".*\.fio$", ".*\.gitignore$", ".*\.gitmodules$", ".*Jenkinsfile.*", ".*supported_vivado_versions\.txt$", "hdk/.*/ccf_ctl\.v$", "hdk/.*/design_error\.inc$", "hdk/.*/flop_ccf\.sv$", "hdk/.*/flop_fifo_2\.sv$", "hdk/.*/flop_fifo_lu\.sv$", "hdk/.*/flop_fifo\.sv$", "hdk/.*/ft_fifo_p2\.v$", "hdk/.*/ft_fifo_p\.v$", "hdk/.*/ft_fifo\.v$", "hdk/.*/gray\.inc$", "hdk/.*/lib_pipe\.sv$", "hdk/.*/push_2_fifo_double_pop\.sv$", "hdk/.*/push_2_fifo_guts\.inc$", "hdk/.*/push_2_fifo\.sv$", "hdk/.*/ram_2p_bit_en\.v$", "hdk/.*/ram_2p_dc\.v$", "hdk/.*/ram_2p_syn\.v$", "hdk/.*/ram_2p_trial_synth\.v$", "hdk/.*/ram_2p\.v$", "hdk/.*/rr_arb\.sv$", "hdk/.*/sync\.v$", "hdk/.*/README$", "hdk/.*/hdk_version\.txt$", "hdk/.*/dest_register_slice\.v$", "hdk/.*/src_register_slice\.v$", "hdk/cl/examples/cl_.+/\.critical_warnings", "hdk/cl/examples/cl_.+/\.warnings", "hdk/cl/examples/cl_sde/ft_fifo_p.v", "hdk/cl/examples/cl_sde/ft_fifo.v", "hdk/cl/examples/cl_sde/rr_arb.sv", "sdk/linux_kernel_drivers/xdma/10-xdma\.rules", "sdk/linux_kernel_drivers/xocl/10-xocl\.rules", "sdk/linux_kernel_drivers/xocl/LICENSE$", "sdk/apps/virtual-ethernet/scripts/pktgen-ena-range.pkt", "sdk/apps/virtual-ethernet/scripts/pktgen-ena.pkt", "SDAccel/userspace/src/test", "SDAccel/examples/aws/kernel_3ddr_bandwidth/description.json", "SDAccel/examples/aws/helloworld_ocl_runtime/helloworld", "SDAccel/examples/aws/helloworld_ocl_runtime/sdaccel.ini", "SDAccel/examples/aws/helloworld_ocl_runtime/vector_addition.hw.xilinx_aws-vu9p-f1-04261818_dynamic_5_0.awsxclbin", "SDAccel/examples/aws/helloworld_ocl_runtime/2018.3_2019.1/helloworld", "SDAccel/examples/aws/helloworld_ocl_runtime/2018.3_2019.1/sdaccel.ini", "SDAccel/examples/aws/helloworld_ocl_runtime/2018.3_2019.1/vector_addition.hw.xilinx_aws-vu9p-f1-04261818_dynamic_5_0.awsxclbin" ]) file_provider.set_exclude_paths([ "\.git$", "hdk/common/shell_.*/design/ip$", "hdk/cl/examples/cl_.*/build/checkpoints$", "hdk/cl/examples/cl_sde/ip$", "hdk/.+/xsim\.dir$", "SDAccel/aws_platform", "SDAccel/examples/3rd_party", "SDAccel/examples/xilinx", "Vitis/aws_platform", "Vitis/examples/xilinx", "Vitis/docs/Alveo_to_AWS_F1_Migration/example", ]) file_path_list = sorted(file_provider.get_files(dir)) assert file_path_list, "No files found in {}".format(dir) logger.info("Checking {} files".format(len(file_path_list))) files_with_bad_headers = [] for file_path in file_path_list: if os.path.islink(file_path): continue logger.debug("Checking {}".format(file_path)) if not find_header(file_path): logger.error("Invalid or missing header in {}".format(file_path)) files_with_bad_headers.append(file_path) rc = 0 if files_with_bad_headers: rc = 1 logger.error( "Following files didn't have the correct header:\n {}".format( "\n ".join(files_with_bad_headers))) logger.info("Checked {} files".format(len(file_path_list))) logger.info("{} errors".format(len(files_with_bad_headers))) return rc
def check_headers(dir): logger.info("Checking path: " + dir) file_provider = FileProvider() os.chdir(file_provider.repo_dir) file_provider.set_exclude_files([ ".*\.css$", ".*\.csv$", ".*\.diff$", ".*\.f$", ".*\.JPG$", ".*\.jpg$", ".*\.md$", ".*\.patch$", ".*\.PNG$", ".*\.png$", ".*\.pdf$", ".*\.pptx$", ".*\.txt$", ".*\.xdc$", ".*\.xlsx$", ".*\.xml$", ".*\.gitignore$", ".*\.gitmodules$", ".*Jenkinsfile.*", "hdk/.*/ccf_ctl\.v$", "hdk/.*/design_error\.inc$", "hdk/.*/flop_ccf\.sv$", "hdk/.*/flop_fifo_2\.sv$", "hdk/.*/flop_fifo_lu\.sv$", "hdk/.*/flop_fifo\.sv$", "hdk/.*/ft_fifo_p2\.v$", "hdk/.*/ft_fifo_p\.v$", "hdk/.*/ft_fifo\.v$", "hdk/.*/gray\.inc$", "hdk/.*/lib_pipe\.sv$", "hdk/.*/push_2_fifo_double_pop\.sv$", "hdk/.*/push_2_fifo_guts\.inc$", "hdk/.*/push_2_fifo\.sv$", "hdk/.*/ram_2p_bit_en\.v$", "hdk/.*/ram_2p_dc\.v$", "hdk/.*/ram_2p_syn\.v$", "hdk/.*/ram_2p_trial_synth\.v$", "hdk/.*/ram_2p\.v$", "hdk/.*/rr_arb\.sv$", "hdk/.*/sync\.v$", "hdk/.*/README$", "hdk/.*/supported_vivado_versions\.txt$", "hdk/.*/hdk_version\.txt$", "hdk/.*/dest_register_slice\.v$", "hdk/.*/src_register_slice\.v$", "hdk/cl/examples/cl_.+/\.critical_warnings", "hdk/cl/examples/cl_.+/\.warnings", "sdk/linux_kernel_drivers/xdma/10-xdma\.rules", "SDAccel/userspace/src/test", ]) file_provider.set_exclude_paths([ "\.git$", "hdk/common/shell_.*/design/ip$", "hdk/cl/examples/cl_.*/build/checkpoints$", "hdk/.+/xsim\.dir$", "SDAccel/aws_platform", "SDAccel/examples/3rd_party", "SDAccel/examples/xilinx", ]) file_path_list = sorted(file_provider.get_files(dir)) assert file_path_list, "No files found in {}".format(dir) logger.info("Checking {} files".format(len(file_path_list))) files_with_bad_headers = [] for file_path in file_path_list: if os.path.islink(file_path): continue logger.debug("Checking {}".format(file_path)) if not find_header(file_path): logger.error("Invalid or missing header in {}".format(file_path)) files_with_bad_headers.append(file_path) rc = 0 if files_with_bad_headers: rc = 1 logger.error( "Following files didn't have the correct header:\n {}".format( "\n ".join(files_with_bad_headers))) logger.info("Checked {} files".format(len(file_path_list))) logger.info("{} errors".format(len(files_with_bad_headers))) return rc