diff --git a/.github/workflows/release.sh b/.github/workflows/release.sh index f75f8b6..5551157 100755 --- a/.github/workflows/release.sh +++ b/.github/workflows/release.sh @@ -1,11 +1,12 @@ #!/usr/bin/env bash +NAME=tools ALGO=384 TAG=${GITHUB_REF_NAME} VERSION=$TAG [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]] && VERSION=${TAG:1} -PREFIX="tools-$VERSION" -RULES_ARCHIVE="./bzlparty_tools-$TAG.tar.gz" +PREFIX="$NAME-$VERSION" +RULES_ARCHIVE="$NAME-$TAG.tar.gz" module_file=$(mktemp) root_build_file=$(mktemp) diff --git a/docs/diff.md b/docs/diff.md deleted file mode 100644 index 3be238e..0000000 --- a/docs/diff.md +++ /dev/null @@ -1,64 +0,0 @@ - - - -# Diff Utils - -Create and Update Patches - -```starlark -load("@bzlparty_tools//lib:diff.bzl", "diff", "update_patches") - -diff( - name = "module_bazel", - source = "//:MODULE.bazel", - target = ":MODULE.bazel", -) - -update_patches() -``` - -> [!NOTE] -> The `diff` rule uses the `diff` command from the host system. -> There is no toolchain that uses a platform specific tool. - - - - -## diff - -
-diff(name, source, target, input) -- -Create a patch file from `source` and `target` files. - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name | A unique name for the target. | none | -| source | Source file to create the patch for. | none | -| target | Target file to compare the
source
to. | none |
-| input | Input patch file, optional. Defaults to a file named like the rule with the patch
extension, e.g. module_bazel.patch
. | None
|
-
-
-
-
-## update_patches
-
--update_patches(name, kwargs) -- -Macro to update all patch files in a package. - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name | A unique name for the target. |
"update_patches"
|
-| kwargs | All other arguments from [write_source_files
](https://github.com/aspect-build/bazel-lib/blob/main/docs/write_source_files.md#write_source_files) | none |
-
-
diff --git a/docs/github.md b/docs/github.md
deleted file mode 100644
index 93b14fb..0000000
--- a/docs/github.md
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-# Github Repository Rules
-
-These rules let you create a repository from a Github asset.
-
-
-
-
-## github_archive
-
--github_archive(path, version, asset, kwargs) -- -Repository rule to download and extract an archive from a github release. - -This is a simple wrapper around [`http_archive`](https://bazel.build/rules/lib/repo/http#http_archive), -that constructs an url form a project path, version and asset name. - -```starlark -load("@bzlparty_tools//rules:github.bzl", "github_archive") - -github_archive( - name = "mylang", - path = "myname/mylang", - version = "0.1.0", - asset = "mylang.tar.gz", -) -``` - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| path | Github project path (owner/project). | none | -| version | Version of the release. | none | -| asset | Name of the asset to download. | none | -| kwargs | All other args of [
http_archive
](https://bazel.build/rules/lib/repo/http#http_archive) | none |
-
-
-
-
-## github_binary
-
--github_binary(path, version, asset, kwargs) -- -Repository rule to download binary from a github release. - -This is a simple wrapper around [`http_binary`](/docs/http.md#http_binary), -that constructs an url form a project path, version and asset name. - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| path | Github project path (owner/project). | none | -| version | Version of the release. | none | -| asset | Name of the asset to download. | none | -| kwargs | All other args of [
http_binary
](/docs/http.md#http_binary) | none |
-
-
diff --git a/docs/goawk.md b/docs/goawk.md
deleted file mode 100644
index 9315323..0000000
--- a/docs/goawk.md
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-# goawk
-
-
-
-## goawk
-
--goawk(name, out, file, kwargs) -- - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name |
-
| none | -| out |-
| none | -| file |-
| none | -| kwargs |-
| none | - - diff --git a/docs/http.md b/docs/http.md deleted file mode 100644 index 6bdcb6c..0000000 --- a/docs/http.md +++ /dev/null @@ -1,41 +0,0 @@ - - -# Http Utils - - - -## http_binary - --http_binary(name, build_file, build_file_content, integrity, output, repo_mapping, sha256, url) -- - -This rule works like [`http_file`](https://bazel.build/rules/lib/repo/http#http_file), but for binaries. - -```starlark -http_binary( - name = "mylang", - url = "https://mylang.org/download/mylang-linux", - sha256 = "f34999afc0dc3fdccba42b4adbdb9767ce32093c24be93c6dfcbb5edbb364787", -) -``` - -Use the binary target as `@mylang//mylang-linux`. - - -**ATTRIBUTES** - - -| Name | Description | Type | Mandatory | Default | -| :------------- | :------------- | :------------- | :------------- | :------------- | -| name | A unique name for this repository. | Name | required | | -| build_file | Label to
BUILD
file | Label | optional | None
|
-| build_file_content | Content of BUILD
file | String | optional | ""
|
-| integrity | Integrity | String | optional | ""
|
-| output | Name of the output target By default, the rule tries to guess the name of the file by stripping the basename
from the URL.starlark http_binary( name = "mylang", output = "linux-bin", url = "https://mylang.org/download/mylang-linux", sha256 = "f34999afc0dc3fdccba42b4adbdb9767ce32093c24be93c6dfcbb5edbb364787", )
@mylang//linux-bin
| String | optional | ""
|
-| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar"
declares that, for any time this repository depends on @foo
(such as a dependency on @foo//some:target
, it should actually resolve that dependency within globally-declared @bar
(@bar//some:target
). | Dictionary: String -> String | required | |
-| sha256 | SHA 256 hash | String | optional | ""
|
-| url | Url to fetch binary from | String | required | |
-
-
diff --git a/docs/lib.md b/docs/lib.md
index 34f0668..bc4742b 100644
--- a/docs/lib.md
+++ b/docs/lib.md
@@ -6,7 +6,6 @@
-
## http_binary
@@ -84,6 +83,114 @@ Create a patch file from `source` and `target` files.
| input | Input patch file, optional. Defaults to a file named like the rule with the patch
extension, e.g. module_bazel.patch
. | None
|
+
+
+## host_platform
+
++host_platform(ctx) ++ + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| ctx |
-
| none | + + + + +## is_amd64 + ++is_amd64(platform) ++ + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| platform |
-
| none | + + + + +## is_darwin + ++is_darwin(platform) ++ + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| platform |
-
| none | + + + + +## is_freebsd + ++is_freebsd(platform) ++ + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| platform |
-
| none | + + + + +## is_netbsd + ++is_netbsd(platform) ++ + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| platform |
-
| none | + + + + +## is_windows + ++is_windows(platform) ++ + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| platform |
-
| none | + + ## platform_binaries diff --git a/lib/BUILD.bazel b/lib/BUILD.bazel index 0be9ee9..58c2eaa 100644 --- a/lib/BUILD.bazel +++ b/lib/BUILD.bazel @@ -2,10 +2,8 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") exports_files(glob([ "*.bzl", -]) + [ - "dist.awk", - "platform_binary.awk", -]) + "*.awk", +])) bzl_library( name = "defs", diff --git a/lib/defs.bzl b/lib/defs.bzl index 91375be..aa5f4e3 100644 --- a/lib/defs.bzl +++ b/lib/defs.bzl @@ -2,16 +2,38 @@ # lib +```starlark +load("@bzlparty_tools//lib:defs.bzl", "...") +``` """ load(":diff.bzl", _diff = "diff") load(":http.bzl", _http_binary = "http_binary") load(":jql.bzl", _jql_test = "jql_test") -load(":platform_binary.bzl", _platform_binaries = "platform_binaries", _platform_binary = "platform_binary") +load( + ":platform_binary.bzl", + _platform_binaries = "platform_binaries", + _platform_binary = "platform_binary", +) +load( + ":platforms.bzl", + _host_platform = "host_platform", + _is_amd64 = "is_amd64", + _is_darwin = "is_darwin", + _is_freebsd = "is_freebsd", + _is_netbsd = "is_netbsd", + _is_windows = "is_windows", +) diff = _diff http_binary = _http_binary jql_test = _jql_test platform_binary = _platform_binary platform_binaries = _platform_binaries +host_platform = _host_platform +is_amd64 = _is_amd64 +is_darwin = _is_darwin +is_freebsd = _is_freebsd +is_netbsd = _is_netbsd +is_windows = _is_windows diff --git a/lib/dist.awk b/lib/dist.awk deleted file mode 100644 index 6a7ea39..0000000 --- a/lib/dist.awk +++ /dev/null @@ -1,32 +0,0 @@ -BEGIN { - skip=1 - exclude = line = 1; -} - -/# release:exclude/ { - skip = 0; - exclude = line = 1; next -} - -/# release:include/ { - skip = 0; - exclude = line = 0; next -} - -skip==1 { - print $0; next -} - -/# exclude \{/ { - line = 0; next -} - -/# include \{/ { - line = 1; next -} - -/# \}/ { - line = exclude; next -} - -line diff --git a/lib/dist.bzl b/lib/dist.bzl deleted file mode 100644 index ac7d49c..0000000 --- a/lib/dist.bzl +++ /dev/null @@ -1,13 +0,0 @@ -# buildifier: disable=module-docstring -def dist(name, srcs, package = None): - if package == None: - package = native.module_name() - - native.genrule( - name = name, - outs = ["%s.tar.gz" % package], - srcs = srcs, - cmd = """ -tar czf $(OUTS) --transform="s,\\.,{}," --dereference --exclude=bazel-out --exclude=external . -""".format(package), - )