Closed patmaddox closed 2 weeks ago
After experimenting a bit more, it clicked that I'm basically doing the same thing as github_repo
- only instead of fetching code via HTTP, I want to fetch it from disk. This led to another insight: if I use my SCM's built-in cloning rather than cp
, then I'll only get committed files, similar to if I were to download a tarball from GitHub. So with new_http_archive
as a reference, I came up with:
def jj_repo(name:str, version:str=None):
target_name = name
version_flag = ""
if version:
target_name = f"{name}-{version}"
version_flag = f"-r {version}"
cmd = " && ".join([
f"jj -R $(plz query reporoot)/repos/{name}.jj workspace add --name __plz {version_flag} {target_name}",
f"jj -R $(plz query reporoot)/repos/{name}.jj workspace forget __plz",
f"rm -rf {target_name}/.jj"
])
workspace_rule = build_rule(
name = target_name,
cmd = cmd,
outs = [target_name],
_subrepo = True
)
return subrepo(
name = target_name,
dep = workspace_rule
)
I have a metarepo, and some sub-repos include
BUILD
files. I want to use please to build from these sources. I am not able to add please to these repos - I need to write a higher-level build task using the source as a dependency, and I want it to use my local source so I can edit it. A good example is building the FreeBSD source code.Right now I am not able to write this build task, because please refuses to copy the source directory.
It was suggested to me that I might change
BuildFileName
in my metarepo. This works as a short-term solution, but I think it kicks the can down the road / forces me to chase a moving target. I would need to change myBuildFileName
any time a new repo causes a conflict. More importantly, all repos that I have access to would need to use a different name, so now I get into a funky naming convention, e.g.BUILD.myorg.proj1
BUILD.myorg.client_a.secret-project
. I may not be permitted to do that, even if I wanted to.proposal: respect
blacklistdirs
when copying srcAssuming that there's currently no simple way for me to copy a dir that has
BuildFileName
in it...I believe that
blacklistdirs
already expresses the idea that a subdir is independent of the repo, and is not a subpackage. Therefore I propose that when definingsrcs
, it should respect theblacklistdirs
setting and permit any matching dirs that include aBuildFileName
.example script
output