diff --git a/.bazelignore b/.bazelignore index bb02298..b323317 100644 --- a/.bazelignore +++ b/.bazelignore @@ -4,3 +4,4 @@ .gitignore docs external +test diff --git a/BUILD.bazel b/BUILD.bazel index 60b082b..c6453f6 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,40 +1,15 @@ -load("@stardoc//stardoc:stardoc.bzl", "stardoc") -load("@bzlws//:index.bzl", "bzlws_copy") -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") +load("//rules:bzlws_copy.bzl", "bzlws_copy") package(default_visibility = ["//visibility:public"]) -exports_files(["index.bzl", "repo.bzl"]) - -stardoc( - name = "docs", - tags = ["manual"], - input = "index.bzl", - out = "index.md", - deps = [":rules_cc"], -) - -# SEE: https://github.com/bazelbuild/stardoc/issues/92 -bzl_library( - name = "rules_cc", - tags = ["manual"], - srcs = [ - "@rules_cc//cc:action_names.bzl", - "@rules_cc//cc:defs.bzl", - "@rules_cc//cc:find_cc_toolchain.bzl", - "@rules_cc//cc/private/rules_impl:cc_flags_supplier.bzl", - "@rules_cc//cc/private/rules_impl:cc_flags_supplier_lib.bzl", - "@rules_cc//cc/private/rules_impl:compiler_flag.bzl", - ], - visibility = ["//visibility:public"], -) - bzlws_copy( - name = "docs_copy", + name = "update_docs", out = "docs/{FILENAME}", tags = ["manual"], force = True, srcs = [ - ":docs", + "//rules:bzlws_copy_doc", + "//rules:bzlws_link_doc", + "//rules:bzlws_extract_doc", ], ) diff --git a/MODULE.bazel b/MODULE.bazel index e6c83af..7b20a1e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -8,7 +8,7 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "yaml-cpp", version = "0.8.0") -bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True) +bazel_dep(name = "stardoc", version = "0.7.0", dev_dependency = True) bazel_dep(name = "toolchains_llvm", version = "1.0.0", dev_dependency = True) bazel_dep(name = "hedron_compile_commands", dev_dependency = True) git_override( diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index e49fa88..8b13789 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -1,4 +1 @@ -load("//:faux_repo.bzl", "faux_repo") - -faux_repo(name = "faux_repo") diff --git a/docs/bzlws_copy.md b/docs/bzlws_copy.md new file mode 100644 index 0000000..cf58e1c --- /dev/null +++ b/docs/bzlws_copy.md @@ -0,0 +1,40 @@ + + + + + + +## bzlws_copy + +
+load("@bzlws//rules:bzlws_copy.bzl", "bzlws_copy") + +bzlws_copy(name, srcs, out, force, strip_filepath_prefix, metafile_path, substitutions, + stamp_substitutions, visibility, tags, kwargs) ++ +Copy generated files into workspace directory + +```python +load("@bzlws//rules:bzlws_copy.bzl", "bzlws_copy") +``` + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| name | Name used for executable target | `None` | +| srcs | List of files that should be copied | `None` | +| out | Output path within the workspace. Certain strings get replaced with workspace status values and information about the `srcs`. This happens in 2 phases.
+load("@bzlws//rules:bzlws_extract.bzl", "bzlws_extract") + +bzlws_extract(name, srcs, out, force, strip_filepath_prefix, metafile_path, visibility, kwargs) ++ + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| name |
-
| `None` | +| srcs |-
| `None` | +| out |-
| `None` | +| force |-
| `None` | +| strip_filepath_prefix |-
| `""` | +| metafile_path |-
| `""` | +| visibility |-
| `None` | +| kwargs |-
| none | + + diff --git a/docs/bzlws_link.md b/docs/bzlws_link.md new file mode 100644 index 0000000..897a671 --- /dev/null +++ b/docs/bzlws_link.md @@ -0,0 +1,36 @@ + + + + + + +## bzlws_link + ++load("@bzlws//rules:bzlws_link.bzl", "bzlws_link") + +bzlws_link(name, srcs, out, force, strip_filepath_prefix, metafile_path, visibility, kwargs) ++ +Symlink generated files into workspace directory + +```python +load("@bzlws//:index.bzl", "bzlws_link") +``` + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| name | Name used for executable target | `None` | +| srcs | List of files that should be symlinked | `None` | +| out | Output path within the workspace. Certain strings get replaced with workspace status values and information about the `srcs`. This happens in 2 phases.
-bzlws_copy(name, srcs, out, force, strip_filepath_prefix, metafile_path, substitutions, - stamp_substitutions, visibility, kwargs) -- -Copy generated files into workspace directory - -```python -load("@bzlws//:index.bzl", "bzlws_copy") -``` - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name | Name used for executable target |
None
|
-| srcs | List of files that should be copied | None
|
-| out | Output path within the workspace. Certain strings get replaced with workspace status values and information about the srcs
. This happens in 2 phases.{KEY}
. For example if you would like to have the name of the host machine in your output path you would put out = "my/path/{BUILD_HOST}/{FILENAME}"
srcs
{BAZEL_LABEL_NAME}
- Label name{BAZEL_LABEL_PACKAGE}
- Label package{BAZEL_LABEL_WORKSPACE_NAME}
- Workspace name of the label{BAZEL_FULL_LABEL}
- Fulll label string{BAZEL_LABEL}
- Full label without the workspace name{EXT}
- File extension (with the dot){EXTNAME}
- File extension name (without the dot){FILENAME}
- Full file name with extension{FILEPATH}
- Fulle file path. Any relative paths are stripped{BASENAME}
- Path basename | None
|
-| force | Overwrite existing paths even if they are not files | None
|
-| strip_filepath_prefix | Strip prefix of {FILEPATH}
| ""
|
-| metafile_path | Path to metafile | ""
|
-| substitutions | BzlwsInfo label keyed, string valued, dictionary. The values will be replaced in the source files with the values from the bazel info
command. The available BzlwsInfo targets are in the @bzlws//info
package. | {}
|
-| stamp_substitutions | Workspace status keyed, string valued, dictionary. The values will be replaced in the sources files the values from the workspace status matching the key. | {}
|
-| visibility | visibility of the executable target | None
|
-| kwargs | rest of arguments get passed to underlying targets | none |
-
-
-
-
-## bzlws_link
-
--bzlws_link(name, srcs, out, force, strip_filepath_prefix, metafile_path, visibility, kwargs) -- - Symlink generated files into workspace directory - -```python -load("@bzlws//:index.bzl", "bzlws_link") -``` - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name | Name used for executable target |
None
|
-| srcs | List of files that should be symlinked | None
|
-| out | Output path within the workspace. Certain strings get replaced with workspace status values and information about the srcs
. This happens in 2 phases.{KEY}
. For example if you would like to have the name of the host machine in your output path you would put out = "my/path/{BUILD_HOST}/{FILENAME}"
srcs
{BAZEL_LABEL_NAME}
- Label name{BAZEL_LABEL_PACKAGE}
- Label package{BAZEL_LABEL_WORKSPACE_NAME}
- Workspace name of the label{BAZEL_FULL_LABEL}
- Fulll label string{BAZEL_LABEL}
- Full label without the workspace name{EXT}
- File extension (with the dot){EXTNAME}
- File extension name (without the dot){FILENAME}
- Full file name with extension{FILEPATH}
- Fulle file path. Any relative paths are stripped{BASENAME}
- Path basename | None
|
-| force | Overwrite existing paths even if they are not symlinks | None
|
-| strip_filepath_prefix | Strip prefix of {FILEPATH}
| ""
|
-| metafile_path | Path to metafile | ""
|
-| visibility | visibility of the executable target | None
|
-| kwargs | rest of arguments get passed to underlying targets | none |
-
-
diff --git a/rules/BUILD.bazel b/rules/BUILD.bazel
index e69de29..e296829 100644
--- a/rules/BUILD.bazel
+++ b/rules/BUILD.bazel
@@ -0,0 +1,68 @@
+load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
+load("@stardoc//stardoc:stardoc.bzl", "stardoc")
+
+bzl_library(
+ name = "bzlws_copy",
+ visibility = ["//visibility:public"],
+ srcs = [
+ "bzlws_copy.bzl",
+ ],
+ deps = [
+ "//rules/private:bzlws_info",
+ "//rules/private:bzlws_util",
+ "//rules/private:bzlws_tool_cc_binary",
+ ],
+)
+
+stardoc(
+ name = "bzlws_copy_doc",
+ visibility = ["//:__pkg__"],
+ input = "bzlws_copy.bzl",
+ out = "bzlws_copy.md",
+ symbol_names = ["bzlws_copy"],
+ deps = [":bzlws_copy"],
+)
+
+bzl_library(
+ name = "bzlws_link",
+ visibility = ["//visibility:public"],
+ srcs = [
+ "bzlws_link.bzl",
+ ],
+ deps = [
+ "//rules/private:bzlws_info",
+ "//rules/private:bzlws_util",
+ "//rules/private:bzlws_tool_cc_binary",
+ ],
+)
+
+stardoc(
+ name = "bzlws_link_doc",
+ visibility = ["//:__pkg__"],
+ input = "bzlws_link.bzl",
+ out = "bzlws_link.md",
+ symbol_names = ["bzlws_link"],
+ deps = [":bzlws_link"],
+)
+
+bzl_library(
+ name = "bzlws_extract",
+ visibility = ["//visibility:public"],
+ srcs = [
+ "bzlws_extract.bzl",
+ ],
+ deps = [
+ "//rules/private:bzlws_info",
+ "//rules/private:bzlws_util",
+ "//rules/private:bzlws_tool_cc_binary",
+ ],
+)
+
+stardoc(
+ name = "bzlws_extract_doc",
+ visibility = ["//:__pkg__"],
+ input = "bzlws_extract.bzl",
+ out = "bzlws_extract.md",
+ symbol_names = ["bzlws_extract"],
+ deps = [":bzlws_extract"],
+)
diff --git a/rules/bzlws_copy.bzl b/rules/bzlws_copy.bzl
index 50b7db8..c9ffbd8 100644
--- a/rules/bzlws_copy.bzl
+++ b/rules/bzlws_copy.bzl
@@ -1,4 +1,3 @@
-load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//rules/private:bzlws_tool_cc_binary.bzl", "bzlws_tool_cc_binary")
load("//rules/private:bzlws_util.bzl", "bzlws_check_common_required_attrs")
@@ -6,7 +5,7 @@ def bzlws_copy(name = None, srcs = None, out = None, force = None, strip_filepat
"""Copy generated files into workspace directory
```python
- load("@bzlws//:index.bzl", "bzlws_copy")
+ load("@bzlws//rules:bzlws_copy.bzl", "bzlws_copy")
```
Args:
@@ -73,17 +72,17 @@ def bzlws_copy(name = None, srcs = None, out = None, force = None, strip_filepat
bzlws_check_common_required_attrs("bzlws_copy", name, srcs, out)
bzlws_tool_cc_binary(
- name = name,
- srcs = srcs,
- out = out,
- strip_filepath_prefix = strip_filepath_prefix,
- force = force,
- metafile_path = metafile_path,
- substitutions = substitutions,
- stamp_substitutions = stamp_substitutions,
- tool = "bzlws_copy",
- deps = ["@bzlws//tools/bzlws_copy"],
- visibility = ["//visibility:private"],
- tags = tags + ["ibazel_notify_changes"],
- **kwargs
+ name = name,
+ srcs = srcs,
+ out = out,
+ strip_filepath_prefix = strip_filepath_prefix,
+ force = force,
+ metafile_path = metafile_path,
+ substitutions = substitutions,
+ stamp_substitutions = stamp_substitutions,
+ tool = "bzlws_copy",
+ deps = ["@bzlws//tools/bzlws_copy"],
+ visibility = ["//visibility:private"],
+ tags = tags + ["ibazel_notify_changes"],
+ **kwargs
)
diff --git a/rules/bzlws_extract.bzl b/rules/bzlws_extract.bzl
index 9e4ff6f..ee21327 100644
--- a/rules/bzlws_extract.bzl
+++ b/rules/bzlws_extract.bzl
@@ -1,4 +1,3 @@
-load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//rules/private:bzlws_tool_cc_binary.bzl", "bzlws_tool_cc_binary")
load("//rules/private:bzlws_util.bzl", "bzlws_check_common_required_attrs")
@@ -6,7 +5,7 @@ def bzlws_extract(name = None, srcs = None, out = None, force = None, strip_file
bzlws_check_common_required_attrs("bzlws_extract", name, srcs, out)
bzlws_tool_cc_binary(
- name = sh_script_name,
+ name = name,
srcs = srcs,
out = out,
strip_filepath_prefix = strip_filepath_prefix,
diff --git a/rules/bzlws_link.bzl b/rules/bzlws_link.bzl
index f2a9974..a708644 100644
--- a/rules/bzlws_link.bzl
+++ b/rules/bzlws_link.bzl
@@ -1,4 +1,3 @@
-load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//rules/private:bzlws_tool_cc_binary.bzl", "bzlws_tool_cc_binary")
load("//rules/private:bzlws_util.bzl", "bzlws_check_common_required_attrs")
diff --git a/rules/private/BUILD.bazel b/rules/private/BUILD.bazel
index f1b1c61..90df7c2 100644
--- a/rules/private/BUILD.bazel
+++ b/rules/private/BUILD.bazel
@@ -1,3 +1,40 @@
+load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
+load("@stardoc//stardoc:stardoc.bzl", "stardoc")
+
package(default_visibility = ["//:__subpackages__"])
-exports_files(["bzlws_info.bzl"])
+bzl_library(
+ name = "rules_cc",
+ srcs = [
+ "@rules_cc//cc:action_names.bzl",
+ "@rules_cc//cc:defs.bzl",
+ "@rules_cc//cc:find_cc_toolchain.bzl",
+ "@rules_cc//cc/private/rules_impl:cc_flags_supplier.bzl",
+ "@rules_cc//cc/private/rules_impl:cc_flags_supplier_lib.bzl",
+ "@rules_cc//cc/private/rules_impl:compiler_flag.bzl",
+ "@bazel_tools//tools/build_defs/cc:action_names.bzl",
+ ],
+ visibility = ["//rules:__subpackages__"],
+)
+
+bzl_library(
+ name = "bzlws_info",
+ srcs = ["bzlws_info.bzl"],
+ deps = [
+ ],
+)
+
+bzl_library(
+ name = "bzlws_util",
+ srcs = ["bzlws_util.bzl"],
+ deps = [
+ ],
+)
+
+bzl_library(
+ name = "bzlws_tool_cc_binary",
+ srcs = ["bzlws_tool_cc_binary.bzl"],
+ deps = [
+ ":rules_cc",
+ ],
+)