Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: generalize the handling of the UNIT_TEST_OBJS list #1797

Closed

Conversation

dscho
Copy link
Member

@dscho dscho commented Sep 18, 2024

This is an add-on for ps/reftable-exclude to let it build with CMake and Visual C.

This patch on its own does not actually fix vs-build; The patch "cmake: stop looking for REFTABLE_TEST_OBJS in the Makefile" which I submitted in https://lore.kernel.org/git/pull.1796.git.1726687400286.gitgitgadget@gmail.com is also needed for a successful vs-build.

In a15d446 (cmake: also build unit tests, 2023-09-25), I
accommodated the CMake definition. Seeing that a `UNIT_TEST_OBJS` list
was introduced that was built by transforming the `UNIT_TEST_PROGRAMS`
list and then adding a single, hard-coded file
("t/unit-tests/test-lib.c"), I decided to hard-code that in the CMake
definition, too.

The reason why I hard-coded it instead of imitating the
`parse_makefile_for_sources()` paradigm that was used elsewhere when
using the `Makefile` as source of truth for given lists of files: This
function expects _only_ hard-coded values, and that transformed
`UNIT_TEST_PROGRAMS` list complicated everything.

In 8727215 (cmake: fix build of `t-oidtree`, 2024-07-12), I
accommodated the CMake definition again, after seeing that the
`UNIT_TEST_OBJS` was still defined via that transformed list but now
appending _two_ hard-coded files ("t/unit-tests/lib-oid.c" joined the
fray).

In 428672a (Makefile: stop listing test library objects twice,
2024-09-16), the `Makefile` was changed so that `UNIT_TEST_OBJS` is
finally only constructed using hard-coded file names just like the other
`*_OBJS` variables. I missed that and therefore did not adjust the CMake
definition. Besides, the code was working, so there was no real need to
adjust it.

With a4f50bb (t/unit-tests: introduce reftable library, 2024-09-16),
however, the `UNIT_TEST_OBJS` list became a trio, and the CMake
definition has to be adjusted again. Now that we can use the
`parse_makefile_for_sources()` function without many complications,
let's do that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member Author

dscho commented Sep 18, 2024

/submit

Copy link

gitgitgadget bot commented Sep 18, 2024

Submitted as pull.1797.git.1726687769585.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1797/dscho/reftable-exclude+cmake-v1

To fetch this version to local tag pr-1797/dscho/reftable-exclude+cmake-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1797/dscho/reftable-exclude+cmake-v1

Copy link

gitgitgadget bot commented Sep 19, 2024

This patch series was integrated into seen via git@35b7d19.

@gitgitgadget gitgitgadget bot added the seen label Sep 19, 2024
Copy link

gitgitgadget bot commented Sep 19, 2024

This branch is now known as jc/cmake-unit-test-updates.

Copy link

gitgitgadget bot commented Sep 19, 2024

This patch series was integrated into seen via git@2c4e8a8.

Copy link

gitgitgadget bot commented Sep 19, 2024

This patch series was integrated into next via git@d892dcd.

@gitgitgadget gitgitgadget bot added the next label Sep 19, 2024
Copy link

gitgitgadget bot commented Sep 20, 2024

This patch series was integrated into seen via git@a452b34.

Copy link

gitgitgadget bot commented Sep 21, 2024

There was a status update in the "Cooking" section about the branch jc/cmake-unit-test-updates on the Git mailing list:

CMake adjustments for recent changes around unit tests.

Will merge to 'master'.
source: <pull.1797.git.1726687769585.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Sep 23, 2024

This patch series was integrated into seen via git@9a970bd.

Copy link

gitgitgadget bot commented Sep 23, 2024

There was a status update in the "Cooking" section about the branch jc/cmake-unit-test-updates on the Git mailing list:

CMake adjustments for recent changes around unit tests.

Will merge to 'master'.
source: <pull.1797.git.1726687769585.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Sep 24, 2024

On the Git mailing list, Junio C Hamano wrote (reply to this):

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> With a4f50bb1e9b (t/unit-tests: introduce reftable library, 2024-09-16),
> however, the `UNIT_TEST_OBJS` list became a trio, and the CMake
> definition has to be adjusted again. Now that we can use the
> `parse_makefile_for_sources()` function without many complications,
> let's do that.

Am I correct to understand that it is not "trio"-ness (has three
things) that makes the approach feasible, but the fact that all
three things are concrete values?

The longer-term aspiration is to migrate everything to clar-based
unit tests, so the list will hopefully keep getting shorter and then
become empty (https://lore.kernel.org/git/Zt_lLsnylKJ9uoqj@pks.im/).

Will queue.  Thanks.

Copy link

gitgitgadget bot commented Sep 24, 2024

This patch series was integrated into seen via git@1050870.

Copy link

gitgitgadget bot commented Sep 25, 2024

This patch series was integrated into seen via git@cbb5b53.

Copy link

gitgitgadget bot commented Sep 25, 2024

This patch series was integrated into master via git@cbb5b53.

Copy link

gitgitgadget bot commented Sep 25, 2024

This patch series was integrated into next via git@cbb5b53.

@gitgitgadget gitgitgadget bot added the master label Sep 25, 2024
Copy link

gitgitgadget bot commented Sep 25, 2024

Closed via cbb5b53.

@gitgitgadget gitgitgadget bot closed this Sep 25, 2024
@dscho dscho deleted the reftable-exclude+cmake branch September 25, 2024 20:19
Copy link

gitgitgadget bot commented Sep 29, 2024

On the Git mailing list, Johannes Schindelin wrote (reply to this):

Hi,

On Mon, 23 Sep 2024, Junio C Hamano wrote:

> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > With a4f50bb1e9b (t/unit-tests: introduce reftable library, 2024-09-16),
> > however, the `UNIT_TEST_OBJS` list became a trio, and the CMake
> > definition has to be adjusted again. Now that we can use the
> > `parse_makefile_for_sources()` function without many complications,
> > let's do that.
>
> Am I correct to understand that it is not "trio"-ness (has three
> things) that makes the approach feasible, but the fact that all
> three things are concrete values?

No, the fact that a third entry was added made it obvious that adding
hard-coded equivalents to the CMake definition is too much of a
whac-a-mole thing and that the `Makefile` parsing approach would be
preferable. With just two items, it was still kind of okay to duplicate
the list, but three is a trend.

> The longer-term aspiration is to migrate everything to clar-based
> unit tests, so the list will hopefully keep getting shorter and then
> become empty (https://lore.kernel.org/git/Zt_lLsnylKJ9uoqj@pks.im/).

Once it becomes empty, I will have to send another CMake-related patch
similar to when the `REFTABLE_TEST_OBJS` list went away, as the CMake
definition cannot handle such empty lists.

Ciao,
Johannes

Copy link

gitgitgadget bot commented Sep 30, 2024

On the Git mailing list, Junio C Hamano wrote (reply to this):

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>> The longer-term aspiration is to migrate everything to clar-based
>> unit tests, so the list will hopefully keep getting shorter and then
>> become empty (https://lore.kernel.org/git/Zt_lLsnylKJ9uoqj@pks.im/).
>
> Once it becomes empty, I will have to send another CMake-related patch
> similar to when the `REFTABLE_TEST_OBJS` list went away, as the CMake
> definition cannot handle such empty lists.

It may be ideal if all contributors learned and updated inputs to
all the build process options like cmake, make, and autoconf at the
same time as they futz with the code they build (in other words, a
change that makes such a list to empty includes cmake update), but
different people chipping in with help in their strong areas and
polishing the system as a whole as a collaborative effort is
probably the best practical alternative.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant