def makefile(cmb): """\ # # This is an automatically generated makefile # SIMHOME={{! simhome}} OMNETPP_PATH={{! opp_path}} CASTALIA_PATH={{! cast_path}} PATH:=/bin:/usr/bin:$(OMNETPP_PATH)/bin LD_LIBRARY_PATH=$(OMNETPP_PATH)/lib SIMEXEC=simexec .PHONY: all compile run all: compile run makefrag: \tln -s $(CASTALIA_PATH)/makefrag.inc makefrag compile: makefrag \topp_makemake -f -r --deep -o $(SIMEXEC) -u Cmdenv -P $(SIMHOME) -M release -X./Simulations -X./src -L$(CASTALIA_PATH) -lnetsim \t$(MAKE) run: \t./$(SIMEXEC) --cmdenv-output-file=simout.txt -c Main """ cast_path = castalia_path() opp_path = omnetpp_path() simhome = context.fileloc return locals()
def setupCastalia(): assertCastaliaSetup() augmentEnvironment() print("Configuration: omnetpp in %s" % omnetpp_path()) print("Configuration: castalia in %s" % castalia_path()) for evar in ("PATH", "LD_LIBRARY_PATH"): print(evar, '=', os.getenv(evar)) buildCastaliaSharedLib() buildIncludePath() print("Castalia has been set up successfully")
def init_omnetpp_general(self): ''' Create Omnetpp model from NSD ''' self.opp.sim_time_limit = self.nsd.parameters.sim_time_limit self.opp.simtime_scale = self.nsd.parameters.simtime_scale self.opp.cpu_time_limit = self.nsd.parameters.cpu_time_limit if not self.nsd.parameters.random_seed: random.seed() else: random.seed(self.nsd.parameters.random_seed) self.opp.seeds = [random.randrange(1000000) for i in range(11)] self.opp.castalia_path = castalia_path()
def make_opp_makemake_args(cls, fileloc): return [ os.path.join(omnetpp_path(), "bin/opp_makemake"), "-f", "-r", "--deep", "-o", cls.SIMEXEC, "-u", "Cmdenv", "-P", fileloc, ### Fileloc must be injected here "-M", "release", "-X./Simulations", "-X./src", "-L" + castalia_path(), "-lcastalia" ]
def link_path(src, fileloc, dst): asrc = os.path.join(castalia_path(), src) adst = os.path.join(fileloc, dst) os.symlink(asrc, adst)
def buildIncludePath(): cmd = 'find ' + castalia_path( ) + '/src -name "*.h" |xargs dirname |uniq|xargs printf "INCLUDE_PATH+= -I%s\n" > makefrag.inc' echoExec(cmd)
def buildCastaliaSharedLib(): cmd = "opp_makemake -f -r --deep -s -o castalia -u Cmdenv -P %s -M release -X Simulations -X out -X bin" % castalia_path( ) os.chdir(castalia_path()) echoExec(cmd) echoExec("make -j4")
def assertCastaliaSetup(): assertFileExists(omnetpp_path(), "include/omnetpp.h") assertFileExists(castalia_path(), "bin/Castalia")