GENie icon indicating copy to clipboard operation
GENie copied to clipboard

Error: custombuildtask multiple command calls not allowed in Ninja

Open TesterPointer opened this issue 5 years ago • 4 comments

custombuildtask {
    {
        _input_file,
        _output_file,
        {},
        {                
            "C:/workcopy/extsw/windows_amd64/qt3/bin/moc.exe $(<) ".._defines_params.." -o $(@)",
            "echo Running MOC on",
        },
    },
}

When I try to compile this with a second command (echo) and error occurs. I tried if there is a MOC error, but if I use 2 echo commands the error output are the same, I dont know if is a Ninja or not....

ninja: error: ASDF.ninja:40: multiple rules generate ../../_input_file.cpp [-w dupbuild=err]

TesterPointer avatar Mar 06 '19 09:03 TesterPointer

See: https://milostosic.github.io/build/

It's set of GENie build scripts, that supports Qt too.

bkaradzic avatar Mar 06 '19 17:03 bkaradzic

mmm really interested, I will take a look at this auto project setup, but independently of this autogen with QT support, Does Ninja supports double command in a same file? I checked that VS can but with Ninja I´m not sure. Thanks for the info, I didnt know the existence of a powerfull magic that uses GENIe

TesterPointer avatar Mar 07 '19 11:03 TesterPointer

mame appears to be affected too (you have to fix some $ escaping errors first):

custombuildtask {
	{ MAME_DIR .. "scripts/font/NotoSans-Bold.bdc", GEN_DIR .. "emu/uismall.fh", { MAME_DIR .. "scripts/build/file2str.py" }, { "@echo Converting NotoSans-Bold.bdc...", PYTHON .. " $(1) $(<) $(@) font_uismall uint8_t" } },
}

custombuildtask {
	{ MAME_DIR .. "src/frontend/mame/ui/uicmd14.png", GEN_DIR .. "emu/ui/uicmd14.fh", { MAME_DIR.. "scripts/build/png2bdc.py",  MAME_DIR .. "scripts/build/file2str.py" }, { "@echo Converting uicmd14.png...", PYTHON .. " $(1) $(<) temp_cmd.bdc", PYTHON .. " $(2) temp_cmd.bdc $(@) font_uicmd14 uint8_t" } },

belegdol avatar Aug 02 '20 13:08 belegdol

Per this:

Internally, ninja just ignores all but the last rule.

Per the ninja manual on rules and commands:

Each rule may have only one command declaration. See the next section for more details on quoting and executing multiple commands.

...

On Unixes, commands are arrays of arguments. The Ninja command variable is passed directly to sh -c, which is then responsible for interpreting that string into an argv array. Therefore the quoting rules are those of the shell, and you can use all the normal shell operators, like && to chain multiple commands, or VAR=value cmd to set environment variables.

ksherlock avatar Jun 14 '21 22:06 ksherlock