Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 9, 2024
1 parent 71b333c commit 4a31dd7
Showing 1 changed file with 66 additions and 45 deletions.
111 changes: 66 additions & 45 deletions packages/project-editor/lvgl/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1366,19 +1366,24 @@ extern const ext_img_desc_t images[${this.bitmaps.length || 1}];
}

async copyBitmapFiles() {
if (!this.project.settings.build.destinationFolder) {
const destinationFolder = this.project.settings.build.destinationFolder;
if (!destinationFolder) {
return;
}
for (const bitmap of this.bitmaps) {
const output = "ui_image_" + this.bitmapNames.get(bitmap.objID)!;

try {
let source = await getLvglBitmapSourceFile(
bitmap,
this.getImageVariableName(bitmap)
);
await Promise.all(
this.bitmaps.map(bitmap =>
(async () => {
const output =
"ui_image_" + this.bitmapNames.get(bitmap.objID)!;

try {
let source = await getLvglBitmapSourceFile(
bitmap,
this.getImageVariableName(bitmap)
);

source = `#ifdef __has_include
source = `#ifdef __has_include
#if __has_include("lvgl.h")
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
#define LV_LVGL_H_INCLUDE_SIMPLE
Expand All @@ -1387,48 +1392,64 @@ extern const ext_img_desc_t images[${this.bitmaps.length || 1}];
#endif
${source}`;

await writeTextFile(
this.project._store.getAbsoluteFilePath(
this.project.settings.build.destinationFolder
) +
"/" +
output +
".c",
source
);
} catch (err) {
this.project._store.outputSectionsStore.write(
Section.OUTPUT,
MessageType.ERROR,
`Error genereting bitmap '${output}.c' file: ${err}`
);
}
}
await writeTextFile(
this.project._store.getAbsoluteFilePath(
destinationFolder
) +
"/" +
output +
".c",
source
);
} catch (err) {
this.project._store.outputSectionsStore.write(
Section.OUTPUT,
MessageType.ERROR,
`Error genereting bitmap file '${output}.c': ${err}`
);
}
})()
)
);
}

async copyFontFiles() {
if (!this.project.settings.build.destinationFolder) {
const destinationFolder = this.project.settings.build.destinationFolder;
if (!destinationFolder) {
return;
}
for (const font of this.fonts) {
if (font.lvglSourceFile) {
const output = getName(
"ui_font_",
font.name || "",
NamingConvention.UnderscoreLowerCase
);

await writeTextFile(
this.project._store.getAbsoluteFilePath(
this.project.settings.build.destinationFolder
) +
"/" +
output +
".c",
font.lvglSourceFile
);
}
}
await Promise.all(
this.fonts.map(font =>
(async () => {
if (font.lvglSourceFile) {
const output = getName(
"ui_font_",
font.name || "",
NamingConvention.UnderscoreLowerCase
);

try {
await writeTextFile(
this.project._store.getAbsoluteFilePath(
destinationFolder
) +
"/" +
output +
".c",
font.lvglSourceFile
);
} catch (err) {
this.project._store.outputSectionsStore.write(
Section.OUTPUT,
MessageType.ERROR,
`Error writing font file '${output}.c': ${err}`
);
}
}
})()
)
);
}
}

Expand Down

0 comments on commit 4a31dd7

Please sign in to comment.