version = {{ version.name }} # call the makefile to generate something for us rule make command = make $out description = MAKE $out generator = true rule codem command = codem -o $out -3 -s127 -v $ -i0 $x.cpu0.code -i1 $x.cpu1.code -i2 $x.cpu2.code -i3 $x.cpu3.code description = CODEM $out rule asm command = asm_mimd -i $in -dcpu${cpu} $asmopt $extraopt $ -od $x.code -ol $x.log -oc $x.clog -oa $x.labels.tcs -oh $x.hex -op $x.dep description = ASM $in deps = gcc depfile = $x.dep rule trapcc command = trapcc -v $extraopt $in -d $out.deps -o $out description = TRAPCC $in deps = gcc depfile = $out.deps rule trapcc-asm command = trapcc $extraopt -s $out $in description = TCCASM $in rule config command = cat $in > $out description = CFG $out rule sqlldr command = python3 scripts/generate_sqlldr.py -o $out $in description = SQLLDR $out rule symlink command = ln -sf ../../$in $out # --------------------------------------------------------------------------- # Hardcode dependencies for Venelin's run_parameters.(tcs,asm) #build src/common/run_parameters.asm: trapcc-asm $ # src/common/scsn_ids.tcs src/common/run_pre_const.tcs $ # src/common/run_parameters.tcs src/common/run_post_const.tcs {# ========================================================================#} {# ========================================================================#} # --------------------------------------------------------------------------- # Scripts {% for script in scripts.values() -%} {# ========================================================================#} {%- if script.name == "trg/ptrg" -%} # --------------------------------------------------------------------------- # TCS file: {{ script.name }} build {{ script.datfile }}: trapcc {{ script.source }} | {%- for cpu in [0,1,2,3] %} $ src/common/fitred.cpu{{ cpu }}.labels.tcs {%- endfor %} {# ========================================================================#} {%- elif script.source.endswith(".tcs") -%} # --------------------------------------------------------------------------- # TCS file: {{ script.name }} build {{ script.datfile }}: trapcc {{ script.source }} {%- if "vars" in script %} extraopt = {%- for k,v in script.vars.items() %} -D{{k}}={{v}}{% endfor %} {% endif %} {# ========================================================================#} {%- elif script.name == "common/fitred" -%} # --------------------------------------------------------------------------- # Assembler programme: {{ script.name }} build {{ script.datfile }}: codem $x.cpu0.code $x.cpu1.code $x.cpu2.code $x.cpu3.code x = build/{{ script.name }} {% for cpu in [0,1,2,3] %} build $x.code $x.labels.tcs | $x.log $x.clog $x.hex: $ asm {{ script.source }} | src/common/run_parameters.asm x = build/{{ script.name }}.cpu{{ cpu }} asmopt = -Ve -dcpu{{ cpu }} {% endfor %} build src/common/run_parameters.asm: trapcc-asm $ src/common/scsn_ids.tcs $ src/common/run_pre_const.tcs $ src/common/run_parameters.tcs $ src/common/run_post_const.tcs # Dirty hack for compatibility with Venelin's makefile {% for cpu in [0,1,2,3] %} build src/{{ script.name }}.cpu{{ cpu }}.labels.tcs: $ symlink build/{{ script.name }}.cpu{{ cpu }}.labels.tcs {% endfor %} {# ========================================================================#} {%- elif script.name.startswith("common/fitred_") -%} # --------------------------------------------------------------------------- # Assembler programme: {{ script.name }} {% set runpar="build/common/runpar_" + script.__template_id__ + ".asm" %} build {{ script.datfile }}: codem $x.cpu0.code $x.cpu1.code $x.cpu2.code $x.cpu3.code x = build/{{ script.name }} {% for cpu in [0,1,2,3] %} build $x.code $x.labels.tcs | $x.log $x.clog $x.hex: $ asm {{ script.source }} | {{ runpar }} x = build/{{ script.name }}.cpu{{ cpu }} asmopt = -Ve -dcpu{{ cpu }} -dRUNPAR_ASM_FILE={{ runpar }} {% endfor %} build {{ runpar }}: trapcc-asm $ src/common/scsn_ids.tcs $ src/common/run_pre_const.tcs $ src/common/run_parameters.tcs $ src/common/run_post_const.tcs extraopt = {%- for k,v in script.vars.items() %} -D{{k}}={{v}}{% endfor %} {% endif -%} {% endfor -%} # ------------------------------------------------------------------------------ {% for asmfile in scripts | selectattr( 'type', 'equalto', 'asm' )%} # ------------------------------------------------------------------------------ # ASM {{ asmfile.source }} {% for cpu in [0,1,2,3] %} build $x.code $x.labels.tcs | $x.log $x.clog $x.hex: $ asm {{ asmfile.source }} | src/common/run_parameters.asm cpu = {{ cpu }} x = build/{{ asmfile.name }}.cpu{{ cpu }} {% endfor %} build $x.dat: codem $x.cpu0.code $x.cpu1.code $x.cpu2.code $x.cpu3.code x = build/{{ asmfile.name }} {{ asmfile.ninjacode }} {% endfor %} # ------------------------------------------------------------------------------ # TRAPCC - .tcs files {% for tcsfile in scripts | selectattr( 'type', 'equalto', 'tcs' ) -%} build {{ tcsfile.datfile }}: trapcc {{ tcsfile.source }} {% endfor %} # ------------------------------------------------------------------------------ # .dat files for configurations where this was requested {%- for c in configs.values() | selectattr( 'datfile', 'defined' ) %} {#%- for c in configs.values() %#} build {{ c.datfile }}: config {%- for s in c.scripts %} $ {{ scripts[s].datfile }}{% endfor %} {#%- set datfiles = c.scripts | map('lookup_by_name',scripts) | map(attribute='datfile') %#} {% endfor %} # ------------------------------------------------------------------------------ # bundles are packaged into .sqlldr files {%- for b in bundles.values() -%} {# Build a list of datfiles needed for this bundle #} {# https://stackoverflow.com/questions/62711771/merge-multiple-lists-in-jinja2 #} {%- set cfgscripts = configs.values() | selectattr('name', 'in', b.configs) | map(attribute='scripts') | map('join',' ') -%} {%- set datfiles = scripts.values() | selectattr('name', 'in', ( cfgscripts | join(' ')).split(' ')) | map(attribute='datfile') -%} build upload/{{b.name}}-{{version.name}}.sqlldr: sqlldr {{ b.source }} | $ {{ datfiles | join(" ") }} {% endfor %} # --------------------------------------------------------------------------- # Regenerate build.ninja file using the Makefile if any version-controlled # file changes build build.ninja: make | templates/ninja.j2 cfginfo.yaml {%- for i in version.files %} $ {{ i }} {%- endfor %}