-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSCan_core.qbs
164 lines (143 loc) · 4.16 KB
/
SCan_core.qbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import qbs
CppApplication {
name: "SCan-core"
// defines
cpp.defines: [
"STM32F10X_CL",
"STM32F105xC",
"BOARD_SIGMA=1", // Sigma 10 module
"BOARD_2CAN=2", // Ancient 2CAN board
"BOARD_CSAT=3", // Custom CS device
"BOARD_2CAN30=4", // 2CAN 30 module
"BOARD_2CAN2LIN=5" // 2CAN-2LIN board
// build for various boards
"BOARD=1",
"PROTOCOL_LAWICEL=1", // commonly used, ascii-based
"PROTOCOL_BINARY=2", // "new" canhacker protocol
"PROTOCOL=2", // current protocol
]
files: [
"CHLic.h",
"Can/Can.h",
"Can/candrv.cpp",
"Can/candrv.h",
"CanHackerBinary.cpp",
"CanHackerBinary.h",
"LedBlink.h",
"Lin/LinBus.cpp",
"Lin/LinBus.h",
"Lin/LinDrv.cpp",
"Lin/LinDrv.h",
"Lin/LinPkt.h",
"canhacker.cpp",
"canhacker.h",
"system/startup.c",
"system/sysinit.cpp",
"system/vectable.c",
"system/syscalls.c",
"Rtt/SEGGER_RTT.c",
"Rtt/SEGGER_RTT_printf.c",
"USB/usb.c",
"USB/usb_control.c",
"USB/usb_f107.c",
"USB/usb_standard.c",
"USB/usb_dwc_common.c",
"USB/cdcacm.cpp",
"main.cpp",
"timer.cpp",
"Pins.h",
"system/stm32F105xC.ld",
]
cpp.includePaths: [
".",
"system",
"system/CMSIS",
"USB",
"Rtt",
"stm32tpl",
]
// linker script
FileTagger {
patterns: "*.ld"
fileTags: ["linkerscript"]
}
cpp.libraryPaths: [ "system" ]
type: ["hex", "size", "dfu"] // The filetags to generate
cpp.cLanguageVersion: "c11"
cpp.cxxLanguageVersion: "c++17"
cpp.positionIndependentCode: false
cpp.generateLinkerMapFile: true
cpp.enableExceptions: false
cpp.executableSuffix: ".elf"
cpp.enableRtti: false
cpp.driverFlags: [
"-mcpu=cortex-m3",
"-mfloat-abi=soft",
"-specs=nosys.specs",
"-fdata-sections",
"-ffunction-sections",
]
cpp.cxxFlags: [
"-fno-use-cxa-atexit",
"-fno-exceptions",
"-fno-rtti",
]
cpp.driverLinkerFlags: [
"-nostartfiles",
"-specs=nano.specs",
"-Wl,--gc-sections",
]
// make hex-file
Rule {
inputs: "application"
Artifact {
fileTags: ["hex"]
filePath: product.name + ".hex"
}
prepare: {
var args = ["-O", "ihex", input.filePath, output.filePath];
var cmd = new Command(product.cpp.objcopyPath, args);
cmd.description = "converting to hex";
return cmd;
}
}
// print size
Rule {
inputs: "application"
outputFileTags: [ "size" ]
prepare: {
var args = [input.filePath];
var sizePath = product.cpp.toolchainInstallPath + "/" + product.cpp.toolchainPrefix + "size";
var cmd = new Command(sizePath, args);
cmd.description = "print size";
return cmd;
}
}
// make dfu image
Rule {
inputs: "hex"
Artifact {
fileTags: ["dfu"]
filePath: "../" + product.name + ".dfu"
}
prepare: {
var util = product.sourceDirectory + "/dfu-convert.py";
var args = [util, "-i", input.filePath, output.filePath];
var cmd = new Command("python", args);
cmd.description = "make dfu: " + output.filePath;
return cmd;
}
}
Properties {
condition: qbs.buildVariant === "debug"
cpp.debugInformation: true
cpp.defines: outer.concat("DEBUG")
cpp.driverFlags: outer.concat("-Og")
}
Properties {
condition: qbs.buildVariant === "release"
cpp.debugInformation: false
cpp.driverFlags: outer.concat("-O3")
cpp.driverLinkerFlags: outer.concat("-flto")
}
}