[SERVER-61012] Instantiation of TEMPLATE rule sometimes has a command in generated ninja Created: 26/Oct/21  Updated: 29/Oct/23  Resolved: 09/Nov/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0, 5.1.2, 5.0.6

Type: Bug Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Daniel Moody
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.1, v5.0
Sprint: Dev Platform 2021-11-01, Dev Platform 2021-11-15
Participants:

 Description   

The TEMPLATE rule doesn't care about your `cmd` value:

rule TEMPLATE
  command = $SCONS_INVOCATION $out
  description = Rendering $out
  pool = scons_pool
  restat = 1

But if you have a stanza like this in your SCons:

env.Command(
    target=[
        'feature_flag_test.idl',
    ],
    source=[
        '#buildscripts/cheetah_source_generator.py',
        'feature_flag_test.idl.tpl',
        '$BUILD_DIR/mongo/util/version/releases.yml',
    ],
    action=[
        '$PYTHON ${SOURCES[0]} -o ${TARGETS[0]} ${SOURCES[1]} ${SOURCES[2]} ${MONGO_VERSION}',
    ],
    # Ensure that that SCons is used to produce this file rather than Ninja, to avoid spurious
    # dependency cycles due to how we manage generated sources with Ninja.
    NINJA_TEMPLATE=True,
)

It ends up in the `cmd` stanza of the sole invocation of the `TEMPLATE` rule:

build build/aib_make_archive.py build/cached/mongo/config.h $
    build/cached/mongo/idl/feature_flag_test.idl build/cached/mongo/util/version_constants.h $
    build/cached/resmoke.ini build/cached/third_party/third_party_shim.cpp $
    build/cached/third_party/wiredtiger/wiredtiger.h: TEMPLATE src/mongo/config.h.in $
    buildscripts/cheetah_source_generator.py src/mongo/idl/feature_flag_test.idl.tpl $
    src/mongo/util/version/releases.yml src/mongo/util/version_constants.h.in $
    src/third_party/wiredtiger/src/include/wiredtiger.in | $
    buildscripts/cheetah_source_generator.py src/mongo/util/version/releases.yml $
    src/mongo/idl/feature_flag_test.idl.tpl @install_dir@$ install//usr/locala/bin
  cmd = /Users/acm/.virtualenvs/mongo/bin/python buildscripts/cheetah_source_generator.py -o $
      build/cached/mongo/idl/feature_flag_test.idl src/mongo/idl/feature_flag_test.idl.tpl $
      src/mongo/util/version/releases.yml 5.1.0-alpha-1746-g1cf0b1f
  env = export PATH='/usr/local/bin:/opt/bin:/bin:/usr/bin';export $
      PATHOSX='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin';

This is harmless, since TEMPLATE isn't going to honor it, but it is confusing when reading the generated ninja file and is probably something we should avoid doing.



 Comments   
Comment by Githook User [ 29/Nov/21 ]

Author:

{'name': 'Daniel Moody', 'email': 'daniel.moody@mongodb.com', 'username': 'dmoody256'}

Message: SERVER-61012 ninja template items should only use agreggate keys

(cherry picked from commit 8c0afec60c1dc85eed55494a886d59652c98c869)
Branch: v5.0
https://github.com/mongodb/mongo/commit/72e3da803f97efbdffa562b8997d0eb181e75076

Comment by Githook User [ 29/Nov/21 ]

Author:

{'name': 'Daniel Moody', 'email': 'daniel.moody@mongodb.com', 'username': 'dmoody256'}

Message: SERVER-61012 ninja template items should only use agreggate keys

(cherry picked from commit 8c0afec60c1dc85eed55494a886d59652c98c869)
Branch: v5.1
https://github.com/mongodb/mongo/commit/5695e6db0b0452d242212036b356629909d46802

Comment by Githook User [ 09/Nov/21 ]

Author:

{'name': 'Daniel Moody', 'email': 'daniel.moody@mongodb.com', 'username': 'dmoody256'}

Message: SERVER-61012 ninja template items should only use agreggate keys
Branch: master
https://github.com/mongodb/mongo/commit/8c0afec60c1dc85eed55494a886d59652c98c869

Generated at Thu Feb 08 05:51:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.