summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE202
-rw-r--r--README.md629
-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/TARGETS1
-rwxr-xr-xetc/generate-doc.sh85
-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/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
-rwxr-xr-xrules/CC/include_scan (renamed from CC/include_scan)0
-rw-r--r--rules/CC/include_scan.c (renamed from CC/include_scan.c)0
-rwxr-xr-xrules/CC/include_scan.py (renamed from CC/include_scan.py)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/lint/RULES (renamed from lint/RULES)0
-rw-r--r--rules/lint/TARGETS (renamed from lint/TARGETS)0
-rwxr-xr-xrules/lint/call_lint (renamed from lint/call_lint)0
-rwxr-xr-xrules/lint/call_summary (renamed from lint/call_summary)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/TARGETS (renamed from shell/test/TARGETS)0
-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/test/EXPRESSIONS (renamed from test/EXPRESSIONS)0
-rw-r--r--rules/test/RULES (renamed from test/RULES)0
-rw-r--r--rules/transitions/EXPRESSIONS (renamed from transitions/EXPRESSIONS)0
-rw-r--r--tests/ROOT0
-rw-r--r--tests/TARGETS10
-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/config/TARGETS57
-rw-r--r--tests/test_cases/config/data/TARGETS48
-rw-r--r--tests/test_cases/config/data/foo.in13
-rwxr-xr-xtests/test_cases/config/run_pytest.sh3
-rw-r--r--tests/test_cases/config/runner_test.py134
-rw-r--r--tests/test_cases/deps/TARGETS419
-rw-r--r--tests/test_cases/deps/chain/TARGETS38
-rw-r--r--tests/test_cases/deps/chain/bar.cpp5
-rw-r--r--tests/test_cases/deps/chain/bar.hpp8
-rw-r--r--tests/test_cases/deps/chain/baz.cpp5
-rw-r--r--tests/test_cases/deps/chain/baz.hpp8
-rw-r--r--tests/test_cases/deps/chain/foo.cpp5
-rw-r--r--tests/test_cases/deps/chain/foo.hpp8
-rw-r--r--tests/test_cases/deps/chain/main.cpp7
-rw-r--r--tests/test_cases/deps/chain/qux.cpp5
-rw-r--r--tests/test_cases/deps/chain/qux.hpp8
-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/components/TARGETS55
-rw-r--r--tests/test_cases/deps/components/bar.cpp9
-rw-r--r--tests/test_cases/deps/components/bar.hpp6
-rw-r--r--tests/test_cases/deps/components/foo.cpp10
-rw-r--r--tests/test_cases/deps/components/foo.hpp8
-rw-r--r--tests/test_cases/deps/components/foodep.cpp9
-rw-r--r--tests/test_cases/deps/components/foodep.hpp8
-rw-r--r--tests/test_cases/deps/components/main.cpp10
-rw-r--r--tests/test_cases/deps/install/TARGETS67
-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/lint/TARGETS78
-rw-r--r--tests/test_cases/deps/lint/bar.cpp10
-rw-r--r--tests/test_cases/deps/lint/bar.hpp8
-rw-r--r--tests/test_cases/deps/lint/bardep.cpp9
-rw-r--r--tests/test_cases/deps/lint/bardep.hpp8
-rw-r--r--tests/test_cases/deps/lint/check-main.sh3
-rwxr-xr-xtests/test_cases/deps/lint/expect.py24
-rw-r--r--tests/test_cases/deps/lint/foo.cpp10
-rw-r--r--tests/test_cases/deps/lint/foo.hpp8
-rw-r--r--tests/test_cases/deps/lint/foodep.cpp9
-rw-r--r--tests/test_cases/deps/lint/foodep.hpp8
-rw-r--r--tests/test_cases/deps/lint/main.cpp9
-rw-r--r--tests/test_cases/deps/lint/plain.cpp5
-rw-r--r--tests/test_cases/deps/lint/plain.hpp9
-rwxr-xr-xtests/test_cases/deps/lint/pretend_lint.py15
-rwxr-xr-xtests/test_cases/deps/lint/summary.py27
-rw-r--r--tests/test_cases/deps/object/TARGETS49
-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_cases/deps/transitive-components/TARGETS64
-rw-r--r--tests/test_cases/deps/transitive-components/bar.cpp10
-rw-r--r--tests/test_cases/deps/transitive-components/bar.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/bardep.cpp9
-rw-r--r--tests/test_cases/deps/transitive-components/bardep.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/baz.cpp10
-rw-r--r--tests/test_cases/deps/transitive-components/baz.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/bazdep.cpp9
-rw-r--r--tests/test_cases/deps/transitive-components/bazdep.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/foo.cpp10
-rw-r--r--tests/test_cases/deps/transitive-components/foo.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/foodep.cpp9
-rw-r--r--tests/test_cases/deps/transitive-components/foodep.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/main.cpp11
-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
205 files changed, 4735 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..1e5f67a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,629 @@
+# 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": "3a5f0f0f50c59495ffc3b198df59e6edb8416450"
+ , "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"`. |
+| `"ARFLAGS"` | Arguments to tell the archiver to create an archive with the specified object files. If the `"ARFLAGS"` specified in the defaults target are empty, the rules will use `["cqs"]`. |
+| `"DEBUGFLAGS"` | Flags to be used for the debug-stage for both C and C++, instead of the resulting CFLAGS and CXXFLAGS, respectively. 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"`. |
+| `"ADD_DEBUGFLAGS"` | Additional compilation flags for the debug-stage. Specifying this field extends values from `"base"` for both, `"CFLAGS"` and `"CXXFLAGS"`. |
+| `"AR"` | The archiver tool to use |
+| `"DWP"` | The DWARF format packaging tool to use. Required by debug builds that enable debug fission. |
+| `"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"`, `"AR"`, or `"DWP"`) 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"`. |
+| `"include_scanner"` | Specify an include scanner to be run before each compile action, which removes unused headers from the include tree. The given target must contain a single executable artifact, a script or binary. The tool specified must accept as first argument the <out_dir> path and as remaining arguments the argv of the preprocessor command (-E -M). The input headers are located in the local directory `"include"` and the scanner should copy all used headers to `"<out_dir>/include"`. Specifying this field overwrites values 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"` | If logically true (typically, a non-empty map), use debug-related options, otherwise not. |
+
+### 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"` | If logically true (typically, a non-empty map), use debug-related options, otherwise not. |
+
+### 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 rather 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 |
+| --------------- | ----------- |
+| `"DWP"` | The DWARF format packaging tool to use in debug builds that enable debug fission. If None, the respective value from `["CC", "defaults"]` will be taken. |
+| `"DEBUG"` | Either a logically false value to disable debugging, or a non-empty map to enable debugging. If debugging is enabled, the following values of the map are used. The key `"USE_DEBUG_FISSION"` expects a flag which enables the debug fission mode, but does not add any flags. Explicitly setting it to a false value is needed to enable regular debug mode. The key `"FISSION_CONFIG"` expects a map configuring debug fission. - subkey `"USE_SPLIT_DWARF"` expects a flag that, if true, adds the -gsplit-dwarf compile flag. - subkey `"DWARF_VERSION"` expects a string that adds the -gdwarf-<value> compile flag. - subkey `"USE_GDB_INDEX"` expects a flag that, if true, adds the -Wl,--gdb-index linker flag. - subkey `"USE_DEBUG_TYPES_SECTION"` expects a flag that, if true, adds the -fdebug-types-section compile flag. If no compile flags are otherwise configured, `["-g"]` will be taken. |
+| `"LINT"` | Also provide nodes describing compile actions and header files; those can be used by lint rules (doing also the config transition) for additional checks. |
+
+### 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). |
+| `"components"` | Any other libraries that are considered part of this library; all object files of those are included unconditionally into this library. |
+| `"shared"` | If non-empty, produce a shared instead of a static library. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"DWP"` | The DWARF format packaging tool to use in debug builds that enable debug fission. If None, the respective value from `["CC", "defaults"]` will be taken. |
+| `"BUILD_OBJECT_ONLY"` | If true, produce an object library, resulting in object files added to the linker line of all depending targets. If this configuration is set, the `"shared"` option is ignored. This variable is cleared for all dependencies. |
+| `"BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING"` | If true, do not include the objects in the provided `"link-args"`. This allows consuming libraries that pick on the objects themselves to still forward the `"link-args"` of that library, and thus getting correct linking instructions for the resulting library. |
+| `"DEBUG"` | Either a logically false value to disable debugging, or a non-empty map to enable debugging. If debugging is enabled, the following values of the map are used. The key `"USE_DEBUG_FISSION"` expects a flag which enables the debug fission mode, but does not add any flags. Explicitly setting it to a false value is needed to enable regular debug mode. The key `"FISSION_CONFIG"` expects a map configuring debug fission. - subkey `"USE_SPLIT_DWARF"` expects a flag that, if true, adds the -gsplit-dwarf compile flag. - subkey `"DWARF_VERSION"` expects a string that adds the -gdwarf-<value> compile flag. - subkey `"USE_GDB_INDEX"` expects a flag that, if true, adds the -Wl,--gdb-index linker flag. - subkey `"USE_DEBUG_TYPES_SECTION"` expects a flag that, if true, adds the -fdebug-types-section compile flag. If no compile flags are otherwise configured, `["-g"]` will be taken. |
+| `"LINT"` | Also provide nodes describing compile actions and header files; those can be used by lint rules (doing also the config transition) for additional checks. |
+
+### 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. |
+| `"LINT"` | Also provide nodes describing compile actions and header files; those can be used by lint rules (doing also the config transition) for additional checks. |
+
+### Rule `["shell", "defaults"]`
+
+A rule to provide defaults for the usage of the shell
+
+ All targets using invocations of the shell use the target `["shell", "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 commands 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 toolchain. |
+| `"outs"` | The expected file outputs |
+| `"out_dirs"` | The expected output directories |
+| `"deps"` | Any inputs to the argument. Both, artifacts and runfiles of the dependencies 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 |
+| `"keep-dirs"` | List of names (relative to the test working directory) of directories 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 implicit 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. |
+| `"FOREIGN_EXECUTION_PROPERTIES"` | A map with extra remote-execution properties to be added to the foreign build action. |
+
+### 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. |
+| `"FOREIGN_EXECUTION_PROPERTIES"` | A map with extra remote-execution properties to be added to the foreign build action. |
+
+### 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. |
+| `"FOREIGN_EXECUTION_PROPERTIES"` | A map with extra remote-execution properties to be added to the foreign build action. |
+
+### 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. |
+| `"FOREIGN_EXECUTION_PROPERTIES"` | A map with extra remote-execution properties to be added to the foreign build action. |
+
+### 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. The disjoint union of the artifacts of the targets specified here are taken as project directory. Its 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. |
+| `"FOREIGN_EXECUTION_PROPERTIES"` | A map with extra remote-execution properties to be added to the foreign build action. |
+
+### 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. The disjoint union of the artifacts of the targets specified here are taken as project directory. Its 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. |
+| `"FOREIGN_EXECUTION_PROPERTIES"` | A map with extra remote-execution properties to be added to the foreign build action. |
+
+### 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. |
+
+### Rule `["test", "suite"]`
+
+Form a compound target out of many test targets.
+
+ More precisely, take the runfiles of the given `"deps"`, take their disjoint union and stage the result. Also propagate relevant providers.
+
+| Field | Description |
+| ----- | ----------- |
+| `"stage"` | The logical location this test suite is to be placed. Individual entries will be joined with `"/"`. |
+| `"deps"` | The targets that suite is composed of. |
+
+### Rule `["test", "matrix"]`
+
+Given a group of tests, build them in a variety of configurations.
+
+ The configuration variable TEST_MATRIX is expected to be a map with each value being a map itself. Sequentially for each key, all possible values of the associated map are tried and staged to the appropriate key. Thus, the tests in `"deps"` are built in an exponential number of configurations.
+
+ If TEST_MATRIX is unset, `{}` will be assumed, i.e., all the `"deps"` will be built precisely once, in the current configuration. In this way, the `"matrix"` rule can be used instead of the `"suite"` rule to allow user-defined configuration matrices, dispatching over parameters for dependencies (e.g., the toolchain).
+
+| Field | Description |
+| ----- | ----------- |
+| `"stage"` | The logical location this test suite is to be placed. Individual entries will be joined with `"/"`. |
+| `"deps"` | The targets that suite is composed of. |
+
+| Config variable | Description |
+| --------------- | ----------- |
+| `"TEST_MATRIX"` | Map describing the dimensions of the matrix to run the tests for. Keys are config variables. The value for each key has to be a map mapping the stage name to the corresponding value for that config variable. |
+
+### Rule `["lint", "targets"]`
+
+Run a given linter on the lint information provided by the given targets.
+
+| Field | Description |
+| ----- | ----------- |
+| `"name"` | Name of the kind of lint check performed, to be reported when an action is failing. |
+| `"linter"` | Single artifact running the lint checks. This program is invoked with - argv`[1]` the file to lint, and - argv`[2:]` the original command line. This invocation happens in an environment with - CONFIG pointing to the directory with all the artifacts given by the field `"config"`, and - OUT pointing to a directory to which files with the lint result can be written. - META pointing to a json file containing - at key `"direct deps artifact names"` a list of all input artifacts that come from the target itself or are runfiles of a direct dependency. - at key `"extra outs"` a list of extra output artifacts that the command might produce, such as DWARF objects if debug fission is enabled. - TMPDIR pointing to a directory location that can be used to create additional temporary files. It is supposed to indicate by the exit code whether the file to lint complies with the given linting policy, with 0 meaning compliant. Stdout and stderr, as well as the directory $`{OUT}` can be used to provide additional information. |
+| `"config"` | Any configuration or other files needed by the linter. |
+| `"summarizer"` | Single artifact generating a summary of the individual lint results. It will be called in a directory where all subdirectories except . and .. represent the results of the individual lint actions. Those are given as - a file `"result"` with content `"PASS"` if and only if the lint action exited 0, - files `"stdout"` and `"stderr"` with stdout and stderr of the lint action, and - a directory `"out"` with the additional information provided by the lint action. The summarizer is required to indicate the overall result by the exit code, produce a human-readable summary on stdout, and optionally additional information in the directory $`{OUT}`. |
+
+### Rule `["lint", "defaults"]`
+
+A rule to provide default paths common to all lint targets.
+
+ While lint targets bring their own host directory via the field `"config"`, it can still be necessary to bring some default paths, e.g., for finding the compiler, or the interpreter for the runner.
+
+| Field | Description |
+| ----- | ----------- |
+| `"PATH"` | Paths for looking up system tools. Specifying this field extends values from `"base"`. |
+| `"base"` | Other targets to inherit values from. |
+
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..1d1e432
--- /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": "3a5f0f0f50c59495ffc3b198df59e6edb8416450"
+ , "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/etc/defaults/shell/test/TARGETS b/etc/defaults/shell/test/TARGETS
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/etc/defaults/shell/test/TARGETS
@@ -0,0 +1 @@
+{}
diff --git a/etc/generate-doc.sh b/etc/generate-doc.sh
new file mode 100755
index 0000000..69bdbb4
--- /dev/null
+++ b/etc/generate-doc.sh
@@ -0,0 +1,85 @@
+#!/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
+ doc2md rules test suite
+ doc2md rules test matrix
+ doc2md rules lint targets
+ doc2md rules lint defaults
+) >> "$OUTFILE"
diff --git a/etc/generate-repos.sh b/etc/generate-repos.sh
new file mode 100755
index 0000000..be235a3
--- /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.5.2}
+: ${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..c419b83
--- /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.5.2"
+ , "commit": "bcf1d9a1ed766ee35808f23b48481cbc5168346f"
+ }
+ , "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": "624cd17664daa964e192c176c98ea2fb919afd3d"
+ , "fetch": "https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.4.2.tar.gz"
+ , "sha256": "f2d893a65c3b1324c50d4e682c0cdc021dd0477ae2c048544f39eed6654b699a"
+ , "sha512": "fdb61c430f5b99a9495fda7f94bfc8d0fb5360c99beeccbcb3b8918713579aac97fa0dcbce296065d9043f141a538c505919c9810fd1d192661e8b48b6a2637a"
+ , "subdir": "CLI11-2.4.2"
+ }
+ , "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": "87c37bc5be5d6ded368667d02958d488b94d6143"
+ , "fetch": "https://github.com/grpc/grpc/archive/refs/tags/v1.70.2.tar.gz"
+ , "sha256": "92f240f7267ed6cd8ba2be4c59a3b5b6ec0c4b4c466071b1e1d62165b25acf64"
+ , "sha512": "4afd34b36b4d7c41260abad6d921154a3e7176a7a46de6ae97335697db5d11f61e37b08889c007463fc8f3e800788585f5f7d5b2cec12f89b69fc9bc15efd17f"
+ , "subdir": "grpc-1.70.2"
+ , "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": "994435922d1ce63b52f6420f90b1b2a9f6670c39"
+ , "fetch": "https://github.com/libarchive/libarchive/releases/download/v3.7.7/libarchive-3.7.7.tar.gz"
+ , "sha256": "4cc540a3e9a1eebdefa1045d2e4184831100667e6d7d5b315bb1cbc951f8ddff"
+ , "sha512": "cce6eecfcd33d228bd1b1162a90bad63750adb53ac4edcaed34e2fdc30b6ba211cf1fd25d4b8761373949ceec266478b09bd70ffa4e374803a29e8573d6d149e"
+ , "subdir": "libarchive-3.7.7"
+ }
+ , "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": "b5cc395c49afa2a2dec1d9c4072500494b126974"
+ , "fetch": "https://github.com/abseil/abseil-cpp/releases/download/20240722.0/abseil-cpp-20240722.0.tar.gz"
+ , "sha256": "f50e5ac311a81382da7fa75b97310e4b9006474f9560ac46f54a9967f07d4ae3"
+ , "sha512": "bd2cca8f007f2eee66f51c95a979371622b850ceb2ce3608d00ba826f7c494a1da0fba3c1427728f2c173fe50d59b701da35c2c9fdad2752a5a49746b1c8ef31"
+ , "subdir": "abseil-cpp-20240722.0"
+ , "mirrors":
+ [ "https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/20240722.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": "90ab7bf7db31acb0fc6d79a823275a96daa81c4a"
+ , "fetch": "https://github.com/fmtlib/fmt/releases/download/11.1.3/fmt-11.1.3.zip"
+ , "sha256": "7df2fd3426b18d552840c071c977dc891efe274051d2e7c47e2c83c3918ba6df"
+ , "sha512": "5b9f5b0c81c2e3e7fb0d985556f98c45e15cbd89fe2ad1bf691bf1ba47c11192efcc83dd643f18bd8086689432c9b8fd9f55704f3d322bfa617ac67b08ba9530"
+ , "subdir": "fmt-11.1.3"
+ }
+ , "target_root": "just/import targets"
+ , "target_file_name": "TARGETS.fmt"
+ , "bindings": {"rules": "just/rules"}
+ }
+ , "just/google_apis":
+ { "repository":
+ { "type": "archive"
+ , "content": "db3c51a8fd9c923a4e4908d8bcd7dd4642cc4664"
+ , "fetch": "https://github.com/googleapis/googleapis/archive/fe8ba054ad4f7eca946c2d14a63c3f07c0b586a0.tar.gz"
+ , "sha256": "0513f0f40af63bd05dc789cacc334ab6cec27cc89db596557cb2dfe8919463e4"
+ , "sha512": "d77ea83f8e68e3c0b667e7de43c2cd28b0ca7b969b2cf127b3873fc19f330ad85afb314bef4174a4e11ed68b620e43853d8b44eb833c5eca7e820ca21c1c3e15"
+ , "subdir": "googleapis-fe8ba054ad4f7eca946c2d14a63c3f07c0b586a0"
+ , "mirrors":
+ [ "https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/googleapis/archive/fe8ba054ad4f7eca946c2d14a63c3f07c0b586a0.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": "80e67abd2e08a54ec21f195b3e9e4abfc64ba7e1"
+ , "fetch": "https://github.com/tukaani-project/xz/releases/download/v5.6.3/xz-5.6.3.tar.gz"
+ , "sha256": "b1d45295d3f71f25a4c9101bd7c8d16cb56348bbef3bbc738da0351e17c73317"
+ , "sha512": "b07b45e18615d1946e9d12157af99b54700d757832a638fccab70549574dcd7f28e69e71cc4c0b9c808959f818e79b668a5ccf108429ea0f40b6125bfd55d274"
+ , "subdir": "xz-5.6.3"
+ }
+ , "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.5.2"
+ , "commit": "bcf1d9a1ed766ee35808f23b48481cbc5168346f"
+ , "subdir": "etc/patches"
+ }
+ }
+ , "just/protobuf":
+ { "repository":
+ { "type": "archive"
+ , "content": "e8787a2f6d661aaaec426743c4e9667be7c8ba2f"
+ , "fetch": "https://github.com/protocolbuffers/protobuf/releases/download/v29.0/protobuf-29.0.tar.gz"
+ , "sha256": "10a0d58f39a1a909e95e00e8ba0b5b1dc64d02997f741151953a2b3659f6e78c"
+ , "sha512": "c5637486a533557ea909d1f880b0f0064fff0c4665612e023170941310c45bf8e7373d2c67de621824b056530e98792c00799d71ec4ff7b6af9142cdc4cb8dee"
+ , "subdir": "protobuf-29.0"
+ }
+ , "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.5.2"
+ , "commit": "bcf1d9a1ed766ee35808f23b48481cbc5168346f"
+ , "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": "d9ff3aa3d22337e93cb0a0e2df00ca8abea2fac6"
+ , "fetch": "https://github.com/google/boringssl/archive/dec0d8f681348af8bb675e07bd89989665fca8bc.tar.gz"
+ , "sha256": "2f12c33d2cf25a658a1b981fb96923dac87e9175fb20e45db6950ee36c526356"
+ , "sha512": "51f91bee640e38ce20c180195de6811b5be7522240faae2b57158fa9c298ed09292ecb09c770df5d4fc6a3100bc2459de4e9d312e315265c1ea7ade347bad3f2"
+ , "subdir": "boringssl-dec0d8f681348af8bb675e07bd89989665fca8bc"
+ , "mirrors":
+ [ "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/boringssl/archive/dec0d8f681348af8bb675e07bd89989665fca8bc.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.5.2"
+ , "commit": "bcf1d9a1ed766ee35808f23b48481cbc5168346f"
+ , "subdir": "etc/toolchain"
+ }
+ , "rule_root": "just/rules"
+ }
+ , "just/zlib":
+ { "repository":
+ { "type": "archive"
+ , "content": "53fa48bf97f0ee0f42c62743b018507a6583ec3e"
+ , "fetch": "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz"
+ , "sha256": "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23"
+ , "sha512": "580677aad97093829090d4b605ac81c50327e74a6c2de0b85dd2e8525553f3ddde17556ea46f8f007f89e435493c9a20bc997d1ef1c1c2c23274528e3c46b94f"
+ , "subdir": "zlib-1.3.1"
+ }
+ , "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.5.2"
+ , "commit": "bcf1d9a1ed766ee35808f23b48481cbc5168346f"
+ , "subdir": "etc/defaults"
+ }
+ }
+ , "just/import targets":
+ { "repository":
+ { "type": "git"
+ , "repository": "https://github.com/just-buildsystem/justbuild"
+ , "branch": "v1.5.2"
+ , "commit": "bcf1d9a1ed766ee35808f23b48481cbc5168346f"
+ , "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 0e06903..0e06903 100644
--- a/CC/EXPRESSIONS
+++ b/rules/CC/EXPRESSIONS
diff --git a/CC/RULES b/rules/CC/RULES
index b57ae91..b57ae91 100644
--- a/CC/RULES
+++ b/rules/CC/RULES
diff --git a/CC/TARGETS b/rules/CC/TARGETS
index 118c9af..118c9af 100644
--- a/CC/TARGETS
+++ b/rules/CC/TARGETS
diff --git a/CC/auto/RULES b/rules/CC/auto/RULES
index 34886d8..34886d8 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 2da44af..2da44af 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 e6463f8..e6463f8 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 e8217dd..e8217dd 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 917b4af..917b4af 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 df3000e..df3000e 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 55d9fa8..55d9fa8 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 e831d4c..e831d4c 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 7ca2741..7ca2741 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 182e46a..182e46a 100644
--- a/CC/foreign/shell/RULES
+++ b/rules/CC/foreign/shell/RULES
diff --git a/CC/include_scan b/rules/CC/include_scan
index aaaa77c..aaaa77c 100755
--- a/CC/include_scan
+++ b/rules/CC/include_scan
diff --git a/CC/include_scan.c b/rules/CC/include_scan.c
index 8652fc0..8652fc0 100644
--- a/CC/include_scan.c
+++ b/rules/CC/include_scan.c
diff --git a/CC/include_scan.py b/rules/CC/include_scan.py
index d99392b..d99392b 100755
--- a/CC/include_scan.py
+++ b/rules/CC/include_scan.py
diff --git a/CC/pkgconfig/EXPRESSIONS b/rules/CC/pkgconfig/EXPRESSIONS
index 72d66fd..72d66fd 100644
--- a/CC/pkgconfig/EXPRESSIONS
+++ b/rules/CC/pkgconfig/EXPRESSIONS
diff --git a/CC/pkgconfig/RULES b/rules/CC/pkgconfig/RULES
index f72fdf6..f72fdf6 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 910b6a1..910b6a1 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 1389bbc..1389bbc 100644
--- a/CC/test/EXPRESSIONS
+++ b/rules/CC/test/EXPRESSIONS
diff --git a/CC/test/RULES b/rules/CC/test/RULES
index 3401974..3401974 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 4984b17..4984b17 100755
--- a/CC/test/runner
+++ b/rules/CC/test/runner
diff --git a/EXPRESSIONS b/rules/EXPRESSIONS
index 0c1f611..0c1f611 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 49bc1f0..49bc1f0 100644
--- a/data/RULES
+++ b/rules/data/RULES
diff --git a/lint/RULES b/rules/lint/RULES
index add3cdb..add3cdb 100644
--- a/lint/RULES
+++ b/rules/lint/RULES
diff --git a/lint/TARGETS b/rules/lint/TARGETS
index de52b00..de52b00 100644
--- a/lint/TARGETS
+++ b/rules/lint/TARGETS
diff --git a/lint/call_lint b/rules/lint/call_lint
index 850812e..850812e 100755
--- a/lint/call_lint
+++ b/rules/lint/call_lint
diff --git a/lint/call_summary b/rules/lint/call_summary
index 9686d0a..9686d0a 100755
--- a/lint/call_summary
+++ b/rules/lint/call_summary
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 ea495f0..ea495f0 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 7dccda3..7dccda3 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 9791911..9791911 100644
--- a/shell/test/EXPRESSIONS
+++ b/rules/shell/test/EXPRESSIONS
diff --git a/shell/test/RULES b/rules/shell/test/RULES
index 3170dcf..3170dcf 100644
--- a/shell/test/RULES
+++ b/rules/shell/test/RULES
diff --git a/shell/test/TARGETS b/rules/shell/test/TARGETS
index 5a4b849..5a4b849 100644
--- a/shell/test/TARGETS
+++ b/rules/shell/test/TARGETS
diff --git a/shell/test/runner b/rules/shell/test/runner
index 29c5135..29c5135 100755
--- a/shell/test/runner
+++ b/rules/shell/test/runner
diff --git a/shell/test/summarizer b/rules/shell/test/summarizer
index 39b66be..39b66be 100755
--- a/shell/test/summarizer
+++ b/rules/shell/test/summarizer
diff --git a/test/EXPRESSIONS b/rules/test/EXPRESSIONS
index 006e804..006e804 100644
--- a/test/EXPRESSIONS
+++ b/rules/test/EXPRESSIONS
diff --git a/test/RULES b/rules/test/RULES
index 3aec6e1..3aec6e1 100644
--- a/test/RULES
+++ b/rules/test/RULES
diff --git a/transitions/EXPRESSIONS b/rules/transitions/EXPRESSIONS
index d1ecefa..d1ecefa 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..e9b0f2a
--- /dev/null
+++ b/tests/TARGETS
@@ -0,0 +1,10 @@
+{ "ALL":
+ { "type": "install"
+ , "deps":
+ [ ["test_cases/deps", "ALL"]
+ , ["test_cases/cflags", "ALL"]
+ , ["test_cases/config", "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/config/TARGETS b/tests/test_cases/config/TARGETS
new file mode 100644
index 0000000..b751130
--- /dev/null
+++ b/tests/test_cases/config/TARGETS
@@ -0,0 +1,57 @@
+{ "both":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["config_both"]
+ , "targets": ["+header_both"]
+ , "asserts":
+ [ "test -f header_both/foo.h"
+ , "cat header_both/foo.h"
+ , "grep '// comment 1$' header_both/foo.h"
+ , "grep '#define FOO 1$' header_both/foo.h"
+ , "grep '#define BAX 0$' header_both/foo.h"
+ , "grep '#define BAR \"foofoo bar foo\"$' header_both/foo.h"
+ , "grep '/\\* #undef BAZ \\*/$' header_both/foo.h"
+ , "grep '/\\* #undef BAX \\*/$' header_both/foo.h"
+ , "grep '#define FOO$' header_both/foo.h"
+ , "grep '// comment 2$' header_both/foo.h"
+ , "grep 'magic_at$' header_both/foo.h"
+ , "grep 'magic_curly$' header_both/foo.h"
+ , "grep 'undefined_at--$' header_both/foo.h"
+ , "grep 'undefined_curly--$' header_both/foo.h"
+ ]
+ , "data": [["TREE", null, "data"]]
+ }
+, "@only":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["config_@only"]
+ , "targets": ["+header_@only"]
+ , "asserts":
+ [ "test -f header_@only/foo.h"
+ , "cat header_@only/foo.h"
+ , "grep '// comment 1$' header_@only/foo.h"
+ , "grep '#define FOO 1$' header_@only/foo.h"
+ , "grep '#define BAX 0$' header_@only/foo.h"
+ , "grep '#define BAR \"foofoo bar \\${FOO}\"$' header_@only/foo.h"
+ , "grep '/\\* #undef BAZ \\*/$' header_@only/foo.h"
+ , "grep '/\\* #undef BAX \\*/$' header_@only/foo.h"
+ , "grep '#define FOO$' header_@only/foo.h"
+ , "grep '// comment 2$' header_@only/foo.h"
+ , "grep 'magic_at$' header_@only/foo.h"
+ , "grep '\\${NO_MAGIC_CURLY}' header_@only/foo.h"
+ , "grep 'undefined_at--$' header_@only/foo.h"
+ , "grep 'undefined_curly-\\${UNDEFINED}-$' header_@only/foo.h"
+ ]
+ , "data": [["TREE", null, "data"]]
+ }
+, "runner.py":
+ { "type": "install"
+ , "files": {"runner.py": ["@", "rules", "CC/auto", "runner"]}
+ }
+, "pytest":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["config_pytest"]
+ , "test": ["run_pytest.sh"]
+ , "deps": ["runner.py", "runner_test.py"]
+ }
+, "ALL":
+ {"type": "install", "deps": ["both", "@only", "pytest"], "tainted": ["test"]}
+}
diff --git a/tests/test_cases/config/data/TARGETS b/tests/test_cases/config/data/TARGETS
new file mode 100644
index 0000000..f3e7cf0
--- /dev/null
+++ b/tests/test_cases/config/data/TARGETS
@@ -0,0 +1,48 @@
+{ "blueprint":
+ { "type": ["@", "rules", "CC/auto", "config_file"]
+ , "input": ["foo.in"]
+ , "output": ["foo.h"]
+ , "magic_string": ["cmakedefine"]
+ }
+, "blueprint_@only":
+ { "type": ["@", "rules", "CC/auto", "config_file"]
+ , "input": ["foo.in"]
+ , "output": ["foo.h"]
+ , "magic_string": ["cmakedefine"]
+ , "@only": ["true"]
+ }
+, "header_both":
+ { "type": "configure"
+ , "target": "blueprint"
+ , "config":
+ { "type": "let*"
+ , "bindings":
+ [ [ "defines"
+ , [ ["FOO", "foo"]
+ , ["BAR", "bar"]
+ , ["NO_MAGIC_AT", "magic_at"]
+ , ["NO_MAGIC_CURLY", "magic_curly"]
+ ]
+ ]
+ ]
+ , "body": {"type": "env", "vars": ["defines"]}
+ }
+ }
+, "header_@only":
+ { "type": "configure"
+ , "target": "blueprint_@only"
+ , "config":
+ { "type": "let*"
+ , "bindings":
+ [ [ "defines"
+ , [ ["FOO", "foo"]
+ , ["BAR", "bar"]
+ , ["NO_MAGIC_AT", "magic_at"]
+ , ["NO_MAGIC_CURLY", "magic_curly"]
+ ]
+ ]
+ ]
+ , "body": {"type": "env", "vars": ["defines"]}
+ }
+ }
+}
diff --git a/tests/test_cases/config/data/foo.in b/tests/test_cases/config/data/foo.in
new file mode 100644
index 0000000..66bd9ba
--- /dev/null
+++ b/tests/test_cases/config/data/foo.in
@@ -0,0 +1,13 @@
+// comment 1
+#cmakedefine01 FOO
+#cmakedefine01 BAX
+#cmakedefine FOO "@FOO@"
+#cmakedefine BAR "@FOO@@FOO@ bar ${FOO}"
+#cmakedefine BAZ "baz"
+#cmakedefine BAX
+#cmakedefine FOO
+// comment 2
+@NO_MAGIC_AT@
+${NO_MAGIC_CURLY}
+undefined_at-@UNDEFINED@-
+undefined_curly-${UNDEFINED}-
diff --git a/tests/test_cases/config/run_pytest.sh b/tests/test_cases/config/run_pytest.sh
new file mode 100755
index 0000000..fc886ea
--- /dev/null
+++ b/tests/test_cases/config/run_pytest.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+python3 -m pytest
diff --git a/tests/test_cases/config/runner_test.py b/tests/test_cases/config/runner_test.py
new file mode 100644
index 0000000..2f0920e
--- /dev/null
+++ b/tests/test_cases/config/runner_test.py
@@ -0,0 +1,134 @@
+# Copyright 2024 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.
+
+from runner import (
+ compute_value,
+ get_tokens,
+ handle01,
+ replace_value,
+ undefine,
+)
+
+from hypothesis import given
+from hypothesis.strategies import text
+import re
+
+
+def test_get_tokens():
+ magic_string = "cmakedefine"
+ match, is_01 = get_tokens(
+ f"# \t \t {magic_string} \t TOKEN_KEY \t\t TOKEN_VALUE \t\n", magic_string
+ )
+ assert match
+ assert not is_01
+ groups = match.groups()
+ assert len(groups) == 6
+ assert groups[1] == magic_string
+ assert groups[3] == "TOKEN_KEY"
+ assert groups[5] == "TOKEN_VALUE \t"
+
+ match, _ = get_tokens("#cmakedefine TOKEN_KEY TOKEN_VALUE", magic_string)
+ assert match
+ groups = match.groups()
+ assert groups[1] == magic_string
+ assert groups[3] == "TOKEN_KEY"
+ assert groups[5] == "TOKEN_VALUE"
+
+ match, _ = get_tokens("#cmakedefine TOKEN_KEY @TOKEN_VALUE@", magic_string)
+ assert match
+ groups = match.groups()
+ assert len(groups) == 6
+ assert groups[1] == magic_string
+ assert groups[3] == "TOKEN_KEY"
+ assert groups[5] == "@TOKEN_VALUE@"
+
+ match, _ = get_tokens("#cmakedefine TOKEN_KEY ${TOKEN_VALUE}", magic_string)
+ assert match
+ groups = match.groups()
+ assert len(groups) == 6
+ assert groups[1] == magic_string
+ assert groups[3] == "TOKEN_KEY"
+ assert groups[5] == "${TOKEN_VALUE}"
+
+ match, _ = get_tokens("#cmakedefine TOKEN_KEY", magic_string)
+ assert match
+ groups = match.groups()
+ assert len(groups) == 6
+ assert groups[1] == magic_string
+ assert groups[3] == "TOKEN_KEY"
+ assert groups[5] == ""
+
+ match, _ = get_tokens("#differnt_magic_string TOKEN_KEY", magic_string)
+ assert not match
+
+ match, is_01 = get_tokens(f"#{magic_string}01 TOKEN_KEY", magic_string)
+ assert match
+ assert is_01
+
+ match, _ = get_tokens(f'#cmakedefine FOO "@FOO@"', "cmakedefine")
+ groups = match.groups()
+ assert groups[5] == '"@FOO@"'
+
+
+def test_handle_01():
+ line = "#cmakedefine01 FOO"
+ tokens, _ = get_tokens(line, "cmakedefine")
+ assert handle01(line, tokens, True) == "#define FOO 1"
+ assert handle01(line, tokens, False) == "#define FOO 0"
+
+
+def test_undefine():
+ lines = [
+ "#cmakedefine FOO",
+ "#cmakedefine FOO foo",
+ "#cmakedefine FOO ${FOO}",
+ "#cmakedefine FOO @FOO@",
+ ]
+ for line in lines:
+ tokens, _ = get_tokens(line, "cmakedefine")
+ assert undefine(tokens) == "/* #undef FOO */"
+
+
+def test_replace_value():
+ line = "#cmakedefine FOO whatever@VVV@${FFF}"
+ tokens, _ = get_tokens(line, "cmakedefine")
+ groups = tokens.groups()
+ assert len(groups) == 6
+ assert groups[1] == "cmakedefine"
+ assert groups[3] == "FOO"
+ assert groups[5] == "whatever@VVV@${FFF}"
+ assert replace_value(tokens, "FOO", "VALUE") == "#define FOO VALUE"
+
+
+def test_compute_value():
+ token = "@KEY1@foo${KEY2}@KEY3@@KEY4@"
+ key_value_dict = {
+ "KEY1": "value1",
+ "KEY2": "value2",
+ "KEY3": "value3",
+ "KEY4": "value4",
+ "KEY5": "0",
+ }
+
+ assert compute_value(token, True, key_value_dict) == "value1foo${KEY2}value3value4"
+ assert compute_value(token, False, key_value_dict) == "value1foovalue2value3value4"
+ assert compute_value("@KEY5@", True, key_value_dict) == "0"
+
+
+@given(text())
+def test_substitution_with_given_value(s):
+ kv = {"FOO": s}
+ assert compute_value("@FOO@", True, kv) == s
+ assert compute_value("${FOO}", False, kv) == s
+ assert compute_value("${FOO}", True, kv) == "${FOO}"
diff --git a/tests/test_cases/deps/TARGETS b/tests/test_cases/deps/TARGETS
new file mode 100644
index 0000000..0ac2f3e
--- /dev/null
+++ b/tests/test_cases/deps/TARGETS
@@ -0,0 +1,419 @@
+{ "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"]]
+ }
+, "components":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_components"]
+ , "targets":
+ [ "+foo"
+ , "+bar"
+ , "+combined_static_lib"
+ , "+combined_shared_lib"
+ , "+main"
+ , "+main-dynamic"
+ , "+installed_static"
+ , "+installed_shared"
+ ]
+ , "asserts":
+ [ "test -f foo/foo.hpp"
+ , "test -f foo/libfoo.a"
+ , "! test -e foo/libfoo.so"
+ , "test -f bar/bar.hpp"
+ , "test -f bar/libbar.a"
+ , "! test -e bar/libbar.so"
+ , "test -f combined_static_lib/libcombstatic.a"
+ , "test -f combined_static_lib/foo.hpp"
+ , "test -f combined_static_lib/bar.hpp"
+ , "! test -f combined_static_lib/libfoo.a"
+ , "! test -f combined_static_lib/libbar.a"
+ , "! test -f combined_static_lib/foodep.hpp"
+ , "! test -f combined_static_lib/foo.o"
+ , "! test -f combined_static_lib/bar.o"
+ , "test -f combined_shared_lib/libcombshared.so"
+ , "test -f combined_shared_lib/foo.hpp"
+ , "test -f combined_shared_lib/bar.hpp"
+ , "! test -f combined_shared_lib/foodep.hpp"
+ , "! test -f combined_shared_lib/libfoo.a"
+ , "! test -f combined_shared_lib/libbar.a"
+ , "! test -f combined_shared_lib/libfoo.so"
+ , "! test -f combined_shared_lib/libbar.so"
+ , "! test -f combined_shared_lib/foo.o"
+ , "! test -f combined_shared_lib/bar.o"
+ , "./main/main"
+ , "./main/main | grep 'Hello-from-main'"
+ , "./main/main | grep 'bar.3'"
+ , "./main/main | grep 'foo.15'"
+ , "./main-dynamic/bin/main"
+ , "./main-dynamic/bin/main | grep 'Hello-from-main'"
+ , "./main-dynamic/bin/main | grep 'bar.3'"
+ , "./main-dynamic/bin/main | grep 'foo.15'"
+ , "test -f installed_static/include/bar.hpp"
+ , "test -f installed_static/include/foo.hpp"
+ , "test -f installed_static/include/foodep.hpp"
+ , "test -f installed_static/lib/libcombstatic.a"
+ , "test -f installed_static/lib/libfoodep.a"
+ , "! test -f installed_static/lib/libbar.a"
+ , "! test -f installed_static/lib/libfoo.a"
+ , "test -f installed_shared/include/bar.hpp"
+ , "test -f installed_shared/include/foo.hpp"
+ , "test -f installed_shared/include/foodep.hpp"
+ , "test -f installed_shared/lib/libcombshared.so"
+ , "! test -f installed_shared/lib/libfoodep.a"
+ , "! test -f installed_shared/lib/libfoodep.so"
+ , "! test -f installed_shared/lib/libbar.a"
+ , "! test -f installed_shared/lib/libbar.so"
+ , "! test -f installed_shared/lib/libfoo.a"
+ , "! test -f installed_shared/lib/libfoo.so"
+ ]
+ , "data": [["TREE", null, "components"]]
+ }
+, "transitive-components":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_transitive_components"]
+ , "targets":
+ ["+baz", "+bar", "+foo", "+main", "+shared-foo", "+installed-shared-main"]
+ , "asserts":
+ [ "test -f foo/libfoo.a"
+ , "test -f foo/foo.hpp"
+ , "test -f foo/bar.hpp"
+ , "test -f foo/baz.hpp"
+ , "! test -f foo/foodep.hpp"
+ , "! test -f foo/bardep.hpp"
+ , "! test -f foo/bazdep.hpp"
+ , "./main/main"
+ , "./main/main | grep main"
+ , "./main/main | grep foodep"
+ , "./main/main | grep bardep"
+ , "./main/main | grep bazdep"
+ , "test -f shared-foo/libfoo.so"
+ , "test -f shared-foo/foo.hpp"
+ , "test -f shared-foo/bar.hpp"
+ , "test -f shared-foo/baz.hpp"
+ , "! test -f shared-foo/foodep.hpp"
+ , "! test -f shared-foo/bardep.hpp"
+ , "! test -f shared-foo/bazdep.hpp"
+ , "./installed-shared-main/bin/main"
+ , "./installed-shared-main/bin/main | grep main"
+ , "./installed-shared-main/bin/main | grep foodep"
+ , "./installed-shared-main/bin/main | grep bardep"
+ , "./installed-shared-main/bin/main | grep bazdep"
+ ]
+ , "data": [["TREE", null, "transitive-components"]]
+ }
+, "lint":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["lint"]
+ , "targets": ["+test", "+test-shared", "+verifier", "+lint", "+lint-shared"]
+ , "asserts":
+ [ "cat lint/report"
+ , "cat lint-shared/report"
+ , "./verifier/expect lint/out/invocations.json foo.hpp foo.cpp foodep.hpp foodep.cpp bar.hpp bar.cpp bardep.hpp bardep.cpp plain.hpp plain.cpp main.cpp"
+ , "./verifier/expect lint-shared/out/invocations.json foo.hpp foo.cpp foodep.hpp foodep.cpp bar.hpp bar.cpp bardep.hpp bardep.cpp plain.hpp plain.cpp main.cpp"
+ ]
+ , "data": [["TREE", null, "lint"]]
+ }
+, "chain":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["chain"]
+ , "targets": ["+main", "+main-with-deps"]
+ , "asserts":
+ [ "./main-with-deps/bin/main | grep 'foo.*fine'"
+ , "./main-with-deps/bin/main | grep 'qux.*ok'"
+ ]
+ , "data": [["TREE", null, "chain"]]
+ }
+, "ALL":
+ { "type": "install"
+ , "deps":
+ [ "private"
+ , "public"
+ , "shared"
+ , "object"
+ , "prebuilt"
+ , "cmake"
+ , "install"
+ , "components"
+ , "transitive-components"
+ , "lint"
+ , "chain"
+ ]
+ , "tainted": ["test"]
+ }
+}
diff --git a/tests/test_cases/deps/chain/TARGETS b/tests/test_cases/deps/chain/TARGETS
new file mode 100644
index 0000000..974df61
--- /dev/null
+++ b/tests/test_cases/deps/chain/TARGETS
@@ -0,0 +1,38 @@
+{ "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "shared": ["yes"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "deps": ["bar"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "shared": ["yes"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "deps": ["baz"]
+ }
+, "baz":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["baz"]
+ , "hdrs": ["baz.hpp"]
+ , "srcs": ["baz.cpp"]
+ , "deps": ["qux"]
+ }
+, "qux":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["qux"]
+ , "hdrs": ["qux.hpp"]
+ , "srcs": ["qux.cpp"]
+ }
+, "main":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["foo", "qux"]
+ }
+, "main-with-deps":
+ {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["main"]}
+}
diff --git a/tests/test_cases/deps/chain/bar.cpp b/tests/test_cases/deps/chain/bar.cpp
new file mode 100644
index 0000000..e79bcf1
--- /dev/null
+++ b/tests/test_cases/deps/chain/bar.cpp
@@ -0,0 +1,5 @@
+#include "bar.hpp"
+
+#include "baz.hpp"
+
+void print_bar(std::string s) { print_baz("[bar]: " + s); }
diff --git a/tests/test_cases/deps/chain/bar.hpp b/tests/test_cases/deps/chain/bar.hpp
new file mode 100644
index 0000000..cf3cb8c
--- /dev/null
+++ b/tests/test_cases/deps/chain/bar.hpp
@@ -0,0 +1,8 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+#include <string>
+
+void print_bar(std::string);
+
+#endif
diff --git a/tests/test_cases/deps/chain/baz.cpp b/tests/test_cases/deps/chain/baz.cpp
new file mode 100644
index 0000000..b22163b
--- /dev/null
+++ b/tests/test_cases/deps/chain/baz.cpp
@@ -0,0 +1,5 @@
+#include "baz.hpp"
+
+#include "qux.hpp"
+
+void print_baz(std::string s) { print_qux("[baz]: " + s); }
diff --git a/tests/test_cases/deps/chain/baz.hpp b/tests/test_cases/deps/chain/baz.hpp
new file mode 100644
index 0000000..f700c9c
--- /dev/null
+++ b/tests/test_cases/deps/chain/baz.hpp
@@ -0,0 +1,8 @@
+#ifndef BAZ_HPP
+#define BAZ_HPP
+
+#include <string>
+
+void print_baz(std::string);
+
+#endif
diff --git a/tests/test_cases/deps/chain/foo.cpp b/tests/test_cases/deps/chain/foo.cpp
new file mode 100644
index 0000000..a981b95
--- /dev/null
+++ b/tests/test_cases/deps/chain/foo.cpp
@@ -0,0 +1,5 @@
+#include "foo.hpp"
+
+#include "bar.hpp"
+
+void print_foo(std::string s) { print_bar("[foo]: " + s); }
diff --git a/tests/test_cases/deps/chain/foo.hpp b/tests/test_cases/deps/chain/foo.hpp
new file mode 100644
index 0000000..9d66a9d
--- /dev/null
+++ b/tests/test_cases/deps/chain/foo.hpp
@@ -0,0 +1,8 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+#include <string>
+
+void print_foo(std::string);
+
+#endif
diff --git a/tests/test_cases/deps/chain/main.cpp b/tests/test_cases/deps/chain/main.cpp
new file mode 100644
index 0000000..db539d4
--- /dev/null
+++ b/tests/test_cases/deps/chain/main.cpp
@@ -0,0 +1,7 @@
+#include "foo.hpp"
+#include "qux.hpp"
+
+int main() {
+ print_foo("Everthing is fine.");
+ print_qux("Everthing is ok.");
+}
diff --git a/tests/test_cases/deps/chain/qux.cpp b/tests/test_cases/deps/chain/qux.cpp
new file mode 100644
index 0000000..e0499cc
--- /dev/null
+++ b/tests/test_cases/deps/chain/qux.cpp
@@ -0,0 +1,5 @@
+#include "qux.hpp"
+
+#include <cstdio>
+
+void print_qux(std::string s) { printf("[qux]: %s\n", s.data()); }
diff --git a/tests/test_cases/deps/chain/qux.hpp b/tests/test_cases/deps/chain/qux.hpp
new file mode 100644
index 0000000..2975cad
--- /dev/null
+++ b/tests/test_cases/deps/chain/qux.hpp
@@ -0,0 +1,8 @@
+#ifndef QUX_HPP
+#define QUX_HPP
+
+#include <string>
+
+void print_qux(std::string);
+
+#endif
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/components/TARGETS b/tests/test_cases/deps/components/TARGETS
new file mode 100644
index 0000000..62a599c
--- /dev/null
+++ b/tests/test_cases/deps/components/TARGETS
@@ -0,0 +1,55 @@
+{ "combined_static_lib":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["combstatic"]
+ , "components": ["foo", "bar"]
+ }
+, "combined_shared_lib":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["combshared"]
+ , "shared": [""]
+ , "components": ["foo", "bar"]
+ }
+, "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "deps": ["foodep"]
+ }
+, "foodep":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foodep"]
+ , "hdrs": ["foodep.hpp"]
+ , "srcs": ["foodep.cpp"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ }
+, "main":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["combined_static_lib"]
+ }
+, "main-shared":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["combined_shared_lib"]
+ }
+, "main-dynamic":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["main-shared"]
+ }
+, "installed_static":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["combined_static_lib"]
+ }
+, "installed_shared":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["combined_shared_lib"]
+ }
+}
diff --git a/tests/test_cases/deps/components/bar.cpp b/tests/test_cases/deps/components/bar.cpp
new file mode 100644
index 0000000..525a3a4
--- /dev/null
+++ b/tests/test_cases/deps/components/bar.cpp
@@ -0,0 +1,9 @@
+#include "bar.hpp"
+
+#include <iostream>
+#include <ostream>
+
+int bar(int x) {
+ std::cout << "bar(" << x << ")" << std::endl;
+ return x * 5;
+}
diff --git a/tests/test_cases/deps/components/bar.hpp b/tests/test_cases/deps/components/bar.hpp
new file mode 100644
index 0000000..63f851d
--- /dev/null
+++ b/tests/test_cases/deps/components/bar.hpp
@@ -0,0 +1,6 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+int bar(int);
+
+#endif
diff --git a/tests/test_cases/deps/components/foo.cpp b/tests/test_cases/deps/components/foo.cpp
new file mode 100644
index 0000000..163c6e2
--- /dev/null
+++ b/tests/test_cases/deps/components/foo.cpp
@@ -0,0 +1,10 @@
+#include "foo.hpp"
+
+#include "foodep.hpp"
+#include <iostream>
+#include <ostream>
+
+int foo(int x) {
+ std::cout << "foo(" << x << ")" << std::endl;
+ return foodep(x) + 7;
+}
diff --git a/tests/test_cases/deps/components/foo.hpp b/tests/test_cases/deps/components/foo.hpp
new file mode 100644
index 0000000..45c286c
--- /dev/null
+++ b/tests/test_cases/deps/components/foo.hpp
@@ -0,0 +1,8 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+#include "foodep.hpp"
+
+foo_t foo(foo_t);
+
+#endif
diff --git a/tests/test_cases/deps/components/foodep.cpp b/tests/test_cases/deps/components/foodep.cpp
new file mode 100644
index 0000000..e26c335
--- /dev/null
+++ b/tests/test_cases/deps/components/foodep.cpp
@@ -0,0 +1,9 @@
+#include "foodep.hpp"
+
+#include <iostream>
+#include <ostream>
+
+foo_t foodep(foo_t x) {
+ std::cout << "foodep(" << x << ")" << std::endl;
+ return x + 2;
+}
diff --git a/tests/test_cases/deps/components/foodep.hpp b/tests/test_cases/deps/components/foodep.hpp
new file mode 100644
index 0000000..ea16bb0
--- /dev/null
+++ b/tests/test_cases/deps/components/foodep.hpp
@@ -0,0 +1,8 @@
+#ifndef FOODEP_HPP
+#define FOODEP_HPP
+
+typedef int foo_t;
+
+foo_t foodep(foo_t);
+
+#endif
diff --git a/tests/test_cases/deps/components/main.cpp b/tests/test_cases/deps/components/main.cpp
new file mode 100644
index 0000000..b6734a2
--- /dev/null
+++ b/tests/test_cases/deps/components/main.cpp
@@ -0,0 +1,10 @@
+#include "foo.hpp"
+#include "bar.hpp"
+
+#include <iostream>
+#include <ostream>
+
+int main(int argc, char **argv) {
+ std::cout << "Hello-from-main" << std::endl;
+ std::cout << foo(bar(3)) << std::endl;
+}
diff --git a/tests/test_cases/deps/install/TARGETS b/tests/test_cases/deps/install/TARGETS
new file mode 100644
index 0000000..232827d
--- /dev/null
+++ b/tests/test_cases/deps/install/TARGETS
@@ -0,0 +1,67 @@
+{ "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": "'"
+ , "$1": {"DEBUG": {"USE_DEBUG_FISSION": false}, "ADD_CXXFLAGS": ["-g"]}
+ }
+ }
+, "main debug":
+ { "type": "configure"
+ , "target": "main"
+ , "config":
+ { "type": "'"
+ , "$1": {"DEBUG": {"USE_DEBUG_FISSION": false}, "ADD_CXXFLAGS": ["-g"]}
+ }
+ }
+, "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/lint/TARGETS b/tests/test_cases/deps/lint/TARGETS
new file mode 100644
index 0000000..425815b
--- /dev/null
+++ b/tests/test_cases/deps/lint/TARGETS
@@ -0,0 +1,78 @@
+{ "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "deps": ["foodep"]
+ , "components": ["bar"]
+ }
+, "foodep":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foodep"]
+ , "hdrs": ["foodep.hpp"]
+ , "srcs": ["foodep.cpp"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "deps": ["bardep"]
+ }
+, "bardep":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bardep"]
+ , "hdrs": ["bardep.hpp"]
+ , "srcs": ["bardep.cpp"]
+ }
+, "plain":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["plain"]
+ , "arguments_config": ["TEST_SHARED"]
+ , "shared":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "TEST_SHARED"}
+ , "then": ["yes"]
+ }
+ , "hdrs": ["plain.hpp"]
+ , "srcs": ["plain.cpp"]
+ , "deps": ["foo"]
+ }
+, "main":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["plain"]
+ }
+, "test":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["test"]
+ , "test": ["check-main.sh"]
+ , "deps": ["main"]
+ }
+, "suite":
+ { "type": ["@", "rules", "test", "suite"]
+ , "deps": ["test"]
+ , "stage": ["suite"]
+ }
+, "lint":
+ { "type": ["@", "rules", "lint", "targets"]
+ , "targets": ["suite"]
+ , "tainted": ["test"]
+ , "linter": ["pretend_lint.py"]
+ , "summarizer": ["summary.py"]
+ }
+, "lint-shared":
+ { "type": "configure"
+ , "target": "lint"
+ , "tainted": ["lint", "test"]
+ , "config": {"type": "singleton_map", "key": "TEST_SHARED", "value": true}
+ }
+, "test-shared":
+ { "type": "configure"
+ , "target": "test"
+ , "tainted": ["test"]
+ , "config": {"type": "singleton_map", "key": "TEST_SHARED", "value": true}
+ }
+, "verifier": {"type": "install", "files": {"expect": "expect.py"}}
+}
diff --git a/tests/test_cases/deps/lint/bar.cpp b/tests/test_cases/deps/lint/bar.cpp
new file mode 100644
index 0000000..437619c
--- /dev/null
+++ b/tests/test_cases/deps/lint/bar.cpp
@@ -0,0 +1,10 @@
+#include "bar.hpp"
+
+#include "bardep.hpp"
+#include <iostream>
+#include <ostream>
+
+int bar(int x) {
+ std::cout << "bar(" << x << ")" << std::endl;
+ return bardep(x) * 7;
+}
diff --git a/tests/test_cases/deps/lint/bar.hpp b/tests/test_cases/deps/lint/bar.hpp
new file mode 100644
index 0000000..e29bfd7
--- /dev/null
+++ b/tests/test_cases/deps/lint/bar.hpp
@@ -0,0 +1,8 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+#include "bardep.hpp"
+
+bar_t bar(bar_t);
+
+#endif
diff --git a/tests/test_cases/deps/lint/bardep.cpp b/tests/test_cases/deps/lint/bardep.cpp
new file mode 100644
index 0000000..33931da
--- /dev/null
+++ b/tests/test_cases/deps/lint/bardep.cpp
@@ -0,0 +1,9 @@
+#include "bardep.hpp"
+
+#include <iostream>
+#include <ostream>
+
+bar_t bardep(bar_t x) {
+ std::cout << "bardep(" << x << ")" << std::endl;
+ return x + 5;
+}
diff --git a/tests/test_cases/deps/lint/bardep.hpp b/tests/test_cases/deps/lint/bardep.hpp
new file mode 100644
index 0000000..ebfaef4
--- /dev/null
+++ b/tests/test_cases/deps/lint/bardep.hpp
@@ -0,0 +1,8 @@
+#ifndef BARDEP_HPP
+#define BARDEP_HPP
+
+typedef int bar_t;
+
+bar_t bardep(bar_t);
+
+#endif
diff --git a/tests/test_cases/deps/lint/check-main.sh b/tests/test_cases/deps/lint/check-main.sh
new file mode 100644
index 0000000..1705968
--- /dev/null
+++ b/tests/test_cases/deps/lint/check-main.sh
@@ -0,0 +1,3 @@
+set -eu
+
+./main | grep result:
diff --git a/tests/test_cases/deps/lint/expect.py b/tests/test_cases/deps/lint/expect.py
new file mode 100755
index 0000000..d26343d
--- /dev/null
+++ b/tests/test_cases/deps/lint/expect.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+import json
+import os
+import sys
+
+with open(sys.argv[1]) as f:
+ invocations = json.load(f)
+
+expected = set(sys.argv[2:])
+found = set()
+
+for name, cmd in invocations.items():
+ print("- %s compiled as %r" % (name, cmd))
+ found.add(os.path.basename(name))
+
+if expected != found:
+ print()
+ print("Found: %r" % (found,))
+ print("missing:%r" % (expected - found,))
+ print("unexpected: %r" % (found - expected,))
+ sys.exit(1)
+else:
+ print("OK")
diff --git a/tests/test_cases/deps/lint/foo.cpp b/tests/test_cases/deps/lint/foo.cpp
new file mode 100644
index 0000000..197e1fb
--- /dev/null
+++ b/tests/test_cases/deps/lint/foo.cpp
@@ -0,0 +1,10 @@
+#include "foo.hpp"
+
+#include "foodep.hpp"
+#include <iostream>
+#include <ostream>
+
+int foo(int x) {
+ std::cout << "foo(" << x << ")" << std::endl;
+ return foodep(x) * 3;
+}
diff --git a/tests/test_cases/deps/lint/foo.hpp b/tests/test_cases/deps/lint/foo.hpp
new file mode 100644
index 0000000..45c286c
--- /dev/null
+++ b/tests/test_cases/deps/lint/foo.hpp
@@ -0,0 +1,8 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+#include "foodep.hpp"
+
+foo_t foo(foo_t);
+
+#endif
diff --git a/tests/test_cases/deps/lint/foodep.cpp b/tests/test_cases/deps/lint/foodep.cpp
new file mode 100644
index 0000000..e26c335
--- /dev/null
+++ b/tests/test_cases/deps/lint/foodep.cpp
@@ -0,0 +1,9 @@
+#include "foodep.hpp"
+
+#include <iostream>
+#include <ostream>
+
+foo_t foodep(foo_t x) {
+ std::cout << "foodep(" << x << ")" << std::endl;
+ return x + 2;
+}
diff --git a/tests/test_cases/deps/lint/foodep.hpp b/tests/test_cases/deps/lint/foodep.hpp
new file mode 100644
index 0000000..ea16bb0
--- /dev/null
+++ b/tests/test_cases/deps/lint/foodep.hpp
@@ -0,0 +1,8 @@
+#ifndef FOODEP_HPP
+#define FOODEP_HPP
+
+typedef int foo_t;
+
+foo_t foodep(foo_t);
+
+#endif
diff --git a/tests/test_cases/deps/lint/main.cpp b/tests/test_cases/deps/lint/main.cpp
new file mode 100644
index 0000000..7453eb9
--- /dev/null
+++ b/tests/test_cases/deps/lint/main.cpp
@@ -0,0 +1,9 @@
+#include "plain.hpp"
+
+#include <iostream>
+#include <ostream>
+
+int main(int argc, char **argv) {
+ std::cout << "result: " << foobar(1) << std::endl;
+ return 0;
+}
diff --git a/tests/test_cases/deps/lint/plain.cpp b/tests/test_cases/deps/lint/plain.cpp
new file mode 100644
index 0000000..1db123f
--- /dev/null
+++ b/tests/test_cases/deps/lint/plain.cpp
@@ -0,0 +1,5 @@
+#include "plain.hpp"
+
+bar_t foobar(foo_t x) {
+ return bar(static_cast<bar_t>(foo(x)));
+}
diff --git a/tests/test_cases/deps/lint/plain.hpp b/tests/test_cases/deps/lint/plain.hpp
new file mode 100644
index 0000000..20b84f5
--- /dev/null
+++ b/tests/test_cases/deps/lint/plain.hpp
@@ -0,0 +1,9 @@
+#ifndef PLAIN_HPP
+#define PLAIN_HPP
+
+#include "foo.hpp"
+#include "bar.hpp"
+
+bar_t foobar(foo_t);
+
+#endif
diff --git a/tests/test_cases/deps/lint/pretend_lint.py b/tests/test_cases/deps/lint/pretend_lint.py
new file mode 100755
index 0000000..c84285b
--- /dev/null
+++ b/tests/test_cases/deps/lint/pretend_lint.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import json
+import os
+import subprocess
+import sys
+
+# log the invocation
+with open(os.path.join(os.environ["OUT"], "invocation.json"), "w") as f:
+ json.dump(sys.argv[1:], f)
+
+# verify the given command succeeds
+result = subprocess.run(sys.argv[2:])
+
+sys.exit(result.returncode)
diff --git a/tests/test_cases/deps/lint/summary.py b/tests/test_cases/deps/lint/summary.py
new file mode 100755
index 0000000..361f681
--- /dev/null
+++ b/tests/test_cases/deps/lint/summary.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+import json
+import os
+import sys
+
+status = 0
+invocations = {}
+
+for lint in sorted(os.listdir()):
+ if os.path.isdir(lint):
+ with open(os.path.join(lint, "result")) as f:
+ result = f.read().strip()
+ if result != "PASS":
+ status = 1
+ with open(os.path.join(lint, "stdout")) as f:
+ print(f.read())
+ with open(os.path.join(lint, "stderr")) as f:
+ print(f.read())
+ with open(os.path.join(lint, "out/invocation.json")) as f:
+ invocation = json.load(f)
+ invocations[invocation[0]] = invocation[1:]
+
+with open(os.path.join(os.environ["OUT"], "invocations.json"), "w") as f:
+ json.dump(invocations, f)
+
+sys.exit(status)
diff --git a/tests/test_cases/deps/object/TARGETS b/tests/test_cases/deps/object/TARGETS
new file mode 100644
index 0000000..412d2ea
--- /dev/null
+++ b/tests/test_cases/deps/object/TARGETS
@@ -0,0 +1,49 @@
+{ "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "shared": ["yes"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "deps": ["bar"]
+ , "stage": ["foo"]
+ }
+, "bar":
+ { "type": "configure"
+ , "target": "bar (plain)"
+ , "config":
+ {"type": "singleton_map", "key": "BUILD_OBJECT_ONLY", "value": "true"}
+ }
+, "bar (plain)":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "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_cases/deps/transitive-components/TARGETS b/tests/test_cases/deps/transitive-components/TARGETS
new file mode 100644
index 0000000..347b94c
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/TARGETS
@@ -0,0 +1,64 @@
+{ "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "deps": ["foodep"]
+ , "components": ["bar"]
+ }
+, "foodep":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foodep"]
+ , "hdrs": ["foodep.hpp"]
+ , "srcs": ["foodep.cpp"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "deps": ["bardep"]
+ , "components": ["baz"]
+ }
+, "bardep":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bardep"]
+ , "hdrs": ["bardep.hpp"]
+ , "srcs": ["bardep.cpp"]
+ }
+, "baz":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["baz"]
+ , "hdrs": ["baz.hpp"]
+ , "srcs": ["baz.cpp"]
+ , "deps": ["bazdep"]
+ }
+, "bazdep":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bazdep"]
+ , "hdrs": ["bazdep.hpp"]
+ , "srcs": ["bazdep.cpp"]
+ }
+, "main":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["foo"]
+ }
+, "shared-foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "shared": [""]
+ , "components": ["foo"]
+ }
+, "shared-main":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["shared-foo"]
+ }
+, "installed-shared-main":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["shared-main"]
+ }
+}
diff --git a/tests/test_cases/deps/transitive-components/bar.cpp b/tests/test_cases/deps/transitive-components/bar.cpp
new file mode 100644
index 0000000..437619c
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bar.cpp
@@ -0,0 +1,10 @@
+#include "bar.hpp"
+
+#include "bardep.hpp"
+#include <iostream>
+#include <ostream>
+
+int bar(int x) {
+ std::cout << "bar(" << x << ")" << std::endl;
+ return bardep(x) * 7;
+}
diff --git a/tests/test_cases/deps/transitive-components/bar.hpp b/tests/test_cases/deps/transitive-components/bar.hpp
new file mode 100644
index 0000000..e29bfd7
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bar.hpp
@@ -0,0 +1,8 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+#include "bardep.hpp"
+
+bar_t bar(bar_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/bardep.cpp b/tests/test_cases/deps/transitive-components/bardep.cpp
new file mode 100644
index 0000000..33931da
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bardep.cpp
@@ -0,0 +1,9 @@
+#include "bardep.hpp"
+
+#include <iostream>
+#include <ostream>
+
+bar_t bardep(bar_t x) {
+ std::cout << "bardep(" << x << ")" << std::endl;
+ return x + 5;
+}
diff --git a/tests/test_cases/deps/transitive-components/bardep.hpp b/tests/test_cases/deps/transitive-components/bardep.hpp
new file mode 100644
index 0000000..ebfaef4
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bardep.hpp
@@ -0,0 +1,8 @@
+#ifndef BARDEP_HPP
+#define BARDEP_HPP
+
+typedef int bar_t;
+
+bar_t bardep(bar_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/baz.cpp b/tests/test_cases/deps/transitive-components/baz.cpp
new file mode 100644
index 0000000..0354d55
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/baz.cpp
@@ -0,0 +1,10 @@
+#include "baz.hpp"
+
+#include "bazdep.hpp"
+#include <iostream>
+#include <ostream>
+
+int baz(int x) {
+ std::cout << "baz(" << x << ")" << std::endl;
+ return bazdep(x) * 13;
+}
diff --git a/tests/test_cases/deps/transitive-components/baz.hpp b/tests/test_cases/deps/transitive-components/baz.hpp
new file mode 100644
index 0000000..926dd6d
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/baz.hpp
@@ -0,0 +1,8 @@
+#ifndef BAZ_HPP
+#define BAZ_HPP
+
+#include "bazdep.hpp"
+
+baz_t baz(baz_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/bazdep.cpp b/tests/test_cases/deps/transitive-components/bazdep.cpp
new file mode 100644
index 0000000..c097661
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bazdep.cpp
@@ -0,0 +1,9 @@
+#include "bazdep.hpp"
+
+#include <iostream>
+#include <ostream>
+
+baz_t bazdep(baz_t x) {
+ std::cout << "bazdep(" << x << ")" << std::endl;
+ return x + 11;
+}
diff --git a/tests/test_cases/deps/transitive-components/bazdep.hpp b/tests/test_cases/deps/transitive-components/bazdep.hpp
new file mode 100644
index 0000000..d2add97
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bazdep.hpp
@@ -0,0 +1,8 @@
+#ifndef BAZDEP_HPP
+#define BAZDEP_HPP
+
+typedef int baz_t;
+
+baz_t bazdep(baz_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/foo.cpp b/tests/test_cases/deps/transitive-components/foo.cpp
new file mode 100644
index 0000000..197e1fb
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/foo.cpp
@@ -0,0 +1,10 @@
+#include "foo.hpp"
+
+#include "foodep.hpp"
+#include <iostream>
+#include <ostream>
+
+int foo(int x) {
+ std::cout << "foo(" << x << ")" << std::endl;
+ return foodep(x) * 3;
+}
diff --git a/tests/test_cases/deps/transitive-components/foo.hpp b/tests/test_cases/deps/transitive-components/foo.hpp
new file mode 100644
index 0000000..45c286c
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/foo.hpp
@@ -0,0 +1,8 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+#include "foodep.hpp"
+
+foo_t foo(foo_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/foodep.cpp b/tests/test_cases/deps/transitive-components/foodep.cpp
new file mode 100644
index 0000000..e26c335
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/foodep.cpp
@@ -0,0 +1,9 @@
+#include "foodep.hpp"
+
+#include <iostream>
+#include <ostream>
+
+foo_t foodep(foo_t x) {
+ std::cout << "foodep(" << x << ")" << std::endl;
+ return x + 2;
+}
diff --git a/tests/test_cases/deps/transitive-components/foodep.hpp b/tests/test_cases/deps/transitive-components/foodep.hpp
new file mode 100644
index 0000000..ea16bb0
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/foodep.hpp
@@ -0,0 +1,8 @@
+#ifndef FOODEP_HPP
+#define FOODEP_HPP
+
+typedef int foo_t;
+
+foo_t foodep(foo_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/main.cpp b/tests/test_cases/deps/transitive-components/main.cpp
new file mode 100644
index 0000000..3e2ae1c
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/main.cpp
@@ -0,0 +1,11 @@
+#include "foo.hpp"
+#include "bar.hpp"
+#include "baz.hpp"
+
+#include <iostream>
+#include <ostream>
+
+int main(int argc, char **argv) {
+ std::cout << "Hello-from-main" << std::endl;
+ std::cout << foo(bar(baz(13))) << std::endl;
+}
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)