Crafter.Build/tests/SameNamedSources/fixture/names/b/Thing.cpp
Jorijn van der Graaf f9bd5333da
test(build): sources of one file name, and where their objects go
SameNamedSources builds configurations whose sources share file names,
on a fresh copy of its fixture outside the checkout, and runs what they
link. `names` is an executable of an a/Thing.cpp and a b/Thing.cpp, the
C sources a/unit.c and b/unit.c, a b/Thing.c beside the b/Thing.cpp and
a Thing.cpp in a directory beside the configuration's own; its program
prints what each returns, the first time and again after a header that
only a/Thing.cpp includes has changed and after b/Thing.cpp and
b/unit.c have. `registry` is a debug executable of an a/Self.cpp and a
b/Self.cpp that register themselves when the program starts, which
prints that each did so once. `things` is a static library of
a/Thing.cpp, b/Thing.cpp, b/Thing.c and the two unit.c, and
`things-app` a program of main.cpp and ../shared/Thing.cpp built on
it, which prints what `names` does. `outside` is a static library of
one C source that lies outside its configuration's directory and is
listed relative to the working directory, built from a working
directory with a space in its name; `llvm-ar t` lists its object.

ObjectPath asks the rule for the objects of sources without building
anything: in the configuration's directory and in directories of it,
of one file name in two directories, a .cpp, a .c and a .cu of one
name in one directory, outside the directory, and under a directory of
the configuration's own that is named objects-outside and holds the
whole path of the source outside. No two of them get one object. A
path spelled with . and .., a relative source, and a source of a
configuration whose path ends in a separator or is ./ are each given
the object of the file they lead to, and a .cppm, a .h and a file
without an extension are refused.

CudaCompile gains a static library of its kernel.cu and a kernel.c
beside it, whose archive lists kernel_source.o and kernel_cuda.o.

Before the fix SameNamedSources failed at the link of `names`, with
duplicate symbols, and of `things-app`, with undefined ones, and its
`registry` printed that one of the two sources had registered twice
and the other not at all. `outside` built before the fix as well, its
object lying in the build directory then: it is there for the path
the fix gives that object.
2026-11-19 11:02:39 +01:00

4 lines
123 B
C++

// SPDX-License-Identifier: LGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
int B() { return 2; }