diff --git a/bin/htmlgen/makefile b/bin/htmlgen/makefile index e89d9d0b141a4d6b4e386e158196cd04495bdf60..6b57eb4e3e18424ef2529fc8756116245f248128 100644 --- a/bin/htmlgen/makefile +++ b/bin/htmlgen/makefile @@ -21,10 +21,7 @@ OUT_DIR ?= $(PROJECT_DIR) # Name of generated filelist by python script OUTPUT_FILELIST := $(OUT_DIR)/filelist.flist -bootrom: - make -C $(NANOSOC_TECH_DIR)/system bootrom - -htmlgen: bootrom +gen_html: @echo building HTML tree @mkdir -p $(OUT_DIR)/build @(cd $(OUT_DIR)/build; \ diff --git a/bin/htmlgen/project_html_gen.py b/bin/htmlgen/project_html_gen.py new file mode 100755 index 0000000000000000000000000000000000000000..922796ae71f42c9e8cf88c2b88c7a06c673a1022 --- /dev/null +++ b/bin/htmlgen/project_html_gen.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +#------------------------------------------------------------------------------------ +# HTML Project Generation Script +# - Generates HTML based on all filelist in PROJECT_DIR/flist/project +# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license. +# +# Contributors +# +# David Mapstone (d.a.mapstone@soton.ac.uk) +# Copyright (c) 2023, SoC Labs (www.soclabs.org) +#------------------------------------------------------------------------------------ + +import argparse +import subprocess +import os + +def top_mod_find(filelist): + # Open Filelist + f = open(filelist, "r") + filelines = f.readlines() + f.close() + # Iterate over file and find first match for DESIGN_TOP in file comments + for line in filelines: + line_list = line.strip().split() + if len(line_list) > 2: + if (line_list[0] == "//") and (line_list[1] == "DESIGN_TOP"): + return line_list[2] + +def bootrom_gen(): + # Runs Bootrom generation script in NanoSoC Directory + bootrom_scipt_dir = os.getenv("NANOSOC_TECH_DIR")+"/system" + subprocess.run(["make","-C",bootrom_scipt_dir,"bootrom"]) + +def html_gen(filelist_path): + filelist = os.path.basename(filelist_path) + filelist_name = os.path.splitext(filelist)[0] + print("Generating HTML for: "+filelist_name) + # Find Top-level module name + top_mod = top_mod_find(filelist_path) + # Work out output Directory + outdir = os.getenv("PROJECT_DIR")+"/"+filelist_name+"/html" + print(outdir) + html_scipt_dir = os.getenv("SOCTOOLS_FLOW_DIR")+"/bin/htmlgen" + subprocess.run(["make","-C",html_scipt_dir,"gen_html","TOP_MODULE="+top_mod,"OUT_DIR="+outdir]) + +def project_gen(args): + # Has filelist option been passed to script + if args.filelist == None: + # Generate bootrom + bootrom_gen() + # Find all filelist in project filelist directory + for filelist in os.listdir(os.getenv("PROJECT_DIR")+"/flist/project"): + filelist_path = os.getenv("PROJECT_DIR")+"/flist/project/"+filelist + html_gen(filelist_path) + else: + if args.bootrom is True: + # Generate bootrom + bootrom_gen() + # Generate HTML for given filelist + html_gen(args.filelist) + +if __name__ == "__main__": + # Capture Arguments from Command Line + parser = argparse.ArgumentParser(description='Generates HTML based on all filelist in PROJECT_DIR/flist/project') + parser.add_argument("-f", "--filelist", type=str, help="Generate only from this List", required=False) + parser.add_argument("-b", "--bootrom", action='store_true', help="Generate Bootrom first", required=False) + parser.add_argument("-o", "--output", type=str, help="Output Filelist location", required=False) + args = parser.parse_args() + project_gen(args) \ No newline at end of file diff --git a/tools/htmlgen b/tools/htmlgen old mode 100644 new mode 100755 index a9bf588e2f88457fdf73ac7361ef1d596fb81453..4e09664ea2ce3610841f341d917ceba3ce155b28 --- a/tools/htmlgen +++ b/tools/htmlgen @@ -1 +1,14 @@ #!/bin/bash +#----------------------------------------------------------------------------- +# HTML Generatoration Tools Script +# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license. +# +# Contributors +# +# David Mapstone (d.a.mapstone@soton.ac.uk) +# +# Copyright � 2021-3, SoC Labs (www.soclabs.org) +#----------------------------------------------------------------------------- + +# Call Python script and pass options across +python3 $SOCTOOLS_FLOW_DIR/bin/htmlgen/project_html_gen.py $@ \ No newline at end of file