qbs avr компиляция

Я пытаюсь построить простой проект с qbs

import qbs
Project {
    name: "simple"
    Product {
        name: "micro"
        type: "obj"
        Group {
            name: "sources"
            files: ["main.c", "*.h", "*.S"]
            fileTags: ['c']
        }
        Rule {
            inputs: ["c"]
            Artifact {
                fileTags: ['obj']
                filePath: input.fileName + '.o'
            }
            prepare: {
                var args = [];
                args.push("-g")
                args.push("-Os")
                args.push("-w")
                args.push("-fno-exceptions")
                args.push("-ffunction-sections")
                args.push("-fdata-sections")
                args.push("-MMD")
                args.push("-mmcu=atmega328p")
                args.push("-DF_CPU=16000000L")
                args.push("-DARDUINO=152")
                args.push("-IC:/Programs/arduino/hardware/arduino/avr/cores/arduino")
                args.push("-IC:/Programs/arduino/hardware/arduino/avr/variants/standard")
                args.push("-c")
                args.push(input.fileName)
                args.push("-o")
                args.push(input.fileName + ".o")
                var compilerPath = "C:/Programs/arduino/hardware/tools/avr/bin/avr-g++.exe"
                var cmd = new Command(compilerPath, args);
                cmd.description = 'compiling ' + input.fileName;
                cmd.highlight = 'compiler';
                cmd.silent = false;
                console.error(input.baseDir + '/' + input.fileName);
                return cmd;
            }
        }
    }
}

И я получаю ошибку

compiling main.c
C:/Programs/arduino/hardware/tools/avr/bin/avr-g++.exe -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD "-mmcu=atmega328p" "-DF_CPU=16000000L" "-DARDUINO=152" -IC:/Programs/arduino/hardware/arduino/avr/cores/arduino -IC:/Programs/arduino/hardware/arduino/avr/variants/standard -c main.c -o main.c.o
avr-g++.exe: main.c: No such file or directory
avr-g++.exe: no input files
Process failed with exit code 1.
The following products could not be built for configuration qtc_avr_f84c45e7-release:
    micro

Что я не так?

Файл main.c присутствует в проекте и в каталоге.

Если я запускаю эту команду из командной строки, я не получаю ошибки.


qbs
person Дмитрий Гранин    schedule 21.02.2017    source источник


Ответы (2)


Короче говоря, вам нужно передать input.filePath после -c и -o, а не input.fileName. Нет гарантии, что рабочий каталог вызванной команды будет вашим исходным каталогом.

Вы можете установить рабочий каталог объекта Command, но это обычно не рекомендуется, так как ваши команды не должны зависеть от рабочего каталога, если это не абсолютно необходимо.

Более того, похоже, вы дублируете функциональность модуля cpp. Вместо этого ваш проект должен выглядеть так:

import qbs
Project {
    name: "simple"
    Product {
        Depends { name: "cpp" }
        name: "micro"
        type: "obj"
        Group {
            name: "sources"
            files: ["main.c", "*.h", "*.S"]
            fileTags: ['c']
        }
        cpp.debugInformation: true // passes -g
        cpp.optimization: "small" // passes -Os
        cpp.warningLevel: "none" // passes -w
        cpp.enableExceptions: false // passes -fno-exceptions
        cpp.commonCompilerFlags: [
            "-ffunction-sections",
            "-fdata-sections",
            "-MMD",
            "-mmcu=atmega328p"
        ]
        cpp.defines: [
            "F_CPU=16000000L",
            "ARDUINO=152"
        ]
        cpp.includePaths: [
            "C:/Programs/arduino/hardware/arduino/avr/cores/arduino",
            "C:/Programs/arduino/hardware/arduino/avr/variants/standard
        ]
        cpp.toolchainInstallPath: "C:/Programs/arduino/hardware/tools/avr/bin"
        cpp.cxxCompilerName: "avr-g++.exe"
    }
}
person Jake Petroules    schedule 22.02.2017

это работает args.push("-c") args.push(input.filePath) at you args.push(input.fileName) args.push("-o") args.push(output.filePath) у вас args.push (input.fileName)

person Slava    schedule 23.05.2017