| 293 | return self.n_threads |
| 294 | |
| 295 | def init_names(self, args): |
| 296 | self.programs_dir = "Programs" |
| 297 | if self.verbose: |
| 298 | print("Compiling program in", self.programs_dir) |
| 299 | |
| 300 | for dirname in (self.programs_dir, "Player-Data"): |
| 301 | if not os.path.exists(dirname): |
| 302 | os.mkdir(dirname) |
| 303 | |
| 304 | # create extra directories if needed |
| 305 | for dirname in ["Public-Input", "Bytecode", "Schedules", "Functions"]: |
| 306 | if not os.path.exists(self.programs_dir + "/" + dirname): |
| 307 | os.mkdir(self.programs_dir + "/" + dirname) |
| 308 | |
| 309 | if self.name is None: |
| 310 | self.name = args[0].split("/")[-1] |
| 311 | exts = ".mpc", ".py" |
| 312 | for ext in exts: |
| 313 | if self.name.endswith(ext): |
| 314 | self.name = self.name[:-len(ext)] |
| 315 | |
| 316 | infiles = [args[0]] |
| 317 | for x in (self.programs_dir, sys.path[0] + "/Programs"): |
| 318 | for ext in exts: |
| 319 | filename = args[0] |
| 320 | if not filename.endswith(ext): |
| 321 | filename += ext |
| 322 | filename = x + "/Source/" + filename |
| 323 | if os.path.abspath(filename) not in \ |
| 324 | [os.path.abspath(f) for f in infiles]: |
| 325 | infiles += [filename] |
| 326 | existing = [f for f in infiles if os.path.exists(f)] |
| 327 | if len(existing) == 1: |
| 328 | self.infile = existing[0] |
| 329 | elif len(existing) > 1: |
| 330 | raise CompilerError("ambiguous input files: " + |
| 331 | ", ".join(existing)) |
| 332 | else: |
| 333 | raise CompilerError( |
| 334 | "found none of the potential input files: " + |
| 335 | ", ".join("'%s'" % x for x in infiles)) |
| 336 | """ |
| 337 | self.name is input file name (minus extension) + any optional arguments. |
| 338 | Used to generate output filenames |
| 339 | """ |
| 340 | if self.options.outfile: |
| 341 | self.name = self.options.outfile + "-" + self.name |
| 342 | else: |
| 343 | self.name = self.name |
| 344 | if len(args) > 1: |
| 345 | self.name += "-" + "-".join(re.sub("/", "_", arg) for arg in args[1:]) |
| 346 | |
| 347 | def set_ring_size(self, ring_size): |
| 348 | from .non_linear import Ring |