diff --git a/backends/tofino/bf-p4c/driver/barefoot.py b/backends/tofino/bf-p4c/driver/barefoot.py index b0fe5206e5..2f5fdf317c 100755 --- a/backends/tofino/bf-p4c/driver/barefoot.py +++ b/backends/tofino/bf-p4c/driver/barefoot.py @@ -77,13 +77,16 @@ def checkEnv(): # Search the environment for assets -# if os.environ['P4C_BUILD_TYPE'] == "DEVELOPER": -# bfas = find_file('bf-asm', 'bfas') -# else: -# bfas = find_file(os.environ['P4C_BIN_DIR'], 'bfas') +enable_bf_asm = os.getenv("ENABLE_BF_ASM") -bfrt_schema = find_file(os.environ['P4C_BIN_DIR'], 'bfrt_schema.py') -p4c_gen_conf = find_file(os.environ['P4C_BIN_DIR'], 'p4c-gen-conf') +if enable_bf_asm: + if os.environ['P4C_BUILD_TYPE'] == "DEVELOPER": + bfas = find_file('bf-asm', 'bfas') + else: + bfas = find_file(os.environ['P4C_BIN_DIR'], 'bfas') + + bfrt_schema = find_file(os.environ['P4C_BIN_DIR'], 'bfrt_schema.py') + p4c_gen_conf = find_file(os.environ['P4C_BIN_DIR'], 'p4c-gen-conf') class BarefootBackend(BackendDriver): @@ -112,7 +115,8 @@ def __init__(self, target, arch, argParser): self.add_command('preclean-runtime', 'rm') self.add_command('preprocessor', 'cc') self.add_command('compiler', os.path.join(os.environ['P4C_BIN_DIR'], 'p4c-barefoot')) - # self.add_command('assembler', bfas) + if enable_bf_asm: + self.add_command('assembler', bfas) self.add_command('bf-rt-verifier', bfrt_schema) self.add_command('p4c-gen-conf', p4c_gen_conf) self.add_command('cleaner', 'rm') diff --git a/backends/tofino/bf-p4c/driver/p4c.tofino.cfg b/backends/tofino/bf-p4c/driver/p4c.tofino.cfg index b188df3953..ad1e0b6f02 100644 --- a/backends/tofino/bf-p4c/driver/p4c.tofino.cfg +++ b/backends/tofino/bf-p4c/driver/p4c.tofino.cfg @@ -18,6 +18,7 @@ from p4c_src.driver import BackendDriver import p4c_src.barefoot as bfn +enable_bf_asm = os.getenv("ENABLE_BF_ASM") class TofinoBackend(bfn.BarefootBackend): def __init__(self, target, arch, argParser): @@ -26,7 +27,8 @@ class TofinoBackend(bfn.BarefootBackend): # command options self.config_preprocessor("__TARGET_TOFINO__=1") self.config_compiler("__TARGET_TOFINO__=1") - # self.config_assembler("tofino") + if enable_bf_asm: + self.config_assembler("tofino") # Tofino Native Architecture tna_target = TofinoBackend('tofino', 'tna', argParser) diff --git a/backends/tofino/bf-p4c/driver/p4c.tofino2.cfg b/backends/tofino/bf-p4c/driver/p4c.tofino2.cfg index a4788a6e04..10e11edeff 100644 --- a/backends/tofino/bf-p4c/driver/p4c.tofino2.cfg +++ b/backends/tofino/bf-p4c/driver/p4c.tofino2.cfg @@ -26,6 +26,8 @@ Tofino2Variants = { 'tofino2' : 1 } +enable_bf_asm = os.getenv("ENABLE_BF_ASM") + class Tofino2Backend(bfn.BarefootBackend): def __init__(self, target, arch, argParser): bfn.BarefootBackend.__init__(self, target, arch, argParser) @@ -35,7 +37,8 @@ class Tofino2Backend(bfn.BarefootBackend): self.config_preprocessor("__TOFINO2_VARIANT__={}".format(Tofino2Variants[target])) self.config_compiler("__TARGET_TOFINO__=2") self.config_compiler("__TOFINO2_VARIANT__={}".format(Tofino2Variants[target])) - # self.config_assembler(target) + if enable_bf_asm: + self.config_assembler(target) for t in Tofino2Variants.keys(): config.target.append(Tofino2Backend(t, 't2na', argParser))