import qbsProject { name: "simple" Product { name: "micro" type: "obj" Group { name: "sources" files: ["*.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; return cmd; } } }}
compiling main.cC:/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.oavr-g++.exe: main.c: No such file or directoryavr-g++.exe: no input files
Group { name: "sources" prefix: "src/**/" // или где там у Вас расположены исходники files: ["*.c", "*.h", "*.S"] fileTags: ['c']}
import qbsProject{ name: "stm32" Product { type: ["hex", "bin"] property string c_compilerPath: "c:/development/gcc-arm/bin/arm-none-eabi-gcc.exe" property string cpp_compilerPath: "c:/development/gcc-arm/bin/arm-none-eabi-g++.exe" property string asm_compilerPath: "c:/development/gcc-arm/bin/arm-none-eabi-as.exe" property string linkerPath: "c:/development/gcc-arm/bin/arm-none-eabi-ld.exe" property string objcpyPath: "c:/development/gcc-arm/bin/arm-none-eabi-objcopy.exe" Group { name: "source_cpp" prefix: "./" files: ["*.cpp"] fileTags: ["cpp"] } Group { name: "source_c" prefix: "./" files: ["*.c"] fileTags: ["c"] } Group { name: "source_asm" prefix: "./" files: ["*.s"] fileTags: ["asm"] } Rule { inputs: ["cpp"] Artifact { filePath: project.path + "/.obj/" + input.fileName + ".o" fileTags: ["obj"] } prepare: { var args = []; args.push("-mcpu=cortex-m3"); args.push("-mthumb"); args.push("-O0"); args.push("--specs=nosys.specs"); args.push("-finline-functions"); args.push("-ffunction-sections"); args.push("-fdata-sections"); args.push("-fno-exceptions"); args.push("-fno-unwind-tables"); args.push("-fno-asynchronous-unwind-tables"); args.push("-c"); args.push("-DSTM32F10X_LD_VL"); args.push(project.path + "/" + input.fileName); args.push("-o"); args.push(project.path + "/.obj/" + output.fileName); var cmd = new Command(product.cpp_compilerPath, args); cmd.description = "compiling: " + input.fileName; cmd.highlight = "compiler"; cmd.silent = false; return cmd; } } Rule { inputs: ["c"] Artifact { filePath: project.path + "/.obj/" + input.fileName + ".o" fileTags: ["obj"] } prepare: { var args = []; args.push("-mcpu=cortex-m3"); args.push("-mthumb"); args.push("-O0"); args.push("--specs=nosys.specs"); args.push("-finline-functions"); args.push("-ffunction-sections"); args.push("-fdata-sections"); args.push("-fno-exceptions"); args.push("-fno-unwind-tables"); args.push("-fno-asynchronous-unwind-tables"); args.push("-c"); args.push("-DSTM32F10X_LD_VL"); args.push(project.path + "/" + input.fileName); args.push("-o"); args.push(project.path + "/.obj/" + output.fileName); var cmd = new Command(product.c_compilerPath, args); cmd.description = "compiling: " + input.fileName; cmd.highlight = "compiler"; cmd.silent = false; return cmd; } } Rule { inputs: ["asm"] Artifact { filePath: project.path + "/.obj/" + input.fileName + ".o" fileTags: ["obj"] } prepare: { var args = []; args.push("-mcpu=cortex-m3"); args.push("-mthumb"); args.push("-c"); args.push(project.path + "/" + input.fileName); args.push("-o"); args.push(project.path + "/.obj/" + output.fileName); var cmd = new Command(product.asm_compilerPath, args); cmd.description = "compiling: " + input.fileName; cmd.highlight = "compiler"; cmd.silent = false; return cmd; } } Rule { multiplex: true inputs: ["obj"] Artifact { filePath: project.path + "/bin/" + project.name + ".elf"; fileTags: ["elf"] } prepare: { var args = []; args.push("-mcpu=cortex-m3"); args.push("-mthumb"); args.push("--specs=nosys.specs"); args.push("-finline-functions"); args.push("-ffunction-sections"); args.push("-fdata-sections"); args.push("-nostartfiles"); args.push("-fno-exceptions"); args.push("-fno-unwind-tables"); args.push("-fno-asynchronous-unwind-tables"); args.push("-T" + project.path + "/" + "stm32f10x_flash.ld"); for(i in inputs["obj"]) args.push(inputs["obj"][i].filePath); args.push("-o"); args.push(output.filePath); var cmd = new Command(product.c_compilerPath, args); cmd.description = "linking project: " + project.name; cmd.highlight = "linker"; cmd.silent = false; return cmd; } } Rule { inputs: ["elf"] Artifact { filePath: project.path + "/bin/" + project.name + ".hex"; fileTags: ["hex"] } prepare: { var args = []; args.push("-O"); args.push("ihex"); args.push(input.filePath); args.push(output.filePath); var cmd = new Command(product.objcpyPath, args); cmd.description = "convert to hex"; cmd.highlight = "codegen"; cmd.silent = false; return cmd; } } Rule { inputs: ["elf"] Artifact { filePath: project.path + "/bin/" + project.name + ".bin"; fileTags: ["bin"] } prepare: { var args = []; args.push("-O"); args.push("binary"); args.push(input.filePath); args.push(output.filePath); var cmd = new Command(product.objcpyPath, args); cmd.description = "convert to bin"; cmd.highlight = "codegen"; cmd.silent = false; return cmd; } } }}
FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16ARCH_FLAGS = -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
import qbsimport qbs.EnvironmentProject { CppApplication { Depends { name: "cpp" } // Взято с форума type: "bin" name: "firmware" property string workDirectory: Environment.getEnv("FIRMWARES_WORKDIR") property string hexExtractor: cpp.toolchainInstallPath + "/" + cpp.toolchainPrefix + "objcopy"; cpp.cxxFlags: [ "-std=c++11", "-msoft-float", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-mthumb", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-mcpu=cortex-m3", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-mfix-cortex-m3-ldrd", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-extra", // главный Makefile в корне libopencm3 "-shadow", // главный Makefile в корне libopencm3 "-implicit-function-declaration", // главный Makefile в корне libopencm3 "-redundant-decls", // главный Makefile в корне libopencm3 "-missing-prototypes", // главный Makefile в корне libopencm3 "-strict-prototypes", // главный Makefile в корне libopencm3 "-fno-common", // главный Makefile в корне libopencm3 "-ffunction-sections", // главный Makefile в корне libopencm3 "-fdata-sections",] // главный Makefile в корне libopencm3 cpp.cFlags: [ "-std=gnu99", "-msoft-float", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-mthumb", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-mcpu=cortex-m3", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-mfix-cortex-m3-ldrd", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-extra", // главный Makefile в корне libopencm3 "-effc++", // главный Makefile в корне libopencm3 "-fno-common", // главный Makefile в корне libopencm3 "-ffunction-sections", // главный Makefile в корне libopencm3 "-fdata-sections" ] // главный Makefile в корне libopencm3 cpp.warningLevel: "all" cpp.linkerFlags: [ "-msoft-float", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-mthumb", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-mcpu=cortex-m3", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-mfix-cortex-m3-ldrd", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/ "-lc", // главный Makefile в корне libopencm3 "-lgcc", // главный Makefile в корне libopencm3 "-lnosys", // главный Makefile в корне libopencm3 "-static", // главный Makefile в корне libopencm3 "-nostartfiles" // главный Makefile в корне libopencm3 ] cpp.includePaths: [ "../libopencm3/libopencm3/include/", ] cpp.libraryPaths: [ "../libopencm3/libopencm3/lib/", ] cpp.staticLibraries: [ "opencm3_stm32l1", "c", "gcc", "nosys" ] Group { name: "linker scripts" files: ["../libopencm3/libopencm3/lib/stm32/l1/stm32l15xxb.ld" ] // Берется из make файла в любом живом примере из libopencm3/examples/stm32/l1/stm32l-discovery/lcd-display/ fileTags: ["linkerscript"] } cpp.defines: [ "STM32L1" ] Group { name: "src" files: [ "src/*.c", "src/*.cpp", "src/*.h" ] } Group { qbs.install: true fileTagsFilter: ["application", "bin"] } Rule { id: hex inputs: ["application"] Artifact { fileTags: ['bin'] filePath: product.name + '.bin' } prepare: { var args = []; args.push("-j") args.push(".text") args.push("-j") args.push(".data") args.push("-O") args.push("binary") args.push(input.filePath); args.push(output.filePath); var extractorPath = product.hexExtractor; var cmd = new Command(extractorPath, args); return cmd; } } }}
...cpp.commonCompilerFlags: ["-fdata-sections","-ffunction-sections", "-flto"]cpp.driverFlags:["-mthumb", "-mcpu=cortex-m4","-mfloat-abi=hard","-mfpu=fpv4-sp-d16"]
import qbsProduct{ type: ["application", "flash"] Depends { name: "cpp" } cpp.defines: ["STM32F10X_LD_VL"] cpp.positionIndependentCode: false cpp.enableExceptions: false cpp.executableSuffix: ".elf" cpp.driverFlags: [ "-mthumb", "-mcpu=cortex-m3", "-mfloat-abi=soft", "-fno-strict-aliasing", "-g3", "-Wall", "-mfpu=vfp", "-O0", "-flto", ] cpp.commonCompilerFlags: [ "-fdata-sections", "-ffunction-sections", "-fno-inline", "-std=c++11", "-flto" ] cpp.linkerFlags: [ "--specs=nano.specs", "-Wl,--start-group", "-Wl,--gc-sections", "-T" + path + "/src/system/linker/stm32f10x_flash.ld", "-lnosys", "-lgcc", "-lc", "-lstdc++", "-lm" ] cpp.includePaths: [ "src/system/cmsis", "src/system/cmsis_boot", "src/system/cmsis_boot/statup" ] files: [ "src/system/cmsis/*.h", "src/system/cmsis/*.h", "src/system/cmsis_boot/*.h", "src/system/cmsis_boot/*.c", "src/system/cmsis_boot/startup/*.c", "src/main.cpp" ] Properties { condition: qbs.buildVariant === "debug" cpp.defines: outer.concat(["DEBUG=1"]) cpp.debugInformation: true cpp.optimization: "none" } Properties { condition: qbs.buildVariant === "release" cpp.debugInformation: false cpp.optimization: "small" } Rule { inputs: ["application"] Artifact { filePath: project.path + "/debug/bin/" + input.baseName + ".hex" fileTags: "flash" } prepare: { var sizePath = "c:/development/gcc-arm/bin/arm-none-eabi-size.exe"; var objcopyPath = "c:/development/gcc-arm/bin/arm-none-eabi-objcopy.exe"; var configStlinkPath = "c:/development/openocd_0_10_0/scripts/interface/stlink-v2.cfg"; var configStm32Path = "c:/development/openocd_0_10_0/scripts/target/stm32f1x.cfg"; var flashPath = "c:/development/openocd_0_10_0/bin/openocd.exe"; var argsSize = [input.filePath]; var argsObjcopy = ["-O", "ihex", input.filePath, output.filePath]; var argsFlashing = [ "-f", configStlinkPath, "-f", configStm32Path, "-c", "init", "-c", "halt", "-c", "flash write_image erase " + input.filePath, "-c", "reset", "-c", "shutdown" ]; var cmdSize = new Command(sizePath, argsSize); var cmdObjcopy = new Command(objcopyPath, argsObjcopy); var cmdFlash = new Command(flashPath, argsFlashing); cmdSize.description = "Size of sections:"; cmdSize.highlight = "linker"; cmdObjcopy.description = "convert to bin..."; cmdObjcopy.highlight = "linker"; cmdFlash.description = "download firmware to uC..."; cmdFlash.highlight = "linker"; return [cmdSize, cmdObjcopy, cmdFlash]; } }}