def installClang(self): # The standard clang version on mac is outdated. # Retrieve a better one. if os.path.exists("clang-3.9.0"): return urllib.urlretrieve("http://releases.llvm.org/3.9.0/clang+llvm-3.9.0-x86_64-apple-darwin.tar.xz", "./clang-3.9.0.tar.xz") utils.run_realtime(["tar", "xf", "clang-3.9.0.tar.xz"]) shutil.move("clang+llvm-3.9.0-x86_64-apple-darwin", "clang-3.9.0") os.unlink("clang-3.9.0.tar.xz")
def installClang(self): # The standard clang version on mac is outdated. # Retrieve a better one. if os.path.exists("clang-3.9.0"): return urllib.urlretrieve( "http://releases.llvm.org/3.9.0/clang+llvm-3.9.0-x86_64-apple-darwin.tar.xz", "./clang-3.9.0.tar.xz") utils.run_realtime(["tar", "xf", "clang-3.9.0.tar.xz"]) shutil.move("clang+llvm-3.9.0-x86_64-apple-darwin", "clang-3.9.0") os.unlink("clang-3.9.0.tar.xz")
def execute(self, command, env, path="."): env_flags = "" shebang = subprocess.check_output( ["adb", "shell", "head " + os.path.join(path, command[0])]) if shebang.startswith("#!/bin/bash"): command = ["sh"] + command if shebang.startswith("#!/usr/bin/perl"): # Make sure we have perl. Copied from corion.net/perl-android perlDir = os.path.dirname(os.path.realpath(__file__)) perlDir = os.path.join(perlDir, "perl-android") self.put(perlDir) command = ["perl"] + command env_flags += 'PATH="$PATH:/data/local/tmp/perl-android/bin/" ' env_flags += 'PERL5LIB=/data/local/tmp/perl-android/lib:/data/local/tmp/perl-android/lib/site_perl ' for i in env: env_flags += i + "=" + env[i] + " " print "ENV: " + utils.diff_env(env) print "adb shell ... " + " ".join(command) + " ..." return utils.run_realtime([ "adb", "shell", "cd " + path + ";" + env_flags + " " + " ".join(command) + "; exit" ])
def execute(self, command, env, path="."): env_flags = "" shebang = subprocess.check_output(["adb", "shell", "head "+os.path.join(path, command[0])]) if shebang.startswith("#!/bin/bash"): command = ["sh"] + command if shebang.startswith("#!/usr/bin/perl"): # Make sure we have perl. Copied from corion.net/perl-android perlDir = os.path.dirname(os.path.realpath(__file__)) perlDir = os.path.join(perlDir, "perl-android") self.put(perlDir) command = ["perl"] + command env_flags += 'PATH="$PATH:/data/local/tmp/perl-android/bin/" ' env_flags += 'PERL5LIB=/data/local/tmp/perl-android/lib:/data/local/tmp/perl-android/lib/site_perl ' for i in env: env_flags += i+"="+env[i]+" " print env_flags print "adb shell ... " + " ".join(command) + " ..." return utils.run_realtime(["adb", "shell", "cd "+path+";"+env_flags+" " + " ".join(command) + "; exit"])
def reconf(self): # Step 0. install ndk if needed. if self.config.startswith("android"): self.env.remove("CC") self.env.remove("CXX") self.env.remove("LINK") self.installNdk() # Step 1. autoconf. with utils.chdir(os.path.join(self.folder, 'js', 'src')): if platform.system() == "Darwin": utils.run_realtime("autoconf213", shell=True) elif platform.system() == "Linux": utils.run_realtime("autoconf2.13", shell=True) elif platform.system() == "Windows": utils.run_realtime("autoconf-2.13", shell=True) # Step 2. configure if os.path.exists(os.path.join(self.folder, 'js', 'src', 'Opt')): shutil.rmtree(os.path.join(self.folder, 'js', 'src', 'Opt')) os.mkdir(os.path.join(self.folder, 'js', 'src', 'Opt')) args = ['--enable-optimize', '--disable-debug'] if self.config == "android": args.append("--target=arm-linux-androideabi") args.append("--with-android-ndk=" + os.path.abspath(self.folder) + "/android-ndk-r12/") args.append("--with-android-version=24") args.append("--enable-pie") if self.config == "android64": args.append("--target=aarch64-linux-androideabi") args.append("--with-android-ndk=" + os.path.abspath(self.folder) + "/android-ndk-r12/") args.append("--with-android-version=24") args.append("--enable-pie") if platform.architecture()[0] == "64bit" and self.config == "32bit": if platform.system() == "Darwin": args.append("--target=i686-apple-darwin10.0.0") elif platform.system() == "Linux": args.append("--target=i686-pc-linux-gnu") else: assert False with utils.chdir(os.path.join(self.folder, 'js', 'src', 'Opt')): Run(['../configure'] + args, self.env.get()) return True
def reconf(self): # Step 0. install ndk if needed. if self.config.startswith("android"): self.env.remove("CC") self.env.remove("CXX") self.env.remove("LINK") self.installNdk() # Step 1. autoconf. with utils.chdir(os.path.join(self.folder, 'js', 'src')): if platform.system() == "Darwin": utils.run_realtime("autoconf213", shell=True) elif platform.system() == "Linux": utils.run_realtime("autoconf2.13", shell=True) elif platform.system() == "Windows": utils.run_realtime("autoconf-2.13", shell=True) # Step 2. configure if os.path.exists(os.path.join(self.folder, 'js', 'src', 'Opt')): shutil.rmtree(os.path.join(self.folder, 'js', 'src', 'Opt')) os.mkdir(os.path.join(self.folder, 'js', 'src', 'Opt')) args = ['--enable-optimize', '--disable-debug'] if self.config == "android": args.append("--target=arm-linux-androideabi") args.append("--with-android-ndk="+os.path.abspath(self.folder)+"/android-ndk-r12/") args.append("--with-android-version=24") args.append("--enable-pie") if self.config == "android64": args.append("--target=aarch64-linux-androideabi") args.append("--with-android-ndk="+os.path.abspath(self.folder)+"/android-ndk-r12/") args.append("--with-android-version=24") args.append("--enable-pie") if platform.architecture()[0] == "64bit" and self.config == "32bit": if platform.system() == "Darwin": args.append("--target=i686-apple-darwin10.0.0") elif platform.system() == "Linux": args.append("--target=i686-pc-linux-gnu") else: assert False with utils.chdir(os.path.join(self.folder, 'js', 'src', 'Opt')): Run(['../configure'] + args, self.env.get()) return True
import os import urllib2 import urllib from optparse import OptionParser import json import utils if __name__ == "__main__": from optparse import OptionParser parser = OptionParser(usage="usage: %prog [options]") parser.add_option("-r", "--run", dest="machine", type="int", help="Get and run the task of a given (control) machine.") (options, args) = parser.parse_args() # Update AWFY to the latest version first. utils.run_realtime(['git', 'pull']) # Query the next tasks. url = "https://www.arewefastyet.com/task.php?unit="+str(options.machine) data = urllib2.urlopen(url).read() data = json.loads(data) # Run the tasks. task = data["task"].replace("\r\n", "\n").replace("\r", "\n") output = utils.run_realtime(task, shell=True) # Report the result. url = "https://www.arewefastyet.com/task.php?finish="+str(data["id"]) req = urllib2.Request(url=url, data=urllib.urlencode({"output": output})); urllib2.urlopen(req)
def execute(self, command, env, path="."): print " ".join(command) print os.getcwd() print path with utils.chdir(path): return utils.run_realtime(command, env=env)
def make(self): if not os.path.exists(os.path.join(self.folder, 'js', 'src', 'Opt')): return utils.run_realtime("make -j6 -C " + os.path.join(self.folder, 'js', 'src', 'Opt'), shell=True)