From b92a060879caf1de82a60ff2980f70ac165ec1a8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 10 Jul 2020 07:25:34 +0200 Subject: Add support for project-local importation An import without a project name or with the same name as the importing project's is now treated as importation from the same project. For example, given the libhello project that exports the lib{hello} target, a buildfile for an executable in the same project instead of doing something like this: include ../libhello/ exe{hello}: ../libhello/lib{hello} Can now do this: import lib = libhello%lib{hello} Or: import lib = lib{hello} And then: exe{hello}: $lib Note that a target in project-local importation must still be exported in the project's export stub. In other words, project-local importation goes through the same mechanisms as normal import. --- doc/manual.cli | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'doc') diff --git a/doc/manual.cli b/doc/manual.cli index ba0aa63..483c61d 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -2601,6 +2601,34 @@ If no \c{export} directive is executed in an export stub then the build system assumes that the target is not exported by the project and issues appropriate diagnostics.| +Let's revisit the executable \c{buildfile} with which we started this section. +Recall that it is for an executable that depends on a library which resides +in the same project: + +\ +include ../libhello/ # Include lib{hello}. + +exe{hello}: {hxx cxx}{**} ../libhello/lib{hello} +\ + +If \c{lib{hello\}} is exported by this project, then instead of manually +including its \c{buildfile} we can use \i{project-local importation}: + +\ +import lib = lib{hello} + +exe{hello}: {hxx cxx}{**} $lib +\ + +The main advantage of project-local importation over inclusion is the ability +to move things around without having to adjust locations in multiple places +(the only place we need to do it is the export stub). This advantage becomes +noticeable in more complex projects with a large number of components. + +\N|An import is project-local if the target being imported has no project +name. Note that the target must still be exported in the project's export +stub. In other words, project-local importation use the same mechanism as the +normal import.| \h#intro-lib|Library Exportation and Versioning| -- cgit v1.1