Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,16 @@ def __init__(self, args):

self.system_paths = os.environ['PATH'].split(os.pathsep)
self._cygpath = self._find_exe('cygpath.exe')
self.bazel_path = self.canonical_path(
self._find_exe('bazel.exe') or self._find_exe('bazel'))

bazel_path = self._find_exe('bazel.exe') or self._find_exe('bazel')
if not bazel_path:
raise StandardError("Could not find bazel or bazel.exe in path")
self.bazel_path = self.canonical_path(bazel_path)

self.default_cfg_dirname = 'x64_windows-fastbuild'

self.cc_workspace_path = self._get_bazel_info()['execution_root']

def _build_target_list(self, args):
# If no query, use all targets in the workspace.
queries = args.query or ['//...']
Expand Down Expand Up @@ -156,6 +161,11 @@ def _get_targets_from_query(self, query, kinds):
labels.append(label)
return labels

def _get_bazel_info(self):
info = subprocess.check_output([BAZEL, 'info'])
keyvals = (line.strip().split(': ', 1) for line in info.split(b'\n'))
return {kv[0]:kv[1] for kv in keyvals if len(kv) == 2}

@property
def bin_path(self):
"""Path to the bazel-bin directory of the current workspace."""
Expand Down Expand Up @@ -293,7 +303,7 @@ def _msb_item_group(rel_ws_root, info, filters, file_targets, func):
def _msb_files(cfg, info, filters=None):
"""Set filters to a set-like when writing filters. All filters used will be added to the set."""
output_dir = cfg.output_path_for_package(info.label.package)
rel_ws_root = os.path.relpath(cfg.workspace_root, output_dir)
rel_ws_root = cfg.cc_workspace_path #os.path.relpath(cfg.workspace_root, output_dir)
return (
_msb_item_group(rel_ws_root, info, filters, info.rule.srcs, _msb_cc_src) +
_msb_item_group(rel_ws_root, info, filters, info.rule.hdrs, _msb_cc_inc))
Expand Down