summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE202
-rw-r--r--README.md560
-rw-r--r--ROOT0
-rw-r--r--doc/being-consumed-by-cmake.md167
-rw-r--r--doc/consume-cmake-libraries.md138
-rw-r--r--etc/README.template.md55
-rw-r--r--etc/defaults/CC/TARGETS3
-rw-r--r--etc/defaults/CC/auto/TARGETS (renamed from CC/auto/TARGETS)0
-rw-r--r--etc/defaults/CC/foreign/TARGETS (renamed from CC/foreign/TARGETS)0
-rw-r--r--etc/defaults/CC/proto/TARGETS14
-rw-r--r--etc/defaults/CC/test/TARGETS (renamed from CC/test/TARGETS)0
-rw-r--r--etc/defaults/patch/TARGETS3
-rw-r--r--etc/defaults/shell/TARGETS (renamed from CC/pkgconfig/TARGETS)0
-rw-r--r--etc/defaults/shell/test/TARGETS (renamed from shell/test/TARGETS)0
-rwxr-xr-xetc/generate-doc.sh81
-rwxr-xr-xetc/generate-repos.sh25
-rw-r--r--etc/imports/gtest.TARGETS6
-rw-r--r--etc/imports/libcurl.TARGETS6
-rw-r--r--etc/imports/libs.TARGETS10
-rw-r--r--etc/imports/libz.TARGETS6
-rw-r--r--etc/imports/rules.TARGETS1
-rwxr-xr-xetc/json-format.py85
-rw-r--r--etc/repos.json502
-rw-r--r--etc/repos.template.json72
-rw-r--r--rules/CC/EXPRESSIONS (renamed from CC/EXPRESSIONS)0
-rw-r--r--rules/CC/RULES (renamed from CC/RULES)0
-rw-r--r--rules/CC/TARGETS (renamed from CC/TARGETS)0
-rw-r--r--rules/CC/auto/EXPRESSIONS (renamed from CC/auto/EXPRESSIONS)0
-rw-r--r--rules/CC/auto/RULES (renamed from CC/auto/RULES)0
-rw-r--r--rules/CC/auto/TARGETS1
-rwxr-xr-xrules/CC/auto/runner (renamed from CC/auto/runner)0
-rw-r--r--rules/CC/foreign/EXPRESSIONS (renamed from CC/foreign/EXPRESSIONS)0
-rw-r--r--rules/CC/foreign/RULES (renamed from CC/foreign/RULES)0
-rw-r--r--rules/CC/foreign/TARGETS7
-rw-r--r--rules/CC/foreign/cmake/EXPRESSIONS (renamed from CC/foreign/cmake/EXPRESSIONS)0
-rw-r--r--rules/CC/foreign/cmake/RULES (renamed from CC/foreign/cmake/RULES)0
-rwxr-xr-xrules/CC/foreign/expand_exec (renamed from CC/foreign/expand_exec)0
-rw-r--r--rules/CC/foreign/expand_exec.c (renamed from CC/foreign/expand_exec.c)0
-rw-r--r--rules/CC/foreign/make/EXPRESSIONS (renamed from CC/foreign/make/EXPRESSIONS)0
-rw-r--r--rules/CC/foreign/make/RULES (renamed from CC/foreign/make/RULES)0
-rw-r--r--rules/CC/foreign/shell/EXPRESSIONS (renamed from CC/foreign/shell/EXPRESSIONS)0
-rw-r--r--rules/CC/foreign/shell/RULES (renamed from CC/foreign/shell/RULES)0
-rw-r--r--rules/CC/pkgconfig/EXPRESSIONS (renamed from CC/pkgconfig/EXPRESSIONS)0
-rw-r--r--rules/CC/pkgconfig/RULES (renamed from CC/pkgconfig/RULES)0
-rw-r--r--rules/CC/pkgconfig/TARGETS (renamed from shell/TARGETS)0
-rwxr-xr-xrules/CC/pkgconfig/add_rpath (renamed from CC/pkgconfig/add_rpath)0
-rw-r--r--rules/CC/prebuilt/EXPRESSIONS (renamed from CC/prebuilt/EXPRESSIONS)0
-rw-r--r--rules/CC/prebuilt/RULES (renamed from CC/prebuilt/RULES)0
-rwxr-xr-xrules/CC/prebuilt/read_pkgconfig.py (renamed from CC/prebuilt/read_pkgconfig.py)0
-rw-r--r--rules/CC/proto/EXPRESSIONS (renamed from CC/proto/EXPRESSIONS)0
-rw-r--r--rules/CC/proto/RULES (renamed from CC/proto/RULES)0
-rw-r--r--rules/CC/proto/TARGETS (renamed from CC/proto/TARGETS)0
-rw-r--r--rules/CC/test/EXPRESSIONS (renamed from CC/test/EXPRESSIONS)0
-rw-r--r--rules/CC/test/RULES (renamed from CC/test/RULES)0
-rw-r--r--rules/CC/test/TARGETS1
-rwxr-xr-xrules/CC/test/runner (renamed from CC/test/runner)0
-rw-r--r--rules/EXPRESSIONS (renamed from EXPRESSIONS)0
-rw-r--r--rules/data/EXPRESSIONS (renamed from data/EXPRESSIONS)0
-rw-r--r--rules/data/RULES (renamed from data/RULES)0
-rw-r--r--rules/patch/EXPRESSIONS (renamed from patch/EXPRESSIONS)0
-rw-r--r--rules/patch/RULES (renamed from patch/RULES)0
-rw-r--r--rules/patch/TARGETS (renamed from patch/TARGETS)0
-rw-r--r--rules/proto/RULES (renamed from proto/RULES)0
-rw-r--r--rules/shell/EXPRESSIONS (renamed from shell/EXPRESSIONS)0
-rw-r--r--rules/shell/RULES (renamed from shell/RULES)0
-rw-r--r--rules/shell/TARGETS1
-rw-r--r--rules/shell/test/EXPRESSIONS (renamed from shell/test/EXPRESSIONS)0
-rw-r--r--rules/shell/test/RULES (renamed from shell/test/RULES)0
-rw-r--r--rules/shell/test/TARGETS1
-rwxr-xr-xrules/shell/test/runner (renamed from shell/test/runner)0
-rwxr-xr-xrules/shell/test/summarizer (renamed from shell/test/summarizer)0
-rw-r--r--rules/transitions/EXPRESSIONS (renamed from transitions/EXPRESSIONS)0
-rw-r--r--tests/ROOT0
-rw-r--r--tests/TARGETS6
-rw-r--r--tests/test_cases/cflags/TARGETS19
-rw-r--r--tests/test_cases/cflags/public/TARGETS49
-rw-r--r--tests/test_cases/cflags/public/half.cpp5
-rw-r--r--tests/test_cases/cflags/public/half.hpp12
-rw-r--r--tests/test_cases/cflags/public/half3.cpp3
-rw-r--r--tests/test_cases/cflags/public/half3.hpp8
-rw-r--r--tests/test_cases/cflags/public/half3f.cpp7
-rw-r--r--tests/test_cases/cflags/public/half3f.hpp6
-rw-r--r--tests/test_cases/cflags/public/main_use_half3.cpp7
-rw-r--r--tests/test_cases/cflags/public/main_use_half3f.cpp11
-rw-r--r--tests/test_cases/cflags/public/test_use_half3.cpp6
-rw-r--r--tests/test_cases/cflags/public/test_use_half3f.cpp10
-rw-r--r--tests/test_cases/deps/TARGETS287
-rw-r--r--tests/test_cases/deps/cmake/TARGETS76
-rw-r--r--tests/test_cases/deps/cmake/main.cpp8
-rw-r--r--tests/test_cases/deps/cmake/test.cpp3
-rw-r--r--tests/test_cases/deps/cmake/test.sh5
-rw-r--r--tests/test_cases/deps/install/TARGETS69
-rw-r--r--tests/test_cases/deps/install/bar.cpp7
-rw-r--r--tests/test_cases/deps/install/bar.hpp8
-rw-r--r--tests/test_cases/deps/install/baz.cpp7
-rw-r--r--tests/test_cases/deps/install/baz.hpp10
-rw-r--r--tests/test_cases/deps/install/foo.cpp10
-rw-r--r--tests/test_cases/deps/install/foo.hpp8
-rw-r--r--tests/test_cases/deps/install/main.cpp10
-rw-r--r--tests/test_cases/deps/install/qux.hpp8
-rw-r--r--tests/test_cases/deps/object/TARGETS43
-rw-r--r--tests/test_cases/deps/object/bar.cpp3
-rw-r--r--tests/test_cases/deps/object/bar.hpp9
-rw-r--r--tests/test_cases/deps/object/foo.cpp3
-rw-r--r--tests/test_cases/deps/object/foo.hpp8
-rw-r--r--tests/test_cases/deps/object/main.cpp8
-rw-r--r--tests/test_cases/deps/prebuilt/TARGETS158
-rw-r--r--tests/test_cases/deps/prebuilt/bar.hpp8
-rw-r--r--tests/test_cases/deps/prebuilt/foo.hpp8
-rw-r--r--tests/test_cases/deps/private/TARGETS36
-rw-r--r--tests/test_cases/deps/private/bar.cpp8
-rw-r--r--tests/test_cases/deps/private/bar.hpp6
-rw-r--r--tests/test_cases/deps/private/foo.cpp7
-rw-r--r--tests/test_cases/deps/private/foo.hpp6
-rw-r--r--tests/test_cases/deps/private/main_includes_foo.cpp9
-rw-r--r--tests/test_cases/deps/private/main_links_bar_foo.cpp9
-rw-r--r--tests/test_cases/deps/private/main_links_foo.cpp10
-rw-r--r--tests/test_cases/deps/public/TARGETS36
-rw-r--r--tests/test_cases/deps/public/bar.cpp7
-rw-r--r--tests/test_cases/deps/public/bar.hpp8
-rw-r--r--tests/test_cases/deps/public/foo.cpp7
-rw-r--r--tests/test_cases/deps/public/foo.hpp8
-rw-r--r--tests/test_cases/deps/public/main_includes_foo.cpp9
-rw-r--r--tests/test_cases/deps/public/main_links_bar_foo.cpp10
-rw-r--r--tests/test_cases/deps/public/main_links_foo.cpp10
-rw-r--r--tests/test_cases/deps/shared/TARGETS104
-rw-r--r--tests/test_cases/deps/shared/bar.cpp8
-rw-r--r--tests/test_cases/deps/shared/bar.hpp6
-rw-r--r--tests/test_cases/deps/shared/baz.cpp8
-rw-r--r--tests/test_cases/deps/shared/baz.hpp6
-rw-r--r--tests/test_cases/deps/shared/foo.cpp7
-rw-r--r--tests/test_cases/deps/shared/foo.hpp6
-rw-r--r--tests/test_cases/deps/shared/main_uses_bar.cpp8
-rw-r--r--tests/test_cases/deps/shared/main_uses_foo.cpp8
-rw-r--r--tests/test_cases/deps/shared/test_diamond.cpp4
-rw-r--r--tests/test_cases/deps/shared/test_uses_bar.cpp3
-rw-r--r--tests/test_cases/deps/shared/test_uses_baz.cpp3
-rw-r--r--tests/test_cases/deps/shared/test_uses_foo.cpp3
-rw-r--r--tests/test_cases/deps/shared/test_uses_main.sh7
-rw-r--r--tests/test_rules/EXPRESSIONS46
-rw-r--r--tests/test_rules/README.md28
-rw-r--r--tests/test_rules/RULES243
-rw-r--r--tests/test_rules/TARGETS1
-rwxr-xr-xtests/test_rules/test_runner.py90
144 files changed, 3635 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fb190b5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,560 @@
+# C/C++ rules for the `just` build system
+
+A collection of rules for building C/C++ libraries and binaries.
+
+## How to use this Repository
+
+There are two ways to import this repository. You can generate your
+`repos.json` from a template (`repos.template.json`) by importing
+the `rules-cc` repository with the tool `just-import-git`
+
+~~~sh
+$ just-import-git -C repos.template.json --as rules-cc -b master https://github.com/just-buildsystem/rules-cc > repos.json
+~~~
+
+Importing this way will also pull in `protoc` and `grpc_cpp_plugin`
+as a dependency for generating bindings for proto dependencies, if
+this feature is used.
+
+Alternatively, the `rules-cc` repository can be added manually to
+your `repos.json`.
+
+~~~jsonc
+...
+ , "rules-cc":
+ { "repository":
+ { "type": "git"
+ , "branch": "master"
+ , "commit": "2ea50063460a3e11dfcbb71651540c0d61fddc1a"
+ , "repository": "https://github.com/just-buildsystem/rules-cc"
+ , "subdir": "rules"
+ }
+ }
+...
+~~~
+
+Importing this way, `protoc` and `grpc_cpp_plugin` will be taken
+from the host system. To change the binary names or to bring your
+own proto toolchain, add a corresponding `target_root` layer (and
+provide the needed binding, if your target files refer to other
+repositories containing the toolchain).
+
+## Consume and being consumed by CMake Libraries
+
+For interoperability with CMake projects, see
+
+- [consume CMake libraries](./doc/consume-cmake-libraries.md)
+- [being consumed by CMake](./doc/being-consumed-by-cmake.md)
+
+## Rule Documentation
+
+In this documentation, the standard configuration variables
+`"AR"`, `"CC"`, `"CXX"`, `"CFLAGS"`, `"CXXFLAGS"`,`"LDFLAGS"`,
+`"ADD_CFLAGS"`, `"ADD_CXXFLAGS"`, `"ADD_LDFLAGS"`, `"ENV"`,
+`"BUILD_POSITION_INDEPENDENT"` are ommitted.
+
+### Rule `["CC", "defaults"]`
+
+A rule to provide defaults. All CC targets take their defaults for CC, CXX, flags, etc from the target `["CC", "defaults"]`. This is probably the only sensible use of this rule. As targets form a different root, the defaults can be provided without changing this directory.
+
+| Field | Description |
+| ----- | ----------- |
+| `"CC"` | The C compiler to use |
+| `"CXX"` | The C++ compiler to use |
+| `"CFLAGS"` | Flags for C compilation. Specifying this field overwrites values from `"base"`. |
+| `"CXXFLAGS"` | Flags for C++ compilation. Specifying this field overwrites values from `"base"`. |
+| `"LDFLAGS"` | Linker flags for linking the final CC library. Specifying this field overwrites values from `"base"`. |
+| `"ADD_COMPILE_FLAGS"` | Additional compilation flags for C and C++. Specifying this field extends values from `"base"` for both, `"CFLAGS"` and `"CXXFLAGS"`. |
+| `"ADD_CFLAGS"` | Additional compilation flags specific for C. Specifying this field extends values from `"base"`. |
+| `"ADD_CXXFLAGS"` | Additional compilation flags specific for C++. Specifying this field extends values from `"base"`. |
+| `"ADD_LDFLAGS"` | Additional linker flags for linking the final CC library. Specifying this field extends values from `"base"`. |
+| `"AR"` | The archiver tool to use |
+| `"PATH"` | Path for looking up the compilers. Individual paths are joined with `":"`. Specifying this field extends values from `"base"`. |
+| `"SYSTEM_TOOLS"` | List of tools (`"CC"`, `"CXX"`, or `"AR"`) that should be taken from the system instead of from `"toolchain"` (if specified). |
+| `"base"` | Other targets (using the same rule) to inherit values from. |
+| `"toolchain"` | Optional toolchain directory. A collection of artifacts that provide the tools CC, CXX, and AR (if needed). Note that only artifacts of the specified targets are considered (no runfiles etc.). Specifying this field extends artifacts from `"base"`. If the toolchain supports cross-compilation, it should perform a dispatch on the configuration variable `"BUILD_ARCH"` to determine for which architecture to generate code for. |
+| `"deps"` | Optional CC libraries any CC library and CC binary implicitly depend on. Those are typically `"libstdc++"` or `"libc++"` for C++ targets. Specifying this field extends dependencies from `"base"`. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"ARCH"` | The unqualified architecture. Is taken as a default for `"HOST_ARCH"` and `"TARGET_ARCH"` if not set. |
+| `"HOST_ARCH"` | The architecture on which the build actions are carried out. |
+| `"TARGET_ARCH"` | The architecture for which to build. |
+| `"DEBUG"` | Compute the debug-stage, needed for local debugging. |
+
+### Rule `["CC/proto", "defaults"]`
+
+A rule to provide protoc/GRPC defaults. Used to implement `["CC/proto", "defaults"]` for CC proto libraries and `["CC/proto", "service defaults"]` for CC proto service libraries (GRPC).
+
+| Field | Description |
+| ----- | ----------- |
+| `"PROTOC"` | The proto compiler. If `"toolchain"` is empty, this field's value is considered the proto compiler name that is looked up in `"PATH"`. If `"toolchain"` is non-empty, this field's value is assumed to be the relative path to the proto compiler in `"toolchain"`. Specifying this field overwrites values from `"base"`. |
+| `"PROTOCFLAGS"` | Protobuf compiler flags. Specifying this field overwrites values from `"base"`. |
+| `"ADD_PROTOCFLAGS"` | Additional protobuf compiler flags. Specifying this field extends values from `"base"`. |
+| `"LDFLAGS"` | Linker flags for linking the final CC library. Specifying this field overwrites values from `"base"`. |
+| `"ADD_LDFLAGS"` | Additional linker flags for linking the final CC library. Specifying this field extends values from `"base"`. |
+| `"GRPC_PLUGIN"` | The GRPC plugin for the proto compiler. If `"toolchain"` is empty, this field's value is considered to be the absolute system path to the plugin. If `"toolchain"` is non-empty, this field's value is assumed to be the relative path to the plugin in `"toolchain"`. Specifying this field overwrites values from `"base"`. |
+| `"PATH"` | Path for looking up the proto compiler. Individual paths are joined with `":"`. Specifying this field extends values from `"base"`. |
+| `"base"` | Other targets (using the same rule) to inherit values from. If multiple targets are specified, for values that are overwritten (see documentation of other fields) the last specified value wins. |
+| `"toolchain"` | Optional toolchain directory. A collection of artifacts that provide the protobuf compiler and the GRPC plugin (if needed). Note that only artifacts of the specified targets are considered (no runfiles etc.). Specifying this field extends artifacts from `"base"`. |
+| `"deps"` | Optional CC libraries the resulting CC proto libraries implicitly depend on. Those are typically `"libprotobuf"` for CC proto libraries and `"libgrpc++"` for CC proto service libraries. Specifying this field extends dependencies from `"base"`. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"ARCH"` | The unqualified architecture. Is taken as a default for `"HOST_ARCH"` and `"TARGET_ARCH"` if not set. |
+| `"HOST_ARCH"` | The architecture on which the build actions are carried out. |
+| `"DEBUG"` | Compute the debug-stage, needed for local debugging. |
+
+### Rule `["CC/foreign", "defaults"]`
+
+A rule to provide defaults for foreign rules. All foreign rules take their defaults for MAKE, CMAKE, etc from the target `["CC/foreign", "defaults"]`.
+
+| Field | Description |
+| ----- | ----------- |
+| `"MAKE"` | The make binary to use |
+| `"CMAKE"` | The cmake binary to use |
+| `"PATH"` | Path for looking up the tools. Individual paths are joined with with `":"`. Specifying this field extends values from `"base"`. |
+| `"SYSTEM_TOOLS"` | List of tools (`"MAKE"`, `"CMAKE"`) that should be taken from the system instead of from `"toolchain"` (if specified). |
+| `"base"` | Other targets (using the same rule) to inherit values from. |
+| `"toolchain"` | Optional toolchain directory. A collection of artifacts that provide the tools MAKE, CMAKE. Note that only artifacts of the specified targets are considered (no runfiles etc.). Specifying this field extends artifacts from `"base"`. |
+
+### Rule `["patch", "defaults"]`
+
+A rule to provide defaults. All targets take their defaults for PATCH from the target `["patch", "defaults"]`. This is probably the only sensible use of this rule. As targets form a different root, the defaults can be provided without changing this directory.
+
+| Field | Description |
+| ----- | ----------- |
+| `"PATCH"` | The patch binary to use |
+| `"PATH"` | Path for looking up the compilers. Individual paths are joined with `":"`. Specifying this field extends values from `"base"`. |
+| `"SYSTEM_TOOLS"` | List of tools (`"PATCH"`) that should be taken from the system instead of from `"toolchain"` (if specified). |
+| `"base"` | Other targets (using the same rule) to inherit values from. |
+| `"toolchain"` | Optional toolchain directory. A collection of artifacts that provide the tool PATCH. Note that only artifacts of the specified targets are considered (no runfiles etc.). Specifying this field extends artifacts from `"base"`. |
+
+### Rule `["CC", "binary"]`
+
+A binary written in C++
+
+| Field | Description |
+| ----- | ----------- |
+| `"name"` | The name of the binary |
+| `"stage"` | The logical location of all header and source files, as well as the resulting binary file. Individual directory components are joined with `"/"`. |
+| `"pure C"` | If non-empty, compile as C sources rathter than C++ sources. In particular, CC is used to compile rather than CXX |
+| `"private-defines"` | List of defines set for source files local to this target. Each list entry will be prepended by `"-D"`. |
+| `"private-cflags"` | List of compile flags set for source files local to this target. |
+| `"private-ldflags"` | Additional linker flags for linking external libraries. |
+| `"srcs"` | The source files of the library. |
+| `"private-hdrs"` | Any header files that need to be present when compiling the source files. |
+| `"private-deps"` | Any other libraries this binary depends upon. |
+| `"private-proto"` | Any `["proto", "library"]` this target depends upon directly. The creation of C++ bindings for this proto library as well as of is dependencies will be taken care of (as anonymous targets, so no duplicate work will be carried out, even if the same proto library is used at various places). |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"DEBUG"` | Compute the debug-stage, needed for local debugging. |
+
+### Rule `["CC", "library"]`
+
+A C++ library
+
+| Field | Description |
+| ----- | ----------- |
+| `"name"` | The name of the library (without leading `"lib"` or trailing `".a"`). |
+| `"stage"` | The logical location of all header and source files, as well as the resulting library file. Individual directory components are joined with `"/"`. |
+| `"pure C"` | If non-empty, compile as C sources rather than C++ sources. In particular, CC is used to compile rather than CXX (or their respective defaults). |
+| `"defines"` | List of defines set for this target and its consumers. Each list entry will be prepended by `"-D"`. |
+| `"private-defines"` | List of defines set for source files local to this target. Each list entry will be prepended by `"-D"`. |
+| `"cflags"` | List of compile flags set for this target and its consumers. |
+| `"private-cflags"` | List of compile flags set for source files local to this target. |
+| `"ldflags"` | Additional linker flags for linking external libraries for this target and its consumers (not built by this tool, typically system libraries). |
+| `"private-ldflags"` | Additional linker flags for linking external libraries (not built by this tool, typically system libraries). |
+| `"soversion"` | The SOVERSION for shared libraries. Individual version components are joined with `"."`. |
+| `"pkg-name"` | Name to use for pkg-config files. If this field is empty, the field `"name"` is used instead. |
+| `"srcs"` | The source files of the library. |
+| `"hdrs"` | Any public header files of the library. |
+| `"private-hdrs"` | Any header files that only need to be present when compiling the source files, but are not needed for any consumer of the library. |
+| `"deps"` | Any other libraries this library depends upon. |
+| `"private-deps"` | Any other libraries this library depends upon but does not include in its public headers. |
+| `"proto"` | Any `["proto", "library"]` this target depends upon directly. The creation of C++ bindings for this proto library as well as of its dependencies will be taken care of (as anonymous targets, so no duplicate work will be carried out, even if the same proto library is used at various places). |
+| `"private-proto"` | Any `["proto", "library"]` this target depends upon privately. The creation of C++ bindings for this proto library as well as of its dependencies will be taken care of (as anonymous targets, so no duplicate work will be carried out, even if the same proto library is used at various places). |
+| `"shared"` | If non-empty, produce a shared instead of a static library. Setting this option is mutually exclusive to the `"object_only"` option. |
+| `"object_only"` | If non-empty, produce an object library, resulting in object files added to the linker line of all depending targets. Setting this option is mutually exclusive to the `"shared"` option. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"DEBUG"` | Compute the debug-stage, needed for local debugging. |
+
+### Rule `["CC/prebuilt", "library"]`
+
+A prebuilt C++ library
+
+| Field | Description |
+| ----- | ----------- |
+| `"name"` | The name of the library (without leading `"lib"` or trailing file name extension), also used as name for pkg-config files. |
+| `"version"` | The library version, used for pkg-config files. Individual version components are joined with `"."`. |
+| `"stage"` | The logical location of all header and source files, as well as the resulting library file. Individual directory components are joined with `"/"`. |
+| `"defines"` | List of defines set for this target and its consumers. Each list entry will be prepended by `"-D"`. |
+| `"cflags"` | List of compile flags set for this target and its consumers. |
+| `"ldflags"` | Additional linker flags (typically for linking system libraries). |
+| `"lib"` | The actual prebuilt library. If multiple libraries are specified (e.g., one depends on the other), the order matters. Library types cannot be mixed. All of them have to be either static or shared. |
+| `"hdrs"` | Any public header files of the library. |
+| `"deps"` | Any other libraries this library depends upon. |
+| `"pkg-config"` | Pkg-config file for optional infer of public cflags and ldflags. If multiple files are specified (e.g., one depends on the other), the first one is used as entry. Note that if this field is non-empty the tool `"pkg-config"` must be available in `"PATH"`, which is taken from `["CC", "defaults"]` or the `"ENV"` variable. |
+
+### Rule `["CC/pkgconfig", "system_library"]`
+
+A system library via pkg-config
+
+| Field | Description |
+| ----- | ----------- |
+| `"name"` | The pkg-config name of the library. |
+| `"args"` | Additional pkg-config arguments (e.g., `"--define-prefix"` or `"--static"`), appended to the config variable `"PKG_CONFIG_ARGS"`. |
+| `"stage"` | The stage of the internally created flag files. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"PKG_CONFIG_ARGS"` | Additional pkg-config arguments (e.g., `"--define-prefix"` or `"--static"`). |
+
+### Rule `["CC", "install-with-deps"]`
+
+Install target's artifacts with transitive dependencies. Depending on the target, artifacts and dependencies will be installed to subdirectories `"bin"`, `"include"`, and `"lib"`. For library targets, a pkg-config file is generated and provided in `"lib/pkgconfig"`. In debug mode, depending on the target, additional artifacts needed for local debugging are gathered and installed, depending on target, to `"work"` and `"include"`.
+
+| Field | Description |
+| ----- | ----------- |
+| `"flat-libs"` | Install libraries flat to the `"lib"` subdirectory. Be aware that conflicts may occur if any of the (transitive) libraries happen to have the same base name. |
+| `"prefix"` | The prefix used for pkg-config files. The path will be made absolute and individual directory components are joined with `"/"`. If no prefix is specified, the value from the config variable `"PREFIX"` is taken, with the default value being `"/"`. |
+| `"hdrs-only"` | Only collect headers from deps (without subdirectory). |
+| `"skip-debug-stage"` | If in debug mode, skip installing additional artifacts gathered if no local debugging is needed, but debug targets are nonetheless desired. |
+| `"targets"` | Targets to install artifacts from. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"PREFIX"` | The absolute path that is used as prefix inside generated pkg-config files. The default value for this variable is `"/"`. This variable is ignored if the field `"prefix"` is set. |
+
+### Rule `["CC/test", "test"]`
+
+A test written in C++
+
+| Field | Description |
+| ----- | ----------- |
+| `"name"` | The name of the test Used to name the test binary as well as for staging the test result |
+| `"args"` | Command line arguments for the test binary |
+| `"stage"` | The logical location of all header and source files. Individual directory components are joined with `"/"`. |
+| `"private-defines"` | List of defines set for source files local to this target. Each list entry will be prepended by `"-D"`. |
+| `"private-cflags"` | List of compile flags set for source files local to this target. |
+| `"private-ldflags"` | Additional linker flags for linking external libraries (not built by this tool, typically system libraries). |
+| `"srcs"` | The sources of the test binary The resulting test binary is run in an environment where it can assume that the environment variable TEST_TMPDIR points to a directory that may be used exclusively by this test. For convenience, the environment variable TMPDIR is also set to TEST_TMPDIR. This running of the test is carried out by the implicit dependency on the target `"runner"`. By setting this target in the target layer of this rules repository (instead of letting it default to the respective file), the C/C++ test environment can be modified globally. |
+| `"private-hdrs"` | Any additional header files that need to be present when compiling the test binary. |
+| `"data"` | Any files the test binary needs access to when running |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"TARGET_ARCH"` | The architecture to build the test for. Will only be honored, if that architecture is available in the ARCH_DISPATCH map. Otherwise, the test will be built for and run on the host architecture. |
+| `"TEST_ENV"` | The environment for executing the test runner. |
+| `"TIMEOUT_SCALE"` | Factor on how to scale the timeout for this test. Defaults to 1.0. |
+| `"CC_TEST_LAUNCHER"` | List of strings representing the launcher that is prepend to the command line for running the test binary. |
+| `"RUNS_PER_TEST"` | The number of times the test should be run in order to detect flakyness. If set, no test action will be taken from cache. Test runs are summarized by the `["shell/test", "summarizer"]` that is also used by shell tests. |
+| `"ARCH_DISPATCH"` | Map of architectures to execution properties that ensure execution on that architecture. Only the actual test binary will be run with the specified execution properties (i.e., on the target architecture); all building will be done on the host architecture. |
+| `"TEST_SUMMARY_EXECUTION_PROPERTIES"` | Additional remote-execution properties for the test-summarizing action in case RUNS_PER_TEST is set; defaults to the empty map. |
+
+### Rule `["shell", "defaults"]`
+
+A rule to provide defaults for the usage of the shell
+
+ All targets using invocations of the shell use the target `["shel", "defaults"]` to determine which shell to use and how to invoke it. The definition of this default target is probably the only meaningful use of this rule.
+
+| Field | Description |
+| ----- | ----------- |
+| `"sh"` | The name of the sh binary; if the the field `"toolchain"` is not empty, the value is interpreted as relative to the toolchain directory. |
+| `"PATH"` | Paths for looking up system tools. Specifying this field extends values from `"base"`. |
+| `"bin dirs"` | Directories of the toolchain that contain additional binaries. Shell-specific rules will add those into PATH. |
+| `"base"` | Other targets (using the same rule) to inherit values from. |
+| `"toolchain"` | Optional toolchain directory. A collection of artifacts that form the toolchain, in particular the shell itself, where not taken from the ambient host environment. Values provided from base are extended. This field is built for the host. |
+
+### Rule `["shell", "cmds"]`
+
+Execute comands using the shell
+
+ This rule behaves similar to the built-in `"generic"` rule, however with the difference that the shell toolchain is honored.
+
+| Field | Description |
+| ----- | ----------- |
+| `"cmds"` | The command to be executed. Individual entries are joined by newline characters; the whole script is then prefixed by commands necessary to set up the work environment using the shell tool chain. |
+| `"outs"` | The expected file outputs |
+| `"out_dirs"` | The expected output directories |
+| `"deps"` | Any inputs to the argument. Both, artifacts and rufiles of the dependecies are staged into the (effective) working directory of the action. Conflicts are resolved by giving artifacts priority to runfiles, and within each of those priority to ones brought by the latest dependency. |
+
+### Rule `["shell/test", "script"]`
+
+Shell test, given by a test script
+
+| Field | Description |
+| ----- | ----------- |
+| `"keep"` | List of names (relative to the test working directory) of files that the test might generate that should be kept as part of the output. This might be useful for further analysis of the test |
+| `"name"` | A name for the test, used in reporting, as well as for staging the test result tree in the runfiles |
+| `"deps"` | Any targets that should be staged (with artifacts and runfiles) into the tests working directory |
+| `"test"` | The shell script for the test, launched with sh. An empty directory is created to store any temporary files needed by the test, and it is made available in the environment variable TEST_TMPDIR. The test should not assume write permissions outside the working directory and the TEST_TMPDIR. For convenience, the environment variable TMPDIR is also set to TEST_TMPDIR. If the configuration variable RUNS_PER_TEST is set, the environment variable TEST_RUN_NUMBER will also be set to the number of the attempt, counting from 0. This running of the test is carried out by the implicit dependency on the target `"runner"`. By setting this target in the target layer of this rues repository (instead of letting it default to the respective file), the shell test environment can be modified globally. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"RUNS_PER_TEST"` | The number of times the test should be run in order to detect flakyness. If set, no test action will be taken from cache. The individual test runs will be summarized by the implict dependency on the target `"summarizer"`. By setting this target in the target in the target layer of this rues repository (instead of letting it default to the respective file) the layout of the summary can be changed globally. |
+| `"TEST_ENV"` | Additional environment for executing the test runner. |
+| `"TIMEOUT_SCALE"` | Factor on how to scale the timeout for this test. Defaults to 1.0. |
+| `"TARGET_ARCH"` | The architecture to build the test for. Will only be honored, if that architecture is available in the ARCH_DISPATCH map. Otherwise, the test will be built for and run on the host architecture. |
+| `"ARCH_DISPATCH"` | Map of architectures to execution properties that ensure execution on that architecture. Only the actual test binary will be run with the specified execution properties (i.e., on the target architecture); all building will be done on the host architecture. |
+| `"TEST_SUMMARY_EXECUTION_PROPERTIES"` | Additional remote-execution properties for the test-summarizing action in case RUNS_PER_TEST is set; defaults to the empty map. |
+
+### Rule `["CC/foreign/cmake", "library"]`
+
+Library produced by CMake configure, build, and install.
+
+ All variables accessible to commands and options are: `"TMPDIR"`, `"LOCALBASE"`, `"CC"`, `"CXX"`, `"CFLAGS"`, `"CXXFLAGS"`, `"LDFLAGS"`, and `"AR"`. `"LOCALBASE"` contains the path to the installed artifacts from `"deps"`.
+
+| Field | Description |
+| ----- | ----------- |
+| `"subdir"` | The subdirectory that contains the entry CMakeLists.txt. Individual directory components are joined with `"/"`. |
+| `"name"` | The name of the library (without leading `"lib"` or trailing file name extension), also used as name for pkg-config files. |
+| `"version"` | The library version, used for pkg-config files. Individual version components are joined with `"."`. |
+| `"stage"` | The logical location of the public headers and library files. Individual directory components are joined with `"/"`. |
+| `"options"` | CMake options for the configuration phase (e.g., `["-GNinja", "-Ax64"]`). Variables can be accessed via `"$(<varname>)"`, e.g., `"$(TMPDIR)"` for variable `"$TMPDIR"`. |
+| `"defines"` | CMake defines for the configuration phase (e.g., `["CMAKE_BUILD_TYPE=Release"]`). Variables can be accessed via `"$(<varname>)"`, e.g., `"$(TMPDIR)"` for variable `"$TMPDIR"`. |
+| `"jobs"` | Number of jobs to run simultaneously. If omitted, CMake's default number is used. |
+| `"pre_cmds"` | List of commands executed in the project directory before calling CMake. Useful for renaming files or directories. Note that data between `"pre_cmds"` and `"post_cmds"` can be exchanged via `"$TMPDIR"` which is uniquely reserved for this action. |
+| `"post_cmds"` | List of commands executed in the install directory after successful installation but before the output files are collected. Useful for renaming files or directories (e.g., in case of SONAME mismatch). Note that data between `"pre_cmds"` and `"post_cmds"` can be exchanged via `"$TMPDIR"`, which is uniquely reserved for this action. The CMake source and build directory can be accessed via `"$CMAKE_SOURCE_DIR"` and `"$CMAKE_BINARY_DIR"`, respectively. |
+| `"out_hdrs"` | Paths to produced public header files. The path is considered relative to the include directory, which be set via `"hdr_prefix"`. Note that `"out_hdrs"` and `"out_hdr_dirs"` may not overlap. |
+| `"out_hdr_dirs"` | Paths to produced public header directories. The path is considered relative to the include directory, which be set via `"hdr_prefix"`. Note that `"out_hdrs"` and `"out_hdr_dirs"` may not overlap. |
+| `"out_libs"` | Paths to produced library files. The path is considered relative to the library directory, which be set via `"lib_prefix"`. Order matters in the case of one library depending on another. |
+| `"cflags"` | List of compile flags set for this target and its consumers. |
+| `"ldflags"` | Additional linker flags that are required for the consumer of the produced libraries. |
+| `"pkg-config"` | Pkg-config file for optional infer of public cflags and ldflags. If multiple files are specified (e.g., one depends on the other), the first one is used as entry. Note that if this field is non-empty the tool `"pkg-config"` must be available in `"PATH"`, which is taken from `["CC", "defaults"]` or the `"ENV"` variable. |
+| `"hdr_prefix"` | Prefix where headers will be installed by CMake. Individual directory components are joined with `"/"`. Defaults to `"include"` if not set. |
+| `"lib_prefix"` | Prefix where libraries will be installed by CMake. Individual directory components are joined with `"/"`. Defaults to `"lib"` if not set. |
+| `"pc_prefix"` | Prefix where pkg-config files will be installed by CMake. Individual directory components are joined with `"/"`. Defaults to `"lib/pkgconfig"` if not set. |
+| `"resolve_symlinks"` | Resolve all symlinks in the install directory. This operation is performed immediately after the install, before `"post_cmds"` are run. |
+| `"project"` | The CMake project directory. It should contain a single tree artifact |
+| `"deps"` | Public dependency on other CC libraries. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"TIMEOUT_SCALE"` | The scaling of the timeout for the invocation of the foreign build. Defaults to 10. |
+
+### Rule `["CC/foreign/cmake", "data"]`
+
+Data produced by CMake configure, build, and install.
+
+ All variables accessible to commands and options are: `"TMPDIR"`, `"LOCALBASE"`, `"CC"`, `"CXX"`, `"CFLAGS"`, `"CXXFLAGS"`, `"LDFLAGS"`, and `"AR"`. `"LOCALBASE"` contains the path to the installed artifacts from `"deps"`.
+
+| Field | Description |
+| ----- | ----------- |
+| `"subdir"` | The subdirectory that contains the entry CMakeLists.txt. Individual directory components are joined with `"/"`. |
+| `"options"` | CMake options for the configuration phase. (e.g., `["-GNinja", "-Ax64"]`) |
+| `"defines"` | CMake defines for the configuration phase. (e.g., `["CMAKE_BUILD_TYPE=Release"]`) |
+| `"targets"` | The CMake targets to build in the specified order (default: `["install"]`). |
+| `"jobs"` | Number of jobs to run simultaneously. If omitted, CMake's default number is used. |
+| `"pre_cmds"` | List of commands executed in the project directory before calling CMake. Useful for renaming files or directories. Note that data between `"pre_cmds"` and `"post_cmds"` can be exchanged via `"$TMPDIR"` which is uniquely reserved for this action. |
+| `"post_cmds"` | List of commands executed in the install directory after successful installation but before the output files are collected. Useful for renaming files or directories. Note that data between `"pre_cmds"` and `"post_cmds"` can be exchanged via `"$TMPDIR"`, which is uniquely reserved for this action. The CMake source and build directory can be accessed via `"$CMAKE_SOURCE_DIR"` and `"$CMAKE_BINARY_DIR"`, respectively. |
+| `"out_files"` | Paths to the produced output files. The paths are considered relative to the install directory. Note that `"out_files"` and `"out_dirs"` may not overlap. |
+| `"out_dirs"` | Paths to the produced output directories. The paths are considered relative to the install directory. Note that `"out_files"` and `"out_dirs"` may not overlap. |
+| `"resolve_symlinks"` | Resolve all symlinks in the install directory. This operation is performed immediately after the install, before `"post_cmds"` are run. |
+| `"project"` | The CMake project directory. It should contain a single tree artifact |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"TIMEOUT_SCALE"` | The scaling of the timeout for the invocation of the foreign build. Defaults to 10. |
+
+### Rule `["CC/foreign/make", "library"]`
+
+Library produced by Configure and Make build and install.
+
+ All variables accessible to commands and options are: `"TMPDIR"`, `"LOCALBASE"`, `"CC"`, `"CXX"`, `"CFLAGS"`, `"CXXFLAGS"`, `"LDFLAGS"`, `"AR"`, and `"PREFIX"`. `"LOCALBASE"` contains the path to the installed artifacts from `"deps"`.
+
+| Field | Description |
+| ----- | ----------- |
+| `"subdir"` | The subdirectory that contains the configure and Makefile. Individual directory components are joined with `"/"`. |
+| `"name"` | The name of the library (without leading `"lib"` or trailing file name extension), also used as name for pkg-config files. |
+| `"version"` | The library version, used for pkg-config files. Individual version components are joined with `"."`. |
+| `"stage"` | The logical location of the public headers and library files. Individual directory components are joined with `"/"`. |
+| `"configure"` | Run ./configure if non-empty. |
+| `"configure_options"` | The configure options (the `"--prefix"` option is automatically set. |
+| `"targets"` | The Make targets to build in the specified order (default: `["install"]`). |
+| `"prefix"` | The prefix used for the Make target. The path will be made absolute and individual directory components are joined with `"/"`. If no prefix is specified, the value from the config variable `"PREFIX"` is taken, with the default value being `"/"`. |
+| `"options"` | Make options for the build phase. (e.g., `["-f", "Makefile", "ARCH=x86"]`) |
+| `"jobs"` | Number of jobs to run simultaneously. If omitted, Make's default number is used. |
+| `"pre_cmds"` | List of commands executed in the project directory before calling Configure or Make. Useful for renaming files or directories. Note that data between `"pre_cmds"` and `"post_cmds"` can be exchanged via `"$TMPDIR"`, which is uniquely reserved for this action. |
+| `"post_cmds"` | List of commands executed in the install directory after successful installation but before the output files are collected. Useful for renaming files or directories (e.g., in case of SONAME mismatch). Note that data between `"pre_cmds"` and `"post_cmds"` can be exchanged via `"$TMPDIR"`, which is uniquely reserved for this action. |
+| `"out_hdrs"` | Paths to produced public header files. The path is considered relative to the include directory, which be set via `"hdr_prefix"`. Note that `"out_hdrs"` and `"out_hdr_dirs"` may not overlap. |
+| `"out_hdr_dirs"` | Paths to produced public header directories. The path is considered relative to the include directory, which be set via `"hdr_prefix"`. Note that `"out_hdrs"` and `"out_hdr_dirs"` may not overlap. |
+| `"out_libs"` | Paths to produced library files. The path is considered relative to the library directory, which be set via `"lib_prefix"`. Order matters in the case of one library depending on another. |
+| `"cflags"` | List of compile flags set for this target and its consumers. |
+| `"ldflags"` | Additional linker flags that are required for the consumer of the produced libraries. |
+| `"pkg-config"` | Pkg-config file for optional infer of public cflags and ldflags. If multiple files are specified (e.g., one depends on the other), the first one is used as entry. Note that if this field is non-empty the tool `"pkg-config"` must be available in `"PATH"`, which is taken from `["CC", "defaults"]` or the `"ENV"` variable. |
+| `"hdr_prefix"` | Prefix where headers will be installed by Make. Individual directory components are joined with `"/"`. Defaults to `"include"` if not set. |
+| `"lib_prefix"` | Prefix where libraries will be installed by Make. Individual directory components are joined with `"/"`. Defaults to `"lib"` if not set. |
+| `"pc_prefix"` | Prefix where pkg-config files will be installed by Make. Individual directory components are joined with `"/"`. Defaults to `"lib/pkgconfig"` if not set. |
+| `"resolve_symlinks"` | Resolve all symlinks in the install directory. This operation is performed immediately after the install, before `"post_cmds"` are run. |
+| `"project"` | The Make project directory. It should contain a single tree artifact |
+| `"deps"` | Public dependency on other CC libraries. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"PREFIX"` | The absolute path that is used as prefix inside generated pkg-config files. The default value for this variable is `"/"`. This variable is ignored if the field `"prefix"` is set. |
+| `"TIMEOUT_SCALE"` | The scaling of the timeout for the invocation of the foreign build. Defaults to 10. |
+
+### Rule `["CC/foreign/make", "data"]`
+
+Data produced by Configure and Make build and install.
+
+ All variables accessible to commands and options are: `"TMPDIR"`, `"LOCALBASE"`, `"CC"`, `"CXX"`, `"CFLAGS"`, `"CXXFLAGS"`, `"LDFLAGS"`, `"AR"`, and `"PREFIX"`. `"LOCALBASE"` contains the path to the installed artifacts from `"deps"`.
+
+| Field | Description |
+| ----- | ----------- |
+| `"subdir"` | The subdirectory that contains the configure and Makefile. Individual directory components are joined with `"/"`. |
+| `"configure"` | Run ./configure if non-empty. |
+| `"configure_options"` | The configure options (the `"--prefix"` option is automatically set. Variables can be accessed via `"$(<varname>)"`, e.g., `"$(TMPDIR)"` for variable `"$TMPDIR"`. |
+| `"targets"` | The Make targets to build in the specified order (default: `["install"]`). |
+| `"prefix"` | The prefix used for the Make target. The path will be made absolute and individual directory components are joined with `"/"`. If no prefix is specified, the value from the config variable `"PREFIX"` is taken, with the default value being `"/"`. |
+| `"options"` | Make options for the configuration phase (e.g., `["-f", "Makefile", "ARCH=x86", "LD=$(CC)"]`). Variables can be accessed via `"$(<varname>)"`, e.g., `"$(TMPDIR)"` for variable `"$TMPDIR"`. |
+| `"jobs"` | Number of jobs to run simultaneously. If omitted, Make's default number is used. |
+| `"pre_cmds"` | List of commands executed in the project directory before calling Configure or Make. Useful for renaming files or directories. Note that data between `"pre_cmds"` and `"post_cmds"` can be exchanged via `"$TMPDIR"`, which is uniquely reserved for this action. |
+| `"post_cmds"` | List of commands executed in the install directory after successful installation but before the output files are collected. Useful for renaming files or directories. Note that data between `"pre_cmds"` and `"post_cmds"` can be exchanged via `"$TMPDIR"`, which is uniquely reserved for this action. |
+| `"out_files"` | Paths to the produced output files. The paths are considered relative to the install directory. Note that `"out_files"` and `"out_dirs"` may not overlap. |
+| `"out_dirs"` | Paths to the produced output directories. The paths are considered relative to the install directory. Note that `"out_files"` and `"out_dirs"` may not overlap. |
+| `"resolve_symlinks"` | Resolve all symlinks in the install directory. This operation is performed immediately after the install, before `"post_cmds"` are run. |
+| `"project"` | The Make project directory. It should contain a single tree artifact |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"PREFIX"` | The absolute path that is used as prefix inside generated pkg-config files. The default value for this variable is `"/"`. This variable is ignored if the field `"prefix"` is set. |
+| `"TIMEOUT_SCALE"` | The scaling of the timeout for the invocation of the foreign build. Defaults to 10. |
+
+### Rule `["CC/foreign/shell", "library"]`
+
+Library produced by generic shell commands with toolchain support.
+
+ All variables accessible to commands and options are: `"TMPDIR"`, `"LOCALBASE"`, `"WORKDIR"`, `"DESTDIR"`, `"CC"`, `"CXX"`, `"CFLAGS"`, `"CXXFLAGS"`, `"LDFLAGS"`, and `"AR"`. `"LOCALBASE"` contains the path to the staged artifacts from `"localbase"` and the installed artifacts from `"deps"`. Furthermore, the variable `"ACTION_DIR"` points to the current action directory, if needed for achieving reproducibility.
+
+| Field | Description |
+| ----- | ----------- |
+| `"name"` | The name of the library (without leading `"lib"` or trailing file name extension), also used as name for pkg-config files. |
+| `"version"` | The library version, used for pkg-config files. Individual version components are joined with `"."`. |
+| `"stage"` | The logical location of the public headers and library files. Individual directory components are joined with `"/"`. |
+| `"cmds"` | List of commands to execute by `"sh"`. Multiple commands will be joined with the newline character. |
+| `"out_hdrs"` | Paths to produced public header files. The path is considered relative to the include directory, which be set via `"hdr_prefix"`. Note that `"out_hdrs"` and `"out_hdr_dirs"` may not overlap. |
+| `"out_hdr_dirs"` | Paths to produced public header directories. The path is considered relative to the include directory, which be set via `"hdr_prefix"`. Note that `"out_hdrs"` and `"out_hdr_dirs"` may not overlap. |
+| `"out_libs"` | Paths to produced library files. The path is considered relative to the library directory, which be set via `"lib_prefix"`. Order matters in the case of one library depending on another. |
+| `"cflags"` | List of compile flags set for this target and its consumers. |
+| `"ldflags"` | Additional linker flags that are required for the consumer of the produced libraries. |
+| `"pkg-config"` | Pkg-config file for optional infer of public cflags and ldflags. If multiple files are specified (e.g., one depends on the other), the first one is used as entry. Note that if this field is non-empty the tool `"pkg-config"` must be available in `"PATH"`, which is taken from `["CC", "defaults"]` or the `"ENV"` variable. |
+| `"hdr_prefix"` | Prefix where headers will be installed by Make. Individual directory components are joined with `"/"`. Defaults to `"include"` if not set. |
+| `"lib_prefix"` | Prefix where libraries will be installed by Make. Individual directory components are joined with `"/"`. Defaults to `"lib"` if not set. |
+| `"pc_prefix"` | Prefix where pkg-config files will be installed by Make. Individual directory components are joined with `"/"`. Defaults to `"lib/pkgconfig"` if not set. |
+| `"resolve_symlinks"` | Resolve all symlinks in the install directory. This operation is performed immediately after `"cmds"` were executed. |
+| `"project"` | The project directory. It should contain a single tree artifact. It's path can be accessed via the `"WORKDIR"` variable. |
+| `"localbase"` | Artifacts to stage to `"LOCALBASE"`. |
+| `"deps"` | Public dependency on other CC libraries. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"PREFIX"` | The absolute path that is used as prefix inside generated pkg-config files. The default value for this variable is `"/"`. This variable is ignored if the field `"prefix"` is set. |
+| `"TIMEOUT_SCALE"` | The scaling of the timeout for the invocation of the foreign build. Defaults to 10. |
+
+### Rule `["CC/foreign/shell", "data"]`
+
+Data produced by generic shell commands with toolchain support.
+
+ All variables accessible to commands and options are: `"TMPDIR"`, `"LOCALBASE"`, `"WORKDIR"`, `"DESTDIR"`, `"CC"`, `"CXX"`, `"CFLAGS"`, `"CXXFLAGS"`, `"LDFLAGS"`, and `"AR"`. `"LOCALBASE"` contains the path to the staged artifacts from `"localbase"` and the installed artifacts from `"deps"`. Furthermore, the variable `"ACTION_DIR"` points to the current action directory, if needed for achieving reproducibility.
+
+| Field | Description |
+| ----- | ----------- |
+| `"cmds"` | List of commands to execute by `"sh"`. Multiple commands will be joined with the newline character. |
+| `"outs"` | Paths to the produced output files in `"DESTDIR"`. |
+| `"out_dirs"` | Paths to the produced output directories in `"DESTDIR"`. |
+| `"resolve_symlinks"` | Resolve all symlinks in the install directory. This operation is performed immediately after `"cmds"` were executed. |
+| `"project"` | The project directory. It should contain a single tree artifact. It's path can be accessed via the `"WORKDIR"` variable. |
+| `"localbase"` | Artifacts to stage to `"LOCALBASE"`. |
+| `"deps"` | CC targets to install to `"LOCALBASE"`. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"PREFIX"` | The absolute path that is used as prefix inside generated pkg-config files. The default value for this variable is `"/"`. This variable is ignored if the field `"prefix"` is set. |
+| `"TIMEOUT_SCALE"` | The scaling of the timeout for the invocation of the foreign build. Defaults to 10. |
+
+### Rule `["proto", "library"]`
+
+A proto library as abstract data structure.
+
+ Such a library does not produce any artifacts itself, but it can be used as a dependency for various language-specific rules.
+
+| Field | Description |
+| ----- | ----------- |
+| `"stage"` | The directory to stage the source files to. Directory components are joined by `"/"`. |
+| `"name"` | The name of the (abstract) library. |
+| `"service"` | If non empty, generate a service library (with access to `"rpc"` definitions) instead of a regular one. |
+| `"srcs"` | The proto files for this library |
+| `"deps"` | Any other proto library this library depends on |
+
+### Rule `["data", "staged"]`
+
+Stage data to a logical subdirectory.
+
+| Field | Description |
+| ----- | ----------- |
+| `"stage"` | The logical directory to stage the files to. Individual directory components are joined with `"/"`. |
+| `"drop"` | List of paths to drop from (each of) the `"srcs"` targets before joining and staging. In this way, GLOB constructs can be used is `"srcs"`. |
+| `"srcs"` | The files to be staged |
+| `"deps"` | Targets of with their runfiles should be added as well. Their staging is not changed. |
+
+### Rule `["patch", "file"]`
+
+Replace a file, logically in place, by a patched version
+
+| Field | Description |
+| ----- | ----------- |
+| `"src"` | The single source file to patch, typically an explicit file reference. |
+| `"patch"` | The patch to apply. |
+
+### Rule `["CC/auto", "config"]`
+
+Generate a C/C++ config header
+
+ Generate a C/C++ configuration header using defines specified via the target configuration. In the usual case, a target using this rule is configured by depending on it from a target that uses the built-in `"configure"` rule.
+
+| Field | Description |
+| ----- | ----------- |
+| `"name"` | Name of the header file to generate (incl. file name ext). |
+| `"stage"` | The location of the header. Path segments are joined with `"/"`. |
+| `"guard"` | The include guard. Multiple segments are joined with `"_"`. |
+| `"hdrs"` | Additional header files to be available in the include path. Useful for providing additional header files to values given in `"have_{cfile,cxxfile,ctype,cxxtype,csymbol,cxxsymbol}"`. |
+| `"deps"` | Additional public header files from targets to be available in the include path. Useful for providing additional header files to values given in `"have_{cfile,cxxfile,ctype,cxxtype,csymbol,cxxsymbol}"`. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"defines"` | Set a define to a specific value unless its value is `"null"`. Must contain a list of pairs. The first element of each pair is the define name and the second argument is the value to set. Strings must be properly escaped. Defines generated from this field are added last, so that they can refer to defines from other `"defines*"`, `"have_*"`, and `"size_*"` values. |
+| `"defines1"` | Set a define to `"1"` unless its value is untrue. Must contain a list of pairs. The first element of each pair is the define name and the second argument is the value. |
+| `"defines01"` | Set a define to `"0"` or `"1"` depending on its value being true. Must contain a list of pairs. The first element of each pair is the define name and the second argument is the value. |
+| `"have_cfile"` | Set a define to `"1"` if the specified C header is in the include path. Must contain a list of pairs. The first element of each pair is the define name and the second argument is the C header file name. |
+| `"have_cxxfile"` | Set a define to `"1"` if the specified C++ header is in the include path. Must contain a list of pairs. The first element of each pair is the define name and the second argument is the C++ header file name. |
+| `"have_ctype"` | Set a define to `"1"` if the specified C type is defined. Must contain a list of pairs. The first element of each pair is the define name and the second argument is name of the C type. If the specified C type is not a built-in type, additionally the headers `"sys/types.h"`, `"stdint.h"`, and `"stddef.h"` are checked as well. |
+| `"have_cxxtype"` | Set a define to `"1"` if the specified C++ type is defined. Must contain a list of pairs. The first element of each pair is the define name and the second argument is name of the C++ type. If the specified C++ type is not a built-in type, additionally the headers `"sys/types.h"`, `"stdint.h"`, and `"stddef.h"` are checked as well. |
+| `"have_csymbol"` | Set a define to `"1"` if the specified C symbol is defined by one of the specified headers in the include path. Must contain a list of pairs. The first element of each pair is the define name and the second argument is another pair. This pair's first value is the C symbol to search for and the second value is a list with the header file names to consider for searching. If the header file defines the symbol as a macro it is considered available and assumed to work. |
+| `"have_cxxsymbol"` | Set a define to `"1"` if the specified C++ symbol is defined by one of the specified headers in the include path. Must contain a list of pairs. The first element of each pair is the define name and the second argument is another pair. This pair's first value is the C++ symbol to search for and the second value is a list with the header file names to consider for searching. If the header file defines the symbol as a macro it is considered available and assumed to work. |
+| `"size_ctype"` | Set a define to size of the specified C type. Must contain a list of pairs. The first element of each pair is the define name and the second argument is another pair. This pair's first value is the C type to check for and the second value is a list with possible sizes as numbers. If none of the specified sizes matches, the action fails. |
+| `"size_cxxtype"` | Set a define to size of the specified C++ type. Must contain a list of pairs. The first element of each pair is the define name and the second argument is another pair. This pair's first value is the C++ type to check for and the second value is a list with possible sizes as numbers. If none of the specified sizes matches, the action fails. |
+
+### Rule `["CC/auto", "config_file"]`
+
+Generate a C/C++ config header from a given template
+
+ Generate a C/C++ configuration header using defines specified via the target configuration. In the usual case, a target using this rule is configured by depending on it from a target that uses the built-in `"configure"` rule.
+
+ The actual generation of the header file from the template is done by the implicit dependency on the `"runner"` target which can be changed globally by setting this target in the target layer of this repository.
+
+| Field | Description |
+| ----- | ----------- |
+| `"magic_string"` | The magic string (e.g., `"cmakedefine"`) which identifies in which line we have to `"#define"` or `"#undef"` variables according to what is defined in the config field `"defines"`. |
+| `"@only"` | If set, only replace @VAR@ and not $`{VAR}` |
+| `"output"` | Name of the header file to generate (incl. file name ext). Components are joined with /. |
+| `"input"` | The input configuration file, used as template. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"defines"` | Set a define to a specific value unless its value is `"null"`. Must contain a list of pairs. The first element of each pair is the define name and the second argument is the value to set. Strings must be properly escaped. Defines generated from this field are added last, so that they can refer to defines from other `"defines*"` values. |
+
diff --git a/ROOT b/ROOT
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ROOT
diff --git a/doc/being-consumed-by-cmake.md b/doc/being-consumed-by-cmake.md
new file mode 100644
index 0000000..b4e0bc5
--- /dev/null
+++ b/doc/being-consumed-by-cmake.md
@@ -0,0 +1,167 @@
+Being consumed by CMake
+=======================
+
+To support libraries built with JustBuild to be consumed by CMake, the
+rule `["CC", "install-with-deps"]` can be used. This rule will install
+the library's artifacts, its public headers, and a pkg-config file,
+which can be used by CMake to properly consume the library.
+
+In this example, we show how to build and install the `ssl` library with
+JustBuild, so it can be picked up and used by CMake afterwards.
+
+Example: Build and install the `ssl` Library with JustBuild
+-----------------------------------------------------------
+
+First make sure that `just`, `just-mr`, and `just-import-git` are
+available in your `PATH`. Then, define a new workspace by creating the
+`ROOT` marker.
+
+``` sh
+$ touch ROOT
+```
+
+The `ssl` library that we want to use is a defined dependency of the
+JustBuild repository `just/ssl`. To define a repository for that
+library, create the following `repos.template.json` file.
+
+``` {.jsonc srcname="repos.template.json"}
+{ "main": "ssl"
+, "repositories":
+ { "ssl":
+ { "repository": {"type": "file", "path": "."}
+ , "bindings": {"rules": "rules-cc", "just-ssl": "just/ssl"}
+ }
+ }
+}
+```
+
+and import the `rules-cc` and JustBuild repository, including its
+dependency `just/ssl`, via:
+
+``` sh
+$ cat repos.template.json \
+ | just-import-git -C - --as just -b master https://github.com/just-buildsystem/justbuild \
+ | just-import-git -C - --as rules-cc -b master https://github.com/just-buildsystem/rules-cc \
+ > repos.json
+$
+```
+
+Next, the following `TARGETS` file needs to be provided.
+
+``` {.jsonc srcname="TARGETS"}
+{ "ssl-lib":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["ssl"]
+ , "deps": [["@", "just-ssl", "", "ssl"]]
+ }
+, "ssl-pkg":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["ssl-lib"]}
+}
+```
+
+The library target `ssl-lib` specifies the name `"ssl"` (also used as
+package name) and a dependency on the `ssl` library from `just-ssl`.
+Note that although this library target is merely a "wrapper"
+(header-only library without headers), it could equally well be a
+full-blown library target. Furthermore, the package target `ssl-pkg`
+installs the `ssl-lib` target including its dependencies and generates a
+pkg-config file that can be later used by CMake.
+
+Finally, the `ssl-pkg` target can be built and installed to a specific
+`PREFIX` (note that `OS` and `ARCH` must be set as well).
+
+``` sh
+$ export PREFIX=/tmp/just_ssl
+$ just-mr install -D'{"OS":"linux", "ARCH":"x64_64", "PREFIX":"'$PREFIX'"}' -o $PREFIX ssl-pkg
+INFO: Requested target is [["@","ssl","","ssl-pkg"],{"ARCH":"x64_64","OS":"linux","PREFIX":"/tmp/just_ssl"}]
+INFO: Analysed target [["@","ssl","","ssl-pkg"],{"ARCH":"x64_64","OS":"linux","PREFIX":"/tmp/just_ssl"}]
+INFO: Export targets found: 0 cached, 2 uncached, 0 not eligible for caching
+INFO: Discovered 269 actions, 3 trees, 1 blobs
+INFO: Building [["@","ssl","","ssl-pkg"],{"ARCH":"x64_64","OS":"linux","PREFIX":"/tmp/just_ssl"}].
+PROG: [ 79%] 0 cached, 215 run, 8 processing (["@","just/ssl","","crypto-lib"]#105, ...).
+INFO: Processed 269 actions, 0 cache hits.
+INFO: Artifacts can be found in:
+ /tmp/just_ssl/include/openssl/aead.h [6d78db27d24746b39eacc20374697476e080c9f6:21054:f]
+ ...
+ /tmp/just_ssl/lib/libcrypto.a [df64da43f0168a717d09d609bf0c631d29c86b61:2336092:f]
+ /tmp/just_ssl/lib/libssl.a [77d2c2bfbe3ef3608895c854f1d1f6e1c200efd0:852620:f]
+ /tmp/just_ssl/lib/pkgconfig/ssl.pc [9b69c758430f5b5fb6ff7a9b1f1ffc89471509af:406:f]
+$
+```
+
+Example: Consume the installed `ssl` Library with CMake
+-------------------------------------------------------
+
+As an example, a minimal `main.cpp` file is created that depends on the
+`ssl` library.
+
+``` {.cpp srcname="main.cpp"}
+#include <openssl/evp.h>
+
+int main(int argc, char** argv) {
+ OpenSSL_add_all_algorithms();
+ return 0;
+}
+```
+
+In the `CMakeLists.txt` file, the `pkg_check_modules()` macro can be
+used to determine the compile and linker flags needed to consume our
+`ssl` library with CMake.
+
+``` {.cmake srcname="CMakeLists.txt"}
+cmake_minimum_required(VERSION 3.1)
+
+project(test_ssl)
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(SSL REQUIRED ssl)
+
+add_executable(main main.cpp)
+target_include_directories(main PRIVATE ${SSL_INCLUDE_DIRS})
+target_compile_options(main PRIVATE ${SSL_CFLAGS_OTHER})
+target_link_directories(main PRIVATE ${SSL_LIBRARY_DIRS})
+target_link_libraries(main PRIVATE ${SSL_LDFLAGS_OTHER} ${SSL_LIBRARIES})
+```
+
+Note that `${SSL_LDFLAGS_OTHER}` can be omitted if the `ssl-pkg` target
+was defined with a non-empty value for the field `"flat-libs"` (see rule
+documentation of `["CC", "install-with-deps"]`).
+
+Finally, when running CMake, make sure to set the `CMAKE_PREFIX_PATH` to
+the previously used install prefix in order to successfully find the
+installed `ssl` library and its pkg-config file.
+
+``` sh
+$ cmake -DCMAKE_PREFIX_PATH=/tmp/just_ssl -S . -B /tmp/test_ssl
+-- The C compiler identification is GNU 10.2.1
+-- The CXX compiler identification is GNU 10.2.1
+-- Detecting C compiler ABI info
+-- Detecting C compiler ABI info - done
+-- Check for working C compiler: /usr/bin/cc - skipped
+-- Detecting C compile features
+-- Detecting C compile features - done
+-- Detecting CXX compiler ABI info
+-- Detecting CXX compiler ABI info - done
+-- Check for working CXX compiler: /usr/bin/c++ - skipped
+-- Detecting CXX compile features
+-- Detecting CXX compile features - done
+-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
+-- Checking for module 'ssl'
+-- Found ssl, version unknown
+-- Configuring done
+-- Generating done
+-- Build files have been written to: /tmp/test_ssl
+$ cmake --build /tmp/test_ssl
+[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
+[100%] Linking CXX executable main
+[100%] Built target main
+$
+```
+
+Note that if the package is moved to a different location, the `prefix`
+variable within the pkg-config file `lib/pkgconfig/ssl.pc` must be
+updated as well. Alternatively, CMake can be instructed to automatically
+guess the correct prefix by setting the variable `PKG_CONFIG_ARGN` to
+`"--define-prefix"` (either on the command line or in the
+`CMakeLists.txt`). However, this is a fairly recent CMake feature and
+requires at least CMake version 3.22.
diff --git a/doc/consume-cmake-libraries.md b/doc/consume-cmake-libraries.md
new file mode 100644
index 0000000..5ba9b41
--- /dev/null
+++ b/doc/consume-cmake-libraries.md
@@ -0,0 +1,138 @@
+Consume CMake Libraries
+=======================
+
+To support libraries built with CMake to be consumed by JustBuild, the
+rule `["CC/foreign/cmake", "library"]` can be used. This rule will run
+CMake and collect the library's artifacts, public headers, and
+pkg-config files (if available), to produce a proper JustBuild library
+target.
+
+In this example, we show how to consume the `gtest` library built with
+CMake using JustBuild.
+
+Example: Build the `gtest` Library with CMake
+---------------------------------------------
+
+First make sure that `just`, `just-mr`, and `just-import-git` are
+available in your `PATH`. Then, define a new workspace by creating a
+`ROOT` marker.
+
+``` sh
+$ touch ROOT
+```
+
+To define a repository for the
+[gtest](https://github.com/google/googletest/tree/v1.13.0) library,
+create the following `repos.template.json` file.
+
+``` {.jsonc srcname="repos.template.json"}
+{ "main": "tests"
+, "repositories":
+ { "imports": {"repository": {"type": "file", "path": "imports"}}
+ , "gtest":
+ { "repository":
+ { "type": "git"
+ , "branch": "v1.13.0"
+ , "commit": "b796f7d44681514f58a683a3a71ff17c94edb0c1"
+ , "repository": "https://github.com/google/googletest"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "gtest.TARGETS"
+ , "bindings": {"rules": "rules-cc"}
+ }
+ , "tests":
+ { "repository": {"type": "file", "path": "."}
+ , "bindings": {"rules": "rules-cc", "gtest": "gtest"}
+ }
+ }
+}
+```
+
+Now the missing `rules-cc` repository can be imported via:
+
+``` sh
+$ just-import-git -C repos.template.json --as rules-cc -b master https://github.com/just-buildsystem/rules-cc > repos.json
+$
+```
+
+Create the file `imports/gtest.TARGETS` with the following content.
+
+``` {.jsonc srcname="imports/gtest.TARGETS"}
+{ "gtest_main":
+ { "type": ["@", "rules", "CC/foreign/cmake", "library"]
+ , "name": ["gtest_main"]
+ , "version": ["1", "13", "0"]
+ , "project": [["TREE", null, "."]]
+ , "defines": ["BUILD_SHARED_LIBS=ON"]
+ , "out_hdr_dirs": ["gtest"]
+ , "out_libs": ["libgtest_main.so.1.13.0", "libgtest.so.1.13.0"]
+ , "pkg-config": ["gtest_main.pc", "gtest.pc"]
+ }
+}
+```
+
+The library `gtest_main` uses the rule
+`["CC/foreign/cmake", "library"]`. It sets `defines` to build shared
+libraries and collects the public header directory `gtest`, as well as
+the two libraries `libgtest_main.so.1.13.0` and `libgtest.so.1.13.0` (in
+this particular link order). Furthermore, to automatically infer public
+compile and link flags (e.g., a link dependency to the system's
+`pthread` library), the pkg-config files `gtest_main.pc` and `gtest.pc`
+are read, with the former (entry point) depending on the latter.
+
+Now, create the actual `test` target, which consumes the `gtest_main`
+library, by creating the following `TARGETS` file.
+
+``` {.jsonc srcname="TARGETS"}
+{ "test":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test"]
+ , "srcs": ["test.cpp"]
+ , "private-deps": [["@", "gtest", "", "gtest_main"]]
+ }
+}
+```
+
+The last file missing yet is the actual test source file `test.cpp`.
+
+``` {.cpp srcname="test.cpp"}
+#include <gtest/gtest.h>
+
+TEST(CastTest, double) {
+ EXPECT_EQ (42.0, double(42));
+}
+```
+
+Finally, build the `test` target to run the test.
+
+``` sh
+$ just-mr build test -Pstdout
+INFO: Requested target is [["@","tests","","test"],{}]
+INFO: Analysed target [["@","tests","","test"],{}]
+INFO: Export targets found: 0 cached, 0 uncached, 0 not eligible for caching
+INFO: Target tainted ["test"].
+INFO: Discovered 7 actions, 2 trees, 3 blobs
+INFO: Building [["@","tests","","test"],{}].
+INFO: Processed 7 actions, 0 cache hits.
+INFO: Artifacts built, logical paths are:
+ result [7ef22e9a431ad0272713b71fdc8794016c8ef12f:5:f]
+ stderr [8b137891791fe96927ad78e64b0aad7bded08bdc:1:f]
+ stdout [fc46e9e95a8a393e3c94875d66b0de956305f6a6:728:f]
+ time-start [93887fee067665917f67e2cb757dd30bf22b23a0:11:f]
+ time-stop [93887fee067665917f67e2cb757dd30bf22b23a0:11:f]
+ (1 runfiles omitted.)
+Running main() from src/gtest_main.cc
+[==========] Running 1 test from 1 test suite.
+[----------] Global test environment set-up.
+[----------] 1 test from CastTest
+[ RUN ] CastTest.double
+[ OK ] CastTest.double (0 ms)
+[----------] 1 test from CastTest (0 ms total)
+
+[----------] Global test environment tear-down
+[==========] 1 test from 1 test suite ran. (0 ms total)
+[ PASSED ] 1 test.
+
+INFO: Target tainted ["test"].
+$
+```
diff --git a/etc/README.template.md b/etc/README.template.md
new file mode 100644
index 0000000..517fc0a
--- /dev/null
+++ b/etc/README.template.md
@@ -0,0 +1,55 @@
+# C/C++ rules for the `just` build system
+
+A collection of rules for building C/C++ libraries and binaries.
+
+## How to use this Repository
+
+There are two ways to import this repository. You can generate your
+`repos.json` from a template (`repos.template.json`) by importing
+the `rules-cc` repository with the tool `just-import-git`
+
+~~~sh
+$ just-import-git -C repos.template.json --as rules-cc -b master https://github.com/just-buildsystem/rules-cc > repos.json
+~~~
+
+Importing this way will also pull in `protoc` and `grpc_cpp_plugin`
+as a dependency for generating bindings for proto dependencies, if
+this feature is used.
+
+Alternatively, the `rules-cc` repository can be added manually to
+your `repos.json`.
+
+~~~jsonc
+...
+ , "rules-cc":
+ { "repository":
+ { "type": "git"
+ , "branch": "master"
+ , "commit": "2ea50063460a3e11dfcbb71651540c0d61fddc1a"
+ , "repository": "https://github.com/just-buildsystem/rules-cc"
+ , "subdir": "rules"
+ }
+ }
+...
+~~~
+
+Importing this way, `protoc` and `grpc_cpp_plugin` will be taken
+from the host system. To change the binary names or to bring your
+own proto toolchain, add a corresponding `target_root` layer (and
+provide the needed binding, if your target files refer to other
+repositories containing the toolchain).
+
+## Consume and being consumed by CMake Libraries
+
+For interoperability with CMake projects, see
+
+- [consume CMake libraries](./doc/consume-cmake-libraries.md)
+- [being consumed by CMake](./doc/being-consumed-by-cmake.md)
+
+## Rule Documentation
+
+In this documentation, the standard configuration variables
+`"AR"`, `"CC"`, `"CXX"`, `"CFLAGS"`, `"CXXFLAGS"`,`"LDFLAGS"`,
+`"ADD_CFLAGS"`, `"ADD_CXXFLAGS"`, `"ADD_LDFLAGS"`, `"ENV"`,
+`"BUILD_POSITION_INDEPENDENT"` are ommitted.
+
diff --git a/etc/defaults/CC/TARGETS b/etc/defaults/CC/TARGETS
new file mode 100644
index 0000000..6e095cc
--- /dev/null
+++ b/etc/defaults/CC/TARGETS
@@ -0,0 +1,3 @@
+{ "defaults":
+ {"type": ["CC", "defaults"], "base": [["@", "base", "CC", "defaults"]]}
+}
diff --git a/CC/auto/TARGETS b/etc/defaults/CC/auto/TARGETS
index 0967ef4..0967ef4 100644
--- a/CC/auto/TARGETS
+++ b/etc/defaults/CC/auto/TARGETS
diff --git a/CC/foreign/TARGETS b/etc/defaults/CC/foreign/TARGETS
index 5fbb6a9..5fbb6a9 100644
--- a/CC/foreign/TARGETS
+++ b/etc/defaults/CC/foreign/TARGETS
diff --git a/etc/defaults/CC/proto/TARGETS b/etc/defaults/CC/proto/TARGETS
new file mode 100644
index 0000000..95ae1b0
--- /dev/null
+++ b/etc/defaults/CC/proto/TARGETS
@@ -0,0 +1,14 @@
+{ "defaults":
+ { "type": ["CC/proto", "defaults"]
+ , "PROTOC": ["bin/protoc"]
+ , "deps": [["@", "protoc", "", "libprotobuf"]]
+ , "toolchain": [["@", "protoc", "", "toolchain"]]
+ }
+, "service defaults":
+ { "type": ["CC/proto", "defaults"]
+ , "base": ["defaults"]
+ , "GRPC_PLUGIN": ["grpc_cpp_plugin"]
+ , "deps": [["@", "grpc", "", "grpc++"]]
+ , "toolchain": [["@", "grpc", "", "grpc_cpp_plugin"]]
+ }
+}
diff --git a/CC/test/TARGETS b/etc/defaults/CC/test/TARGETS
index 0967ef4..0967ef4 100644
--- a/CC/test/TARGETS
+++ b/etc/defaults/CC/test/TARGETS
diff --git a/etc/defaults/patch/TARGETS b/etc/defaults/patch/TARGETS
new file mode 100644
index 0000000..16a4670
--- /dev/null
+++ b/etc/defaults/patch/TARGETS
@@ -0,0 +1,3 @@
+{ "defaults":
+ {"type": ["patch", "defaults"], "base": [["@", "base", "patch", "defaults"]]}
+}
diff --git a/CC/pkgconfig/TARGETS b/etc/defaults/shell/TARGETS
index 705d1d7..705d1d7 100644
--- a/CC/pkgconfig/TARGETS
+++ b/etc/defaults/shell/TARGETS
diff --git a/shell/test/TARGETS b/etc/defaults/shell/test/TARGETS
index 0967ef4..0967ef4 100644
--- a/shell/test/TARGETS
+++ b/etc/defaults/shell/test/TARGETS
diff --git a/etc/generate-doc.sh b/etc/generate-doc.sh
new file mode 100755
index 0000000..3a18996
--- /dev/null
+++ b/etc/generate-doc.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+# Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -eu
+
+readonly ROOT=$(readlink -f $(dirname $0)/..)
+
+: ${OUTFILE:=README.md}
+
+doc2md() {
+ local MAIN="$1"
+ local MODULE="$2"
+ local RULE="$3"
+
+ local RULE_DOC="$(just-mr --main "$MAIN" describe --rule --json "$MODULE" "$RULE")"
+ local DOC="$(echo "$RULE_DOC" | jq -r '.doc')"
+ local FIELD_DOC="$(echo "$RULE_DOC" | jq -r '.field_doc')"
+ local CONFIG_DOC="$(echo "$RULE_DOC" | jq -r '.config_doc | delpaths([["AR"], ["CC"], ["CXX"], ["CFLAGS"], ["CXXFLAGS"],["LDFLAGS"], ["ADD_CFLAGS"], ["ADD_CXXFLAGS"], ["ADD_LDFLAGS"], ["ENV"], ["BUILD_POSITION_INDEPENDENT"]])')"
+
+ echo "### Rule \`[\"$MODULE\", \"$RULE\"]\`"
+ echo
+ echo "$DOC" \
+ | jq -r '[.[] as $v | if ($v == "") then "\n\n" else $v end] | join(" ")' \
+ | sed 's/\("[^"]*"\|\[[^]]*\]\|{[^}]*}\)/`\1`/g'
+ echo
+ echo "| Field | Description |"
+ echo "| ----- | ----------- |"
+ echo "$FIELD_DOC" \
+ | jq -r 'keys_unsorted[] as $k | "| \"\($k)\" | \(.[$k] | join(" ")) |"' \
+ | sed 's/\("[^"]*"\|\[[^]]*\]\|{[^}]*}\)/`\1`/g'
+ echo
+ if [ "$(echo "$CONFIG_DOC" | jq -r 'length')" -gt 0 ]
+ then
+ echo "| Config variable | Description |"
+ echo "| --------------- | ----------- |"
+ echo "$CONFIG_DOC" \
+ | jq -r 'keys_unsorted[] as $k | "| \"\($k)\" | \(.[$k] | join(" ")) |"' \
+ | sed 's/\("[^"]*"\|\[[^]]*\]\|{[^}]*}\)/`\1`/g'
+ echo
+ fi
+}
+
+rm -f "$OUTFILE"
+( cat "$ROOT/etc/README.template.md"
+ doc2md rules CC defaults
+ doc2md rules CC/proto defaults
+ doc2md rules CC/foreign defaults
+ doc2md rules patch defaults
+ doc2md rules CC binary
+ doc2md rules CC library
+ doc2md rules CC/prebuilt library
+ doc2md rules CC/pkgconfig system_library
+ doc2md rules CC install-with-deps
+ doc2md rules CC/test test
+ doc2md rules shell defaults
+ doc2md rules shell cmds
+ doc2md rules shell/test script
+ doc2md rules CC/foreign/cmake library
+ doc2md rules CC/foreign/cmake data
+ doc2md rules CC/foreign/make library
+ doc2md rules CC/foreign/make data
+ doc2md rules CC/foreign/shell library
+ doc2md rules CC/foreign/shell data
+ doc2md rules proto library
+ doc2md rules data staged
+ doc2md rules patch file
+ doc2md rules CC/auto config
+ doc2md rules CC/auto config_file
+) >> "$OUTFILE"
diff --git a/etc/generate-repos.sh b/etc/generate-repos.sh
new file mode 100755
index 0000000..a3d97b3
--- /dev/null
+++ b/etc/generate-repos.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -eu
+
+readonly ROOT=$(readlink -f $(dirname $0)/..)
+
+: ${BRANCH:=v1.4.0-alpha+20240619}
+: ${OUTFILE:=${ROOT}/etc/repos.json}
+
+just-import-git --as just -C ${ROOT}/etc/repos.template.json \
+ -b ${BRANCH} https://github.com/just-buildsystem/justbuild \
+ | ${ROOT}/etc/json-format.py > ${OUTFILE}
diff --git a/etc/imports/gtest.TARGETS b/etc/imports/gtest.TARGETS
new file mode 100644
index 0000000..a9b2217
--- /dev/null
+++ b/etc/imports/gtest.TARGETS
@@ -0,0 +1,6 @@
+{ "tree":
+ { "type": "install"
+ , "dirs": [[["TREE", null, "."], "googletest"]]
+ , "tainted": ["test"]
+ }
+}
diff --git a/etc/imports/libcurl.TARGETS b/etc/imports/libcurl.TARGETS
new file mode 100644
index 0000000..f33a101
--- /dev/null
+++ b/etc/imports/libcurl.TARGETS
@@ -0,0 +1,6 @@
+{ "tree":
+ { "type": "install"
+ , "dirs": [[["TREE", null, "."], "libcurl"]]
+ , "tainted": ["test"]
+ }
+}
diff --git a/etc/imports/libs.TARGETS b/etc/imports/libs.TARGETS
new file mode 100644
index 0000000..57adf74
--- /dev/null
+++ b/etc/imports/libs.TARGETS
@@ -0,0 +1,10 @@
+{ "tree":
+ { "type": "tree"
+ , "deps":
+ [ ["@", "gtest", "", "tree"]
+ , ["@", "libz", "", "tree"]
+ , ["@", "libcurl", "", "tree"]
+ ]
+ , "tainted": ["test"]
+ }
+}
diff --git a/etc/imports/libz.TARGETS b/etc/imports/libz.TARGETS
new file mode 100644
index 0000000..5b5ef8f
--- /dev/null
+++ b/etc/imports/libz.TARGETS
@@ -0,0 +1,6 @@
+{ "tree":
+ { "type": "install"
+ , "dirs": [[["TREE", null, "."], "libz"]]
+ , "tainted": ["test"]
+ }
+}
diff --git a/etc/imports/rules.TARGETS b/etc/imports/rules.TARGETS
new file mode 100644
index 0000000..73e1ff5
--- /dev/null
+++ b/etc/imports/rules.TARGETS
@@ -0,0 +1 @@
+{"tree": {"type": "install", "dirs": [[["TREE", null, "."], "rules"]], "tainted": ["test"]}}
diff --git a/etc/json-format.py b/etc/json-format.py
new file mode 100755
index 0000000..827205a
--- /dev/null
+++ b/etc/json-format.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2021-2022 Klaus Aehlig. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import json
+import sys
+
+from typing import Any, Dict, List, cast
+
+
+def is_simple(entry: Any) -> bool:
+ if isinstance(entry, list):
+ return len(cast(List[Any], entry)) == 0
+ if isinstance(entry, dict):
+ return len(cast(Dict[str, Any], entry)) == 0
+ return True
+
+
+def is_short(entry: Any, indent: int) -> bool:
+ return len(json.dumps(entry)) + indent < 80
+
+
+def hdumps(entry: Any, *, _current_indent: int = 0) -> str:
+ if entry:
+ if is_short(entry, _current_indent):
+ return json.dumps(entry)
+ if isinstance(entry, list):
+ result: str = "[ " + hdumps(cast(Any, entry[0]),
+ _current_indent=_current_indent + 2)
+ entries: List[Any] = entry[1:] # explicit type hint
+ for x in entries:
+ result += "\n" + " " * _current_indent + ", "
+ result += hdumps(x, _current_indent=_current_indent + 2)
+ result += "\n" + " " * _current_indent + "]"
+ return result
+ if isinstance(entry, dict):
+ result: str = "{ "
+ is_first: bool = True
+ keys = cast(Dict[str, Any], entry).keys() # explicit type hint
+ for k in keys:
+ key_entry: Any = entry[k] # explicit type hint
+ if not is_first:
+ result += "\n" + " " * _current_indent + ", "
+ result += json.dumps(k) + ":"
+ if is_simple(key_entry):
+ result += " " + json.dumps(key_entry)
+ elif is_short(key_entry,
+ _current_indent + len(json.dumps(k)) + 4):
+ result += " " + json.dumps(key_entry)
+ else:
+ result += "\n" + " " * _current_indent + " "
+ result += hdumps(key_entry,
+ _current_indent=_current_indent + 2)
+ is_first = False
+ result += "\n" + " " * _current_indent + "}"
+ return result
+ return json.dumps(entry)
+
+
+if __name__ == "__main__":
+ data = json.load(sys.stdin)
+ print(hdumps(data))
diff --git a/etc/repos.json b/etc/repos.json
new file mode 100644
index 0000000..49aa13e
--- /dev/null
+++ b/etc/repos.json
@@ -0,0 +1,502 @@
+{ "main": "rules with bundled tools"
+, "repositories":
+ { "rules": {"repository": {"type": "file", "path": "rules"}}
+ , "rules with bundled tools":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "rule_root": "rules"
+ , "bindings":
+ { "base": "just/rules"
+ , "protoc": "just/protobuf"
+ , "grpc": "just/com_github_grpc_grpc"
+ }
+ }
+ , "defaults": {"repository": {"type": "file", "path": "etc/defaults"}}
+ , "tests":
+ { "repository": {"type": "file", "path": "tests"}
+ , "bindings":
+ { "test-just": "just"
+ , "test-rules": "test-rules"
+ , "test-libs": "test-libs"
+ , "rules": "rules"
+ }
+ }
+ , "imports": {"repository": {"type": "file", "path": "etc/imports"}}
+ , "test-rules":
+ { "repository": {"type": "file", "path": "rules"}
+ , "target_root": "imports"
+ , "target_file_name": "rules.TARGETS"
+ }
+ , "test-libs":
+ { "repository": "imports"
+ , "target_file_name": "libs.TARGETS"
+ , "bindings": {"gtest": "gtest", "libz": "libz", "libcurl": "libcurl"}
+ }
+ , "gtest":
+ { "repository":
+ { "type": "archive"
+ , "fetch": "https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz"
+ , "content": "cbd19f97df3ab86b174520cd850d238617c156e0"
+ , "sha256": "ad7fdba11ea011c1d925b3289cf4af2c66a352e18d4c7264392fead75e919363"
+ , "subdir": "googletest-1.13.0"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "gtest.TARGETS"
+ }
+ , "libz":
+ { "repository":
+ { "type": "archive"
+ , "content": "d115fc690fa59d3be51b3442158876536140b6c2"
+ , "fetch": "https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz"
+ , "sha256": "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30"
+ , "sha512": "99f0e843f52290e6950cc328820c0f322a4d934a504f66c7caa76bd0cc17ece4bf0546424fc95135de85a2656fed5115abb835fd8d8a390d60ffaf946c8887ad"
+ , "subdir": "zlib-1.2.13"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "libz.TARGETS"
+ }
+ , "libcurl":
+ { "repository":
+ { "type": "archive"
+ , "content": "540b4de2edfa015b894ad86d51b33a55f451ac99"
+ , "fetch": "https://github.com/curl/curl/releases/download/curl-8_0_1/curl-8.0.1.tar.gz"
+ , "sha256": "5fd29000a4089934f121eff456101f0a5d09e2a3e89da1d714adf06c4be887cb"
+ , "sha512": "87d945e65176613c6296f8b130bd6c5355e3ca3c62ee4010edd481950cad9760482fd3be8a84e51501c118c29ebc284b8f87c49b06f9d248e9da5819fda38f8f"
+ , "subdir": "curl-8.0.1"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "libcurl.TARGETS"
+ , "bindings": {"libz": "libz"}
+ }
+ , "just":
+ { "repository":
+ { "type": "git"
+ , "repository": "https://github.com/just-buildsystem/justbuild"
+ , "branch": "v1.4.0-alpha+20240619"
+ , "commit": "96158f57c36bbc649abcd9a213bf04df6cf8a1f5"
+ }
+ , "bindings":
+ { "rules": "just/rules-just"
+ , "gsl": "just/com_github_microsoft_gsl"
+ , "cli11": "just/cli11"
+ , "json": "just/json"
+ , "fmt": "just/fmt"
+ , "ssl": "just/ssl"
+ , "grpc": "just/com_github_grpc_grpc"
+ , "googleapis": "just/google_apis"
+ , "bazel_remote_apis": "just/bazel_remote_apis"
+ , "libgit2": "just/com_github_libgit2_libgit2"
+ , "protoc": "just/protobuf"
+ , "libcurl": "just/com_github_curl_curl"
+ , "libarchive": "just/com_github_libarchive_libarchive"
+ }
+ }
+ , "just/bazel_remote_apis":
+ { "repository":
+ { "type": "archive"
+ , "content": "da6d7d589ccd1924ba9840a4e329e438dfa27f86"
+ , "fetch": "https://github.com/bazelbuild/remote-apis/archive/e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0.tar.gz"
+ , "sha256": "7421abd5352ccf927c2050453a4dbfa1f7b1c7170ec3e8702b6fe2d39b8805fe"
+ , "sha512": "3042690ee4b17a27db92ca867b4225c25f3f16344dce5fe86695d72ddda531e1593a5f0f70a291283451ce1e9f606c2285d222df3787815cd8f4054e1113bc9d"
+ , "subdir": "remote-apis-e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.bazel_remote_apis"
+ , "bindings":
+ { "rules": "just/rules"
+ , "google_apis": "just/google_apis"
+ , "patches": "just/patches"
+ }
+ }
+ , "just/bzip2":
+ { "repository":
+ { "type": "archive"
+ , "content": "f9d91f2012aedeedcfd3bd918124ca11f0160373"
+ , "fetch": "https://github.com/libarchive/bzip2/archive/refs/tags/bzip2-1.0.8.tar.gz"
+ , "sha256": "db106b740252669664fd8f3a1c69fe7f689d5cd4b132f82ba82b9afba27627df"
+ , "sha512": "596d1b304f1f2d64b020d04845db10a2330c7f614a9fd0b5344afff65877d2141b3fcaa43d9e2dbc2f6a7929a1dab07df54d3d4bd69678b53906472958c7b80c"
+ , "subdir": "bzip2-bzip2-1.0.8"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.bzip2"
+ , "bindings": {"rules": "just/rules-bzip2"}
+ }
+ , "just/cli11":
+ { "repository":
+ { "type": "archive"
+ , "content": "eb82119c62808a65bb2d15561f1968259ed50c95"
+ , "fetch": "https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.4.1.tar.gz"
+ , "sha256": "73b7ec52261ce8fe980a29df6b4ceb66243bb0b779451dbd3d014cfec9fdbb58"
+ , "sha512": "965290d09977672d3bc3c57ca4b89a88c2c09461da6e866b18217d702d4d5a0977588fcb8fef1a3c3804e61ad80d276029f47469cc83dbfdc7021ee35f6b7269"
+ , "subdir": "CLI11-2.4.1"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.cli11"
+ , "bindings": {"rules": "just/rules"}
+ }
+ , "just/com_github_cares_cares":
+ { "repository":
+ { "type": "archive"
+ , "content": "4237a53f7a5dc1cfb4d04a6b6374f8674c32e271"
+ , "fetch": "https://github.com/c-ares/c-ares/releases/download/cares-1_19_1/c-ares-1.19.1.tar.gz"
+ , "sha256": "321700399b72ed0e037d0074c629e7741f6b2ec2dda92956abe3e9671d3e268e"
+ , "sha512": "466a94efda626e815a6ef7a890637056339f883d549ea6055e289fd8cd2391130e5682c905c0fb3bd7e955af7f6deb793562c170eb0ee066a4a62085a82ba470"
+ , "subdir": "c-ares-1.19.1"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.cares"
+ , "bindings": {"rules": "just/rules", "grpc": "just/com_github_grpc_grpc"}
+ }
+ , "just/com_github_curl_curl":
+ { "repository":
+ { "type": "archive"
+ , "content": "7b7ace4d7cc7d4059163bbd789ef7071e5d326e5"
+ , "fetch": "https://github.com/curl/curl/releases/download/curl-8_6_0/curl-8.6.0.tar.gz"
+ , "sha256": "9c6db808160015f30f3c656c0dec125feb9dc00753596bf858a272b5dd8dc398"
+ , "sha512": "43fdb6b81b394f3382d353d5f57673b2b3d26cfe34b25d08a526bc0597f508d5298e5a7088d0736d1f139cad19cd922affa51533c3a5a4bb5f2de68891c2958d"
+ , "subdir": "curl-8.6.0"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.curl"
+ , "bindings":
+ { "rules": "just/rules-curl"
+ , "zlib": "just/zlib"
+ , "ssl": "just/ssl"
+ , "cares": "just/com_github_cares_cares"
+ }
+ }
+ , "just/com_github_grpc_grpc":
+ { "repository":
+ { "type": "archive"
+ , "content": "d89bbef10ae30b511e062e6aa36520a2805e0f97"
+ , "fetch": "https://github.com/grpc/grpc/archive/refs/tags/v1.62.1.tar.gz"
+ , "sha256": "c9f9ae6e4d6f40464ee9958be4068087881ed6aa37e30d0e64d40ed7be39dd01"
+ , "sha512": "3224ad2617c18156f90c54c1ebf1f2015e405a6f12546e8709e0c905f52508c9f1a13b4d5a6cc7a35abf58b429985b5b504c9062f50c0d3d6aa163180a61047a"
+ , "subdir": "grpc-1.62.1"
+ , "pragma": {"special": "ignore"}
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.grpc"
+ , "rule_file_name": "RULES.grpc"
+ , "bindings":
+ { "rules": "just/rules-grpc"
+ , "protobuf": "just/protobuf"
+ , "ssl": "just/ssl"
+ , "absl": "just/com_google_absl"
+ , "zlib": "just/zlib"
+ , "re2": "just/re2"
+ , "cares": "just/com_github_cares_cares"
+ , "google_apis": "just/google_apis"
+ }
+ }
+ , "just/com_github_libarchive_libarchive":
+ { "repository":
+ { "type": "archive"
+ , "content": "50abf77b7226df46a33013f278464c1588b0ceea"
+ , "fetch": "https://github.com/libarchive/libarchive/releases/download/v3.7.4/libarchive-3.7.4.tar.gz"
+ , "sha256": "7875d49596286055b52439ed42f044bd8ad426aa4cc5aabd96bfe7abb971d5e8"
+ , "sha512": "a37006350c2a61a35ecbe638c3168661bef5cbcb7dd3e5ec9a14af1a9aa89ec1be23902cdd17c60bf15859ba1e41bad8456dee9df686bc2d825b30d453cb2e44"
+ , "subdir": "libarchive-3.7.4"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.archive"
+ , "bindings":
+ { "rules": "just/rules-archive"
+ , "zlib": "just/zlib"
+ , "ssl": "just/ssl"
+ , "bzip2": "just/bzip2"
+ , "lzma": "just/lzma"
+ }
+ }
+ , "just/com_github_libgit2_libgit2":
+ { "repository":
+ { "type": "archive"
+ , "content": "80f999c62e8da8da7d64fe543c8eeb9953bf6974"
+ , "fetch": "https://github.com/libgit2/libgit2/archive/refs/tags/v1.7.2.tar.gz"
+ , "sha256": "de384e29d7efc9330c6cdb126ebf88342b5025d920dcb7c645defad85195ea7f"
+ , "sha512": "825737e4a1991fba50ea535f15b0e560ebe76ead752e04aeba36925b944d0da77fe9826a70980a1aa3d0bf9afbedfab79dd92e799c9252931384c89ebec9b012"
+ , "subdir": "libgit2-1.7.2"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.git2"
+ , "bindings":
+ {"rules": "just/rules-git2", "zlib": "just/zlib", "ssl": "just/ssl"}
+ }
+ , "just/com_github_microsoft_gsl":
+ { "repository":
+ { "type": "archive"
+ , "content": "386f0a89a47763481223a63d5026215af8d3c827"
+ , "fetch": "https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.tar.gz"
+ , "sha256": "f0e32cb10654fea91ad56bde89170d78cfbf4363ee0b01d8f097de2ba49f6ce9"
+ , "sha512": "7fa7446796c6bf82fb3bff09f86a69c446a27be528bef3b17c8bc5ad2f24d5cf86bdb3d3813ecb44726e8f395020180e97e41027330d1fbf545cc0f0b44aac29"
+ , "subdir": "GSL-4.0.0/include/gsl"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.gsl"
+ , "bindings": {"rules": "just/rules"}
+ }
+ , "just/com_google_absl":
+ { "repository":
+ { "type": "archive"
+ , "content": "e9bacd5f3a5c3a51f4f0f50e9ed963464714caa7"
+ , "fetch": "https://github.com/abseil/abseil-cpp/releases/download/20240116.0/abseil-cpp-20240116.0.tar.gz"
+ , "sha256": "338420448b140f0dfd1a1ea3c3ce71b3bc172071f24f4d9a57d59b45037da440"
+ , "sha512": "018488e69cca472ef118631bd79bca4ef0cf1363432e79b81532942168d305511e4cdf4dc72611275e9a9de00cd71c0245be4ec287ff36147248e218218bf825"
+ , "subdir": "abseil-cpp-20240116.0"
+ , "mirrors":
+ [ "https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/20240116.0.tar.gz"
+ ]
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.absl"
+ , "bindings": {"rules": "just/rules-absl", "patches": "just/patches"}
+ }
+ , "just/fmt":
+ { "repository":
+ { "type": "zip"
+ , "content": "c54a3ec3cba9177c0be51051b762a74449ea1466"
+ , "fetch": "https://github.com/fmtlib/fmt/releases/download/10.2.1/fmt-10.2.1.zip"
+ , "sha256": "312151a2d13c8327f5c9c586ac6cf7cddc1658e8f53edae0ec56509c8fa516c9"
+ , "sha512": "1cf0e3dd09c7d87e0890b8743559159d3be2a8f33c135516962d17c4eeb7b00659e6acd74518bd5566ee4e83ddaba155fecb4c229f90cd258b3b832e72ad82cd"
+ , "subdir": "fmt-10.2.1"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.fmt"
+ , "bindings": {"rules": "just/rules"}
+ }
+ , "just/google_apis":
+ { "repository":
+ { "type": "archive"
+ , "content": "5d9001f3dff8dec1880c06c0de100a0c2fc65094"
+ , "fetch": "https://github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz"
+ , "sha256": "5bb6b0253ccf64b53d6c7249625a7e3f6c3bc6402abd52d3778bfa48258703a0"
+ , "sha512": "cdeefae807df7097174b4bb28c0900b06a68d424c00ebba4ff5add260c9c651351d5e429bfc5de42f95ebb75dadec313f7bd3991c2fa476c9104f9ea656acad4"
+ , "subdir": "googleapis-2f9af297c84c55c8b871ba4495e01ade42476c92"
+ , "mirrors":
+ [ "https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz"
+ ]
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.google_apis"
+ , "bindings": {"rules": "just/rules", "patches": "just/patches"}
+ }
+ , "just/json":
+ { "repository":
+ { "type": "zip"
+ , "content": "733571f96614cc01fcebf76c8359f52706677c61"
+ , "fetch": "https://github.com/nlohmann/json/releases/download/v3.11.3/include.zip"
+ , "sha256": "a22461d13119ac5c78f205d3df1db13403e58ce1bb1794edc9313677313f4a9d"
+ , "sha512": "8d923e2586acf736fc1886bf1839ca0126444ec60ce93a4bd18c21eef4475dff6f608203e42bf4968878dc50727a8c20c517dd8c1ac5c6b0bb6a95f2dce5546e"
+ , "subdir": "include/nlohmann"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.json"
+ , "bindings": {"rules": "just/rules"}
+ }
+ , "just/lzma":
+ { "repository":
+ { "type": "archive"
+ , "content": "6dae9322046ff66b7074c33b24be9a98f5cee42a"
+ , "fetch": "https://github.com/xz-mirror/xz/archive/refs/tags/v5.4.0.tar.gz"
+ , "sha256": "26ec069c41e5dfae221825b9f28a4934cb6ce3bedd3f55bc0a08073f7c2e42fd"
+ , "sha512": "60aba20197d329a1e0d86b32de8a9727a98e5ff6f1eda6111c5ddf85086edeefcf9e2cc3998d237e248bf4af7cf746923b45d236e6b47d88f63cf3d57cae9e8f"
+ , "subdir": "xz-5.4.0"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.lzma"
+ , "bindings": {"rules": "just/rules-lzma"}
+ }
+ , "just/patches":
+ { "repository":
+ { "type": "git"
+ , "repository": "https://github.com/just-buildsystem/justbuild"
+ , "branch": "v1.4.0-alpha+20240619"
+ , "commit": "96158f57c36bbc649abcd9a213bf04df6cf8a1f5"
+ , "subdir": "etc/patches"
+ }
+ }
+ , "just/protobuf":
+ { "repository":
+ { "type": "archive"
+ , "content": "989aa1fec35687ab84229fa84099582dd8f0246a"
+ , "fetch": "https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz"
+ , "sha256": "9bd87b8280ef720d3240514f884e56a712f2218f0d693b48050c836028940a42"
+ , "sha512": "d2fad2188118ced2cd951bdb472d72cc9e9b2158c88eeca652c76332a884b5b5b4b58628f7777272fa693140753823584ea9c7924f1655b1d5a363f59bdf7a4c"
+ , "subdir": "protobuf-25.1"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.protobuf"
+ , "bindings":
+ { "rules": "just/rules-protobuf"
+ , "zlib": "just/zlib"
+ , "absl": "just/com_google_absl"
+ }
+ }
+ , "just/re2":
+ { "repository":
+ { "type": "archive"
+ , "content": "8eebd70d7ebd33ac5d736090cecd7cfe1831b9e3"
+ , "fetch": "https://github.com/google/re2/archive/refs/tags/2022-04-01.tar.gz"
+ , "sha256": "1ae8ccfdb1066a731bba6ee0881baad5efd2cd661acd9569b689f2586e1a50e9"
+ , "sha512": "fc3d7cc1ee6bd771719845566d83ffc8c4e19d838748e842a1e19c7564473c9a0a061bebb3966ffa82de6515346f9bbddc2d94ceb3de89233f58826774bd7ce7"
+ , "subdir": "re2-2022-04-01"
+ , "mirrors":
+ [ "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/re2/archive/2022-04-01.tar.gz"
+ ]
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.re2"
+ , "bindings": {"rules": "just/rules-re2"}
+ }
+ , "just/rules":
+ { "repository":
+ { "type": "git"
+ , "repository": "https://github.com/just-buildsystem/justbuild"
+ , "branch": "v1.4.0-alpha+20240619"
+ , "commit": "96158f57c36bbc649abcd9a213bf04df6cf8a1f5"
+ , "subdir": "rules"
+ }
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "bindings": {"toolchain": "just/toolchain"}
+ }
+ , "just/rules-absl":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.absl"
+ , "bindings": {"base": "just/rules"}
+ }
+ , "just/rules-archive":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.archive"
+ , "bindings": {"base": "just/rules"}
+ }
+ , "just/rules-boringssl":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.boringssl"
+ , "bindings": {"base": "just/rules"}
+ }
+ , "just/rules-bzip2":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.bzip2"
+ , "bindings": {"base": "just/rules"}
+ }
+ , "just/rules-curl":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.curl"
+ , "bindings": {"base": "just/rules"}
+ }
+ , "just/rules-git2":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.git2"
+ , "bindings": {"base": "just/rules"}
+ }
+ , "just/rules-grpc":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.grpc"
+ , "bindings": {"base": "just/rules", "protoc": "just/protobuf"}
+ }
+ , "just/rules-just":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.just"
+ , "bindings":
+ { "base": "just/rules"
+ , "protoc": "just/protobuf"
+ , "grpc": "just/com_github_grpc_grpc"
+ }
+ }
+ , "just/rules-lzma":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.lzma"
+ , "bindings": {"base": "just/rules"}
+ }
+ , "just/rules-protobuf":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.protobuf"
+ , "bindings": {"base": "just/rules"}
+ }
+ , "just/rules-re2":
+ { "repository": "just/rules"
+ , "target_root": "just/defaults"
+ , "rule_root": "just/rules"
+ , "target_file_name": "TARGETS.re2"
+ , "bindings": {"base": "just/rules"}
+ }
+ , "just/ssl":
+ { "repository":
+ { "type": "archive"
+ , "content": "7b7deaf147baf61c8efdc8a4ac79a16ba70b216e"
+ , "fetch": "https://github.com/google/boringssl/archive/ae72a4514c7afd150596b0a80947f3ca9b8363b5.tar.gz"
+ , "sha256": "057f662b0e85931a84945b2e89ba201fd44b0583da827c948fe443593690fb83"
+ , "sha512": "757a2727a2ab0e45656c22d807ea1217c74c276f51fa721a87f92b59a4d040d9931586e912b4558f57330340cc3af6361f1694b1479b764635c6a111b356afc4"
+ , "subdir": "boringssl-ae72a4514c7afd150596b0a80947f3ca9b8363b5"
+ , "mirrors":
+ [ "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/boringssl/archive/ae72a4514c7afd150596b0a80947f3ca9b8363b5.tar.gz"
+ ]
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.boringssl"
+ , "bindings": {"rules": "just/rules-boringssl", "patches": "just/patches"}
+ }
+ , "just/toolchain":
+ { "repository":
+ { "type": "git"
+ , "repository": "https://github.com/just-buildsystem/justbuild"
+ , "branch": "v1.4.0-alpha+20240619"
+ , "commit": "96158f57c36bbc649abcd9a213bf04df6cf8a1f5"
+ , "subdir": "etc/toolchain"
+ }
+ , "rule_root": "just/rules"
+ }
+ , "just/zlib":
+ { "repository":
+ { "type": "archive"
+ , "content": "88faf0fca21e0d82de44366fdd52aaadbab2e6b6"
+ , "fetch": "https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.gz"
+ , "sha256": "ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e"
+ , "sha512": "185795044461cd78a5545250e06f6efdb0556e8d1bfe44e657b509dd6f00ba8892c8eb3febe65f79ee0b192d6af857f0e0055326d33a881449f3833f92e5f8fb"
+ , "subdir": "zlib-1.3"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.zlib"
+ , "bindings": {"rules": "just/rules"}
+ }
+ , "just/defaults":
+ { "repository":
+ { "type": "git"
+ , "repository": "https://github.com/just-buildsystem/justbuild"
+ , "branch": "v1.4.0-alpha+20240619"
+ , "commit": "96158f57c36bbc649abcd9a213bf04df6cf8a1f5"
+ , "subdir": "etc/defaults"
+ }
+ }
+ , "just/import targets":
+ { "repository":
+ { "type": "git"
+ , "repository": "https://github.com/just-buildsystem/justbuild"
+ , "branch": "v1.4.0-alpha+20240619"
+ , "commit": "96158f57c36bbc649abcd9a213bf04df6cf8a1f5"
+ , "subdir": "etc/import"
+ }
+ }
+ }
+}
diff --git a/etc/repos.template.json b/etc/repos.template.json
new file mode 100644
index 0000000..daf9103
--- /dev/null
+++ b/etc/repos.template.json
@@ -0,0 +1,72 @@
+{ "main": "rules with bundled tools"
+, "repositories":
+ { "rules": {"repository": {"type": "file", "path": "rules"}}
+ , "rules with bundled tools":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "rule_root": "rules"
+ , "bindings":
+ { "base": "just/rules"
+ , "protoc": "just/protobuf"
+ , "grpc": "just/com_github_grpc_grpc"
+ }
+ }
+ , "defaults": {"repository": {"type": "file", "path": "etc/defaults"}}
+ , "tests":
+ { "repository": {"type": "file", "path": "tests"}
+ , "bindings":
+ { "test-just": "just"
+ , "test-rules": "test-rules"
+ , "test-libs": "test-libs"
+ , "rules": "rules"
+ }
+ }
+ , "imports": {"repository": {"type": "file", "path": "etc/imports"}}
+ , "test-rules":
+ { "repository": {"type": "file", "path": "rules"}
+ , "target_root": "imports"
+ , "target_file_name": "rules.TARGETS"
+ }
+ , "test-libs":
+ { "repository": "imports"
+ , "target_file_name": "libs.TARGETS"
+ , "bindings": {"gtest": "gtest", "libz": "libz", "libcurl": "libcurl"}
+ }
+ , "gtest":
+ { "repository":
+ { "type": "archive"
+ , "fetch": "https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz"
+ , "content": "cbd19f97df3ab86b174520cd850d238617c156e0"
+ , "sha256": "ad7fdba11ea011c1d925b3289cf4af2c66a352e18d4c7264392fead75e919363"
+ , "subdir": "googletest-1.13.0"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "gtest.TARGETS"
+ }
+ , "libz":
+ { "repository":
+ { "type": "archive"
+ , "content": "d115fc690fa59d3be51b3442158876536140b6c2"
+ , "fetch": "https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz"
+ , "sha256": "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30"
+ , "sha512": "99f0e843f52290e6950cc328820c0f322a4d934a504f66c7caa76bd0cc17ece4bf0546424fc95135de85a2656fed5115abb835fd8d8a390d60ffaf946c8887ad"
+ , "subdir": "zlib-1.2.13"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "libz.TARGETS"
+ }
+ , "libcurl":
+ { "repository":
+ { "type": "archive"
+ , "content": "540b4de2edfa015b894ad86d51b33a55f451ac99"
+ , "fetch": "https://github.com/curl/curl/releases/download/curl-8_0_1/curl-8.0.1.tar.gz"
+ , "sha256": "5fd29000a4089934f121eff456101f0a5d09e2a3e89da1d714adf06c4be887cb"
+ , "sha512": "87d945e65176613c6296f8b130bd6c5355e3ca3c62ee4010edd481950cad9760482fd3be8a84e51501c118c29ebc284b8f87c49b06f9d248e9da5819fda38f8f"
+ , "subdir": "curl-8.0.1"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "libcurl.TARGETS"
+ , "bindings": {"libz": "libz"}
+ }
+ }
+}
diff --git a/CC/EXPRESSIONS b/rules/CC/EXPRESSIONS
index 938c342..938c342 100644
--- a/CC/EXPRESSIONS
+++ b/rules/CC/EXPRESSIONS
diff --git a/CC/RULES b/rules/CC/RULES
index e5d887a..e5d887a 100644
--- a/CC/RULES
+++ b/rules/CC/RULES
diff --git a/CC/TARGETS b/rules/CC/TARGETS
index 8860e8b..8860e8b 100644
--- a/CC/TARGETS
+++ b/rules/CC/TARGETS
diff --git a/CC/auto/EXPRESSIONS b/rules/CC/auto/EXPRESSIONS
index 9520975..9520975 100644
--- a/CC/auto/EXPRESSIONS
+++ b/rules/CC/auto/EXPRESSIONS
diff --git a/CC/auto/RULES b/rules/CC/auto/RULES
index debae9c..debae9c 100644
--- a/CC/auto/RULES
+++ b/rules/CC/auto/RULES
diff --git a/rules/CC/auto/TARGETS b/rules/CC/auto/TARGETS
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/rules/CC/auto/TARGETS
@@ -0,0 +1 @@
+{}
diff --git a/CC/auto/runner b/rules/CC/auto/runner
index 47c2f94..47c2f94 100755
--- a/CC/auto/runner
+++ b/rules/CC/auto/runner
diff --git a/CC/foreign/EXPRESSIONS b/rules/CC/foreign/EXPRESSIONS
index 2988b32..2988b32 100644
--- a/CC/foreign/EXPRESSIONS
+++ b/rules/CC/foreign/EXPRESSIONS
diff --git a/CC/foreign/RULES b/rules/CC/foreign/RULES
index 935d477..935d477 100644
--- a/CC/foreign/RULES
+++ b/rules/CC/foreign/RULES
diff --git a/rules/CC/foreign/TARGETS b/rules/CC/foreign/TARGETS
new file mode 100644
index 0000000..5fbb6a9
--- /dev/null
+++ b/rules/CC/foreign/TARGETS
@@ -0,0 +1,7 @@
+{ "defaults":
+ { "type": ["CC/foreign", "defaults"]
+ , "MAKE": ["make"]
+ , "CMAKE": ["cmake"]
+ , "PATH": ["/bin", "/usr/bin"]
+ }
+}
diff --git a/CC/foreign/cmake/EXPRESSIONS b/rules/CC/foreign/cmake/EXPRESSIONS
index bf2385e..bf2385e 100644
--- a/CC/foreign/cmake/EXPRESSIONS
+++ b/rules/CC/foreign/cmake/EXPRESSIONS
diff --git a/CC/foreign/cmake/RULES b/rules/CC/foreign/cmake/RULES
index b7fd406..b7fd406 100644
--- a/CC/foreign/cmake/RULES
+++ b/rules/CC/foreign/cmake/RULES
diff --git a/CC/foreign/expand_exec b/rules/CC/foreign/expand_exec
index 32891ca..32891ca 100755
--- a/CC/foreign/expand_exec
+++ b/rules/CC/foreign/expand_exec
diff --git a/CC/foreign/expand_exec.c b/rules/CC/foreign/expand_exec.c
index a4ff311..a4ff311 100644
--- a/CC/foreign/expand_exec.c
+++ b/rules/CC/foreign/expand_exec.c
diff --git a/CC/foreign/make/EXPRESSIONS b/rules/CC/foreign/make/EXPRESSIONS
index bff8205..bff8205 100644
--- a/CC/foreign/make/EXPRESSIONS
+++ b/rules/CC/foreign/make/EXPRESSIONS
diff --git a/CC/foreign/make/RULES b/rules/CC/foreign/make/RULES
index cf67998..cf67998 100644
--- a/CC/foreign/make/RULES
+++ b/rules/CC/foreign/make/RULES
diff --git a/CC/foreign/shell/EXPRESSIONS b/rules/CC/foreign/shell/EXPRESSIONS
index a0a9a00..a0a9a00 100644
--- a/CC/foreign/shell/EXPRESSIONS
+++ b/rules/CC/foreign/shell/EXPRESSIONS
diff --git a/CC/foreign/shell/RULES b/rules/CC/foreign/shell/RULES
index 6a5d8ec..6a5d8ec 100644
--- a/CC/foreign/shell/RULES
+++ b/rules/CC/foreign/shell/RULES
diff --git a/CC/pkgconfig/EXPRESSIONS b/rules/CC/pkgconfig/EXPRESSIONS
index 8707f87..8707f87 100644
--- a/CC/pkgconfig/EXPRESSIONS
+++ b/rules/CC/pkgconfig/EXPRESSIONS
diff --git a/CC/pkgconfig/RULES b/rules/CC/pkgconfig/RULES
index 363136f..363136f 100644
--- a/CC/pkgconfig/RULES
+++ b/rules/CC/pkgconfig/RULES
diff --git a/shell/TARGETS b/rules/CC/pkgconfig/TARGETS
index 705d1d7..705d1d7 100644
--- a/shell/TARGETS
+++ b/rules/CC/pkgconfig/TARGETS
diff --git a/CC/pkgconfig/add_rpath b/rules/CC/pkgconfig/add_rpath
index d020f2b..d020f2b 100755
--- a/CC/pkgconfig/add_rpath
+++ b/rules/CC/pkgconfig/add_rpath
diff --git a/CC/prebuilt/EXPRESSIONS b/rules/CC/prebuilt/EXPRESSIONS
index b84e494..b84e494 100644
--- a/CC/prebuilt/EXPRESSIONS
+++ b/rules/CC/prebuilt/EXPRESSIONS
diff --git a/CC/prebuilt/RULES b/rules/CC/prebuilt/RULES
index 16f9f26..16f9f26 100644
--- a/CC/prebuilt/RULES
+++ b/rules/CC/prebuilt/RULES
diff --git a/CC/prebuilt/read_pkgconfig.py b/rules/CC/prebuilt/read_pkgconfig.py
index 115c305..115c305 100755
--- a/CC/prebuilt/read_pkgconfig.py
+++ b/rules/CC/prebuilt/read_pkgconfig.py
diff --git a/CC/proto/EXPRESSIONS b/rules/CC/proto/EXPRESSIONS
index 0b44506..0b44506 100644
--- a/CC/proto/EXPRESSIONS
+++ b/rules/CC/proto/EXPRESSIONS
diff --git a/CC/proto/RULES b/rules/CC/proto/RULES
index 6fb0f40..6fb0f40 100644
--- a/CC/proto/RULES
+++ b/rules/CC/proto/RULES
diff --git a/CC/proto/TARGETS b/rules/CC/proto/TARGETS
index 87bebd0..87bebd0 100644
--- a/CC/proto/TARGETS
+++ b/rules/CC/proto/TARGETS
diff --git a/CC/test/EXPRESSIONS b/rules/CC/test/EXPRESSIONS
index fe4918e..fe4918e 100644
--- a/CC/test/EXPRESSIONS
+++ b/rules/CC/test/EXPRESSIONS
diff --git a/CC/test/RULES b/rules/CC/test/RULES
index 9f3313d..9f3313d 100644
--- a/CC/test/RULES
+++ b/rules/CC/test/RULES
diff --git a/rules/CC/test/TARGETS b/rules/CC/test/TARGETS
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/rules/CC/test/TARGETS
@@ -0,0 +1 @@
+{}
diff --git a/CC/test/runner b/rules/CC/test/runner
index 45a1bee..45a1bee 100755
--- a/CC/test/runner
+++ b/rules/CC/test/runner
diff --git a/EXPRESSIONS b/rules/EXPRESSIONS
index 52a381f..52a381f 100644
--- a/EXPRESSIONS
+++ b/rules/EXPRESSIONS
diff --git a/data/EXPRESSIONS b/rules/data/EXPRESSIONS
index 929eaf8..929eaf8 100644
--- a/data/EXPRESSIONS
+++ b/rules/data/EXPRESSIONS
diff --git a/data/RULES b/rules/data/RULES
index ab5c92e..ab5c92e 100644
--- a/data/RULES
+++ b/rules/data/RULES
diff --git a/patch/EXPRESSIONS b/rules/patch/EXPRESSIONS
index 7f8ce19..7f8ce19 100644
--- a/patch/EXPRESSIONS
+++ b/rules/patch/EXPRESSIONS
diff --git a/patch/RULES b/rules/patch/RULES
index c55de58..c55de58 100644
--- a/patch/RULES
+++ b/rules/patch/RULES
diff --git a/patch/TARGETS b/rules/patch/TARGETS
index 9a0ad77..9a0ad77 100644
--- a/patch/TARGETS
+++ b/rules/patch/TARGETS
diff --git a/proto/RULES b/rules/proto/RULES
index a9152dd..a9152dd 100644
--- a/proto/RULES
+++ b/rules/proto/RULES
diff --git a/shell/EXPRESSIONS b/rules/shell/EXPRESSIONS
index 34a5c92..34a5c92 100644
--- a/shell/EXPRESSIONS
+++ b/rules/shell/EXPRESSIONS
diff --git a/shell/RULES b/rules/shell/RULES
index 41530a2..41530a2 100644
--- a/shell/RULES
+++ b/rules/shell/RULES
diff --git a/rules/shell/TARGETS b/rules/shell/TARGETS
new file mode 100644
index 0000000..705d1d7
--- /dev/null
+++ b/rules/shell/TARGETS
@@ -0,0 +1 @@
+{"defaults": {"type": "defaults"}}
diff --git a/shell/test/EXPRESSIONS b/rules/shell/test/EXPRESSIONS
index 635a407..635a407 100644
--- a/shell/test/EXPRESSIONS
+++ b/rules/shell/test/EXPRESSIONS
diff --git a/shell/test/RULES b/rules/shell/test/RULES
index 91b7637..91b7637 100644
--- a/shell/test/RULES
+++ b/rules/shell/test/RULES
diff --git a/rules/shell/test/TARGETS b/rules/shell/test/TARGETS
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/rules/shell/test/TARGETS
@@ -0,0 +1 @@
+{}
diff --git a/shell/test/runner b/rules/shell/test/runner
index 2f97005..2f97005 100755
--- a/shell/test/runner
+++ b/rules/shell/test/runner
diff --git a/shell/test/summarizer b/rules/shell/test/summarizer
index 72cd1b9..72cd1b9 100755
--- a/shell/test/summarizer
+++ b/rules/shell/test/summarizer
diff --git a/transitions/EXPRESSIONS b/rules/transitions/EXPRESSIONS
index fef8542..fef8542 100644
--- a/transitions/EXPRESSIONS
+++ b/rules/transitions/EXPRESSIONS
diff --git a/tests/ROOT b/tests/ROOT
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/ROOT
diff --git a/tests/TARGETS b/tests/TARGETS
new file mode 100644
index 0000000..c64245e
--- /dev/null
+++ b/tests/TARGETS
@@ -0,0 +1,6 @@
+{ "ALL":
+ { "type": "install"
+ , "deps": [["test_cases/deps", "ALL"], ["test_cases/cflags", "ALL"]]
+ , "tainted": ["test"]
+ }
+}
diff --git a/tests/test_cases/cflags/TARGETS b/tests/test_cases/cflags/TARGETS
new file mode 100644
index 0000000..44c99f1
--- /dev/null
+++ b/tests/test_cases/cflags/TARGETS
@@ -0,0 +1,19 @@
+{ "public":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["cflags_public"]
+ , "targets":
+ [ "+main_use_half3"
+ , "+test_use_half3"
+ , "+main_use_half3f"
+ , "+test_use_half3f"
+ ]
+ , "asserts":
+ [ "./main_use_half3/main_use_half3 | grep 1.5"
+ , "[ \"$(cat ./test_use_half3/result)\" = \"PASS\" ]"
+ , "./main_use_half3f/main_use_half3f | grep 1.5"
+ , "[ \"$(cat ./test_use_half3f/result)\" = \"PASS\" ]"
+ ]
+ , "data": [["TREE", null, "public"]]
+ }
+, "ALL": {"type": "install", "deps": ["public"], "tainted": ["test"]}
+}
diff --git a/tests/test_cases/cflags/public/TARGETS b/tests/test_cases/cflags/public/TARGETS
new file mode 100644
index 0000000..79aadb3
--- /dev/null
+++ b/tests/test_cases/cflags/public/TARGETS
@@ -0,0 +1,49 @@
+{ "half":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["half"]
+ , "hdrs": ["half.hpp"]
+ , "srcs": ["half.cpp"]
+ , "cflags": ["-DHALF_PRECISION_DOUBLE"]
+ , "stage": ["half"]
+ }
+, "half3":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["half3"]
+ , "hdrs": ["half3.hpp"]
+ , "srcs": ["half3.cpp"]
+ , "deps": ["half"]
+ , "stage": ["half3"]
+ }
+, "half3f":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["half3f"]
+ , "hdrs": ["half3f.hpp"]
+ , "srcs": ["half3f.cpp"]
+ , "private-deps": ["half3"]
+ , "stage": ["half3f"]
+ }
+, "main_use_half3":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main_use_half3"]
+ , "srcs": ["main_use_half3.cpp"]
+ , "private-deps": ["half3"]
+ }
+, "test_use_half3":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_use_half3"]
+ , "srcs": ["test_use_half3.cpp"]
+ , "private-deps": ["half3"]
+ }
+, "main_use_half3f":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main_use_half3f"]
+ , "srcs": ["main_use_half3f.cpp"]
+ , "private-deps": ["half3f"]
+ }
+, "test_use_half3f":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_use_half3f"]
+ , "srcs": ["test_use_half3f.cpp"]
+ , "private-deps": ["half3f"]
+ }
+}
diff --git a/tests/test_cases/cflags/public/half.cpp b/tests/test_cases/cflags/public/half.cpp
new file mode 100644
index 0000000..e26ff6e
--- /dev/null
+++ b/tests/test_cases/cflags/public/half.cpp
@@ -0,0 +1,5 @@
+#include "half.hpp"
+
+HALF_RESULT_TYPE half(int val) {
+ return static_cast<HALF_RESULT_TYPE>(val / 2.0);
+}
diff --git a/tests/test_cases/cflags/public/half.hpp b/tests/test_cases/cflags/public/half.hpp
new file mode 100644
index 0000000..0baebcb
--- /dev/null
+++ b/tests/test_cases/cflags/public/half.hpp
@@ -0,0 +1,12 @@
+#ifndef HALF_HPP
+#define HALF_HPP
+
+#ifdef HALF_PRECISION_DOUBLE
+#define HALF_RESULT_TYPE double
+#else
+#define HALF_RESULT_TYPE int
+#endif
+
+HALF_RESULT_TYPE half(int val);
+
+#endif
diff --git a/tests/test_cases/cflags/public/half3.cpp b/tests/test_cases/cflags/public/half3.cpp
new file mode 100644
index 0000000..484f7f8
--- /dev/null
+++ b/tests/test_cases/cflags/public/half3.cpp
@@ -0,0 +1,3 @@
+#include "half3.hpp"
+
+HALF_RESULT_TYPE half3() { return half(3); }
diff --git a/tests/test_cases/cflags/public/half3.hpp b/tests/test_cases/cflags/public/half3.hpp
new file mode 100644
index 0000000..271ed68
--- /dev/null
+++ b/tests/test_cases/cflags/public/half3.hpp
@@ -0,0 +1,8 @@
+#ifndef HALF3_HPP
+#define HALF3_HPP
+
+#include "half/half.hpp"
+
+HALF_RESULT_TYPE half3();
+
+#endif
diff --git a/tests/test_cases/cflags/public/half3f.cpp b/tests/test_cases/cflags/public/half3f.cpp
new file mode 100644
index 0000000..88b6d55
--- /dev/null
+++ b/tests/test_cases/cflags/public/half3f.cpp
@@ -0,0 +1,7 @@
+#include "half3/half3.hpp"
+
+#ifndef HALF_PRECISION_DOUBLE
+#error should be defined
+#endif
+
+float half3f() { return static_cast<float>(half3()); }
diff --git a/tests/test_cases/cflags/public/half3f.hpp b/tests/test_cases/cflags/public/half3f.hpp
new file mode 100644
index 0000000..1207f63
--- /dev/null
+++ b/tests/test_cases/cflags/public/half3f.hpp
@@ -0,0 +1,6 @@
+#ifndef BAZ_HPP
+#define BAZ_HPP
+
+float half3f();
+
+#endif
diff --git a/tests/test_cases/cflags/public/main_use_half3.cpp b/tests/test_cases/cflags/public/main_use_half3.cpp
new file mode 100644
index 0000000..1c9d6ba
--- /dev/null
+++ b/tests/test_cases/cflags/public/main_use_half3.cpp
@@ -0,0 +1,7 @@
+#include "half3/half3.hpp"
+#include <iostream>
+
+int main() {
+ std::cout << half3() << std::endl;
+ return 0;
+}
diff --git a/tests/test_cases/cflags/public/main_use_half3f.cpp b/tests/test_cases/cflags/public/main_use_half3f.cpp
new file mode 100644
index 0000000..3e855cd
--- /dev/null
+++ b/tests/test_cases/cflags/public/main_use_half3f.cpp
@@ -0,0 +1,11 @@
+#include "half3f/half3f.hpp"
+#include <iostream>
+
+#ifdef HALF_PRECISION_DOUBLE
+#error should not be defined
+#endif
+
+int main() {
+ std::cout << half3f() << std::endl;
+ return 0;
+}
diff --git a/tests/test_cases/cflags/public/test_use_half3.cpp b/tests/test_cases/cflags/public/test_use_half3.cpp
new file mode 100644
index 0000000..1cf50ad
--- /dev/null
+++ b/tests/test_cases/cflags/public/test_use_half3.cpp
@@ -0,0 +1,6 @@
+#include "half3/half3.hpp"
+
+int main() {
+ auto result = half3();
+ return result > 1 and result < 2 ? 0 : 1;
+}
diff --git a/tests/test_cases/cflags/public/test_use_half3f.cpp b/tests/test_cases/cflags/public/test_use_half3f.cpp
new file mode 100644
index 0000000..078e69c
--- /dev/null
+++ b/tests/test_cases/cflags/public/test_use_half3f.cpp
@@ -0,0 +1,10 @@
+#include "half3f/half3f.hpp"
+
+#ifdef HALF_PRECISION_DOUBLE
+#error should not be defined
+#endif
+
+int main() {
+ auto result = half3f();
+ return result > 1 and result < 2 ? 0 : 1;
+}
diff --git a/tests/test_cases/deps/TARGETS b/tests/test_cases/deps/TARGETS
new file mode 100644
index 0000000..b1047a8
--- /dev/null
+++ b/tests/test_cases/deps/TARGETS
@@ -0,0 +1,287 @@
+{ "private":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_private"]
+ , "targets":
+ [ "+foo"
+ , "-main_includes_foo"
+ , "+main_links_foo"
+ , "+main_links_bar_foo"
+ , "+install_bar"
+ ]
+ , "asserts":
+ [ "test -f foo/foo/libfoo.a"
+ , "test -f foo/foo/foo.hpp"
+ , "! test -f foo/bar/bar.hpp"
+ , "./main_links_foo/main | grep foo"
+ , "./main_links_bar_foo/main | grep bar"
+ , "./main_links_bar_foo/main | grep foo"
+ , "test -f install_bar/lib/bar/libbar.a"
+ , "test -f install_bar/include/bar/bar.hpp"
+ , "test -f install_bar/lib/foo/libfoo.a"
+ , "! test -f install_bar/include/foo/foo.hpp"
+ ]
+ , "data": [["TREE", null, "private"]]
+ }
+, "public":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_public"]
+ , "targets":
+ [ "+foo"
+ , "+main_includes_foo"
+ , "+main_links_foo"
+ , "+main_links_bar_foo"
+ , "+install_bar"
+ ]
+ , "asserts":
+ [ "test -f foo/foo/libfoo.a"
+ , "test -f foo/foo/foo.hpp"
+ , "! test -f foo/bar/bar.hpp"
+ , "./main_includes_foo/main | grep main"
+ , "./main_links_foo/main | grep foo"
+ , "./main_links_bar_foo/main | grep bar"
+ , "./main_links_bar_foo/main | grep foo"
+ , "test -f install_bar/lib/bar/libbar.a"
+ , "test -f install_bar/include/bar/bar.hpp"
+ , "test -f install_bar/lib/foo/libfoo.a"
+ , "test -f install_bar/include/foo/foo.hpp"
+ ]
+ , "data": [["TREE", null, "public"]]
+ }
+, "shared":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_shared"]
+ , "targets":
+ [ "+foo"
+ , "+bar"
+ , "+main_uses_foo"
+ , "+test_uses_foo"
+ , "+main_uses_bar"
+ , "+test_uses_bar"
+ , "+test_uses_bar_s"
+ , "+test_uses_baz"
+ , "+test_uses_main"
+ , "+test_diamond"
+ , "+install_foo"
+ , "+install_bar_s"
+ , "+install_baz"
+ , "+install_main"
+ ]
+ , "asserts":
+ [ "test -f foo/libfoo.so.1.2.3"
+ , "test -f foo/foo/foo.hpp"
+ , "test -f bar/libbar.so"
+ , "test -f bar/bar/bar.hpp"
+ , "! test -f bar/foo/foo.hpp"
+ , "test -f install_foo/lib/libfoo.so.1.2.3"
+ , "test -f install_foo/include/foo/foo.hpp"
+ , "grep 'Name: foo' install_foo/lib/pkgconfig/foo.pc"
+ , "grep 'Version: 1.2.3' install_foo/lib/pkgconfig/foo.pc"
+ , "grep -- '-L${libdir}' install_foo/lib/pkgconfig/foo.pc"
+ , "grep -- '-l:libfoo.so.1.2.3' install_foo/lib/pkgconfig/foo.pc"
+ , "test -f install_bar_s/lib/bar/libbar.a"
+ , "test -f install_bar_s/include/bar/bar.hpp"
+ , "test -f install_bar_s/lib/libfoo.so.1.2.3"
+ , "! test -f install_bar_s/include/foo/foo.hpp"
+ , "grep 'Name: bar' install_bar_s/lib/pkgconfig/bar.pc"
+ , "grep '${libdir}/bar/libbar.a' install_bar_s/lib/pkgconfig/bar.pc"
+ , "grep '${libdir}/libfoo.so.1.2.3' install_bar_s/lib/pkgconfig/bar.pc"
+ , "test -f install_baz/lib/libbaz.so"
+ , "test -f install_baz/include/baz/baz.hpp"
+ , "! test -f install_baz/lib/foo/libfoo.a"
+ , "! test -f install_baz/include/foo/foo.hpp"
+ , "./install_main/bin/main_uses_bar | grep main"
+ , "./install_main/bin/main_uses_bar | grep bar"
+ , "./install_main/bin/main_uses_bar | grep foo"
+ , "! test -d install_main/include"
+ ]
+ , "data": [["TREE", null, "shared"]]
+ }
+, "object":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_object"]
+ , "targets": ["+foo", "+bar", "+baz", "+main", "+test_main", "+install_main"]
+ , "asserts":
+ [ "[ -f ./foo/libfoo.so ]"
+ , "[ -f ./bar/bar/bar.o ]"
+ , "[ -f ./baz/libbaz.so ]"
+ , "[ -f ./install_main/lib/libfoo.so ]"
+ , "[ ! -f ./install_main/lib/bar/bar.o ]"
+ , "[ \"$(./install_main/bin/main)\" = 'Hello World and Galaxy' ]"
+ ]
+ , "data": [["TREE", null, "object"]]
+ }
+, "prebuilt_tests":
+ { "type": "tree"
+ , "deps":
+ [ ["test_cases/deps/prebuilt", "foo.hpp"]
+ , ["test_cases/deps/prebuilt", "bar.hpp"]
+ , ["test_cases/deps/prebuilt", "TARGETS"]
+ , ["TREE", null, "shared"]
+ ]
+ }
+, "prebuilt":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_prebuilt"]
+ , "targets":
+ [ "+foo"
+ , "+bar"
+ , "+main_uses_foo"
+ , "+test_uses_foo"
+ , "+main_uses_bar"
+ , "+test_uses_bar"
+ , "+test_uses_bar_s"
+ , "+test_uses_main"
+ , "+install_foo"
+ , "+install_bar"
+ , "+install_main"
+ , "+test_uses_foobar"
+ , "+test_uses_foobar_s"
+ , "+install_foobar"
+ ]
+ , "asserts":
+ [ "test -f foo/libfoo.so.1.2.3"
+ , "test -f foo/foo/foo.hpp"
+ , "test -f bar/libbar.so"
+ , "test -f bar/bar/bar.hpp"
+ , "test -f install_foo/lib/pkgconfig/foo/foo.cflags"
+ , "test -f install_foo/lib/pkgconfig/foo/foo.ldflags"
+ , "test -f install_bar/lib/pkgconfig/foo/foo.cflags"
+ , "test -f install_bar/lib/pkgconfig/foo/foo.ldflags"
+ , "test -f install_bar/lib/pkgconfig/bar/bar.cflags"
+ , "test -f install_bar/lib/pkgconfig/bar/bar.ldflags"
+ , "./install_main/bin/main_uses_bar | grep main"
+ , "./install_main/bin/main_uses_bar | grep bar"
+ , "./install_main/bin/main_uses_bar | grep foo"
+ , "test -f install_foobar/lib/libfoo.so.1.2.3"
+ , "test -f install_foobar/lib/libbar.so"
+ , "test -f install_foobar/lib/pkgconfig/foobar.pc"
+ , "grep 'Cflags:.*@${prefix}/lib/pkgconfig/bar/foobar.cflags' install_foobar/lib/pkgconfig/foobar.pc"
+ , "grep -- '-DUSE_BAR=1 -DUSE_FOO=1' install_foobar/lib/pkgconfig/bar/foobar.cflags"
+ , "grep 'Libs:.*@${prefix}/lib/pkgconfig/bar/foobar.ldflags' install_foobar/lib/pkgconfig/foobar.pc"
+ , "grep -- '-lm -lpthread' install_foobar/lib/pkgconfig/bar/foobar.ldflags"
+ ]
+ , "data": ["prebuilt_tests"]
+ }
+, "cmake":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_cmake"]
+ , "libs": ["googletest", "libz", "libcurl"]
+ , "targets":
+ [ "+gtest"
+ , "+test"
+ , "+gtest_main"
+ , "+testbin"
+ , "+shell_test"
+ , "+install_gtest"
+ , "+install_gtest_main"
+ , "+install_testbin"
+ , "+install_libcurl"
+ ]
+ , "asserts":
+ [ "test -f gtest/libgtest.a"
+ , "test -f gtest/gtest/gtest.h"
+ , "grep 'PASSED.*1 test' test/stdout"
+ , "test -f gtest_main/libgtest.so.1.13.0"
+ , "test -f gtest_main/libgtest_main.so.1.13.0"
+ , "test -f gtest_main/gtest/gtest.h"
+ , "test -f ./testbin/test"
+ , "grep 'PASSED.*1 test' shell_test/stdout"
+ , "test -f install_gtest/lib/libgtest.a"
+ , "test -f install_gtest/include/gtest/gtest.h"
+ , "grep 'Cflags.*lib/pkgconfig/gtest.cflags' install_gtest/lib/pkgconfig/gtest.pc"
+ , "grep 'Libs.*libgtest.a' install_gtest/lib/pkgconfig/gtest.pc"
+ , "grep 'Libs.*lib/pkgconfig/gtest.ldflags' install_gtest/lib/pkgconfig/gtest.pc"
+ , "test -f install_gtest_main/lib/libgtest.so.1.13.0"
+ , "test -f install_gtest_main/lib/libgtest_main.so.1.13.0"
+ , "test -f install_gtest_main/include/gtest/gtest.h"
+ , "grep 'Cflags.*lib/pkgconfig/gtest_main.cflags' install_gtest_main/lib/pkgconfig/gtest_main.pc"
+ , "grep 'Libs.*libgtest.so.1.13.0' install_gtest_main/lib/pkgconfig/gtest_main.pc"
+ , "grep 'Libs.*libgtest_main.so.1.13.0' install_gtest_main/lib/pkgconfig/gtest_main.pc"
+ , "grep 'Libs.*lib/pkgconfig/gtest_main.ldflags' install_gtest_main/lib/pkgconfig/gtest_main.pc"
+ , "./install_testbin/bin/test | grep 'PASSED.*1 test'"
+ , "path=$(ldd install_libcurl/lib/libcurl.so.4.8.0 | awk '/libz/{print $3}') && test -z \"${path##$(pwd)*}\""
+ ]
+ , "data": [["TREE", null, "cmake"]]
+ }
+, "install":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_install"]
+ , "targets":
+ [ "+install_bar_release"
+ , "+install_main_release"
+ , "+install_bar_debug"
+ , "+install_main_debug"
+ , "+install_bar_debug_slim"
+ , "+install_main_debug_slim"
+ ]
+ , "asserts":
+ [ "test -f install_bar_release/lib/bar/libbar.a"
+ , "test -f install_bar_release/lib/foo/libfoo.a"
+ , "test -f install_bar_release/lib/baz/libbaz.a"
+ , "test -f install_bar_release/lib/pkgconfig/bar.pc"
+ , "test -f install_bar_release/include/bar/bar.hpp"
+ , "test -f install_bar_release/include/foo/foo.hpp"
+ , "! test -f install_bar_release/include/baz/baz.hpp"
+ , "! test -d install_bar_release/work"
+ , "test -f install_main_release/bin/main"
+ , "! test -f install_main_release/lib/bar/libbar.a"
+ , "! test -f install_main_release/lib/foo/libfoo.a"
+ , "! test -f install_main_release/lib/baz/libbaz.a"
+ , "! test -d install_main_release/lib/pkgconfig"
+ , "! test -d install_main_release/include"
+ , "! test -d install_main_release/work"
+ , "test -f install_bar_debug/lib/bar/libbar.a"
+ , "test -f install_bar_debug/lib/foo/libfoo.a"
+ , "test -f install_bar_debug/lib/baz/libbaz.a"
+ , "test -f install_bar_debug/lib/pkgconfig/bar.pc"
+ , "test -f install_bar_debug/include/bar/bar.hpp"
+ , "test -f install_bar_debug/include/foo/foo.hpp"
+ , "test -f install_bar_debug/include/baz/baz.hpp"
+ , "test -f install_bar_debug/work/bar/bar.cpp"
+ , "test -f install_bar_debug/work/bar/bar.hpp"
+ , "test -f install_bar_debug/work/foo/foo.cpp"
+ , "test -f install_bar_debug/work/foo/foo.hpp"
+ , "test -f install_bar_debug/work/foo/qux.hpp"
+ , "test -f install_bar_debug/work/baz/baz.cpp"
+ , "test -f install_bar_debug/work/baz/baz.hpp"
+ , "test -f install_main_debug/bin/main"
+ , "test -f install_main_debug/include/bar/bar.hpp"
+ , "test -f install_main_debug/include/foo/foo.hpp"
+ , "test -f install_main_debug/include/baz/baz.hpp"
+ , "test -f install_main_debug/work/bar/bar.cpp"
+ , "test -f install_main_debug/work/bar/bar.hpp"
+ , "test -f install_main_debug/work/foo/foo.cpp"
+ , "test -f install_main_debug/work/foo/foo.hpp"
+ , "test -f install_main_debug/work/foo/qux.hpp"
+ , "test -f install_main_debug/work/baz/baz.cpp"
+ , "test -f install_main_debug/work/baz/baz.hpp"
+ , "test -f install_main_debug/work/main.cpp"
+ , "! test -f install_main_debug/lib/bar/libbar.a"
+ , "! test -f install_main_debug/lib/foo/libfoo.a"
+ , "! test -f install_main_debug/lib/baz/libbaz.a"
+ , "! test -d install_main_debug/lib/pkgconfig"
+ , "test -f install_bar_debug_slim/lib/bar/libbar.a"
+ , "test -f install_bar_debug_slim/lib/foo/libfoo.a"
+ , "test -f install_bar_debug_slim/lib/baz/libbaz.a"
+ , "test -f install_bar_debug_slim/lib/pkgconfig/bar.pc"
+ , "test -f install_bar_debug_slim/include/bar/bar.hpp"
+ , "test -f install_bar_debug_slim/include/foo/foo.hpp"
+ , "! test -f install_bar_debug_slim/include/baz/baz.hpp"
+ , "! test -d install_bar_debug_slim/work"
+ , "test -f install_main_debug_slim/bin/main"
+ , "! test -f install_main_debug_slim/lib/bar/libbar.a"
+ , "! test -f install_main_debug_slim/lib/foo/libfoo.a"
+ , "! test -f install_main_debug_slim/lib/baz/libbaz.a"
+ , "! test -d install_main_debug_slim/lib/pkgconfig"
+ , "! test -d install_main_debug_slim/include"
+ , "! test -d install_main_debug_slim/work"
+ ]
+ , "data": [["TREE", null, "install"]]
+ }
+, "ALL":
+ { "type": "install"
+ , "deps":
+ ["private", "public", "shared", "object", "prebuilt", "cmake", "install"]
+ , "tainted": ["test"]
+ }
+}
diff --git a/tests/test_cases/deps/cmake/TARGETS b/tests/test_cases/deps/cmake/TARGETS
new file mode 100644
index 0000000..2c02f53
--- /dev/null
+++ b/tests/test_cases/deps/cmake/TARGETS
@@ -0,0 +1,76 @@
+{ "gtest":
+ { "type": ["@", "rules", "CC/foreign/cmake", "library"]
+ , "name": ["gtest"]
+ , "version": ["1", "13", "0"]
+ , "project": [["@", "googletest", "", "tree"]]
+ , "out_hdr_dirs": ["gtest"]
+ , "out_libs": ["libgtest.a"]
+ , "pkg-config": ["gtest.pc"]
+ }
+, "testlib":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["testlib"]
+ , "shared": ["yes"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["gtest"]
+ }
+, "test":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test"]
+ , "private-deps": ["testlib", "gtest"]
+ }
+, "gtest_main":
+ { "type": ["@", "rules", "CC/foreign/cmake", "library"]
+ , "name": ["gtest_main"]
+ , "version": ["1", "13", "0"]
+ , "project": [["@", "googletest", "", "tree"]]
+ , "defines": ["BUILD_SHARED_LIBS=ON"]
+ , "out_hdr_dirs": ["gtest"]
+ , "out_libs": ["libgtest_main.so.1.13.0", "libgtest.so.1.13.0"]
+ , "pkg-config": ["gtest_main.pc", "gtest.pc"]
+ }
+, "testbin":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["test"]
+ , "srcs": ["test.cpp"]
+ , "private-deps": ["gtest_main"]
+ }
+, "shell_test":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["shell_test"]
+ , "test": ["test.sh"]
+ , "deps": ["testbin"]
+ }
+, "install_gtest":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["gtest"]}
+, "install_gtest_main":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["gtest_main"]
+ }
+, "install_testbin":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["testbin"]}
+, "libz":
+ { "type": ["@", "rules", "CC/foreign/cmake", "library"]
+ , "name": ["libz"]
+ , "version": ["1", "2", "13"]
+ , "project": [["@", "libz", "", "tree"]]
+ , "defines": ["BUILD_SHARED_LIBS=ON"]
+ , "out_hdrs": ["zconf.h", "zlib.h"]
+ , "out_libs": ["libz.so", "libz.so.1", "libz.so.1.2.13"]
+ , "pc_prefix": ["share/pkgconfig"]
+ , "pkg-config": ["zlib.pc"]
+ }
+, "libcurl":
+ { "type": ["@", "rules", "CC/foreign/cmake", "library"]
+ , "name": ["libcurl"]
+ , "version": ["8", "0", "1"]
+ , "project": [["@", "libcurl", "", "tree"]]
+ , "defines": ["BUILD_SHARED_LIBS=ON", "CURL_ENABLE_SSL=OFF", "USE_ZLIB=ON"]
+ , "out_hdr_dirs": ["curl"]
+ , "out_libs": ["libcurl.so.4.8.0"]
+ , "pkg-config": ["libcurl.pc"]
+ , "deps": ["libz"]
+ }
+, "install_libcurl":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["libcurl"]}
+}
diff --git a/tests/test_cases/deps/cmake/main.cpp b/tests/test_cases/deps/cmake/main.cpp
new file mode 100644
index 0000000..575a358
--- /dev/null
+++ b/tests/test_cases/deps/cmake/main.cpp
@@ -0,0 +1,8 @@
+#include <gtest/gtest.h>
+
+TEST(CastTest, float) { EXPECT_EQ(42.0f, float(42)); }
+
+int main(int argc, char **argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/tests/test_cases/deps/cmake/test.cpp b/tests/test_cases/deps/cmake/test.cpp
new file mode 100644
index 0000000..b1811d8
--- /dev/null
+++ b/tests/test_cases/deps/cmake/test.cpp
@@ -0,0 +1,3 @@
+#include <gtest/gtest.h>
+
+TEST(CastTest, double) { EXPECT_EQ(42.0, double(42)); }
diff --git a/tests/test_cases/deps/cmake/test.sh b/tests/test_cases/deps/cmake/test.sh
new file mode 100644
index 0000000..80b7965
--- /dev/null
+++ b/tests/test_cases/deps/cmake/test.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+./test | grep PASSED
diff --git a/tests/test_cases/deps/install/TARGETS b/tests/test_cases/deps/install/TARGETS
new file mode 100644
index 0000000..c2cab52
--- /dev/null
+++ b/tests/test_cases/deps/install/TARGETS
@@ -0,0 +1,69 @@
+{ "baz":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["baz"]
+ , "hdrs": ["baz.hpp"]
+ , "srcs": ["baz.cpp"]
+ , "stage": ["baz"]
+ }
+, "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "hdrs": ["foo.hpp"]
+ , "private-hdrs": ["qux.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "private-deps": ["baz"]
+ , "stage": ["foo"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "deps": ["foo"]
+ , "stage": ["bar"]
+ }
+, "main":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["bar"]
+ }
+, "install_bar_release":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["bar"]}
+, "install_main_release":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["main"]}
+, "bar debug":
+ { "type": "configure"
+ , "target": "bar"
+ , "config":
+ { "type": "let*"
+ , "bindings": [["DEBUG", true], ["ADD_CXXFLAGS", ["-g"]]]
+ , "body": {"type": "env", "vars": ["DEBUG", "ADD_CXXFLAGS"]}
+ }
+ }
+, "main debug":
+ { "type": "configure"
+ , "target": "main"
+ , "config":
+ { "type": "let*"
+ , "bindings": [["DEBUG", true], ["ADD_CXXFLAGS", ["-g"]]]
+ , "body": {"type": "env", "vars": ["DEBUG", "ADD_CXXFLAGS"]}
+ }
+ }
+, "install_bar_debug":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["bar debug"]}
+, "install_main_debug":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["main debug"]
+ }
+, "install_bar_debug_slim":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "skip-debug-stage": ["yes"]
+ , "targets": ["bar debug"]
+ }
+, "install_main_debug_slim":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "skip-debug-stage": ["yes"]
+ , "targets": ["main debug"]
+ }
+}
diff --git a/tests/test_cases/deps/install/bar.cpp b/tests/test_cases/deps/install/bar.cpp
new file mode 100644
index 0000000..6cc1260
--- /dev/null
+++ b/tests/test_cases/deps/install/bar.cpp
@@ -0,0 +1,7 @@
+#include "bar.hpp"
+#include <iostream>
+
+int bar(Foo *foo) {
+ std::cout << "bar" << std::endl;
+ return (foo == nullptr) ? -1 : foo->foo();
+}
diff --git a/tests/test_cases/deps/install/bar.hpp b/tests/test_cases/deps/install/bar.hpp
new file mode 100644
index 0000000..ec9c165
--- /dev/null
+++ b/tests/test_cases/deps/install/bar.hpp
@@ -0,0 +1,8 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+#include "foo/foo.hpp"
+
+int bar(Foo *foo);
+
+#endif
diff --git a/tests/test_cases/deps/install/baz.cpp b/tests/test_cases/deps/install/baz.cpp
new file mode 100644
index 0000000..c2c26f0
--- /dev/null
+++ b/tests/test_cases/deps/install/baz.cpp
@@ -0,0 +1,7 @@
+#include "baz.hpp"
+#include <iostream>
+
+int baz() {
+ std::cout << baz_str() << std::endl;
+ return 0;
+}
diff --git a/tests/test_cases/deps/install/baz.hpp b/tests/test_cases/deps/install/baz.hpp
new file mode 100644
index 0000000..f0f8377
--- /dev/null
+++ b/tests/test_cases/deps/install/baz.hpp
@@ -0,0 +1,10 @@
+#ifndef BAZ_HPP
+#define BAZ_HPP
+
+int baz();
+
+#include <string>
+
+static inline std::string baz_str() { return "baz"; }
+
+#endif
diff --git a/tests/test_cases/deps/install/foo.cpp b/tests/test_cases/deps/install/foo.cpp
new file mode 100644
index 0000000..4a3b17a
--- /dev/null
+++ b/tests/test_cases/deps/install/foo.cpp
@@ -0,0 +1,10 @@
+#include "foo.hpp"
+#include "baz/baz.hpp"
+#include "qux.hpp"
+#include <iostream>
+
+int Foo::foo() {
+ std::cout << "foo & inline " << baz_str() << std::endl;
+ qux();
+ return baz();
+}
diff --git a/tests/test_cases/deps/install/foo.hpp b/tests/test_cases/deps/install/foo.hpp
new file mode 100644
index 0000000..025f3ef
--- /dev/null
+++ b/tests/test_cases/deps/install/foo.hpp
@@ -0,0 +1,8 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+struct Foo {
+ int foo();
+};
+
+#endif
diff --git a/tests/test_cases/deps/install/main.cpp b/tests/test_cases/deps/install/main.cpp
new file mode 100644
index 0000000..2e46d75
--- /dev/null
+++ b/tests/test_cases/deps/install/main.cpp
@@ -0,0 +1,10 @@
+// test binary consuming libraries
+
+#include "bar/bar.hpp"
+#include <iostream>
+
+int main() {
+ std::cout << "main" << std::endl;
+ Foo foo{};
+ return bar(&foo);
+}
diff --git a/tests/test_cases/deps/install/qux.hpp b/tests/test_cases/deps/install/qux.hpp
new file mode 100644
index 0000000..b2f1611
--- /dev/null
+++ b/tests/test_cases/deps/install/qux.hpp
@@ -0,0 +1,8 @@
+#ifndef QUX_HPP
+#define QUX_HPP
+
+#include <iostream>
+
+void qux() { std::cout << "qux" << std::endl; }
+
+#endif \ No newline at end of file
diff --git a/tests/test_cases/deps/object/TARGETS b/tests/test_cases/deps/object/TARGETS
new file mode 100644
index 0000000..98d7bdb
--- /dev/null
+++ b/tests/test_cases/deps/object/TARGETS
@@ -0,0 +1,43 @@
+{ "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "shared": ["yes"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "deps": ["bar"]
+ , "stage": ["foo"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "object_only": ["yes"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "stage": ["bar"]
+ }
+, "baz":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["baz"]
+ , "shared": ["yes"]
+ , "deps": ["bar"]
+ , "stage": ["baz"]
+ }
+, "main":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["foo"]
+ }
+, "test_main":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["test_main"]
+ , "test": ["test_main.sh"]
+ , "deps": ["main"]
+ }
+, "test_main.sh":
+ { "type": "file_gen"
+ , "name": "test.sh"
+ , "data": "set -e\n[ \"$(./main)\" = \"Hello World and Galaxy\" ]"
+ }
+, "install_main":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["main"]}
+}
diff --git a/tests/test_cases/deps/object/bar.cpp b/tests/test_cases/deps/object/bar.cpp
new file mode 100644
index 0000000..5d7c616
--- /dev/null
+++ b/tests/test_cases/deps/object/bar.cpp
@@ -0,0 +1,3 @@
+#include <string>
+
+std::string bar() { return "and Galaxy"; }
diff --git a/tests/test_cases/deps/object/bar.hpp b/tests/test_cases/deps/object/bar.hpp
new file mode 100644
index 0000000..9c97d54
--- /dev/null
+++ b/tests/test_cases/deps/object/bar.hpp
@@ -0,0 +1,9 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+#include <string>
+
+// use this object lib to extend the public symbols of shared lib 'foo' by 'bar'
+std::string bar();
+
+#endif
diff --git a/tests/test_cases/deps/object/foo.cpp b/tests/test_cases/deps/object/foo.cpp
new file mode 100644
index 0000000..9687a6a
--- /dev/null
+++ b/tests/test_cases/deps/object/foo.cpp
@@ -0,0 +1,3 @@
+#include "foo.hpp"
+
+std::string foo() { return "Hello World"; }
diff --git a/tests/test_cases/deps/object/foo.hpp b/tests/test_cases/deps/object/foo.hpp
new file mode 100644
index 0000000..d880c27
--- /dev/null
+++ b/tests/test_cases/deps/object/foo.hpp
@@ -0,0 +1,8 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+#include <string>
+
+std::string foo();
+
+#endif
diff --git a/tests/test_cases/deps/object/main.cpp b/tests/test_cases/deps/object/main.cpp
new file mode 100644
index 0000000..cfc2a4f
--- /dev/null
+++ b/tests/test_cases/deps/object/main.cpp
@@ -0,0 +1,8 @@
+#include "bar/bar.hpp"
+#include "foo/foo.hpp"
+#include <iostream>
+
+int main(int argc, char const *argv[]) {
+ std::cout << foo() << " " << bar() << std::endl;
+ return 0;
+}
diff --git a/tests/test_cases/deps/prebuilt/TARGETS b/tests/test_cases/deps/prebuilt/TARGETS
new file mode 100644
index 0000000..c923995
--- /dev/null
+++ b/tests/test_cases/deps/prebuilt/TARGETS
@@ -0,0 +1,158 @@
+{ "foo.pc":
+ { "type": "file_gen"
+ , "name": "foo.pc"
+ , "data":
+ { "type": "join"
+ , "separator": "\n"
+ , "$1":
+ [ "Name: foo"
+ , "Version: 1.2.3"
+ , "Description: test prebuilt foo"
+ , "URL: unknown"
+ , "Cflags: -I/usr/include -DUSE_FOO=1"
+ , "Libs: -L/usr/lib -lfoo -lpthread"
+ ]
+ }
+ }
+, "foo":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["foo"]
+ , "version": ["1", "2", "3"]
+ , "hdrs": ["foo.hpp"]
+ , "lib": [["shared", "foo"]]
+ , "pkg-config": ["foo.pc"]
+ , "stage": ["foo"]
+ }
+, "foo_s":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["foo"]
+ , "version": ["1", "2", "3"]
+ , "hdrs": ["foo.hpp"]
+ , "lib": [["shared", "foo_s"]]
+ , "pkg-config": ["foo.pc"]
+ , "stage": ["foo"]
+ }
+, "bar.pc":
+ { "type": "file_gen"
+ , "name": "bar.pc"
+ , "data":
+ { "type": "join"
+ , "separator": "\n"
+ , "$1":
+ [ "Name: bar"
+ , "Version: unknown"
+ , "Description: test prebuilt bar"
+ , "URL: unknown"
+ , "Cflags: -I/usr/include -DUSE_BAR=1"
+ , "Libs: -L/usr/lib -lbar -lpthread -lm"
+ ]
+ }
+ }
+, "bar":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "lib": [["shared", "bar"]]
+ , "pkg-config": ["bar.pc"]
+ , "stage": ["bar"]
+ , "deps": ["foo"]
+ }
+, "bar_s":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "lib": [["shared", "bar_s"]]
+ , "pkg-config": ["bar.pc"]
+ , "stage": ["bar"]
+ , "deps": ["foo"]
+ }
+, "main_uses_foo":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main_uses_foo"]
+ , "srcs": [["shared", "main_uses_foo.cpp"]]
+ , "private-deps": ["foo"]
+ }
+, "test_uses_foo":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_uses_foo"]
+ , "srcs": [["shared", "test_uses_foo.cpp"]]
+ , "private-deps": ["foo"]
+ }
+, "main_uses_bar":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main_uses_bar"]
+ , "srcs": [["shared", "main_uses_bar.cpp"]]
+ , "private-deps": ["bar"]
+ }
+, "test_uses_bar":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_uses_bar"]
+ , "srcs": [["shared", "test_uses_bar.cpp"]]
+ , "private-deps": ["bar"]
+ }
+, "test_uses_bar_s":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_uses_bar"]
+ , "srcs": [["shared", "test_uses_bar.cpp"]]
+ , "private-deps": ["bar_s"]
+ }
+, "test_uses_main":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["test_uses_main"]
+ , "test": [["shared", "test_uses_main.sh"]]
+ , "deps": ["main_uses_bar"]
+ }
+, "install_foo":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["foo"]}
+, "install_bar":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["bar"]}
+, "install_main":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["main_uses_bar"]
+ }
+, "foobar.pc":
+ { "type": "file_gen"
+ , "name": "foobar.pc"
+ , "data":
+ { "type": "join"
+ , "separator": "\n"
+ , "$1":
+ [ "Name: foobar"
+ , "Version: unknown"
+ , "Description: test compound prebuilt foobar"
+ , "URL: unknown"
+ , "Requires: bar, foo >= 1.2.3"
+ ]
+ }
+ }
+, "foobar":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["foobar"]
+ , "hdrs": ["bar.hpp"]
+ , "lib": [["shared", "bar"], ["shared", "foo"]]
+ , "pkg-config": ["foobar.pc", "foo.pc", "bar.pc"]
+ , "stage": ["bar"]
+ }
+, "foobar_s":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["foobar"]
+ , "hdrs": ["bar.hpp"]
+ , "lib": [["shared", "bar_s"], ["shared", "foo_s"]]
+ , "pkg-config": ["foobar.pc", "foo.pc", "bar.pc"]
+ , "stage": ["bar"]
+ }
+, "test_uses_foobar":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_uses_bar"]
+ , "srcs": [["shared", "test_uses_bar.cpp"]]
+ , "private-deps": ["foobar"]
+ }
+, "test_uses_foobar_s":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_uses_bar"]
+ , "srcs": [["shared", "test_uses_bar.cpp"]]
+ , "private-deps": ["foobar_s"]
+ }
+, "install_foobar":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["foobar"]}
+}
diff --git a/tests/test_cases/deps/prebuilt/bar.hpp b/tests/test_cases/deps/prebuilt/bar.hpp
new file mode 100644
index 0000000..243dba6
--- /dev/null
+++ b/tests/test_cases/deps/prebuilt/bar.hpp
@@ -0,0 +1,8 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+#ifdef USE_BAR
+int bar();
+#endif
+
+#endif
diff --git a/tests/test_cases/deps/prebuilt/foo.hpp b/tests/test_cases/deps/prebuilt/foo.hpp
new file mode 100644
index 0000000..4f040d4
--- /dev/null
+++ b/tests/test_cases/deps/prebuilt/foo.hpp
@@ -0,0 +1,8 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+#ifdef USE_FOO
+int foo();
+#endif
+
+#endif
diff --git a/tests/test_cases/deps/private/TARGETS b/tests/test_cases/deps/private/TARGETS
new file mode 100644
index 0000000..dd72948
--- /dev/null
+++ b/tests/test_cases/deps/private/TARGETS
@@ -0,0 +1,36 @@
+{ "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "stage": ["foo"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "private-deps": ["foo"]
+ , "stage": ["bar"]
+ }
+, "main_includes_foo":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main_includes_foo.cpp"]
+ , "private-deps": ["bar"]
+ }
+, "main_links_foo":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main_links_foo.cpp"]
+ , "private-deps": ["bar"]
+ }
+, "main_links_bar_foo":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main_links_bar_foo.cpp"]
+ , "private-deps": ["bar"]
+ }
+, "install_bar":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["bar"]}
+}
diff --git a/tests/test_cases/deps/private/bar.cpp b/tests/test_cases/deps/private/bar.cpp
new file mode 100644
index 0000000..dfce0e8
--- /dev/null
+++ b/tests/test_cases/deps/private/bar.cpp
@@ -0,0 +1,8 @@
+#include "foo/foo.hpp"
+#include "bar.hpp"
+#include <iostream>
+
+int bar() {
+ std::cout << "bar\n";
+ return foo();
+}
diff --git a/tests/test_cases/deps/private/bar.hpp b/tests/test_cases/deps/private/bar.hpp
new file mode 100644
index 0000000..94d4f16
--- /dev/null
+++ b/tests/test_cases/deps/private/bar.hpp
@@ -0,0 +1,6 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+int bar();
+
+#endif
diff --git a/tests/test_cases/deps/private/foo.cpp b/tests/test_cases/deps/private/foo.cpp
new file mode 100644
index 0000000..f985022
--- /dev/null
+++ b/tests/test_cases/deps/private/foo.cpp
@@ -0,0 +1,7 @@
+#include "foo.hpp"
+#include <iostream>
+
+int foo() {
+ std::cout << "foo\n";
+ return 0;
+}
diff --git a/tests/test_cases/deps/private/foo.hpp b/tests/test_cases/deps/private/foo.hpp
new file mode 100644
index 0000000..1a28686
--- /dev/null
+++ b/tests/test_cases/deps/private/foo.hpp
@@ -0,0 +1,6 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+int foo();
+
+#endif
diff --git a/tests/test_cases/deps/private/main_includes_foo.cpp b/tests/test_cases/deps/private/main_includes_foo.cpp
new file mode 100644
index 0000000..16701c7
--- /dev/null
+++ b/tests/test_cases/deps/private/main_includes_foo.cpp
@@ -0,0 +1,9 @@
+// test that foo.hpp not available
+
+#include "foo/foo.hpp"
+#include <iostream>
+
+int main() {
+ std::cout << "main\n";
+ return 0;
+}
diff --git a/tests/test_cases/deps/private/main_links_bar_foo.cpp b/tests/test_cases/deps/private/main_links_bar_foo.cpp
new file mode 100644
index 0000000..e936074
--- /dev/null
+++ b/tests/test_cases/deps/private/main_links_bar_foo.cpp
@@ -0,0 +1,9 @@
+// test that foo is linked after bar
+
+#include "bar/bar.hpp"
+#include <iostream>
+
+int main() {
+ std::cout << "main\n";
+ return bar();
+}
diff --git a/tests/test_cases/deps/private/main_links_foo.cpp b/tests/test_cases/deps/private/main_links_foo.cpp
new file mode 100644
index 0000000..1e1e07a
--- /dev/null
+++ b/tests/test_cases/deps/private/main_links_foo.cpp
@@ -0,0 +1,10 @@
+// test that foo is linked
+
+#include <iostream>
+
+int foo(); // forward declare
+
+int main() {
+ std::cout << "main\n";
+ return foo();
+}
diff --git a/tests/test_cases/deps/public/TARGETS b/tests/test_cases/deps/public/TARGETS
new file mode 100644
index 0000000..bc1807a
--- /dev/null
+++ b/tests/test_cases/deps/public/TARGETS
@@ -0,0 +1,36 @@
+{ "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "stage": ["foo"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "deps": ["foo"]
+ , "stage": ["bar"]
+ }
+, "main_includes_foo":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main_includes_foo.cpp"]
+ , "private-deps": ["bar"]
+ }
+, "main_links_foo":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main_links_foo.cpp"]
+ , "private-deps": ["bar"]
+ }
+, "main_links_bar_foo":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main_links_bar_foo.cpp"]
+ , "private-deps": ["bar"]
+ }
+, "install_bar":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["bar"]}
+}
diff --git a/tests/test_cases/deps/public/bar.cpp b/tests/test_cases/deps/public/bar.cpp
new file mode 100644
index 0000000..f2a779a
--- /dev/null
+++ b/tests/test_cases/deps/public/bar.cpp
@@ -0,0 +1,7 @@
+#include "bar.hpp"
+#include <iostream>
+
+int bar(Foo *foo) {
+ std::cout << "bar\n";
+ return (foo == nullptr) ? -1 : foo->foo();
+}
diff --git a/tests/test_cases/deps/public/bar.hpp b/tests/test_cases/deps/public/bar.hpp
new file mode 100644
index 0000000..ec9c165
--- /dev/null
+++ b/tests/test_cases/deps/public/bar.hpp
@@ -0,0 +1,8 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+#include "foo/foo.hpp"
+
+int bar(Foo *foo);
+
+#endif
diff --git a/tests/test_cases/deps/public/foo.cpp b/tests/test_cases/deps/public/foo.cpp
new file mode 100644
index 0000000..6899c7a
--- /dev/null
+++ b/tests/test_cases/deps/public/foo.cpp
@@ -0,0 +1,7 @@
+#include "foo.hpp"
+#include <iostream>
+
+int Foo::foo() {
+ std::cout << "foo\n";
+ return 0;
+}
diff --git a/tests/test_cases/deps/public/foo.hpp b/tests/test_cases/deps/public/foo.hpp
new file mode 100644
index 0000000..025f3ef
--- /dev/null
+++ b/tests/test_cases/deps/public/foo.hpp
@@ -0,0 +1,8 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+struct Foo {
+ int foo();
+};
+
+#endif
diff --git a/tests/test_cases/deps/public/main_includes_foo.cpp b/tests/test_cases/deps/public/main_includes_foo.cpp
new file mode 100644
index 0000000..e8a85b6
--- /dev/null
+++ b/tests/test_cases/deps/public/main_includes_foo.cpp
@@ -0,0 +1,9 @@
+// test that foo.hpp is available (despite unused here)
+
+#include "foo/foo.hpp"
+#include <iostream>
+
+int main() {
+ std::cout << "main\n";
+ return 0;
+}
diff --git a/tests/test_cases/deps/public/main_links_bar_foo.cpp b/tests/test_cases/deps/public/main_links_bar_foo.cpp
new file mode 100644
index 0000000..02c2966
--- /dev/null
+++ b/tests/test_cases/deps/public/main_links_bar_foo.cpp
@@ -0,0 +1,10 @@
+// test that foo is linked after bar
+
+#include "bar/bar.hpp"
+#include <iostream>
+
+int main() {
+ std::cout << "main\n";
+ Foo foo{};
+ return bar(&foo);
+}
diff --git a/tests/test_cases/deps/public/main_links_foo.cpp b/tests/test_cases/deps/public/main_links_foo.cpp
new file mode 100644
index 0000000..f9cc308
--- /dev/null
+++ b/tests/test_cases/deps/public/main_links_foo.cpp
@@ -0,0 +1,10 @@
+// test that foo is linked
+
+#include "foo/foo.hpp"
+#include <iostream>
+
+int main() {
+ std::cout << "main\n";
+ Foo{}.foo();
+ return 0;
+}
diff --git a/tests/test_cases/deps/shared/TARGETS b/tests/test_cases/deps/shared/TARGETS
new file mode 100644
index 0000000..9db7fb8
--- /dev/null
+++ b/tests/test_cases/deps/shared/TARGETS
@@ -0,0 +1,104 @@
+{ "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "shared": ["yes"]
+ , "name": ["foo"]
+ , "soversion": ["1", "2", "3"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "stage": ["foo"]
+ }
+, "foo_s":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "stage": ["foo"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "shared": ["yes"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "stage": ["bar"]
+ , "private-deps": ["foo"]
+ }
+, "bar_s":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "stage": ["bar"]
+ , "private-deps": ["foo"]
+ }
+, "baz":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["baz"]
+ , "shared": ["yes"]
+ , "hdrs": ["baz.hpp"]
+ , "srcs": ["baz.cpp"]
+ , "stage": ["baz"]
+ , "private-deps": ["foo_s"]
+ }
+, "main_uses_foo":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main_uses_foo"]
+ , "srcs": ["main_uses_foo.cpp"]
+ , "private-deps": ["foo"]
+ }
+, "test_uses_foo":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_uses_foo"]
+ , "srcs": ["test_uses_foo.cpp"]
+ , "private-deps": ["foo"]
+ }
+, "main_uses_bar":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main_uses_bar"]
+ , "srcs": ["main_uses_bar.cpp"]
+ , "private-deps": ["bar"]
+ }
+, "test_uses_bar":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_uses_bar"]
+ , "srcs": ["test_uses_bar.cpp"]
+ , "private-deps": ["bar"]
+ }
+, "test_uses_bar_s":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_uses_bar_s"]
+ , "srcs": ["test_uses_bar.cpp"]
+ , "private-deps": ["bar_s"]
+ }
+, "test_uses_baz":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_uses_baz"]
+ , "srcs": ["test_uses_baz.cpp"]
+ , "private-deps": ["baz"]
+ }
+, "test_uses_main":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["test_uses_main"]
+ , "test": ["test_uses_main.sh"]
+ , "deps": ["main_uses_bar"]
+ }
+, "test_diamond":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["test_diamond"]
+ , "srcs": ["test_diamond.cpp"]
+ , "private-deps": ["foo_s", "baz"]
+ }
+, "install_foo":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["foo"]
+ , "flat-libs": ["yes"]
+ }
+, "install_bar_s":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["bar_s"]}
+, "install_baz":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["baz"]}
+, "install_main":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["main_uses_bar"]
+ }
+}
diff --git a/tests/test_cases/deps/shared/bar.cpp b/tests/test_cases/deps/shared/bar.cpp
new file mode 100644
index 0000000..dfce0e8
--- /dev/null
+++ b/tests/test_cases/deps/shared/bar.cpp
@@ -0,0 +1,8 @@
+#include "foo/foo.hpp"
+#include "bar.hpp"
+#include <iostream>
+
+int bar() {
+ std::cout << "bar\n";
+ return foo();
+}
diff --git a/tests/test_cases/deps/shared/bar.hpp b/tests/test_cases/deps/shared/bar.hpp
new file mode 100644
index 0000000..94d4f16
--- /dev/null
+++ b/tests/test_cases/deps/shared/bar.hpp
@@ -0,0 +1,6 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+int bar();
+
+#endif
diff --git a/tests/test_cases/deps/shared/baz.cpp b/tests/test_cases/deps/shared/baz.cpp
new file mode 100644
index 0000000..fae4845
--- /dev/null
+++ b/tests/test_cases/deps/shared/baz.cpp
@@ -0,0 +1,8 @@
+#include "foo/foo.hpp"
+#include "baz.hpp"
+#include <iostream>
+
+int baz() {
+ std::cout << "baz\n";
+ return foo();
+}
diff --git a/tests/test_cases/deps/shared/baz.hpp b/tests/test_cases/deps/shared/baz.hpp
new file mode 100644
index 0000000..643cf65
--- /dev/null
+++ b/tests/test_cases/deps/shared/baz.hpp
@@ -0,0 +1,6 @@
+#ifndef BAZ_HPP
+#define BAZ_HPP
+
+int baz();
+
+#endif
diff --git a/tests/test_cases/deps/shared/foo.cpp b/tests/test_cases/deps/shared/foo.cpp
new file mode 100644
index 0000000..f985022
--- /dev/null
+++ b/tests/test_cases/deps/shared/foo.cpp
@@ -0,0 +1,7 @@
+#include "foo.hpp"
+#include <iostream>
+
+int foo() {
+ std::cout << "foo\n";
+ return 0;
+}
diff --git a/tests/test_cases/deps/shared/foo.hpp b/tests/test_cases/deps/shared/foo.hpp
new file mode 100644
index 0000000..1a28686
--- /dev/null
+++ b/tests/test_cases/deps/shared/foo.hpp
@@ -0,0 +1,6 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+int foo();
+
+#endif
diff --git a/tests/test_cases/deps/shared/main_uses_bar.cpp b/tests/test_cases/deps/shared/main_uses_bar.cpp
new file mode 100644
index 0000000..9cfc855
--- /dev/null
+++ b/tests/test_cases/deps/shared/main_uses_bar.cpp
@@ -0,0 +1,8 @@
+#include "bar/bar.hpp"
+#include <iostream>
+
+int main() {
+ std::cout << "main\n";
+ bar();
+ return 0;
+}
diff --git a/tests/test_cases/deps/shared/main_uses_foo.cpp b/tests/test_cases/deps/shared/main_uses_foo.cpp
new file mode 100644
index 0000000..0fb3bb6
--- /dev/null
+++ b/tests/test_cases/deps/shared/main_uses_foo.cpp
@@ -0,0 +1,8 @@
+#include "foo/foo.hpp"
+#include <iostream>
+
+int main() {
+ std::cout << "main\n";
+ foo();
+ return 0;
+}
diff --git a/tests/test_cases/deps/shared/test_diamond.cpp b/tests/test_cases/deps/shared/test_diamond.cpp
new file mode 100644
index 0000000..9298230
--- /dev/null
+++ b/tests/test_cases/deps/shared/test_diamond.cpp
@@ -0,0 +1,4 @@
+#include "baz/baz.hpp"
+#include "foo/foo.hpp"
+
+int main() { return foo() + baz(); }
diff --git a/tests/test_cases/deps/shared/test_uses_bar.cpp b/tests/test_cases/deps/shared/test_uses_bar.cpp
new file mode 100644
index 0000000..c2076ec
--- /dev/null
+++ b/tests/test_cases/deps/shared/test_uses_bar.cpp
@@ -0,0 +1,3 @@
+#include "bar/bar.hpp"
+
+int main() { return bar(); }
diff --git a/tests/test_cases/deps/shared/test_uses_baz.cpp b/tests/test_cases/deps/shared/test_uses_baz.cpp
new file mode 100644
index 0000000..02d67f9
--- /dev/null
+++ b/tests/test_cases/deps/shared/test_uses_baz.cpp
@@ -0,0 +1,3 @@
+#include "baz/baz.hpp"
+
+int main() { return baz(); }
diff --git a/tests/test_cases/deps/shared/test_uses_foo.cpp b/tests/test_cases/deps/shared/test_uses_foo.cpp
new file mode 100644
index 0000000..88feb93
--- /dev/null
+++ b/tests/test_cases/deps/shared/test_uses_foo.cpp
@@ -0,0 +1,3 @@
+#include "foo/foo.hpp"
+
+int main() { return foo(); }
diff --git a/tests/test_cases/deps/shared/test_uses_main.sh b/tests/test_cases/deps/shared/test_uses_main.sh
new file mode 100644
index 0000000..ab8672f
--- /dev/null
+++ b/tests/test_cases/deps/shared/test_uses_main.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+./main_uses_bar | grep main
+./main_uses_bar | grep bar
+./main_uses_bar | grep foo
diff --git a/tests/test_rules/EXPRESSIONS b/tests/test_rules/EXPRESSIONS
new file mode 100644
index 0000000..f1ca6f4
--- /dev/null
+++ b/tests/test_rules/EXPRESSIONS
@@ -0,0 +1,46 @@
+{ "stage_singleton_field":
+ { "vars": ["fieldname", "transition", "location"]
+ , "expression":
+ { "type": "assert_non_empty"
+ , "msg":
+ ["No artifact specified in field", {"type": "var", "name": "fieldname"}]
+ , "$1":
+ { "type": "disjoint_map_union"
+ , "msg":
+ [ "Expecting (essentially) a single artifact in field"
+ , {"type": "var", "name": "fieldname"}
+ ]
+ , "$1":
+ { "type": "foreach"
+ , "var": "src"
+ , "range":
+ {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}}
+ , "body":
+ { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "artifact"
+ , "range":
+ { "type": "values"
+ , "$1":
+ { "type": "DEP_ARTIFACTS"
+ , "dep": {"type": "var", "name": "src"}
+ , "transition":
+ { "type": "var"
+ , "name": "transition"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ }
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "location"}
+ , "value": {"type": "var", "name": "artifact"}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/test_rules/README.md b/tests/test_rules/README.md
new file mode 100644
index 0000000..5a1baed
--- /dev/null
+++ b/tests/test_rules/README.md
@@ -0,0 +1,28 @@
+# Test Rules
+
+This is a test rule that supports building and installing multiple targets with
+a given set of rules. For each target, it can be specified whether building it
+should fail or succeed. After processing all targets, additional assertions
+(list of shell commands) can be run.
+
+## Setup
+
+The test rules expect to find the following three bindings:
+ - `[["@", "test-rules", "", "tree"]]`, which contains a single tree artifact
+ with the rules to test.
+ - `[["@", "test-just", "", ""]]`, which contains a single executable artifact
+ that is the JustBuild binary to use for the tests.
+ - `[["@", "test-libs", "", "tree"]]`, which contains a single tree artifact
+ that holds the file trees of external libraries.
+
+## Rule `["test_rules", "test_case"]`
+
+Define a test case for rule tests.
+
+| Field | Description |
+| ----- | ----------- |
+| `"name"` | Name of the test (multiple entries are joined). |
+| `"libs"` | Paths to external libraries' trees provided by the `"test-libs"` repository. From within a test cases, the library's tree can be accessed via `["@", "<libname>", "", "tree"]`. |
+| `"targets"` | Target names to build and install. Each target name is prefixed by `"+"` or `"-"`, indicating if the build should fail or not. Targets that build successfully will be installed to a directory named identical to the target name (without the prefix). |
+| `"asserts"` | List of commands to execute after all targets were processed. To access artifacts from installed targets, use the corresponding target name as prefix dir (e.g., target `"+foo"` installs to `"./foo/"`). |
+| `"data"` | The directory that contains the project with the targets to test. |
diff --git a/tests/test_rules/RULES b/tests/test_rules/RULES
new file mode 100644
index 0000000..3d2aba5
--- /dev/null
+++ b/tests/test_rules/RULES
@@ -0,0 +1,243 @@
+{ "test_case":
+ { "doc":
+ [ "Define a test case for rule tests."
+ , "The config variables \"ENV\", \"ARCH\", \"HOST_ARCH\", \"TARGET_ARCH\","
+ , "\"BUILD_ARCH\", \"OS\" are collected in a file named \"conf_vars.json\"."
+ , "The test runner will pass that file as argument to \"-c\" to the \"just\""
+ , "binary, which is internally called."
+ ]
+ , "string_fields": ["name", "libs", "targets", "asserts"]
+ , "target_fields": ["data"]
+ , "field_doc":
+ { "name": ["Name of the test (multiple entries are joined)."]
+ , "libs":
+ [ "Paths to external libraries' trees provided by the \"test-libs\""
+ , "repository. From within a test cases, the library's tree can be"
+ , "accessed via [\"@\", \"<libpath>\", \"\", \"tree\"]."
+ ]
+ , "targets":
+ [ "Target names to build and install. Each target name is prefixed by"
+ , "\"+\" or \"-\", indicating if the build should fail or not."
+ , "Targets that build successfully will be installed to a directory"
+ , "named identical to the target name (without the prefix)."
+ ]
+ , "asserts":
+ [ "List of commands to execute after all targets were processed. To"
+ , "access artifacts from installed targets, use the corresponding target"
+ , "name as prefix dir (e.g., target \"+foo\" installs to \"./foo/\")."
+ ]
+ , "data":
+ ["The directory that contains the project with the targets to test."]
+ }
+ , "tainted": ["test"]
+ , "config_vars":
+ [ "ENV"
+ , "ARCH"
+ , "HOST_ARCH"
+ , "TARGET_ARCH"
+ , "BUILD_ARCH"
+ , "OS"
+ , "TOOLCHAIN_CONFIG"
+ ]
+ , "implicit":
+ { "runner": ["test_runner.py"]
+ , "rules": [["@", "test-rules", "", "tree"]]
+ , "just": [["@", "test-just", "", ""]]
+ , "libs_tree": [["@", "test-libs", "", "tree"]]
+ }
+ , "imports": {"stage_artifact": "stage_singleton_field"}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["name", {"type": "join", "$1": {"type": "FIELD", "name": "name"}}]
+ , ["fieldname", "just"]
+ , ["location", "bin/just"]
+ , ["just", {"type": "CALL_EXPRESSION", "name": "stage_artifact"}]
+ , ["fieldname", "rules"]
+ , ["location", "rules"]
+ , ["rules", {"type": "CALL_EXPRESSION", "name": "stage_artifact"}]
+ , [ "imports"
+ , { "type": "singleton_map"
+ , "key": "imports/TARGETS"
+ , "value":
+ { "type": "BLOB"
+ , "data": "{\"tree\":{\"type\":\"install\",\"dirs\":[[[\"TREE\",null,\".\"],\".\"]]}}"
+ }
+ }
+ ]
+ , ["fieldname", "libs_tree"]
+ , ["location", "libs"]
+ , ["libs", {"type": "CALL_EXPRESSION", "name": "stage_artifact"}]
+ , ["fieldname", "data"]
+ , ["location", "work"]
+ , ["work", {"type": "CALL_EXPRESSION", "name": "stage_artifact"}]
+ , ["fieldname", "runner"]
+ , ["location", "runner"]
+ , ["runner", {"type": "CALL_EXPRESSION", "name": "stage_artifact"}]
+ , ["targets", {"type": "FIELD", "name": "targets"}]
+ , ["asserts", {"type": "FIELD", "name": "asserts"}]
+ , [ "work_bindings"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ [{"type": "singleton_map", "key": "rules", "value": "rules"}]
+ , { "type": "foreach"
+ , "range": {"type": "FIELD", "name": "libs"}
+ , "var": "libpath"
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "libpath"}
+ , "value": {"type": "var", "name": "libpath"}
+ }
+ }
+ ]
+ }
+ }
+ ]
+ , [ "work_deps"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ [ { "type": "let*"
+ , "bindings":
+ [ ["workspace_root", ["file", "rules"]]
+ , ["rules", {"type": "env", "vars": ["workspace_root"]}]
+ ]
+ , "body": {"type": "env", "vars": ["rules"]}
+ }
+ ]
+ , { "type": "foreach"
+ , "range": {"type": "FIELD", "name": "libs"}
+ , "var": "libpath"
+ , "body":
+ { "type": "let*"
+ , "bindings":
+ [ [ "workspace_root"
+ , [ "file"
+ , { "type": "join"
+ , "$1": ["libs/", {"type": "var", "name": "libpath"}]
+ }
+ ]
+ ]
+ , ["target_root", ["file", "imports"]]
+ ]
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "libpath"}
+ , "value":
+ { "type": "env"
+ , "vars": ["workspace_root", "target_root"]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ , [ "repos"
+ , { "type": "singleton_map"
+ , "key": "repos.json"
+ , "value":
+ { "type": "BLOB"
+ , "data":
+ { "type": "json_encode"
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [ ["workspace_root", ["file", "work"]]
+ , ["bindings", {"type": "var", "name": "work_bindings"}]
+ , [ "work"
+ , {"type": "env", "vars": ["workspace_root", "bindings"]}
+ ]
+ , [ "repositories"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "env", "vars": ["work"]}
+ , {"type": "var", "name": "work_deps"}
+ ]
+ }
+ ]
+ , ["main", "work"]
+ ]
+ , "body": {"type": "env", "vars": ["main", "repositories"]}
+ }
+ }
+ }
+ }
+ ]
+ , [ "config"
+ , { "type": "singleton_map"
+ , "key": "config.json"
+ , "value":
+ { "type": "BLOB"
+ , "data":
+ { "type": "json_encode"
+ , "$1": {"type": "env", "vars": ["targets", "asserts"]}
+ }
+ }
+ }
+ ]
+ , [ "conf_vars"
+ , { "type": "singleton_map"
+ , "key": "conf_vars.json"
+ , "value":
+ { "type": "BLOB"
+ , "data":
+ { "type": "json_encode"
+ , "$1":
+ { "type": "env"
+ , "vars":
+ [ "ENV"
+ , "ARCH"
+ , "HOST_ARCH"
+ , "TARGET_ARCH"
+ , "BUILD_ARCH"
+ , "OS"
+ , "TOOLCHAIN_CONFIG"
+ ]
+ }
+ }
+ }
+ }
+ ]
+ , [ "results"
+ , { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "runner"}
+ , {"type": "var", "name": "rules"}
+ , {"type": "var", "name": "just"}
+ , {"type": "var", "name": "imports"}
+ , {"type": "var", "name": "libs"}
+ , {"type": "var", "name": "repos"}
+ , {"type": "var", "name": "work"}
+ , {"type": "var", "name": "config"}
+ , {"type": "var", "name": "conf_vars"}
+ ]
+ }
+ , "outs": ["stdout", "stderr", "result", "time-start", "time-stop"]
+ , "cmd": ["./runner"]
+ , "may_fail": ["test"]
+ , "fail_message":
+ { "type": "join"
+ , "$1": ["Rule test ", {"type": "var", "name": "name"}, " failed"]
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "artifacts": {"type": "var", "name": "results"}
+ , "runfiles":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "name"}
+ , "value": {"type": "TREE", "$1": {"type": "var", "name": "results"}}
+ }
+ }
+ }
+ }
+}
diff --git a/tests/test_rules/TARGETS b/tests/test_rules/TARGETS
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/tests/test_rules/TARGETS
@@ -0,0 +1 @@
+{}
diff --git a/tests/test_rules/test_runner.py b/tests/test_rules/test_runner.py
new file mode 100755
index 0000000..5c0d129
--- /dev/null
+++ b/tests/test_rules/test_runner.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python3
+# Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import json
+import os
+import subprocess
+import time
+
+time_start: float = time.time()
+time_stop: float = 0
+result: str = "UNKNOWN"
+stderr: str = ""
+stdout: str = ""
+
+
+def dump_results() -> None:
+ with open("result", "w") as f:
+ f.write("%s\n" % (result, ))
+ with open("time-start", "w") as f:
+ f.write("%d\n" % (time_start, ))
+ with open("time-stop", "w") as f:
+ f.write("%d\n" % (time_stop, ))
+ with open("stdout", "w") as f:
+ f.write("%s\n" % (stdout, ))
+ with open("stderr", "w") as f:
+ f.write("%s\n" % (stderr, ))
+
+
+dump_results()
+
+with open('config.json') as f:
+ config = json.load(f)
+
+os.makedirs("./outs")
+
+# install targets
+failed_targets = 0
+stdout += "Test targets:\n"
+for t in config.get('targets', []):
+ target = t[1:]
+ should_fail = t[0] == "-"
+ ret = subprocess.run([
+ "./bin/just", "install", "--local-build-root", "./build_root", "-C",
+ "repos.json", "-o", "/".join(["./outs", target]),
+ "-c", "conf_vars.json", target
+ ],
+ capture_output=True)
+ success = ret.returncode != 0 if should_fail else ret.returncode == 0
+ failed_targets += 0 if success else 1
+ stdout += f" [{'PASS' if success else 'FAIL'}] {target}\n"
+ stderr += "".join([
+ f"stdout/stderr of test target '{target}':\n",
+ ret.stdout.decode("utf-8"),
+ ret.stderr.decode("utf-8"), "\n"
+ ])
+stdout += f" {failed_targets} targets failed\n"
+
+# run asserts
+failed_asserts = 0
+stdout += "Test asserts:\n"
+for cmd in config.get('asserts', []):
+ ret = subprocess.run(cmd, cwd="./outs", shell=True, capture_output=True)
+ success = ret.returncode == 0
+ failed_asserts += 0 if success else 1
+ stdout += f" [{'PASS' if success else 'FAIL'}] {cmd}\n"
+ stderr += "".join([
+ f"stdout/stderr of test assert '{cmd}':\n",
+ ret.stdout.decode("utf-8"),
+ ret.stderr.decode("utf-8"), "\n"
+ ])
+stdout += f" {failed_asserts} asserts failed\n"
+
+retval = min(failed_targets + failed_asserts, 125)
+result = "PASS" if retval == 0 else "FAIL"
+
+time_stop = time.time()
+dump_results()
+exit(retval)