Skip to content

Commit 81faa9f

Browse files
committed
Add make.bat for exceptions sample
The cpp-baremetal-semihosting-exceptions sample is the only sample missing a make.bat for running on Windows. A batch file has now been added based on the others to carry out the same commands as the Makefile, but without the grep commands since these are less likely to be available.
1 parent 2f683fa commit 81faa9f

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

samples/src/cpp-baremetal-semihosting-exceptions/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ hello.hex: hello.cpp
2525
$(BIN_PATH)/llvm-objcopy -O ihex hello.elf hello.hex
2626

2727
hello-exn.hex: hello-exn.cpp
28-
$(BIN_PATH)/clang++ $(MICROBIT_TARGET) $(CRT_SEMIHOST) -print-multi-directory -g -T ../../ldscripts/microbit.ld -o hello.elf $^ | grep "_exn_"
28+
$(BIN_PATH)/clang++ $(MICROBIT_TARGET) $(CRT_SEMIHOST) -print-multi-directory -g -T ../../ldscripts/microbit.ld -o hello-exn.elf $^ | grep "_exn_"
2929
$(BIN_PATH)/clang++ $(MICROBIT_TARGET) $(CRT_SEMIHOST) -g -T ../../ldscripts/microbit.ld -o hello-exn.elf $^
3030
$(BIN_PATH)/llvm-objcopy -O ihex hello-exn.elf hello-exn.hex
3131

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
@REM Copyright (c) 2024, Arm Limited and affiliates.
2+
@REM SPDX-License-Identifier: Apache-2.0
3+
@REM
4+
@REM Licensed under the Apache License, Version 2.0 (the "License");
5+
@REM you may not use this file except in compliance with the License.
6+
@REM You may obtain a copy of the License at
7+
@REM
8+
@REM http://www.apache.org/licenses/LICENSE-2.0
9+
@REM
10+
@REM Unless required by applicable law or agreed to in writing, software
11+
@REM distributed under the License is distributed on an "AS IS" BASIS,
12+
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@REM See the License for the specific language governing permissions and
14+
@REM limitations under the License.
15+
16+
@if [%1]==[] goto :target_empty
17+
@set target=%1
18+
@goto :make
19+
:target_empty
20+
@set target=build
21+
22+
:make
23+
@if [%target%]==[build] goto :build
24+
@if [%target%]==[run] goto :run
25+
@if [%target%]==[clean] goto :clean
26+
@echo Error: unknown target "%target%"
27+
@exit /B 1
28+
29+
:build
30+
@if [%BIN_PATH%]==[] goto :bin_path_empty
31+
@call :build_fn
32+
@exit /B
33+
34+
:run
35+
@if exist hello.hex goto :do_run
36+
@if [%BIN_PATH%]==[] goto :bin_path_empty
37+
@call :build_fn
38+
:do_run
39+
qemu-system-arm.exe -M microbit -semihosting -nographic -device loader,file=hello.hex
40+
qemu-system-arm.exe -M microbit -semihosting -nographic -device loader,file=hello-exn.hex
41+
@exit /B
42+
43+
:clean
44+
if exist hello.elf del /q hello.elf
45+
if exist hello.hex del /q hello.hex
46+
if exist hello-exn.elf del /q hello-exn.elf
47+
if exist hello-exn.hex del /q hello-exn.hex
48+
@exit /B
49+
50+
:bin_path_empty
51+
@echo Error: BIN_PATH environment variable is not set
52+
@exit /B 1
53+
54+
:build_fn
55+
%BIN_PATH%\clang++.exe --target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m -mfpu=none -lcrt0-semihost -lsemihost -fno-exceptions -fno-rtti -print-multi-directory -g -T ..\..\ldscripts\microbit.ld -o hello.elf hello.cpp
56+
%BIN_PATH%\clang++.exe --target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m -mfpu=none -lcrt0-semihost -lsemihost -fno-exceptions -fno-rtti -g -T ..\..\ldscripts\microbit.ld -o hello.elf hello.cpp
57+
%BIN_PATH%\llvm-objcopy.exe -O ihex hello.elf hello.hex
58+
%BIN_PATH%\clang++.exe --target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m -mfpu=none -lcrt0-semihost -lsemihost -print-multi-directory -g -T ..\..\ldscripts\microbit.ld -o hello-exn.elf hello-exn.cpp
59+
%BIN_PATH%\clang++.exe --target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m -mfpu=none -lcrt0-semihost -lsemihost -g -T ..\..\ldscripts\microbit.ld -o hello-exn.elf hello-exn.cpp
60+
%BIN_PATH%\llvm-objcopy.exe -O ihex hello-exn.elf hello-exn.hex
61+
@exit /B
62+
63+
:build_exn_fn
64+
@exit /B

0 commit comments

Comments
 (0)