| 1907 | } |
| 1908 | |
| 1909 | const fsdir* |
| 1910 | inject_fsdir_impl (target& t, bool prereq, bool parent) |
| 1911 | { |
| 1912 | tracer trace ("inject_fsdir"); |
| 1913 | |
| 1914 | // If t is a directory (name is empty), say foo/bar/, then t is bar and |
| 1915 | // its parent directory is foo/. |
| 1916 | // |
| 1917 | const dir_path& d (parent && t.name.empty () ? t.dir.directory () : t.dir); |
| 1918 | |
| 1919 | const scope& bs (t.ctx.scopes.find_out (d)); |
| 1920 | const scope* rs (bs.root_scope ()); |
| 1921 | |
| 1922 | // If root scope is NULL, then this can mean that we are out of any |
| 1923 | // project or if the directory is in src_root. In both cases we don't |
| 1924 | // inject anything unless explicitly requested. |
| 1925 | // |
| 1926 | // Note that we also used to bail out if this is the root of the |
| 1927 | // project. But that proved not to be such a great idea in case of |
| 1928 | // subprojects (e.g., tests/). |
| 1929 | // |
| 1930 | const fsdir* r (nullptr); |
| 1931 | |
| 1932 | if (rs != nullptr && !d.sub (rs->src_path ())) |
| 1933 | { |
| 1934 | l6 ([&]{trace << d << " for " << t;}); |
| 1935 | |
| 1936 | // Target is in the out tree, so out directory is empty. |
| 1937 | // |
| 1938 | r = &search<fsdir> (t, d, dir_path (), string (), nullptr, nullptr); |
| 1939 | } |
| 1940 | else if (prereq) |
| 1941 | { |
| 1942 | // See if one was mentioned explicitly. |
| 1943 | // |
| 1944 | for (const prerequisite& p: group_prerequisites (t)) |
| 1945 | { |
| 1946 | if (p.is_a<fsdir> ()) |
| 1947 | { |
| 1948 | const target& pt (search (t, p)); |
| 1949 | |
| 1950 | if (pt.dir == d) |
| 1951 | { |
| 1952 | r = &pt.as<fsdir> (); |
| 1953 | break; |
| 1954 | } |
| 1955 | } |
| 1956 | } |
| 1957 | } |
| 1958 | |
| 1959 | return r; |
| 1960 | } |
| 1961 | |
| 1962 | const fsdir* |
| 1963 | inject_fsdir (action a, target& t, bool match, bool prereq, bool parent) |
nothing calls this directly
no outgoing calls
no test coverage detected