Skip to content

Commit ec893e8

Browse files
committed
remove path assumptions from compiler wrapper scripts for IDE build (fully functional for Linux now)
1 parent 9efb6af commit ec893e8

8 files changed

Lines changed: 164 additions & 157 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ forum. It will help to catch my attention to prefix your topic with
4343

4444
## Usage example
4545

46+
*Preview: IDE integration is on the way now! It already works for Linux (and
47+
probably MacOS), Windows is to follow soon*
48+
4649
If you have ever used the Arduino environment before you will feel at home
4750
right away, despite this project beeing based on a makefile rather than the
4851
full Arduino IDE. But don't be afraid, it is based on the amazing

docs/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ including shipping on [aliexpress](http://www.aliexpress.com/).
1616

1717
## Usage
1818

19+
*Preview: IDE integration is on the way now! It already works for Linux (and
20+
probably MacOS), Windows is to follow soon*
21+
1922
If you have ever used the Arduino environment before you will feel at home
2023
right away, despite this project beeing based on a makefile rather than the
2124
full Arduino IDE. But don't be afraid, it is based on the amazing
@@ -318,6 +321,18 @@ Migration guideline within the STM8L familiy
318321

319322

320323

324+
## Similar or related projects
325+
326+
None of these projects are related to or part of Sduino. They are written
327+
independently, but with a similar goal in mind: To simplify STM8 programming
328+
for the beginner.
329+
330+
[STM8Sduino](https://github.com/dannyf00/STM8Sduino): A minimalistic
331+
approach to adopt parts of the Arduino-API to the STM8. Based on IAR and
332+
COSMIC compiler (Windows only). Port to SDCC shouldn't be too hard but is
333+
not done yet. Low overhead, but basic functions only. No support for porting
334+
Arduino libraries.
335+
321336

322337

323338

sduino/hardware/sduino/stm8/platform.txt

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,27 @@ compiler.warning_flags.more=-Wall
1818
compiler.warning_flags.all=-Wall -Wextra
1919

2020
# Default "compiler.path" is correct, change only if you want to override the initial value
21-
compiler.path={runtime.hardware.path}/tools/sdcc/bin/
21+
compiler.path=/opt/sdcc/bin/
22+
compiler.path.windows={runtime.hardware.path}/tools/sdcc/bin/
23+
compiler.wrapper.path={runtime.hardware.path}/tools/wrapper/
2224
compiler.tools.path=/usr/bin/
23-
#compiler.tools.path={runtime.hardware.path}/tools/bin/
24-
compiler.path.emu={runtime.hardware.path}/tools/linux/
25-
compiler.path.emu.windows={runtime.hardware.path}/tools/win/
26-
compiler.path.emu.macos={runtime.hardware.path}/tools/macos/
27-
#/home/mmayer/stm8/abuild/
28-
29-
compiler.c.cmd=sdcc-pseudo-g++
30-
compiler.c.cmd.windows=sdcc-pseudo-g++.bat
25+
compiler.tools.path.windows={runtime.hardware.path}/tools/bin/
26+
27+
compiler.c.cmd=sdcc
28+
compiler.c.wrapper=sdcc.sh
3129
compiler.c.flags=-MMD -c -Ddouble=float -D__PROG_TYPES_COMPAT__ {compiler.warning_flags}
3230
compiler.c.elf.flags=--code-size {upload.maximum_size} --iram-size {upload.maximum_data_size}
3331

34-
compiler.c.elf.cmd=sdcc-link
35-
compiler.c.elf.cmd.windows=sdcc-link.bat
32+
compiler.c.elf.cmd=sdcc
33+
compiler.c.elf.wrapper=sdcc-link.sh
3634
compiler.S.flags=-c -g -x assembler-with-cpp -flto
3735

38-
compiler.cpp.cmd=sdcc-pseudo-g++
39-
compiler.cpp.cmd.windows=sdcc-pseudo-g++.bat
36+
compiler.cpp.cmd=sdcc
37+
compiler.cpp.wrapper=sdcc.sh
4038
compiler.cpp.flags=-MMD -c -Ddouble=float -D__PROG_TYPES_COMPAT__ {compiler.warning_flags}
4139

4240
compiler.ar.cmd=sdar
43-
compiler.ar.cmd.windows=sdar.exe
41+
compiler.ar.wrapper=sdar.sh
4442
compiler.ar.flags=rcs
4543

4644
compiler.objcopy.cmd=objcopy
@@ -50,19 +48,15 @@ compiler.objcopy.cmd=objcopy
5048
compiler.elf2hex.cmd=objcopy
5149
compiler.elf2hex.flags=-O ihex -R DATA -R INITIALIZED -R SSEG
5250

53-
compiler.syslibs.stdlib.path={runtime.hardware.path}/tools/sdcc/share/sdcc/
51+
compiler.syslibs.stdlib.path=/opt/sdcc/share/sdcc/
52+
compiler.syslibs.stdlib.path.windows={runtime.hardware.path}/tools/sdcc/share/sdcc/
5453
compiler.syslibs.spl.path={runtime.platform.path}/STM8S_StdPeriph_Driver/
5554

5655
compiler.ldflags=
57-
#compiler.ld.stdlib=lib/stm8/
5856

5957
compiler.size.cmd=size
6058
compiler.size.cmd.windows=size.exe
6159

62-
# Meine Ergänzungen, müssen irgendwie automatisiert werden:
63-
#compiler.systemincludes=-I/home/mmayer/rsync/stm8/STM8S_StdPeriph_Driver/inc -I/opt/sdcc/share/sdcc/include
64-
#compiler.systemincludes=-I/home/mmayer/rsync/stm8/STM8S_StdPeriph_Driver/inc "-I{runtime.hardware.path}/tools/sdcc/share/sdcc/include"
65-
#compiler.systemincludes="-I{runtime.platform.path}/STM8S_StdPeriph_Driver/inc" "-I{runtime.hardware.path}/tools/sdcc/share/sdcc/include"
6660
compiler.systemincludes="-I{compiler.syslibs.spl.path}inc" "-I{compiler.syslibs.stdlib.path}include"
6761

6862
# This can be overridden in boards.txt
@@ -81,36 +75,24 @@ compiler.elf2hex.extra_flags=
8175
# --------------------
8276

8377
## Compile c files (re1)
84-
recipe.c.o.pattern="{compiler.path.emu}{compiler.c.cmd}" "{source_file}" "{object_file}" re2 {compiler.c.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
78+
#recipe.c.o.pattern="{compiler.path.wrapper}{compiler.c.cmd}" "{source_file}" "{object_file}" re2 {compiler.c.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
79+
recipe.c.o.pattern="{compiler.wrapper.path}{compiler.c.wrapper}" "{compiler.path}{compiler.c.cmd}" "{source_file}" "{object_file}" re2 {compiler.c.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
8580

8681
## Compile c++ files (re2)
87-
recipe.cpp.o.pattern="{compiler.path.emu}{compiler.cpp.cmd}" "{source_file}" "{object_file}" re2 {compiler.cpp.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
88-
89-
# Soll-Aufruf .c.o:
90-
#/opt/sdcc/bin/sdcc "-Wp-MMD build-stm8sblue/Blink.c.d" -c -Ddouble=float -I.
91-
#-I/home/mmayer/rsync/stm8/sduino/../STM8S_StdPeriph_Driver/inc
92-
#-I/opt/sdcc/share/sdcc/include/ -mstm8 -DSTM8S103 -DF_CPU=16000000L
93-
#-DARDUINO=160 -DARDUINO_ARCH_STM8 -D__PROG_TYPES_COMPAT__
94-
#-I/home/mmayer/rsync/stm8/sduino/hardware/sduino/stm8/cores/sduino
95-
#-I/home/mmayer/rsync/stm8/sduino/hardware/sduino/stm8/variants/standard
96-
#Blink.c -o build-stm8sblue/Blink.c.rel
97-
98-
##FIXME Compile S files
82+
#recipe.cpp.o.pattern="{compiler.path.wrapper}{compiler.cpp.cmd}" "{source_file}" "{object_file}" re2 {compiler.cpp.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
83+
recipe.cpp.o.pattern="{compiler.wrapper.path}{compiler.cpp.wrapper}" "{compiler.path}{compiler.cpp.cmd}" "{source_file}" "{object_file}" re2 {compiler.cpp.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
84+
85+
##FIXME Compile S files (re3)
9986
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" re3 {compiler.S.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
10087

10188
## Create archives (re4)
10289
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
103-
archive_file_path={build.path}/{archive_file}
90+
#archive_file_path={build.path}/{archive_file}
10491
#recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
105-
recipe.ar.pattern="{compiler.path.emu}{compiler.ar.cmd}" "{archive_file_path}" "{object_file}" re4 {compiler.ar.flags} {compiler.ar.extra_flags}
92+
recipe.ar.pattern="{compiler.wrapper.path}{compiler.ar.wrapper}" "{compiler.path}{compiler.ar.cmd}" "{archive_file_path}" "{object_file}" re4 {compiler.ar.flags} {compiler.ar.extra_flags}
10693

10794
## Combine gc-sections, archives, and objects (re5)
108-
#recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" re5 {compiler.c.elf.flags} -mstm8 -D{build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
109-
# produziert ihx:
110-
#recipe.c.combine.pattern="{compiler.path.emu}{compiler.c.elf.cmd}" "-L{runtime.platform.path}/STM8S_StdPeriph_Driver/lib" "-L{build.path}" "-L{compiler.ld.stdlib}" {compiler.c.elf.flags} -mstm8 -D{build.mcu} {compiler.c.elf.extra_flags} {object_files} "{build.path}/{archive_file}" "{build.path}/core/main.c.rel" -l{build.mcu} -lstm8 -o "{build.path}/{build.project_name}.ihx"
111-
# produziert elf:
112-
#recipe.c.combine.pattern="{compiler.path.emu}{compiler.c.elf.cmd}" "-L{runtime.platform.path}/STM8S_StdPeriph_Driver/lib" "-L{build.path}" "-L{compiler.ld.stdlib}" {compiler.c.elf.flags} -mstm8 -D{build.mcu} {compiler.c.elf.extra_flags} {object_files} "{build.path}/{archive_file}" "{build.path}/core/main.c.rel" -l{build.mcu} -lstm8 --out-fmt-elf -o "{build.path}/{build.project_name}.elf"
113-
recipe.c.combine.pattern="{compiler.path.emu}{compiler.c.elf.cmd}" "-L{compiler.syslibs.spl.path}lib" "-L{build.path}" "-L{compiler.syslibs.stdlib.path}lib/stm8" {compiler.c.elf.flags} -mstm8 -D{build.mcu} {compiler.c.elf.extra_flags} {object_files} "{build.path}/{archive_file}" "{build.path}/core/main.c.rel" -l{build.mcu} -lstm8 --out-fmt-elf -o "{build.path}/{build.project_name}.elf"
95+
recipe.c.combine.pattern="{compiler.wrapper.path}{compiler.c.elf.wrapper}" "{compiler.path}{compiler.c.elf.cmd}" "-L{compiler.syslibs.spl.path}lib" "-L{build.path}" "-L{compiler.syslibs.stdlib.path}lib/stm8" {compiler.c.elf.flags} -mstm8 -D{build.mcu} {compiler.c.elf.extra_flags} {object_files} "{build.path}/{archive_file}" "{build.path}/core/main.c.rel" -l{build.mcu} -lstm8 --out-fmt-elf -o "{build.path}/{build.project_name}.elf"
11496

11597
# Soll-Wert:
11698
#/opt/sdcc/bin/sdcc
@@ -145,17 +127,18 @@ recipe.size.regex=^(?:HOME|GSINIT|GSFINAL|CODE|INITIALIZER)\s+([0-9]+).*
145127
recipe.size.regex.data=^(?:DATA|INITIALIZED)\s+([0-9]+).*
146128
recipe.size.regex.eeprom=^(?:EEPROM)\s+([0-9]+).*
147129

148-
## Preprocessor
130+
## Preprocessor (re11, re12)
149131
#preproc.includes.flags=-w -x c++ -M -MG -MP
150132
preproc.includes.flags=-M -MG -MP
151-
recipe.preproc.includes="{compiler.path.emu}{compiler.cpp.cmd}" re11 {compiler.cpp.flags} {preproc.includes.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"
133+
recipe.preproc.includes="{compiler.path.wrapper}{compiler.cpp.wrapper}" "{compiler.path}{compiler.cpp.cmd}" re11 {compiler.cpp.flags} {preproc.includes.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"
152134

153135
#preproc.macros.flags=-w -x c++ -E -CC
154136
preproc.macros.flags=-E -MC
155137
#recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" re12 {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"
156138
#recipe.preproc.macros="avr-g++" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"
157139
#recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" re12 {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"
158-
recipe.preproc.macros="{compiler.path.emu}{compiler.cpp.cmd}" "{source_file}" "{preprocessed_file_path}" re12 {compiler.cpp.flags} {preproc.macros.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
140+
#recipe.preproc.macros="{compiler.path.emu}{compiler.cpp.cmd}" "{source_file}" "{preprocessed_file_path}" re12 {compiler.cpp.flags} {preproc.macros.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
141+
recipe.preproc.macros="{compiler.wrapper.path}{compiler.cpp.cmd}.sh" "{compiler.path}{compiler.cpp.cmd}" "{source_file}" "{preprocessed_file_path}" re12 {compiler.cpp.flags} {preproc.macros.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
159142

160143

161144
# STlink/v2 Uploader

sduino/hardware/sduino/tools/linux64/sdar

Lines changed: 0 additions & 34 deletions
This file was deleted.

sduino/hardware/sduino/tools/linux64/sdcc-link

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/dash
2+
3+
# ANSI color codes to beautify the output:
4+
BLACK='\033[0;30m'
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
ORANGE='\033[0;33m'
8+
BLUE='\033[0;34m'
9+
PURPLE='\033[0;35m'
10+
CYAN='\033[0;36m'
11+
LGRAY='\033[0;37m'
12+
DGRAY='\033[1;30m'
13+
LRED='\033[1;31m'
14+
LGREEN='\033[1;32m'
15+
YELLOW='\033[1;33m'
16+
LBLUE='\033[1;34m'
17+
LPURPLE='\033[1;35m'
18+
LCYAN='\033[1;36m'
19+
WHITE='\033[1;37m'
20+
OFF='\033[0m'
21+
22+
23+
# echo the full command line in cyan:
24+
>&2 echo "${CYAN}${@}${OFF}"
25+
26+
# echo the mark id in green and the compiler call in white:
27+
SDAR=$1
28+
LIB=$2
29+
OBJ=${3%.o}.rel
30+
MARK=$4
31+
shift 4
32+
33+
>&2 echo "${GREEN}Mark $MARK:${OFF}" "$SDAR" "$@" "$LIB" "$OBJ"
34+
"$SDAR" "$@" "$LIB" "$OBJ"
35+
cp -a "$LIB" "${LIB%.a}.lib"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# usage: sdcc-link [.lib and .rel files] re5 [other flags and files]
4+
5+
# ANSI color codes to beautify the output:
6+
BLACK='\033[0;30m'
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
ORANGE='\033[0;33m'
10+
BLUE='\033[0;34m'
11+
PURPLE='\033[0;35m'
12+
CYAN='\033[0;36m'
13+
LGRAY='\033[0;37m'
14+
DGRAY='\033[1;30m'
15+
LRED='\033[1;31m'
16+
LGREEN='\033[1;32m'
17+
YELLOW='\033[1;33m'
18+
LBLUE='\033[1;34m'
19+
LPURPLE='\033[1;35m'
20+
LCYAN='\033[1;36m'
21+
WHITE='\033[1;37m'
22+
OFF='\033[0m'
23+
24+
SDCC="$1"
25+
shift
26+
27+
# echo the full command line in cyan:
28+
>&2 echo -e "${CYAN}${@}${OFF}"
29+
30+
declare -a OBJS
31+
while [ $# -gt 0 ]; do
32+
echo $1
33+
FILE=$1
34+
if [[ $FILE == *.a ]]; then
35+
FILE=${FILE%.a}.lib
36+
fi
37+
if [[ $FILE == *.o ]]; then
38+
FILE=${FILE%.o}.rel
39+
fi
40+
OBJS+=(${FILE})
41+
shift
42+
done
43+
echo "$SDCC" "${OBJS[@]}"
44+
"$SDCC" "${OBJS[@]}"

0 commit comments

Comments
 (0)