added provisioning, clang compiler, minor tweaks
parent
a882cdca9e
commit
91874aebd7
|
@ -0,0 +1,5 @@
|
|||
# -*- mode: ruby -*-
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "bento/ubuntu-16.04"
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
#! /usr/bin/env sh
|
||||
apt-get install -y build-essential libssl-dev nasm
|
48
run.py
48
run.py
|
@ -3,30 +3,30 @@
|
|||
import os
|
||||
import logging
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
|
||||
class Sins():
|
||||
logger = logging.getLogger()
|
||||
|
||||
def __init__(self, parent, seed=None, run_dir=None):
|
||||
self.logger.info('execute\n{}'.format(json.dumps(
|
||||
self.logger.info('execute\n{}'.format((
|
||||
(parent, seed, run_dir))
|
||||
))
|
||||
|
||||
if os.path.isdir(run_dir):
|
||||
self.run_dir = os.path.abspath(run_dir)
|
||||
|
||||
self.seed = os.path.abspath(seed)
|
||||
|
||||
parent = os.path.abspath(parent)
|
||||
self.parent = os.path.abspath(parent)
|
||||
if not os.path.isfile(parent):
|
||||
raise ValueError('Invalid executable image path.')
|
||||
|
||||
self.parent = parent
|
||||
self.seed = os.path.abspath(seed)
|
||||
|
||||
if os.path.isdir(run_dir):
|
||||
self.run_dir = os.path.abspath(run_dir)
|
||||
shutil.copy2(args.seed, args.dir)
|
||||
else:
|
||||
self.run_dir = os.path.dirname(self.seed)
|
||||
|
||||
parsed = self.parent, self.seed, self.run_dir
|
||||
self.logger.info('parsed\n{}'.format(json.dumps(parsed)))
|
||||
self.logger.info('parsed\n{}'.format((parsed)))
|
||||
|
||||
while True:
|
||||
self.execute(self.parent, self.seed, self.run_dir)
|
||||
|
@ -49,9 +49,7 @@ class Sins():
|
|||
return None
|
||||
|
||||
def execute(self, parent, scrap, cwd):
|
||||
self.logger.info('execute\n{}'.format(
|
||||
json.dumps((parent, scrap, cwd))
|
||||
))
|
||||
self.logger.info('execute\n{}'.format(((parent, scrap, cwd))))
|
||||
subprocess.run([parent, scrap], cwd=cwd)
|
||||
|
||||
|
||||
|
@ -81,16 +79,18 @@ def hex_dumps(scrap_dir):
|
|||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
import shutil
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
file_handler = logging.FileHandler(filename='sins.log')
|
||||
# handler = logging.FileHandler(filename='sins.log')
|
||||
handler = logging.StreamHandler()
|
||||
formatter = logging.Formatter(
|
||||
'#%(asctime)s %(name)s %(levelname)s\n##%(message)s\n'
|
||||
)
|
||||
file_handler.setFormatter(formatter)
|
||||
logger.addHandler(file_handler)
|
||||
handler.setFormatter(formatter)
|
||||
logger.addHandler(handler)
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-seed', default='build/scrap.asm.2.o')
|
||||
|
@ -98,14 +98,22 @@ if __name__ == '__main__':
|
|||
parser.add_argument('-dir', default='sandbox')
|
||||
parser.add_argument('-dumps', action='store_true')
|
||||
parser.add_argument('-build', action='store_true')
|
||||
parser.add_argument('-provision', action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.build:
|
||||
waf = ['python3', 'waf.py', 'configure', 'build']
|
||||
waf_proc = subprocess.run(waf, stdout=subprocess.PIPE)
|
||||
if args.provision:
|
||||
provision = ['sudo', 'sh', 'provision-ubuntu.sh']
|
||||
prov_proc = subprocess.run(provision)
|
||||
|
||||
elif args.build:
|
||||
import sys
|
||||
|
||||
os.environ['CC'] = 'clang'
|
||||
waf = [sys.executable, 'waf.py', 'configure', 'build']
|
||||
waf_proc = subprocess.run(waf)
|
||||
logger.info(waf_proc.stdout)
|
||||
|
||||
if args.dumps:
|
||||
elif args.dumps:
|
||||
hex_dumps(args.dir)
|
||||
else:
|
||||
sins = Sins(parent=args.parent, seed=args.seed, run_dir=args.dir)
|
||||
|
|
12
sins.c
12
sins.c
|
@ -34,6 +34,9 @@ int main(int argc, const char **argv)
|
|||
struct process_list scraps;
|
||||
struct process_list *iter = NULL;
|
||||
pid_t process_id;
|
||||
int status = 0;
|
||||
int count = 0;
|
||||
int return_value = 0;
|
||||
|
||||
INIT_LIST_HEAD(&scraps.list);
|
||||
|
||||
|
@ -54,16 +57,19 @@ int main(int argc, const char **argv)
|
|||
|
||||
if (process_id < 0)
|
||||
{
|
||||
sleep(1);
|
||||
count = 0;
|
||||
list_for_each_entry(iter, &scraps.list, list)
|
||||
{
|
||||
continue; /* @todo clean up pids */
|
||||
count++; /* @todo clean up pids */
|
||||
return_value = waitpid(iter->process_id, &status, 0);
|
||||
return_value = WEXITSTATUS(return_value);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return count;
|
||||
}
|
||||
|
||||
int generation(char *seed_path)
|
||||
|
|
Loading…
Reference in New Issue