Skip to content

Commit e2a3d9f

Browse files
committed
Small improvement in generate-fonts.py following code review.
Add lv_img_conf in Docker image to build resources at build time.
1 parent cbe2f08 commit e2a3d9f

File tree

6 files changed

+39
-3
lines changed

6 files changed

+39
-3
lines changed

CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ if(BUILD_DFU)
5454
set(BUILD_DFU true)
5555
endif()
5656

57+
if(BUILD_RESOURCES)
58+
set(BUILD_RESOURCES true)
59+
endif()
60+
5761
set(TARGET_DEVICE "PINETIME" CACHE STRING "Target device")
5862
set_property(CACHE TARGET_DEVICE PROPERTY STRINGS PINETIME MOY-TFK5 MOY-TIN5 MOY-TON5 MOY-UNK)
5963

@@ -98,6 +102,11 @@ if(BUILD_DFU)
98102
else()
99103
message(" * Build DFU (using adafruit-nrfutil) : Disabled")
100104
endif()
105+
if(BUILD_RESOURCES)
106+
message(" * Build resources : Enabled")
107+
else()
108+
message(" * Build resources : Disabled")
109+
endif()
101110

102111
set(VERSION_EDIT_WARNING "// Do not edit this file, it is automatically generated by CMAKE!")
103112
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/Version.h)

docker/Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ RUN apt-get update -qq \
2222
python3-dev \
2323
git \
2424
apt-utils \
25+
pkg-config \
26+
libpixman-1-dev \
27+
libcairo2-dev \
28+
libpango-1.0-0 \
29+
ibpango1.0-dev \
30+
libpangocairo-1.0-0 \
2531
&& curl -sL https://deb.nodesource.com/setup_18.x | bash - \
2632
&& apt-get install -y nodejs \
2733
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*;
@@ -33,6 +39,10 @@ RUN pip3 install -Iv cryptography==3.3
3339
RUN pip3 install cbor
3440
RUN npm i lv_font_conv@1.5.2 -g
3541

42+
RUN npm i ts-node@10.9.1 -g
43+
RUN npm i @swc/core -g
44+
RUN npm i lv_img_conv@0.3.0 -g
45+
3646
# build.sh knows how to compile
3747
COPY build.sh /opt/
3848

docker/build.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export SOURCES_DIR="${SOURCES_DIR:=/sources}"
1111
export BUILD_DIR="${BUILD_DIR:=$SOURCES_DIR/build}"
1212
export OUTPUT_DIR="${OUTPUT_DIR:=$SOURCES_DIR/build/output}"
1313

14+
# Specify a folder with read/write access to NPM
15+
export NPM_DIR="$BUILD_DIR/npm"
16+
export npm_config_cache="${NPM_DIR}"
17+
1418
export BUILD_TYPE=${BUILD_TYPE:=Release}
1519
export GCC_ARM_VER=${GCC_ARM_VER:="10.3-2021.10"}
1620
export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"}
@@ -62,7 +66,8 @@ CmakeGenerate() {
6266
-DUSE_OPENOCD=1 \
6367
-DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_PATH" \
6468
-DNRF5_SDK_PATH="$TOOLS_DIR/$NRF_SDK_VER" \
65-
-DBUILD_DFU=1
69+
-DBUILD_DFU=1 \
70+
-DBUILD_RESOURCES=1
6671
}
6772

6873
CmakeBuild() {

docker/post_build.sh.in

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ cp "$BUILD_DIR/src/pinetime-mcuboot-app-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/p
1515
cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin"
1616
cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip"
1717

18+
cp "$BUILD_DIR/src/resources/infinitime-resources-$PROJECT_VERSION.zip" "$OUTPUT_DIR/infinitime-resources-$PROJECT_VERSION.zip"
19+
1820
mkdir -p "$OUTPUT_DIR/src"
1921
cp $BUILD_DIR/src/*.bin "$OUTPUT_DIR/src/"
2022
cp $BUILD_DIR/src/*.hex "$OUTPUT_DIR/src/"

src/CMakeLists.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,10 @@ add_custom_command(TARGET ${EXECUTABLE_NAME}
940940
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_FILE_NAME}.out "${EXECUTABLE_FILE_NAME}.hex"
941941
COMMENT "post build steps for ${EXECUTABLE_FILE_NAME}")
942942

943+
if(BUILD_RESOURCES)
944+
add_dependencies(${EXECUTABLE_NAME} GenerateResources)
945+
endif()
946+
943947
# Build binary intended to be used by bootloader
944948
set(EXECUTABLE_MCUBOOT_NAME "pinetime-mcuboot-app")
945949
set(EXECUTABLE_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
@@ -973,6 +977,10 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
973977
COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_FILE_NAME}"
974978
)
975979

980+
if(BUILD_RESOURCES)
981+
add_dependencies(${EXECUTABLE_MCUBOOT_NAME} GenerateResources)
982+
endif()
983+
976984
if(BUILD_DFU)
977985
add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
978986
POST_BUILD
@@ -1127,7 +1135,9 @@ if(BUILD_DFU)
11271135
)
11281136
endif()
11291137

1130-
add_subdirectory(resources)
1138+
if(BUILD_RESOURCES)
1139+
add_subdirectory(resources)
1140+
endif()
11311141

11321142

11331143
# FLASH

src/resources/generate-fonts.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, d):
2020

2121
def gen_lvconv_line(lv_font_conv: str, dest: str, size: int, bpp: int, format: str, sources: typing.List[Source], compress:bool=False):
2222
if format != "lvgl" and format != "bin":
23-
format = "lvgl"
23+
format = "bin" if dest.lower().endswith(".bin") else "lvgl"
2424

2525
args = [lv_font_conv, '--size', str(size), '--output', dest, '--bpp', str(bpp), '--format', format]
2626
if not compress:

0 commit comments

Comments
 (0)