Skip to content

Commit

Permalink
eden/edenapi and mononoke integration tests: add edenapi/tools to get…
Browse files Browse the repository at this point in the history
…deps and use them in tests (#51)

Summary:
Pull Request resolved: facebook/sapling#51

This diff extends capabilities of CargoBuilder in getdeps so that individual manifests can be build even without workspaces. Thanks to that a build for edenapi/tools can be made and its artifacts can be used in mononoke integration tests.

Reviewed By: StanislavGlebik

Differential Revision: D23574887

fbshipit-source-id: 8a974a6b5235d36a44fe082aad55cd380d84dd09
  • Loading branch information
lukaspiatkowski authored and facebook-github-bot committed Sep 18, 2020
1 parent 55a0e84 commit 1977922
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 13 deletions.
50 changes: 39 additions & 11 deletions build/fbcode_builder/getdeps/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,13 +999,15 @@ def __init__(
inst_dir,
build_doc,
workspace_dir,
manifests_to_build,
loader,
):
super(CargoBuilder, self).__init__(
build_opts, ctx, manifest, src_dir, build_dir, inst_dir
)
self.build_doc = build_doc
self.ws_dir = workspace_dir
self.manifests_to_build = manifests_to_build and manifests_to_build.split(",")
self.loader = loader

def run_cargo(self, install_dirs, operation, args=None):
Expand All @@ -1026,7 +1028,10 @@ def build_source_dir(self):
return os.path.join(self.build_dir, "source")

def workspace_dir(self):
return os.path.join(self.build_source_dir(), self.ws_dir)
return os.path.join(self.build_source_dir(), self.ws_dir or "")

def manifest_dir(self, manifest):
return os.path.join(self.build_source_dir(), manifest)

def recreate_dir(self, src, dst):
if os.path.isdir(dst):
Expand Down Expand Up @@ -1058,7 +1063,8 @@ def _build(self, install_dirs, reconfigure):
)
)

self._patchup_workspace()
if self.ws_dir is not None:
self._patchup_workspace()

try:
from getdeps.facebook.rust import vendored_crates
Expand All @@ -1069,11 +1075,26 @@ def _build(self, install_dirs, reconfigure):
# so just rely on cargo downloading crates on it's own
pass

self.run_cargo(
install_dirs,
"build",
["--out-dir", os.path.join(self.inst_dir, "bin"), "-Zunstable-options"],
)
if self.manifests_to_build is None:
self.run_cargo(
install_dirs,
"build",
["--out-dir", os.path.join(self.inst_dir, "bin"), "-Zunstable-options"],
)
else:
for manifest in self.manifests_to_build:
self.run_cargo(
install_dirs,
"build",
[
"--out-dir",
os.path.join(self.inst_dir, "bin"),
"-Zunstable-options",
"--manifest-path",
self.manifest_dir(manifest),
],
)

self.recreate_dir(build_source_dir, os.path.join(self.inst_dir, "source"))

def run_tests(
Expand All @@ -1082,11 +1103,18 @@ def run_tests(
if test_filter:
args = ["--", test_filter]
else:
args = None
args = []

self.run_cargo(install_dirs, "test", args)
if self.build_doc:
self.run_cargo(install_dirs, "doc", ["--no-deps"])
if self.manifests_to_build is None:
self.run_cargo(install_dirs, "test", args)
if self.build_doc:
self.run_cargo(install_dirs, "doc", ["--no-deps"])
else:
for manifest in self.manifests_to_build:
margs = ["--manifest-path", self.manifest_dir(manifest)]
self.run_cargo(install_dirs, "test", args + margs)
if self.build_doc:
self.run_cargo(install_dirs, "doc", ["--no-deps"] + margs)

def _patchup_workspace(self):
"""
Expand Down
10 changes: 8 additions & 2 deletions build/fbcode_builder/getdeps/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@
"msbuild": {"optional_section": True, "fields": {"project": REQUIRED}},
"cargo": {
"optional_section": True,
"fields": {"build_doc": OPTIONAL, "workspace_dir": OPTIONAL},
"fields": {
"build_doc": OPTIONAL,
"workspace_dir": OPTIONAL,
"manifests_to_build": OPTIONAL,
},
},
"cmake.defines": {"optional_section": True},
"autoconf.args": {"optional_section": True},
Expand Down Expand Up @@ -489,7 +493,8 @@ def create_builder( # noqa:C901

if builder == "cargo":
build_doc = self.get("cargo", "build_doc", False, ctx)
workspace_dir = self.get("cargo", "workspace_dir", "", ctx)
workspace_dir = self.get("cargo", "workspace_dir", None, ctx)
manifests_to_build = self.get("cargo", "manifests_to_build", None, ctx)
return CargoBuilder(
build_options,
ctx,
Expand All @@ -499,6 +504,7 @@ def create_builder( # noqa:C901
inst_dir,
build_doc,
workspace_dir,
manifests_to_build,
loader,
)

Expand Down
36 changes: 36 additions & 0 deletions build/fbcode_builder/manifests/eden_scm_lib_edenapi_tools
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[manifest]
name = eden_scm_lib_edenapi_tools
fbsource_path = fbcode/eden
shipit_project = eden
shipit_fbcode_builder = true

[git]
repo_url = https://github.com/facebookexperimental/eden.git

[build]
builder = cargo

[cargo]
build_doc = true
manifests_to_build = eden/scm/lib/edenapi/tools/make_req/Cargo.toml,eden/scm/lib/edenapi/tools/read_res/Cargo.toml

[shipit.pathmap]
fbcode/eden/oss = .
fbcode/eden = eden
fbcode/tools/lfs = tools/lfs
fbcode/fboss/common = common

[shipit.strip]
^fbcode/eden/fs/eden-config\.h$
^fbcode/eden/fs/py/eden/config\.py$
^fbcode/eden/hg/.*$
^fbcode/eden/mononoke/(?!lfs_protocol)
^fbcode/eden/scm/build/.*$
^fbcode/eden/scm/lib/third-party/rust/.*/Cargo.toml$
^fbcode/eden/.*/\.cargo/.*$
^.*/fb/.*$
/Cargo\.lock$
\.pyc$

[dependencies.fb=on]
rust
1 change: 1 addition & 0 deletions build/fbcode_builder/manifests/rust-shed
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ builder = cargo

[cargo]
build_doc = true
workspace_dir =

[shipit.pathmap]
fbcode/common/rust/shed = shed
Expand Down

0 comments on commit 1977922

Please sign in to comment.