config: Refactor the network switch configuration file
authorGabor Dozsa <gabor.dozsa@arm.com>
Tue, 14 Feb 2017 21:09:18 +0000 (15:09 -0600)
committerGabor Dozsa <gabor.dozsa@arm.com>
Tue, 14 Feb 2017 21:09:18 +0000 (15:09 -0600)
This patch prevents the body of the script getting executed when
the script is imported as a module.

Change-Id: I70a50f6295f1e7a088398017f5fa9d06fe90476a
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
configs/dist/sw.py

index b2476e2c28c057554c2d9923c105cc3a2f3ad659..e7f31c0f3c36def5b34345075c6626d196831047 100644 (file)
@@ -63,13 +63,17 @@ def build_switch(options):
         link.int0 = switch.interface[i]
 
     return switch
-# Add options
-parser = optparse.OptionParser()
-Options.addCommonOptions(parser)
-Options.addFSOptions(parser)
-(options, args) = parser.parse_args()
 
-system = build_switch(options)
-root = Root(full_system = True, system = system)
-Simulation.run(options, root, None, None)
+def main():
+    # Add options
+    parser = optparse.OptionParser()
+    Options.addCommonOptions(parser)
+    Options.addFSOptions(parser)
+    (options, args) = parser.parse_args()
 
+    system = build_switch(options)
+    root = Root(full_system = True, system = system)
+    Simulation.run(options, root, None, None)
+
+if __name__ == "__m5_main__":
+    main()