Docker-based SDCC Toolchain
The SDCC parameters can be added to a <source_file_name>.params
file
Ex.:
> ls
asm.s
asm.params
file.c
file.params
other.asm
other.params
- For executable files:
SDCC_ARGS="--code-loc 0x180 --data-loc 0 -mz80 --disable-warning 196 --no-std-crt0 $SDCC_LIB/crt0_msxdos_advanced.rel $SDCC_LIB/printf.rel $SDCC_LIB/putchar_msxdos.rel asm.lib fusion.lib"
TARGET_BIN_FILE="$FILE_NAME.com"
- For library files:
SDCC_ARGS="--code-loc 0x180 --data-loc 0 -mz80 --disable-warning 196 --no-std-crt0"
TARGET_LIB_FILE="$FILE_NAME.lib"
Ps.: You can use environment variables on .params
file. To get a list of available variables, execute info
command.
docker run --rm \
rfocosi/sdcc-toolchain:latest \
info
To build a single source file, run:
docker run --rm \
-v {/host-workspace/}:/workspace/ \
-v {/host-extra-lib/}:/extra-lib/ \
-v {/host-extra-include/}:/extra-include/ \
rfocosi/sdcc-toolchain:latest \
build "file.c"
To build all project's sources:
docker run --rm \
-v {/host-workspace/}:/workspace/ \
-v {/host-extra-lib/}:/extra-lib/ \
-v {/host-extra-include/}:/extra-include/ \
rfocosi/sdcc-toolchain:latest \
build "*.c"
docker run --rm \
-e SDAS_BIN=sdasz80 \
-v {/host-workspace/}:/workspace/ \
-v {/host-extra-lib/}:/extra-lib/ \
-v {/host-extra-include/}:/extra-include/ \
rfocosi/sdcc-toolchain:latest \
sdasm "asm.s"
To build all:
docker run --rm \
-e SDAS_BIN=sdasz80 \
-v {/host-workspace/}:/workspace/ \
-v {/host-extra-lib/}:/extra-lib/ \
-v {/host-extra-include/}:/extra-include/ \
rfocosi/sdcc-toolchain:latest \
sdasm "*.s"
Removes build\
and target\
directories
docker run --rm \
-v {/host-workspace/}:/workspace/ \
rfocosi/sdcc-toolchain:latest \
clean
- Create a
docker-composer.yml
on your project's root:
version: '3'
services:
sdcc:
image: rfocosi/sdcc-toolchain:latest
environment:
- SDAS_BIN=sdasz80
volumes:
- ${PROJECT_WORKSPACE}:/workspace
- ${PROJECT_EXTRA_LIBS}:/extra-lib
- ${PROJECT_EXTRA_INCLUDES}:/extra-include
- Create a
.env
on your project's root:
# Your project source files' root directory
PROJECT_WORKSPACE=./workspace
# Directory of your library files, if any (\*.lib, \*.rel)
PROJECT_EXTRA_LIBS=./share/lib
# Directory of your include files, if any (\*.h)
PROJECT_EXTRA_INCLUDES=./share/include
docker-compose run --rm sdcc info
To build a single source file, run:
docker-compose run --rm sdcc build "file.c"
To build all project's sources:
docker-compose run --rm sdcc build "*.c"
Ps.: The root directory is $PROJECT_WORKSPACE\src
docker-compose run --rm sdcc sdasm "asm.s"
To build all:
docker-compose run --rm sdcc sdasm "*.s"
docker-compose run --rm sdcc clean