mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
[tools.darkcult] fix help message.
This commit is contained in:
parent
429aab2ac2
commit
6a58eade0e
3 changed files with 84 additions and 87 deletions
|
@ -1,7 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# =============================================================================
|
||||
# Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
# https://github.com/bolero-MURAKAMI/Sprout
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
# =============================================================================
|
||||
import sys
|
||||
import os
|
||||
import optparse
|
||||
import subprocess
|
||||
import multiprocessing
|
||||
|
||||
|
@ -10,45 +16,50 @@ def compile(command):
|
|||
sys.stdout.flush()
|
||||
return subprocess.call(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
|
||||
if __name__=="__main__":
|
||||
argv = sys.argv
|
||||
argc = len(argv)
|
||||
def main():
|
||||
parser = optparse.OptionParser(description='darkcult.py')
|
||||
parser.add_option('--src', type='string')
|
||||
parser.add_option('--stagedir', type='string')
|
||||
parser.add_option('--output', type='string')
|
||||
parser.add_option('--compiler', type='string')
|
||||
parser.add_option('--width', type='int')
|
||||
parser.add_option('--height', type='int')
|
||||
parser.add_option('--tile_width', type='int')
|
||||
parser.add_option('--tile_height', type='int')
|
||||
parser.add_option('--compile_options', type='string')
|
||||
parser.add_option('--darkcult_cpp', type='string')
|
||||
parser.add_option('--max_procs', type='int')
|
||||
(opts, args) = parser.parse_args()
|
||||
|
||||
src = argv[1]
|
||||
stagedir = argv[2]
|
||||
output = argv[3]
|
||||
compiler = argv[4]
|
||||
width = int(argv[5])
|
||||
height = int(argv[6])
|
||||
tile_width = int(argv[7])
|
||||
tile_height = int(argv[8])
|
||||
compile_options = argv[9]
|
||||
darkcult_cpp = argv[10]
|
||||
max_procs = int(argv[11])
|
||||
pool = multiprocessing.Pool(opts.max_procs if opts.max_procs != 0 else None)
|
||||
|
||||
commands = []
|
||||
for y in range(0, height, tile_height):
|
||||
for x in range(0, width, tile_width):
|
||||
bin = "%s/%d/%d.out" % (stagedir, y, x)
|
||||
out = "%s/%d/%d.ppm" % (stagedir, y, x)
|
||||
command = "%s -o %s" \
|
||||
" %s" \
|
||||
" -DDARKROOM_SOURCE=\'\"%s\"\'" \
|
||||
" -DDARKROOM_TOTAL_WIDTH=%d -DDARKROOM_TOTAL_HEIGHT=%d" \
|
||||
" -DDARKROOM_TILE_WIDTH=%d -DDARKROOM_TILE_HEIGHT=%d" \
|
||||
" -DDARKROOM_OFFSET_X=%d -DDARKROOM_OFFSET_Y=%d" \
|
||||
" %s" \
|
||||
" && %s > %s" \
|
||||
% (compiler, bin,
|
||||
compile_options,
|
||||
src,
|
||||
width, height,
|
||||
tile_width, tile_height,
|
||||
x, y,
|
||||
darkcult_cpp,
|
||||
bin, out
|
||||
def format_command(x, y):
|
||||
bin = "%s/%d/%d.out" % (opts.stagedir, y, x)
|
||||
out = "%s/%d/%d.ppm" % (opts.stagedir, y, x)
|
||||
return "%s -o %s" \
|
||||
" %s" \
|
||||
" -DDARKROOM_SOURCE=\'\"%s\"\'" \
|
||||
" -DDARKROOM_TOTAL_WIDTH=%d -DDARKROOM_TOTAL_HEIGHT=%d" \
|
||||
" -DDARKROOM_TILE_WIDTH=%d -DDARKROOM_TILE_HEIGHT=%d" \
|
||||
" -DDARKROOM_OFFSET_X=%d -DDARKROOM_OFFSET_Y=%d" \
|
||||
" %s" \
|
||||
" && %s > %s" \
|
||||
% (opts.compiler, bin,
|
||||
opts.compile_options,
|
||||
opts.src,
|
||||
opts.width, opts.height,
|
||||
opts.tile_width, opts.tile_height,
|
||||
x, y,
|
||||
opts.darkcult_cpp,
|
||||
bin, out
|
||||
)
|
||||
commands.append(command);
|
||||
return any(pool.map(
|
||||
compile,
|
||||
[format_command(x, y)
|
||||
for x in range(0, opts.width, opts.tile_width)
|
||||
for y in range(0, opts.height, opts.tile_height)
|
||||
]
|
||||
))
|
||||
|
||||
pool = multiprocessing.Pool(max_procs)
|
||||
sys.exit(any(pool.map(compile, commands)))
|
||||
if __name__=="__main__":
|
||||
sys.exit(main())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue