Skip to content

Commit c22557c

Browse files
fix(Build): Fix "empty.c file not found" Error on Make v3.81 or Older (#657)
Co-authored-by: Sihyung Woo <[email protected]>
1 parent 950b21a commit c22557c

File tree

8 files changed

+214
-36
lines changed

8 files changed

+214
-36
lines changed

.github/pull_request_template.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ The scopes are dependent on the changes based on their location in the MSDK. The
5252
9. **ThirdParty** – Any third-party library changes (e.g. FreeRTOS, LVGL, lwIP)
5353
10. **MAXUSB** – Any MAXUSB changes
5454
11. **SDHC** – Any SDHC changes
55-
12. **ignore** – Small and quick miscellaneous fixes (should not be used often)
56-
13. **workflow** – Any GitHub workflow related changes
57-
14. **Other** – Any changes that may not fit in the other scopes
55+
12. **Build** – Any changes involving the build system
56+
13. **ignore** – Small and quick miscellaneous fixes (should not be used often)
57+
14. **workflow** – Any GitHub workflow related changes
58+
15. **Other** – Any changes that may not fit in the other scopes
5859

5960
NOTE: The scope is case sensitive and must match one of the listed scopes.
6061

.github/workflows/Build_Examples.yml

Lines changed: 149 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ jobs:
173173
run: pip install -r .github/workflows/scripts/requirements.txt
174174

175175
# Runs a set of commands using the runners shell
176-
- name: Build_Examples
176+
- name: Build All Examples
177177
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
178178
run: |
179179
# This environment variable is required for the SBTs.
@@ -184,3 +184,151 @@ jobs:
184184
export MAXIM_PATH=$(pwd)
185185
186186
python .github/workflows/scripts/build.py
187+
188+
Regression_Test_Make_3_81:
189+
runs-on:
190+
- ubuntu-latest
191+
steps:
192+
- uses: actions/checkout@v3
193+
with:
194+
# Update the submodules below, doing so here will convert ssh to https
195+
submodules: false
196+
fetch-depth: 0
197+
ref: '${{ github.event.pull_request.head.ref }}'
198+
repository: '${{ github.event.pull_request.head.repo.full_name }}'
199+
200+
- name: Install Make 3.81
201+
run: |
202+
# Build and install Make version 3.81.
203+
cd $GITHUB_WORKSPACE
204+
ls -la
205+
wget https://ftp.gnu.org/gnu/make/make-3.81.tar.gz
206+
tar -xvf make-3.81.tar.gz
207+
cd make-3.81
208+
209+
# Note: This patch is necessary to get make to build on Ubuntu-22.04.
210+
patch glob/glob.c $GITHUB_WORKSPACE/.github/workflows/patch/glob_patch.patch
211+
212+
./configure --prefix=$GITHUB_WORKSPACE/make-3.81
213+
make
214+
make install
215+
216+
# Pre-prend 3.81 to path
217+
echo "$GITHUB_WORKSPACE/make-3.81/bin:$GITHUB_PATH" > $GITHUB_PATH
218+
make --version
219+
220+
- name: Check Make Version
221+
run: |
222+
# If this fails, there is a setup issue with the workflow.
223+
VERSION_CHECK=$(make --version | grep 3.81)
224+
if [ ! "$VERSION_CHECK" ];then
225+
exit 2
226+
fi
227+
228+
- name: Check watch files
229+
id: check_watch
230+
run: |
231+
# Determine if we need to run the test
232+
RUN_TEST=0
233+
234+
# Always run test if a workflow_dispatch
235+
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
236+
RUN_TEST=1
237+
fi
238+
239+
# Check for changes made to these files
240+
WATCH_FILES="\
241+
Build_Examples.yml \
242+
.c \
243+
.cpp \
244+
.S \
245+
.s \
246+
.h \
247+
.a \
248+
.mk \
249+
makefile \
250+
Makefile"
251+
252+
# Get the diff from main
253+
CHANGE_FILES=$(git diff --ignore-submodules --name-only remotes/origin/main)
254+
255+
echo "Watching these locations and files"
256+
echo $WATCH_FILES
257+
258+
echo "Checking the following changes"
259+
echo $CHANGE_FILES
260+
261+
for watch_file in $WATCH_FILES; do
262+
for change_file in $CHANGE_FILES; do
263+
if [[ "${change_file,,}" == *"${watch_file,,}" ]]; then
264+
echo "Match found. Watch type: $watch_file, File: $change_file"
265+
RUN_TEST=1
266+
fi
267+
done
268+
done
269+
270+
# End the test early if there wasn't a significant change
271+
if [[ $RUN_TEST -eq 0 ]]; then
272+
echo "Skipping Build"
273+
else
274+
echo "Running Build"
275+
fi
276+
277+
echo "RUN_TEST=$RUN_TEST" >> $GITHUB_OUTPUT
278+
279+
- name: Install ARM GCC Toolchain (arm-none-eabi-gcc)
280+
uses: carlosperate/arm-none-eabi-gcc-action@v1
281+
id: arm-none-eabi-gcc-action
282+
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
283+
with:
284+
release: '10.3-2021.10' # <-- The compiler release to use
285+
286+
- name: Install RISCV GCC Toolchain (riscv-none-embed-gcc)
287+
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
288+
run: |
289+
# Install RISCV tools
290+
npm install --global xpm@latest
291+
292+
TOOL_VER=10.2.0-1.2.1
293+
xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@$TOOL_VER
294+
cp -r /home/runner/.local/xPacks/@xpack-dev-tools/riscv-none-embed-gcc /home/runner/riscv-none-embed-gcc
295+
296+
# Add riscv tools to path
297+
echo "/home/runner/riscv-none-embed-gcc/$TOOL_VER/.content/bin" >> $GITHUB_PATH
298+
299+
- name: Install RISCV GCC Toolchain (riscv-none-elf-gcc)
300+
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
301+
run: |
302+
# Install RISCV tools (updated)
303+
npm install --global xpm@latest
304+
305+
# https://www.npmjs.com/package/@xpack-dev-tools/riscv-none-elf-gcc
306+
TOOL_VER=12.2.0-3.1
307+
xpm install --global @xpack-dev-tools/riscv-none-elf-gcc@$TOOL_VER
308+
cp -r /home/runner/.local/xPacks/@xpack-dev-tools/riscv-none-elf-gcc /home/runner/riscv-none-elf-gcc
309+
310+
# Add riscv tools to path
311+
echo "/home/runner/riscv-none-elf-gcc/$TOOL_VER/.content/bin" >> $GITHUB_PATH
312+
313+
- name: Setup Python
314+
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
315+
uses: actions/[email protected]
316+
with:
317+
python-version: '3.10'
318+
319+
- name: Install packages
320+
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
321+
run: pip install -r .github/workflows/scripts/requirements.txt
322+
323+
- name: Build PeriphDrivers and Hello_World
324+
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
325+
run: |
326+
# This environment variable is required for the SBTs.
327+
# It must be set to the absolute path inside the Github repo.
328+
export MAXIM_SBT_DIR=$(pwd)/Tools/SBT
329+
330+
# Set MAXIM_PATH to limit warnings
331+
export MAXIM_PATH=$(pwd)
332+
333+
python .github/workflows/scripts/build.py --projects Hello_World
334+

.github/workflows/PR_Title_Check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
scopes: |
4646
Documentation
4747
Examples
48+
Build
4849
Tools
4950
BLE
5051
Boards
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--- glob-old.c 2023-07-15 18:06:47.276205928 -0500
2+
+++ glob.c 2023-07-15 18:08:24.256204829 -0500
3+
@@ -207,7 +207,7 @@
4+
#endif /* __GNU_LIBRARY__ */
5+
6+
7+
-#if !defined __alloca && !defined __GNU_LIBRARY__
8+
+#if !defined __alloca && defined __GNU_LIBRARY__
9+
10+
# ifdef __GNUC__
11+
# undef alloca
12+
@@ -230,7 +230,7 @@
13+
14+
#endif
15+
16+
-#ifndef __GNU_LIBRARY__
17+
+#ifdef __GNU_LIBRARY__
18+
# define __stat stat
19+
# ifdef STAT_MACROS_BROKEN
20+
# undef S_ISDIR

.github/workflows/scripts/build.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from rich.progress import Progress
77
from rich.console import Console
88
from rich.text import Text
9+
from rich import inspect
910
import time
1011
import shutil
1112

@@ -38,7 +39,7 @@ def build_project(project:Path, target, board, maxim_path:Path, distclean=False)
3839
res = run(clean_cmd, cwd=project, shell=True, capture_output=True, encoding="utf-8")
3940

4041
# Test build
41-
build_cmd = f"make -r -j 8 --output-sync=target --no-print-directory TARGET={target} MAXIM_PATH={maxim_path.as_posix()} BOARD={board} FORCE_COLOR=1"
42+
build_cmd = f"make -r -j 8 TARGET={target} MAXIM_PATH={maxim_path.as_posix()} BOARD={board} FORCE_COLOR=1"
4243
res = run(build_cmd, cwd=project, shell=True, capture_output=True, encoding="utf-8")
4344

4445
project_info = {
@@ -83,23 +84,27 @@ def build_project(project:Path, target, board, maxim_path:Path, distclean=False)
8384
return (return_code, project_info)
8485

8586

86-
def test(maxim_path : Path = None, targets=None, boards=None, projects=None):
87+
def test(maxim_path : Path = None, targets=None, boards=None, projects=None):
88+
89+
console = Console(emoji=False, color_system="standard")
90+
8791
env = os.environ.copy()
8892
if maxim_path is None and "MAXIM_PATH" in env.keys():
8993
maxim_path = Path(env['MAXIM_PATH']).absolute()
94+
console.print(f"[green]Detected MAXIM_PATH[/green] = {maxim_path}")
9095
else:
91-
print("MAXIM_PATH not set.")
96+
console.print("MAXIM_PATH not set.")
9297
return
93-
98+
9499
env["FORCE_COLOR"] = 1
95100

96-
console = Console(emoji=False, color_system="standard")
97-
98101
# Remove the periphdrivers build directory
102+
console.print("Cleaning PeriphDrivers build directories...")
99103
shutil.rmtree(Path(maxim_path) / "Libraries" / "PeriphDrivers" / "bin", ignore_errors=True)
100104

101105
# Get list of target micros if none is specified
102106
if targets is None:
107+
console.print("[yellow]Auto-searching for targets...[/yellow]")
103108
targets = []
104109

105110
for dir in os.scandir(f"{maxim_path}/Examples"):
@@ -122,11 +127,15 @@ def test(maxim_path : Path = None, targets=None, boards=None, projects=None):
122127

123128
for target in sorted(targets):
124129

130+
console.print("====================")
131+
console.print(f"Testing {target}...")
132+
125133
target_fails = 0
126134
target_warnings = 0
127135

128136
# Get list of supported boards for this target.
129137
if boards is None:
138+
console.print(f"[yellow]Auto-searching for {target} BSPs...[/yellow]")
130139
boards = []
131140
for dirpath, subdirs, items in os.walk(maxim_path / "Libraries" / "Boards" / target):
132141
if "board.mk" in items and Path(dirpath).name not in blacklist:
@@ -139,36 +148,34 @@ def test(maxim_path : Path = None, targets=None, boards=None, projects=None):
139148
boards = sorted(boards) # Enforce alphabetical ordering
140149

141150
# Get list of examples for this target.
151+
_projects = []
142152
if projects is None:
143-
projects = []
153+
console.print(f"[yellow]Auto-searching for {target} examples...[/yellow]")
144154
for dirpath, subdirs, items in os.walk(maxim_path / "Examples" / target):
145155
if 'Makefile' in items and ("main.c" in items or "project.mk" in items):
146-
projects.append(Path(dirpath))
156+
_projects.append(Path(dirpath))
147157

148158
else:
149159
assert(type(projects) is list)
150160
for dirpath, subdirs, items in os.walk(maxim_path / "Examples" / target):
151161
dirpath = Path(dirpath)
152162
if dirpath.name in projects:
153-
projects.remove(dirpath.name)
154-
projects.append(dirpath)
155-
156-
157-
console.print("====================")
158-
console.print(f"Found {len(projects)} projects for [bold cyan]{target}[/bold cyan]")
163+
_projects.append(dirpath)
164+
165+
console.print(f"Found {len(_projects)} projects for [bold cyan]{target}[/bold cyan]")
159166
console.print(f"Detected boards: {boards}")
160167

161-
projects = sorted(projects) # Enforce alphabetical ordering
168+
_projects = sorted(_projects) # Enforce alphabetical ordering
162169

163170

164171
with Progress(console=console) as progress:
165-
task_build = progress.add_task(description=f"{target}: PeriphDrivers", total=(len(projects) * len(boards)) + len(boards))
172+
task_build = progress.add_task(description=f"{target}: PeriphDrivers", total=(len(_projects) * len(boards)) + len(boards))
166173

167174
periph_success = True
168175

169176
# Find Hello_World and do a PeriphDriver build test first.
170177
hello_world = None
171-
for p in projects:
178+
for p in _projects:
172179
if p.name == "Hello_World":
173180
hello_world = p
174181

@@ -211,7 +218,7 @@ def test(maxim_path : Path = None, targets=None, boards=None, projects=None):
211218

212219
if periph_success:
213220
# Iteratively across and test example projects
214-
for project in projects:
221+
for project in _projects:
215222
project_name = project.name
216223

217224
for board in boards:
@@ -254,10 +261,10 @@ def test(maxim_path : Path = None, targets=None, boards=None, projects=None):
254261
elif not periph_success:
255262
progress.update(task_build, description=f"[bold cyan]{target}[/bold cyan]: [red]PeriphDriver build failed.[/red]", refresh=True)
256263
else:
257-
progress.update(task_build, description=f"[bold cyan]{target}[/bold cyan]: [red]Failed for {target_fails}/{len(projects)} projects[/red]", refresh=True)
264+
progress.update(task_build, description=f"[bold cyan]{target}[/bold cyan]: [red]Failed for {target_fails}/{len(_projects)} projects[/red]", refresh=True)
258265

259266
boards = None # Reset boards list
260-
projects = None # Reset projects list
267+
_projects = None # Reset projects list
261268

262269
console.print(f"Tested {count} cases. {count - len(failed)}/{count} succeeded.")
263270
if (len(warnings) > 0):
@@ -283,6 +290,7 @@ def test(maxim_path : Path = None, targets=None, boards=None, projects=None):
283290

284291
if __name__ == "__main__":
285292
args = parser.parse_args()
293+
inspect(args, title="Script arguments:", )
286294
exit(
287295
test(
288296
maxim_path=args.maxim_path,

Libraries/CMSIS/Device/Maxim/GCC/gcc.mk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ debug:
503503
.PHONY: project_defines
504504
project_defines: $(BUILD_DIR)/project_defines.h
505505
$(BUILD_DIR)/project_defines.h: mkbuildir
506-
$(file > $(BUILD_DIR)/empty.c,)
507-
$(file > $(BUILD_DIR)/project_defines.h,// This is a generated file that's used to detect definitions that have been set by the compiler and build system.)
508-
@$(CC) -E -P -dD $(BUILD_DIR)/empty.c $(CFLAGS) >> $(BUILD_DIR)/project_defines.h
509-
@rm $(BUILD_DIR)/empty.c
510-
@rm empty.d
506+
@echo "" > $(BUILD_DIR)/_empty_tmp_file.c
507+
@echo "// This is a generated file that's used to detect definitions that have been set by the compiler and build system." > $@
508+
@$(CC) -E -P -dD $(BUILD_DIR)/_empty_tmp_file.c $(CFLAGS) >> $@
509+
@rm $(BUILD_DIR)/_empty_tmp_file.c
510+
@rm _empty_tmp_file.d

Libraries/CMSIS/Device/Maxim/GCC/gcc_riscv.mk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ debug:
460460
.PHONY: project_defines
461461
project_defines: $(BUILD_DIR)/project_defines.h
462462
$(BUILD_DIR)/project_defines.h: mkbuildir
463-
$(file > $(BUILD_DIR)/empty.c,)
464-
$(file > $(BUILD_DIR)/project_defines.h,// This is a generated file that's used to detect definitions that have been set by the compiler and build system.)
465-
@$(CC) -E -P -dD $(BUILD_DIR)/empty.c $(CFLAGS) >> $(BUILD_DIR)/project_defines.h
466-
@rm $(BUILD_DIR)/empty.c
467-
@rm empty.d
463+
@echo "" > $(BUILD_DIR)/_empty_tmp_file.c
464+
@echo "// This is a generated file that's used to detect definitions that have been set by the compiler and build system." > $@
465+
@$(CC) -E -P -dD $(BUILD_DIR)/_empty_tmp_file.c $(CFLAGS) >> $@
466+
@rm $(BUILD_DIR)/_empty_tmp_file.c
467+
@rm _empty_tmp_file.d

commitlint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ module.exports = {
1111
* Any rules defined here will override rules from @commitlint/config-conventional
1212
*/
1313
rules: {
14-
"scope-enum": [2, "always", ["Documentation", "Examples", "Tools", "BLE", "Boards", "CMSIS", "MiscDrivers", "PeriphDrivers", "ThirdParty", "SDHC", "MAXUSB", "ignore", "workflow", "Other"]],
14+
"scope-enum": [2, "always", ["Documentation", "Build", "Examples", "Tools", "BLE", "Boards", "CMSIS", "MiscDrivers", "PeriphDrivers", "ThirdParty", "SDHC", "MAXUSB", "ignore", "workflow", "Other"]],
1515
"scope-empty": [2, "never"],
1616
"type-enum": [2, "always", ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test"]],
1717
"subject-case": [2, "always", ["sentence-case", "start-case", "pascal-case", "upper-case"]],
1818
"body-case": [2, "always", ["sentence-case", "start-case", "pascal-case", "upper-case"]],
1919
}
2020

21-
};
21+
};

0 commit comments

Comments
 (0)