This repository has been archived by the owner on Jun 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from DACH-NY/custom-build-path
Allow to customize BUILD file path for hazel_custom_package_*
- Loading branch information
Showing
1 changed file
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,22 +178,37 @@ def hazel_repositories( | |
def hazel_custom_package_hackage( | ||
package_name, | ||
version, | ||
sha256=None): | ||
sha256=None, | ||
build_file=None, | ||
build_file_content=None): | ||
"""Generate a repo for a Haskell package fetched from Hackage. | ||
Args: | ||
package_name: string, package name. | ||
version: string, package version. | ||
sha256: string, SHA256 hash of archive. | ||
build_file: string, | ||
the file to use as the BUILD file for this package. | ||
Defaults to //third_party/haskel:BUILD.<package_name> if | ||
neither build_file nor build_file_content are specified. | ||
This attribute is a label relative to the main workspace. | ||
build_file and build_file_content are mutually exclusive. | ||
build_file_content: string, | ||
the content for the BUILD file for this repository. | ||
Will fall back to build_file if not specified. | ||
build_file and build_file_content are mutually exclusive. | ||
""" | ||
package_id = package_name + "-" + version | ||
url = "https://hackage.haskell.org/package/{0}/{1}.tar.gz".format( | ||
package_id, | ||
package_id, | ||
) | ||
if not build_file and not build_file_content: | ||
build_file = "//third_party/haskell:BUILD.{0}".format(package_name) | ||
http_archive( | ||
name = hazel_workspace(package_name), | ||
build_file = "//third_party/haskell:BUILD.{0}".format(package_name), | ||
build_file = build_file, | ||
build_file_content = build_file_content, | ||
sha256 = sha256, | ||
strip_prefix = package_id, | ||
urls = [url], | ||
|
@@ -206,7 +221,9 @@ def hazel_custom_package_github( | |
repo_sha, | ||
strip_prefix=None, | ||
archive_sha256=None, | ||
clone_via_ssh=False): | ||
clone_via_ssh=False, | ||
build_file=None, | ||
build_file_content=None): | ||
"""Generate a repo for a Haskell package coming from a GitHub repo. | ||
Args: | ||
|
@@ -219,16 +236,28 @@ def hazel_custom_package_github( | |
archive_sha256: hash of the actual archive to download. | ||
clone_via_ssh: whether to clone the repo using SSH (useful for private | ||
repos). | ||
build_file: string, | ||
the file to use as the BUILD file for this package. | ||
Defaults to //third_party/haskel:BUILD.<package_name> if | ||
neither build_file nor build_file_content are specified. | ||
This attribute is a label relative to the main workspace. | ||
build_file and build_file_content are mutually exclusive. | ||
build_file_content: string, | ||
the content for the BUILD file for this repository. | ||
Will fall back to build_file if not specified. | ||
build_file and build_file_content are mutually exclusive. | ||
""" | ||
|
||
build_file = "//third_party/haskell:BUILD.{0}".format(package_name) | ||
if not build_file and not build_file_content: | ||
build_file = "//third_party/haskell:BUILD.{0}".format(package_name) | ||
url = "https://github.com/{0}/{1}".format(github_user, github_repo) | ||
ssh_url = "[email protected]:{0}/{1}".format(github_user, github_repo) | ||
|
||
new_git_repository( | ||
name = hazel_workspace(package_name), | ||
remote = ssh_url if clone_via_ssh else url, | ||
build_file = build_file, | ||
build_file_content = build_file_content, | ||
commit = repo_sha, | ||
strip_prefix = strip_prefix, | ||
) |