More updates for Windows support

This commit is contained in:
Andrew Grant committed 2020-04-23 07:56:09 -04:00
1 parent 10cf785779
commit fde8fc3b9b
1 file changed
+10 -15
+10 -15
View File
@@ -42,6 +42,8 @@ CUSTOM_SETTINGS = {
IS_WINDOWS = platform.system() == 'Windows' IS_WINDOWS = platform.system() == 'Windows'
IS_LINUX = platform.system() != 'Windows' IS_LINUX = platform.system() != 'Windows'
def addExtension(name):
return name + ["", ".exe"][IS_WINDOWS]
def pathjoin(*args): def pathjoin(*args):
@@ -154,8 +156,7 @@ def getEngine(data, engine):
# Move the binary to the /Engines/ directory # Move the binary to the /Engines/ directory
output = '{0}{1}'.format(pathway, engine['name']) output = '{0}{1}'.format(pathway, engine['name'])
destination = 'Engines/{0}'.format(engine['sha']) destination = addExtension(pathjoin('Engines', engine['sha']).rstrip('/'))
if IS_WINDOWS: destination += '.exe'
# Check to see if the compiler included a file extension or not # Check to see if the compiler included a file extension or not
if os.path.isfile(output): os.rename(output, destination) if os.path.isfile(output): os.rename(output, destination)
@@ -177,10 +178,8 @@ def getCutechessCommand(arguments, data, nps):
baseoptions = ' option.'.join(['']+tokens) baseoptions = ' option.'.join(['']+tokens)
# Ensure .exe extension on Windows # Ensure .exe extension on Windows
devCommand = data['test']['dev']['sha'] devCommand = addExtension(data['test']['dev']['sha'])
if IS_WINDOWS: devCommand += '.exe' baseCommand = addExtension(data['test']['base']['sha'])
baseCommand = data['test']['base']['sha']
if IS_WINDOWS: baseCommand += '.exe'
# Scale the time control for this machine's speed # Scale the time control for this machine's speed
timecontrol = computeAdjustedTimecontrol(arguments, data, nps) timecontrol = computeAdjustedTimecontrol(arguments, data, nps)
@@ -264,13 +263,10 @@ def computeSingleThreadedBenchmark(engine, outqueue):
try: try:
# Ensure .exe for Windows and correct path
if IS_WINDOWS: engine += '.exe'
dir = os.path.join('Engines', engine)
# Launch the engine and run a benchmark # Launch the engine and run a benchmark
pathway = addExtension(os.path.join('Engines', engine).rstrip('/'))
stdout, stderr = subprocess.Popen( stdout, stderr = subprocess.Popen(
'./{0} bench'.format(dir).split(), './{0} bench'.format(pathway).split(),
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
).communicate() ).communicate()
@@ -379,8 +375,8 @@ def verifyOpeningBook(data):
def verifyEngine(arguments, data, engine): def verifyEngine(arguments, data, engine):
# Download the engine if we do not already have it # Download the engine if we do not already have it
if not os.path.isfile('Engines/{0}'.format(engine['sha'])): pathway = addExtension(pathjoin('Engines', engine['sha']).rstrip('/'))
getEngine(data, engine) if not os.path.isfile(pathway): getEngine(data, engine)
# Run a group of benchmarks in parallel in order to better scale NPS # Run a group of benchmarks in parallel in order to better scale NPS
# values for this worker. We obtain a bench and average NPS value # values for this worker. We obtain a bench and average NPS value
@@ -490,8 +486,7 @@ def processCutechess(arguments, data, cutechess, concurrency):
def processWorkload(arguments, data): def processWorkload(arguments, data):
# Verify and possibly download the opening book # Verify and possibly download the opening book
if not verifyOpeningBook(data['test']['book']): if not verifyOpeningBook(data['test']['book']): sys.exit()
sys.exit()
# Download, Verify, and Benchmark each engine. If we are unable # Download, Verify, and Benchmark each engine. If we are unable
# to obtain a valid bench for an engine, we exit this workload # to obtain a valid bench for an engine, we exit this workload