+ def dce_version(self):
+ dce_version = self.get("dceVersion")
+ return dce_version or "dce-dev"
+
+ @property
+ def ns3_build_location(self):
+ location = "${BIN}/ns-3/%(ns3_version)s%(dce_version)s/%(build_mode)s/build" \
+ % {
+ "ns3_version": self.get("ns3Version"),
+ "dce_version": "-%s" % self.get("dceVersion") \
+ if self.enable_dce else "",
+ "build_mode": self.get("buildMode"),
+ }
+
+ return location
+
+
+ @property
+ def ns3_src_location(self):
+ location = "${SRC}/ns-3/%(ns3_version)s" \
+ % {
+ "ns3_version": self.get("ns3Version"),
+ }
+
+ return location
+
+ @property
+ def dce_src_location(self):
+ location = "${SRC}/ns-3-dce/%(dce_version)s" \
+ % {
+ "dce_version": self.get("dceVersion"),
+ }
+
+ return location
+
+ @property
+ def _clone_ns3_command(self):
+ source = self.get("sources")
+
+ if not source:
+ clone_ns3_cmd = "hg clone %(ns3_repo)s/%(ns3_version)s %(ns3_src)s" \
+ % {
+ "ns3_version": self.get("ns3Version"),
+ "ns3_repo": self.ns3_repo,
+ "ns3_src": self.ns3_src_location,
+ }
+ else:
+ if source.find(".tar.gz") > -1:
+ clone_ns3_cmd = (
+ "tar xzf ${SRC}/ns-3/%(basename)s "
+ " --strip-components=1 -C %(ns3_src)s"
+ ) % {
+ "basename": os.path.basename(source),
+ "ns3_src": self.ns3_src_location,
+ }
+ elif source.find(".tar") > -1:
+ clone_ns3_cmd = (
+ "tar xf ${SRC}/ns-3/%(basename)s "
+ " --strip-components=1 -C %(ns3_src)s"
+ ) % {
+ "basename": os.path.basename(source),
+ "ns3_src": self.ns3_src_location,
+ }
+ elif source.find(".zip") > -1:
+ basename = os.path.basename(source)
+ bare_basename = basename.replace(".zip", "")
+
+ clone_ns3_cmd = (
+ "unzip ${SRC}/ns-3/%(basename)s && "
+ "mv ${SRC}/ns-3/%(bare_basename)s %(ns3_src)s"
+ ) % {
+ "bare_basename": basename_name,
+ "basename": basename,
+ "ns3_src": self.ns3_src_location,
+ }
+
+ return clone_ns3_cmd
+
+ @property
+ def _clone_dce_command(self):
+ clone_dce_cmd = " echo 'DCE will not be built' "
+
+ if self.enable_dce:
+ dce_version = self.dce_version
+ dce_tag = ""
+ if dce_version != "dce-dev":
+ dce_tag = "-r %s" % dce_version
+
+ clone_dce_cmd = (
+ # DCE installation
+ # Test if dce is alredy cloned
+ " ( "
+ " ( "
+ " ( test -d %(dce_src)s ) "
+ " && echo 'dce binaries found, nothing to do'"
+ " ) "
+ " ) "
+ " || "
+ # Get dce source code
+ " ( "
+ " mkdir -p %(dce_src)s && "
+ " hg clone %(dce_repo)s %(dce_tag)s %(dce_src)s"
+ " ) "
+ ) % {
+ "dce_repo": self.dce_repo,
+ "dce_tag": dce_tag,
+ "dce_src": self.dce_src_location,
+ }
+
+ return clone_dce_cmd