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 присутствует в проекте и в каталоге.

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

2 ответа

Решение

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

Вы можете установить workingDirectory объекта 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"
    }
}

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

Другие вопросы по тегам