Page MenuHomeFreeBSD

Mk/Uses/ninja.mk: Fix build error when both 'emacs' and 'ninja' are added to USES
AbandonedPublic

Authored by yasu on Dec 6 2020, 10:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 2 2024, 11:52 PM
Unknown Object (File)
Dec 22 2023, 12:35 AM
Unknown Object (File)
Dec 20 2023, 5:27 AM
Unknown Object (File)
Nov 19 2023, 7:52 AM
Unknown Object (File)
Nov 14 2023, 6:07 AM
Unknown Object (File)
Oct 13 2023, 3:43 PM
Unknown Object (File)
Oct 13 2023, 5:07 AM
Unknown Object (File)
Oct 11 2023, 6:35 PM

Details

Reviewers
None
Group Reviewers
portmgr
Summary
  • Fix build error when both 'emacs' and 'ninja' are added to USES.
  • Change custom targets of ports using ninja so they don't use MAKE_{ARGS,CMD,ENV}.
  • Always define DO_MAKE_TEST.
Test Plan

Test with exp-run.

Diff Detail

Repository
rP FreeBSD ports repository
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 35222
Build 32166: arc lint + arc unit

Event Timeline

yasu requested review of this revision.Dec 6 2020, 10:40 PM

I don't understand why so many ports are changed.

It seems there are two things going on here:

  • a fix for emacs+ninja
  • a cleanup of some sort for the whole ports tree.

As it does not seem to me that they are related, it would be better to split those two in two different reviews.

cad/brlcad/Makefile
62–63

It could probably be simplified to this.

cad/brlcad/Makefile
62–63

It could probably be simplified to this.

62–63

No, everything is related. The beginning is that build error happens when I specified USES=cmake emacs such as following.

ninja: error: unknown target 'EMACS=/usr/local/bin/emacs-27.1'

According to my investigation it happens as following.

  • In Mk/Uses/ninja.mk there are following settings.
    • MAKEFILE is set to empty.
    • MAKE_CMD is set to 'ninja'.
    • MAKE_FLAG' is set to empty.
  • In Mk/Uses/emacs.mk there is following setting.
    • EMACS=${EMACS_CMD} is added to MAKE_ARGS.
  • So when make build is invoked, following command is executed.

${SETENV} ${MAKE_ENV} ninja -j${MAKE_JOBS_NUMBER} EMACS=${EMACS_CMD}

  • Unfortunately ninja doesn't accept NAME=value style arguments that make(1) accepts.
  • As a result above build error happens.

I checked Mk/Uses/*.mk and found some other files also add
NAME=value to MAKE_ARGS. So I thought it should be fixed by changing Mk/Uses/ninja.mk.

At first I tried to fix it as following.

  • Instead of setting MAKEFILE, MAKE_CMD and MAKE_ARGS, set DO_MAKE_BUILD and DO_MAKE_TEST in Mk/Uses/ninja.mk so ninja is invoked with right syntax.
  • As for do-install target DO_MAKE_INSTALL isn't defined. So,
    • Change Mk/bsd.port.mk as following
      • Define DO_MAKE_INSTALL variable.
      • Use it in 'do-install' target.
    • Set DO_MAKE_INSTALL in Mk/Uses/ninja.mk so ninja is invoked with right syntax.

I thought the problem is fixed with these changes. But soon I found build of devel/llvm* fails with them. I investigated it and found build error happens with following reason.

  • There are a lot of ports that use either USES=cmake or USES=ninja and also define custom {do,pre,post}-{build,insall,test} targets.
  • Many of them use MAKE_CMD to define their customized targets and they assume the variable is set to ninja in Mk/Uses/ninja.mk.
  • But now Mk/Uses/ninja.mk don't change the value of MAKE_CMD.
  • So make is used in these targets and it results in error.

So I need to change all of them so they don't used MAKE_CMD in their customized targets. I did it as following.

  • In most of them use DO_MAKE_{BUILD,INSTALL,TEST} in their customized targets
  • In the rest of them use literal 'ninja' in their customized targets.

But the former caused another problem that DO_MAKE_TEST isn't defined if customized do-test target is defined. So I need to change Mk/bsd.port.mk so DO_MAKE_TEST is always defined.

This is why so many changes are necessary to fix this problem.