deploy_chrome: Get the board name from --build-dir

The build directory generated by chrome-sdk (i.e. out_$BOARD/Release)
contains the board name.
If the build directory is specified, there is no need to specify the
board name separately.

BUG=None
TEST=deploy_chrome --build-dir=out_hatch/Release --device=$DUT
TEST=./run_tests

Change-Id: Ib3c8af99837b4f4dad398c0bb1ca66340bce429a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2830281
Tested-by: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
diff --git a/scripts/deploy_chrome.py b/scripts/deploy_chrome.py
index d9d2415..7b810e8 100644
--- a/scripts/deploy_chrome.py
+++ b/scripts/deploy_chrome.py
@@ -25,6 +25,7 @@
 import glob
 import multiprocessing
 import os
+import re
 import shlex
 import shutil
 import sys
@@ -710,6 +711,11 @@
     if options.local_pkg_path:
       parser.error('--lacros does not support --local-pkg-path')
   else:
+    if not options.board and options.build_dir:
+      match = re.search(r'out_([^/]+)/Release$', options.build_dir)
+      if match:
+        options.board = match.group(1)
+        logging.info('--board is set to %s', options.board)
     if not options.board:
       parser.error('--board is required')
   if options.gs_path and options.local_pkg_path: