Skip to content

Commit 19a3889

Browse files
Merge pull request #1 from RandomGenericUsername/rec
Rec
2 parents cf649bc + 2cb748b commit 19a3889

132 files changed

Lines changed: 1426803 additions & 22 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ COPY setup/container_packages_installation_scripts ${INSTALLATION_SCRIPTS_LOCATI
1616

1717
RUN apt-get update -y && \
1818
apt-get upgrade -y && \
19-
apt-get install -y pixz wget curl gcc g++ git subversion autoconf pkg-config automake libtool cmake make build-essential ninja-build zsh \
19+
apt-get install -y pixz wget curl gcc g++ git unzip subversion autoconf pkg-config automake libtool cmake make build-essential ninja-build zsh \
2020
libusb-1.0.0 libusb-dev libusb-1.0.0-dev gnupg libncursesw5 libncurses5-dev \
2121
bash-completion vim htop libreadline-dev clang clang-tidy lcov flawfinder cppcheck && \
22-
apt-get clean
22+
apt-get clean
2323

2424
#install scripts
2525
RUN chmod +x ${INSTALLATION_SCRIPTS_LOCATION}/*
@@ -40,3 +40,11 @@ RUN apt-get update && \
4040

4141
COPY setup/create_project ${CREATE_PROJECT_SCRIPT}
4242
ENV PATH="${PATH}:${CREATE_PROJECT_SCRIPT}"
43+
44+
# Set zsh as the default shell
45+
RUN sed -i -e "s/bin\/bash/bin\/zsh/" /etc/passwd
46+
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
47+
48+
49+
50+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
3+
4+
target_config_name=${TARGET_CONFIG[${MCU_FAMILY}]}
5+
declare -n target_config=$target_config_name
6+
7+
target_sel_name=${TARGET_SEL[${MCU_FAMILY}]}
8+
declare -n target_sel=$target_sel_name
9+
10+
interface_config_name=${INTERFACE_CONFIG[${MCU_FAMILY}]}
11+
declare -n interface_config=$interface_config_name
12+
13+
14+
COMMON_CONFIG=$(cat << EOM
15+
{
16+
"name": "Debug Test",
17+
"type": "cppdbg",
18+
"request": "launch",
19+
"program": "\${workspaceFolder}/${BUILD_DIR}/${TESTS_DIR}/${PROJECT_NAME}_test.elf",
20+
"args": [],
21+
"stopAtEntry": false,
22+
"cwd": "\${workspaceFolder}",
23+
"environment": [],
24+
"externalConsole": false,
25+
"MIMode": "gdb",
26+
"miDebuggerPath": "/usr/bin/gdb-multiarch",
27+
"setupCommands": [
28+
{
29+
"description": "Enable pretty-printing for gdb",
30+
"text": "-enable-pretty-printing",
31+
"ignoreFailures": true
32+
}
33+
]
34+
}
35+
EOM
36+
)
37+
38+
DEDICATED_CONFIGS=""
39+
for cores in ${MCU_SRC_DIRS[@]}; do
40+
41+
svd_file=$(find "${PROJECT_NAME}" -name '*.svd' )
42+
43+
BOARD_OR_TARGET=${target_sel[$cores]}
44+
BOARD_OR_TARGET_VALUE=${target_config[$cores]}
45+
INTERFACE=${interface_config[$cores]}
46+
47+
if [[ ${#MCU_SRC_DIRS[@]} -gt 1 ]];then
48+
49+
executable=\"./${BUILD_DIR}/${PROJECT_NAME}_${cores}.elf\"
50+
cores=${cores^^}
51+
svd_file=$(echo "${svd_file}" | grep -E "${UPPERCASE_MCU_FAMILY:0:8}[a-z A-Z 0-9]_C${cores:0:3}\.svd$")
52+
else
53+
cores=""
54+
executable=\"./${BUILD_DIR}/${PROJECT_NAME}.elf\"
55+
fi
56+
57+
svd_file="${svd_file#*/}"
58+
cores=${cores,,}
59+
DEDICATED_CONFIGS+=$(cat << EOM
60+
{
61+
"name": "Cortex Debug ${cores}",
62+
"cwd": "${workspaceFolder}",
63+
"executable": $executable,
64+
"request": "launch",
65+
"type": "cortex-debug",
66+
"runToEntryPoint": "main",
67+
"servertype": "openocd",
68+
"configFiles": [
69+
"/usr/local/share/openocd/scripts/interface/${INTERFACE}.cfg",
70+
"/usr/local/share/openocd/scripts/${BOARD_OR_TARGET}/${BOARD_OR_TARGET_VALUE}.cfg"
71+
],
72+
"svdFile": "${svd_file}"
73+
74+
},
75+
{
76+
"name": "Flash and Debug ${cores}",
77+
"cwd": "${workspaceFolder}",
78+
"executable": $executable,
79+
"request": "launch",
80+
"type": "cortex-debug",
81+
"runToEntryPoint": "main",
82+
"servertype": "openocd",
83+
"configFiles": [
84+
"/usr/local/share/openocd/scripts/interface/${INTERFACE}.cfg",
85+
"/usr/local/share/openocd/scripts/${BOARD_OR_TARGET}/${BOARD_OR_TARGET_VALUE}.cfg"
86+
],
87+
"preLaunchTask": "Flash Core ${cores}"
88+
},
89+
EOM
90+
)
91+
done
92+
93+
LAUNCH_JSON=$(cat << EOM
94+
{
95+
"version": "0.2.0",
96+
"configurations": [
97+
$COMMON_CONFIG,
98+
$DEDICATED_CONFIGS
99+
]
100+
}
101+
EOM
102+
)
103+
104+
echo "${LAUNCH_JSON}" > $PROJECT_NAME/.vscode/launch.json
105+

setup/create_project/create_project.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ source ./download_cmsis.sh
5252
source ./download_linker_and_startup_script.sh
5353
./create_settings_json.sh
5454
source ./create_c_cpp_properties_json.sh
55+
source ./create_tasks_json.sh
56+
source ./download_svd_files.sh
57+
source ./create_launch_json.sh
5558
source ./copy_files.sh
5659
set --
5760
source ./move_makefiles.sh

setup/create_project/create_root_makefile.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,31 @@ for dir in "${MCU_SRC_DIRS[@]}"; do
4141
if [[ ${#MCU_SRC_DIRS[@]} -eq 1 ]]; then
4242
dir=$MCU_SRC_DIR_DEFAULT
4343
suffix=""
44+
create_rule --target "build_test" --command "\$(MAKE) -C ${CORE_DIR}/${dir} build_test"
45+
create_rule --target "clean_test" --command "\$(MAKE) -C ${CORE_DIR}/${dir} clean_test"
46+
create_rule --target "run_test" --command "\$(MAKE) -C ${CORE_DIR}/${dir} run_test"
47+
else
48+
if [[ "$dir" == "${MCU_SRC_DIRS[0]}" ]]; then
49+
create_rule --target "build_test" --command "\$(MAKE) -C ${CORE_DIR}/${dir} build_test"
50+
create_rule --target "clean_test" --command "\$(MAKE) -C ${CORE_DIR}/${dir} clean_test"
51+
create_rule --target "run_test" --command "\$(MAKE) -C ${CORE_DIR}/${dir} run_test"
52+
fi
4453
fi
4554
create_rule --target "all${suffix}" --command "\$(MAKE) -C ${CORE_DIR}/${dir} all"
4655
create_rule --target "build_project${suffix}" --command "\$(MAKE) -C ${CORE_DIR}/${dir} build_project"
47-
create_rule --target "build_test${suffix}" --command "\$(MAKE) -C ${CORE_DIR}/${dir} build_test"
4856
create_rule --target "flash${suffix}" --command "\$(MAKE) -C ${CORE_DIR}/${dir} flash"
4957
create_rule --target "clean${suffix}" --command "\$(MAKE) -C ${CORE_DIR}/${dir} clean"
50-
create_rule --target "clean_test${suffix}" --command "\$(MAKE) -C ${CORE_DIR}/${dir} clean_test"
5158
build_all_deps+="all${suffix} "
5259
build_project_deps+="build_project${suffix} "
53-
build_test_deps+="build_test${suffix} "
5460
flash_deps+="flash${suffix} "
5561
clean_deps+="clean${suffix} "
56-
clean_test_deps+="clean_test${suffix} "
5762
done
5863

5964
if [[ ${#MCU_SRC_DIRS[@]} -gt 1 ]]; then
6065
create_rule --target "all" --dependencies "${build_all_deps}"
6166
create_rule --target "build_projects" --dependencies "${build_project_deps}"
62-
create_rule --target "build_tests" --dependencies "${build_test_deps}"
6367
create_rule --target "flash" --dependencies "${flash_deps}"
6468
create_rule --target "clean" --dependencies "${clean_deps}"
65-
create_rule --target "clean_tests" --dependencies "${clean_test_deps}"
6669
fi
6770

6871

setup/create_project/create_sub_makefile.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ MPU_ARCH=""
103103
FPU_V=""
104104
FPU=""
105105
SRC_PATH=""
106-
#if there is more than one core, the build directory is Build/mx. if single core -> Build/
107-
SRC_BUILD_PATH="/${SRC_PATH}"
108-
#if there is more than one core, the target is projectName_mx.elf. if single core -> projectName.elf
109-
BUILD_PATH_SUFFIX="_${SRC_PATH}"
110106
#Directories excluded from the main build
111107
EXCLUDED_DIRS=""
112108
#Directories excluded from the test build
@@ -117,9 +113,14 @@ FPU_FLAGS=""
117113
# Main script execution
118114
parse_args "$@"
119115
check_missing_params
120-
change_pthsfx_bldpth_if_single_core
121116
exclude_files
122117

118+
#if there is more than one core, the build directory is Build/mx. if single core -> Build/
119+
SRC_BUILD_PATH="/${SRC_PATH}"
120+
#if there is more than one core, the target is projectName_mx.elf. if single core -> projectName.elf
121+
BUILD_PATH_SUFFIX="_${SRC_PATH}"
122+
change_pthsfx_bldpth_if_single_core
123+
123124
core_name="$(get_core_name ${MPU_ARCH})"
124125
BOARD_OR_TARGET=${target_sel[$core_name]}
125126
BOARD_OR_TARGET_VALUE=${target_config[$core_name]}
@@ -135,7 +136,7 @@ LINKER_SCRIPT_PATH=${STARTUP_REL_PATH}/$LINKER_SCRIPT
135136
OBJ_DIR=${BUILD_PATH}${SRC_BUILD_PATH}
136137
TEST_OBJ_DIR=${BUILD_PATH}/${TESTS_DIR}${SRC_BUILD_PATH}
137138
TARGET=${BUILD_PATH}/${PROJECT_NAME}${BUILD_PATH_SUFFIX}.elf
138-
TEST_TARGET=${TEST_BUILD_PATH}/${PROJECT_NAME}${BUILD_PATH_SUFFIX}.elf
139+
TEST_TARGET=${TEST_BUILD_PATH}/${PROJECT_NAME}_test.elf
139140

140141
# Define include directories
141142
INC_DIRS="\$(shell find ${CORE_REL_PATH} -type d -name .svn -prune -o -type d -print)"
@@ -157,8 +158,8 @@ TEST_C_SOURCES_CORE="\$(shell find ${TESTS_REL_PATH} -name '*.c') \$(shell find
157158
ASM_OBJECTS="\$(STARTUP_SCRIPT_PATH:\${STARTUP_REL_PATH}/%.s=\$(OBJ_DIR)/${STARTUP_DIR}/%.o)"
158159
CXX_OBJECTS="\$(CXX_SOURCES_CORE:\${CORE_REL_PATH}/%.cpp=\$(OBJ_DIR)/%.o)"
159160
C_OBJECTS="\$(C_SOURCES_CORE:\${CORE_REL_PATH}/%.c=\$(OBJ_DIR)/%.o)"
160-
TEST_CXX_OBJ="\$(TEST_CXX_SOURCES_CORE:../../%.cpp=${TEST_OBJ_DIR}/%.o)"
161-
TEST_C_OBJ="\$(TEST_C_SOURCES_CORE:../../%.c=${TEST_OBJ_DIR}/%.o)"
161+
TEST_CXX_OBJ="\$(TEST_CXX_SOURCES_CORE:../..//%.cpp=${TEST_OBJ_DIR}/%.o)"
162+
TEST_C_OBJ="\$(TEST_C_SOURCES_CORE:../..//%.c=${TEST_OBJ_DIR}/%.o)"
162163

163164
DEPS="\$(CXX_OBJECTS:.o=.d) \$(C_OBJECTS:.o=.d) \$(ASM_OBJECTS:.o=.d)"
164165

@@ -221,6 +222,7 @@ run_test: build_test
221222
@echo ' '
222223
223224
\$(TEST_TARGET): \$(TEST_CXX_OBJECTS) \$(TEST_C_OBJECTS)
225+
@mkdir -p \$(dir \$@)
224226
\$(TEST_CXX) $^ -o \$@
225227
@echo 'Finished building test target: \$@'
226228
@echo ' '
@@ -256,10 +258,10 @@ run_test: build_test
256258
.PHONY: clean clean_test
257259
258260
clean:
259-
rm -rf \$(OBJ_DIR)
261+
rm -rf \$(OBJ_DIR)/* \$(TARGET)
260262
261263
clean_test:
262-
rm -rf \$(TEST_OBJ_DIR)
264+
rm -rf \$(TEST_OBJ_DIR) \$(TEST_TARGET)
263265
264266
EOM
265267
)
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,127 @@
11
#!/bin/bash
22

33

4+
#!/bin/bash
5+
PROBLEM_MATCHER=$(cat << 'EOM'
6+
"problemMatcher": {
7+
"owner": "cpp",
8+
"fileLocation": ["relative", "${workspaceFolder}"],
9+
"pattern": {
10+
"regexp": "^(.*):(\\\\\\d+):(\\\\\\d+):\\\\\\s+(warning|error):\\\\\\s+(.*)$",
11+
"file": 1,
12+
"line": 2,
13+
"column": 3,
14+
"severity": 4,
15+
"message": 5
16+
}
17+
},
18+
"presentation": {
19+
"reveal": "always"
20+
}
21+
EOM
22+
)
23+
24+
DEDICATED_MAKE_RULES=""
25+
if [[ ${#MCU_SRC_DIRS[@]} -gt 1 ]]; then
26+
for cores in ${MCU_SRC_DIRS[@]}; do
27+
# Use printf and sed to adjust the indentation
28+
INDENTED_PROBLEM_MATCHER=$(printf "$PROBLEM_MATCHER" | sed 's/^/\t/')
29+
DEDICATED_MAKE_RULES+=$(cat << EOM
30+
{
31+
//Build for Core ${cores}
32+
"label": "Build Core ${cores}",
33+
"type": "process",
34+
"command": "make",
35+
"args": [
36+
"build_project_${cores}"
37+
],
38+
$INDENTED_PROBLEM_MATCHER
39+
},
40+
{
41+
//Clean for Core ${cores}
42+
"label": "Clean Core ${cores}",
43+
"type": "process",
44+
"command": "make",
45+
"args": [
46+
"clean_${cores}"
47+
],
48+
},
49+
{
50+
"label": "Flash Core ${cores}",
51+
"type": "process",
52+
"command": "make",
53+
"args": [
54+
"flash_${cores}"
55+
],
56+
"presentation": {
57+
"reveal": "always"
58+
},
59+
"dependsOn": "Clean Core ${cores} & Build Core ${cores}"
60+
},
61+
{
62+
"label": "Clean & Build Core ${cores}",
63+
"dependsOrder": "sequence",
64+
"dependsOn": ["Clean Core ${cores}", "Build Core ${cores}"]
65+
},
66+
EOM
67+
)\\n
68+
done
69+
fi
70+
71+
INDENTED_MAKE_RULES=$(printf "$DEDICATED_MAKE_RULES" | sed 's/^/\t\t/')
72+
COMMON_TASKS=$(cat << EOM
73+
{
74+
"version": "2.0.0",
75+
"tasks": [
76+
{
77+
"label": "Clean Project",
78+
"type": "process",
79+
"command": "make",
80+
"args": [
81+
"clean"
82+
],
83+
"problemMatcher": []
84+
},
85+
{
86+
"label": "Build Project",
87+
"type": "process",
88+
"command": "make",
89+
"args": [
90+
"all"
91+
],
92+
},
93+
{
94+
"label": "Flash Project",
95+
"type": "process",
96+
"command": "make",
97+
"args": [
98+
"flash"
99+
],
100+
"dependsOrder": "sequence",
101+
"dependsOn": ["Clean Project", "Build Project"]
102+
},
103+
{
104+
"label": "Build Test",
105+
"type": "process",
106+
"command": "make",
107+
"args": [
108+
"build_test"
109+
],
110+
},
111+
{
112+
"label": "Run Test",
113+
"type": "process",
114+
"command": "make",
115+
"args": [
116+
"run_test"
117+
],
118+
},
119+
$INDENTED_MAKE_RULES
120+
]
121+
}
122+
123+
EOM
124+
)
125+
126+
127+
echo "${COMMON_TASKS}" > $PROJECT_NAME/.vscode/tasks.json

0 commit comments

Comments
 (0)