diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-12-12 18:20:57 +0100 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-12-16 12:05:27 +0100 |
commit | e284a92750538653b0c9824ee035a8e0992ebb05 (patch) | |
tree | 3cdcb3e60e58f12a3ccccab6dcd426048cc05c40 /doc | |
parent | fb7bf97e680f97833268c7bb4c8220a3cf58e297 (diff) | |
download | justbuild-e284a92750538653b0c9824ee035a8e0992ebb05.tar.gz |
tutorial: Use rules-cc from public Git repository
Diffstat (limited to 'doc')
-rw-r--r-- | doc/tutorial/getting-started.org | 24 | ||||
-rw-r--r-- | doc/tutorial/hello-world.org | 44 | ||||
-rw-r--r-- | doc/tutorial/target-file-glob-tree.org | 4 | ||||
-rw-r--r-- | doc/tutorial/third-party-software.org | 77 |
4 files changed, 78 insertions, 71 deletions
diff --git a/doc/tutorial/getting-started.org b/doc/tutorial/getting-started.org index 1573a8b9..3dc48511 100644 --- a/doc/tutorial/getting-started.org +++ b/doc/tutorial/getting-started.org @@ -145,19 +145,14 @@ any problem, add a second target also generating a file ~out.txt~. #+SRCNAME: TARGETS #+BEGIN_SRC js -{ "greeter": - { "type": "generic" - , "cmds": ["echo -n 'Hello ' > out.txt", "cat name.txt >> out.txt"] - , "outs": ["out.txt"] - , "deps": ["name.txt"] - } +... , "upper": { "type": "generic" , "cmds": ["cat name.txt | tr a-z A-Z > out.txt"] , "outs": ["out.txt"] , "deps": ["name.txt"] } -} +... #+END_SRC As we only request targets, no conflicts arise. @@ -196,21 +191,10 @@ argument ~"files"~ can be used to map that file to a new location. #+SRCNAME: TARGETS #+BEGIN_SRC js -{ "greeter": - { "type": "generic" - , "cmds": ["echo -n 'Hello ' > out.txt", "cat name.txt >> out.txt"] - , "outs": ["out.txt"] - , "deps": ["name.txt"] - } -, "upper": - { "type": "generic" - , "cmds": ["cat name.txt | tr a-z A-Z > out.txt"] - , "outs": ["out.txt"] - , "deps": ["name.txt"] - } +... , "both": {"type": "install", "files": {"hello.txt": "greeter", "upper.txt": "upper"}} -} +... #+END_SRC #+BEGIN_SRC sh diff --git a/doc/tutorial/hello-world.org b/doc/tutorial/hello-world.org index 4f4f318b..9a680b30 100644 --- a/doc/tutorial/hello-world.org +++ b/doc/tutorial/hello-world.org @@ -7,10 +7,6 @@ rather provided via a set of rules. These rules can be specified as a true dependency to your project like any other external repository your project might depend on. -For the remainder of this tutorial, we will use the rules provided in the -open-source repository of justbuild, which we assume is checked out to the path -~/tmp/justbuild~. - ** Setting up the Multi-Repository Configuration To build a project with multi-repository dependencies, we first need to provide @@ -29,12 +25,18 @@ in the workspace root: #+BEGIN_SRC js { "main": "tutorial" , "repositories": - { "just-rules": - { "repository": {"type": "file", "path": "/tmp/justbuild/rules"} + { "rules-cc": + { "repository": + { "type": "git" + , "branch": "master" + , "commit": "886c7b680928276d7f925d30fc206ca27d9a97d1" + , "repository": "https://github.com/just-buildsystem/rules-cc.git" + , "subdir": "rules" + } } , "tutorial": { "repository": {"type": "file", "path": "."} - , "bindings": {"rules": "just-rules"} + , "bindings": {"rules": "rules-cc"} } } } @@ -42,14 +44,16 @@ in the workspace root: In that configuration, two repositories are defined: - 1. The ~"just-rules"~ repository located at ~/tmp/justbuild/rules~, which - contains the high-level concepts for building C/C++ binaries and libraries. + 1. The ~"rules-cc"~ repository located in the subdirectory ~rules~ of + [[https://github.com/just-buildsystem/rules-cc/tree/886c7b680928276d7f925d30fc206ca27d9a97d1][just-buildsystem/rules-cc:886c7b680928276d7f925d30fc206ca27d9a97d1]], + which contains the high-level concepts for building C/C++ binaries and + libraries. 2. The ~"tutorial"~ repository located at ~.~, which contains the targets that we want to build. It has a single dependency, which is the /rules/ that are needed to build the target. These rules are bound via the open name - ~"rules"~ to the just created repository ~"just-rules"~. In this way, the - entities provided by ~"just-rules"~ can be accessed from within the + ~"rules"~ to the just created repository ~"rules-cc"~. In this way, the + entities provided by ~"rules-cc"~ can be accessed from within the ~"tutorial"~ repository via the fully-qualified name ~["@", "rules", "<module>", "<name>"]~; fully-qualified names (for rules, targets to build (like libraries, binaries), @@ -206,14 +210,20 @@ following content: #+BEGIN_SRC js { "main": "tutorial" , "repositories": - { "just-rules": - { "repository": {"type": "file", "path": "/tmp/justbuild/rules"} + { "rules-cc": + { "repository": + { "type": "git" + , "branch": "master" + , "commit": "886c7b680928276d7f925d30fc206ca27d9a97d1" + , "repository": "https://github.com/just-buildsystem/rules-cc.git" + , "subdir": "rules" + } , "target_root": "tutorial-defaults" - , "rule_root": "just-rules" + , "rule_root": "rules-cc" } , "tutorial": { "repository": {"type": "file", "path": "."} - , "bindings": {"rules": "just-rules"} + , "bindings": {"rules": "rules-cc"} } , "tutorial-defaults": { "repository": {"type": "file", "path": "./tutorial-defaults"} @@ -225,8 +235,8 @@ following content: Note that the ~"defaults"~ target uses the rule ~["CC", "defaults"]~ without specifying any external repository (e.g., ~["@", "rules", ...]~). This is because ~"tutorial-defaults"~ is not a full-fledged repository but merely a file -root that is considered local to the ~"just-rules"~ repository. In fact, the -~"just-rules"~ repository cannot refer to any external repository as it does not +root that is considered local to the ~"rules-cc"~ repository. In fact, the +~"rules-cc"~ repository cannot refer to any external repository as it does not have any defined bindings. To rebuild the project, we need to rerun ~just-mr~ (note that due to diff --git a/doc/tutorial/target-file-glob-tree.org b/doc/tutorial/target-file-glob-tree.org index 486bbd16..0337c558 100644 --- a/doc/tutorial/target-file-glob-tree.org +++ b/doc/tutorial/target-file-glob-tree.org @@ -23,7 +23,7 @@ with the following content. #+BEGIN_SRC js { "main": "units" , "repositories": - { "just-rules":{ /* ... unchanged ... */ } + { "rules-cc":{ /* ... unchanged ... */ } , "import targets": {"repository": {"type": "file", "path": "."}} , "patches": {"repository": {"type": "file", "path": "files"}} , "units": @@ -35,7 +35,7 @@ with the following content. } , "target_root": "import targets" , "target_file_name": "TARGETS.units" - , "bindings": {"rules": "just-rules", "patches": "patches"} + , "bindings": {"rules": "rules-cc", "patches": "patches"} } } } diff --git a/doc/tutorial/third-party-software.org b/doc/tutorial/third-party-software.org index 6fdde256..4d06cecc 100644 --- a/doc/tutorial/third-party-software.org +++ b/doc/tutorial/third-party-software.org @@ -7,7 +7,9 @@ relying on the integration of out-of-band binary distributions. justbuild offers a flexible approach to provide the required build description via an overlay layer without the need to touch the original code base. -In the remainder of this section, we will use the open-source project +For the remainder of this section, we expect to have the project files available +resulting from successfully completing the tutorial section on /Building C++ +Hello World/. We will demonstrate how to use the open-source project [[https://github.com/fmtlib/fmt][fmtlib]] as an example for integrating third-party software to a justbuild project. @@ -136,12 +138,20 @@ therefore need to introduce an additional binding ~"format"~ for it: #+BEGIN_SRC js { "main": "tutorial" , "repositories": - { "just-rules": - { "repository": {"type": "file", "path": "/tmp/justbuild/rules"} + { "rules-cc": + { "repository": + { "type": "git" + , "branch": "master" + , "commit": "886c7b680928276d7f925d30fc206ca27d9a97d1" + , "repository": "https://github.com/just-buildsystem/rules-cc.git" + , "subdir": "rules" + } + , "target_root": "tutorial-defaults" + , "rule_root": "rules-cc" } , "tutorial": { "repository": {"type": "file", "path": "."} - , "bindings": {"rules": "just-rules", "format": "fmtlib"} + , "bindings": {"rules": "rules-cc", "format": "fmtlib"} } , "tutorial-defaults": { "repository": {"type": "file", "path": "./tutorial-defaults"} @@ -157,7 +167,7 @@ therefore need to introduce an additional binding ~"format"~ for it: , "repository": "https://github.com/fmtlib/fmt.git" } , "target_root": "fmt-targets-layer" - , "bindings": {"rules": "just-rules"} + , "bindings": {"rules": "rules-cc"} } } } @@ -199,11 +209,11 @@ $ just-mr build helloworld INFO: Requested target is [["@","tutorial","","helloworld"],{}] INFO: Analysed target [["@","tutorial","","helloworld"],{}] INFO: Export targets found: 0 cached, 0 uncached, 1 not eligible for caching -INFO: Discovered 7 actions, 4 trees, 0 blobs +INFO: Discovered 7 actions, 3 trees, 0 blobs INFO: Building [["@","tutorial","","helloworld"],{}]. -INFO: Processed 7 actions, 0 cache hits. +INFO: Processed 7 actions, 1 cache hits. INFO: Artifacts built, logical paths are: - helloworld [ccca0c1aa443e5b2adce16949de24b50d6826636:324432:x] + helloworld [0ec4e36cfb5f2c3efa0fff789349a46694a6d303:132736:x] $ #+END_SRC @@ -214,11 +224,11 @@ $ just-mr --main fmtlib build fmt INFO: Requested target is [["@","fmtlib","","fmt"],{}] INFO: Analysed target [["@","fmtlib","","fmt"],{}] INFO: Export targets found: 0 cached, 0 uncached, 1 not eligible for caching -INFO: Discovered 3 actions, 2 trees, 0 blobs +INFO: Discovered 3 actions, 1 trees, 0 blobs INFO: Building [["@","fmtlib","","fmt"],{}]. INFO: Processed 3 actions, 3 cache hits. INFO: Artifacts built, logical paths are: - libfmt.a [14c5156a6a988f417928970e750c8c8f928460ab:863452:f] + libfmt.a [513b2ac17c557675fc841f3ebf279003ff5a73ae:240914:f] (1 runfiles omitted.) $ #+END_SRC @@ -228,9 +238,9 @@ $ The make use of high-level target caching for exported targets, we need to ensure that all inputs to an export target are transitively content-fixed. This is automatically the case for ~"type":"git"~ repositories. However, the ~libfmt~ -repository also depends on ~"fmt-target-layer"~, ~"just-rules"~, and -~"tutorial-defaults"~. As those are ~"type":"file"~ repositories, they must be -put under Git versioning first: +repository also depends on ~"rules-cc"~, ~"tutorial-defaults"~, and +~"fmt-target-layer"~. As the latter two are ~"type":"file"~ repositories, they +must be put under Git versioning first: #+BEGIN_SRC sh $ git init . @@ -238,8 +248,7 @@ $ git add tutorial-defaults fmt-layer $ git commit -m"fix compile flags and fmt targets layer" #+END_SRC -Note that ~just-rules~ already is under Git versioning as it is a subtree of the -checked out justbuild repository. +Note that ~rules-cc~ already is under Git versioning. Now, to instruct ~just-mr~ to use the content-fixed, committed source trees of those ~"type":"file"~ repositories the pragma ~"to_git"~ must be set for them in @@ -249,18 +258,20 @@ those ~"type":"file"~ repositories the pragma ~"to_git"~ must be set for them in #+BEGIN_SRC js { "main": "tutorial" , "repositories": - { "just-rules": + { "rules-cc": { "repository": - { "type": "file" - , "path": "/tmp/justbuild/rules" - , "pragma": {"to_git": true} + { "type": "git" + , "branch": "master" + , "commit": "886c7b680928276d7f925d30fc206ca27d9a97d1" + , "repository": "https://github.com/just-buildsystem/rules-cc.git" + , "subdir": "rules" } , "target_root": "tutorial-defaults" - , "rule_root": "just-rules" + , "rule_root": "rules-cc" } , "tutorial": { "repository": {"type": "file", "path": "."} - , "bindings": {"rules": "just-rules", "format": "fmtlib"} + , "bindings": {"rules": "rules-cc", "format": "fmtlib"} } , "tutorial-defaults": { "repository": @@ -284,7 +295,7 @@ those ~"type":"file"~ repositories the pragma ~"to_git"~ must be set for them in , "repository": "https://github.com/fmtlib/fmt.git" } , "target_root": "fmt-targets-layer" - , "bindings": {"rules": "just-rules"} + , "bindings": {"rules": "rules-cc"} } } } @@ -298,9 +309,9 @@ $ just-mr build helloworld INFO: Requested target is [["@","tutorial","","helloworld"],{}] INFO: Analysed target [["@","tutorial","","helloworld"],{}] INFO: Export targets found: 0 cached, 1 uncached, 0 not eligible for caching -INFO: Discovered 7 actions, 4 trees, 0 blobs +INFO: Discovered 7 actions, 3 trees, 0 blobs INFO: Building [["@","tutorial","","helloworld"],{}]. -INFO: Processed 7 actions, 0 cache hits. +INFO: Processed 7 actions, 7 cache hits. INFO: Artifacts built, logical paths are: helloworld [0ec4e36cfb5f2c3efa0fff789349a46694a6d303:132736:x] $ @@ -357,18 +368,20 @@ defines the overlay ~"common-targets-layer"~, which is used by ~"fmtlib"~ and #+BEGIN_SRC js { "main": "tutorial" , "repositories": - { "just-rules": + { "rules-cc": { "repository": - { "type": "file" - , "path": "/tmp/justbuild/rules" - , "pragma": {"to_git": true} + { "type": "git" + , "branch": "master" + , "commit": "886c7b680928276d7f925d30fc206ca27d9a97d1" + , "repository": "https://github.com/just-buildsystem/rules-cc.git" + , "subdir": "rules" } , "target_root": "tutorial-defaults" - , "rule_root": "just-rules" + , "rule_root": "rules-cc" } , "tutorial": { "repository": {"type": "file", "path": "."} - , "bindings": {"rules": "just-rules", "format": "fmtlib"} + , "bindings": {"rules": "rules-cc", "format": "fmtlib"} } , "tutorial-defaults": { "repository": @@ -393,7 +406,7 @@ defines the overlay ~"common-targets-layer"~, which is used by ~"fmtlib"~ and } , "target_root": "common-targets-layer" , "target_file_name": "TARGETS.fmt" - , "bindings": {"rules": "just-rules"} + , "bindings": {"rules": "rules-cc"} } , "gsl-lite": { "repository": @@ -404,7 +417,7 @@ defines the overlay ~"common-targets-layer"~, which is used by ~"fmtlib"~ and } , "target_root": "common-targets-layer" , "target_file_name": "TARGETS.gsl" - , "bindings": {"rules": "just-rules"} + , "bindings": {"rules": "rules-cc"} } } } |