Skip to content

Commit

Permalink
xorp: etc: templates: Add option for skipping click entry in fea.tp.raw
Browse files Browse the repository at this point in the history
Added this option, so the created fea.tp would be without click code, when click is not compiled
in to the Xorp. This code works when click code starts with "click {". That's the case for now.

Signed-off-by: Igor Maravic <igorm@etf.rs>
  • Loading branch information
Igor Maravic authored and greearb committed Feb 20, 2012
1 parent 9115d92 commit 94bf998
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions xorp/etc/templates/SConscript
Expand Up @@ -96,9 +96,13 @@ if env['enable_xorpsh']:
def BuildXrlTemplate(target, source, env):
# base = tp[:-len('.raw')]
skip_fw = False
skip_click = True
if (env.has_key('disable_fw') and env['disable_fw']):
skip_fw = True

if (env.has_key('enable_click') and env['enable_click']):
skip_click = False

sfname = str(source[0])

print "source: ", sfname
Expand All @@ -109,11 +113,27 @@ def BuildXrlTemplate(target, source, env):

if sfname == 'etc/templates/fea.tp.raw':
ignore_ln = re.compile(".*firewall.*")

opened_brackets = 0
opened_bracket_ln = re.compile(".*{.*")
closed_bracket_ln = re.compile(".*}.*")
click_ln = re.compile(".*click.*")

for line in ifile.readlines():
if not (skip_fw and ignore_ln.match(line)):
if line[-1] == "\n":
# trim trailing newline
line = line[0 : -1]
if opened_brackets > 0:
if opened_bracket_ln.match(line):
opened_brackets += 1
if closed_bracket_ln.match(line):
opened_brackets -= 1
continue
if (skip_fw and ignore_ln.match(line)):
continue
if (skip_click and click_ln.match(line)):
opened_brackets = 1
continue
if line[-1] == "\n":
# trim trailing newline
line = line[0 : -1]
print >>ofile, "%s" % line
else:
return -1 # error
Expand Down

0 comments on commit 94bf998

Please sign in to comment.