Skip to content

Commit dce6114

Browse files
authored
Merge pull request #48 from esp-cpp/ci/build-package
Add CI for building and uploading
2 parents ccf788b + a692cd4 commit dce6114

File tree

22 files changed

+224
-274
lines changed

22 files changed

+224
-274
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repo
12+
uses: actions/checkout@v2
13+
with:
14+
submodules: 'recursive'
15+
16+
- name: Build Examples
17+
uses: espressif/esp-idf-ci-action@v1
18+
with:
19+
esp_idf_version: release-v5.2
20+
target: esp32s3
21+
path: '.'

.github/workflows/package_main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build and Package Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
continue-on-error: false
14+
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v2
18+
with:
19+
submodules: 'recursive'
20+
21+
- name: Build Main Code
22+
uses: espressif/esp-idf-ci-action@v1
23+
with:
24+
esp_idf_version: release-v5.2
25+
target: esp32s3
26+
path: '.'
27+
command: './patches.sh && idf.py build'
28+
29+
- name: Upload Build Outputs
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: build-artifacts
33+
path: build/bootloader/bootloader.bin
34+
path: build/partition_table/partition-table.bin
35+
path: build/esp-box-emu.bin
36+
37+
- name: Attach files to release
38+
uses: softprops/action-gh-release@v1
39+
if: ${{ github.event.release && github.event.action == 'published' }}
40+
with:
41+
files: |
42+
build/esp-box-emu.bin
43+
build/bootloader/bootloader.bin
44+
build/partition_table/partition-table.bin
45+
build/flash_args
46+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Static analysis
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
static_analysis:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repo
11+
uses: actions/checkout@v2
12+
with:
13+
submodules: 'recursive'
14+
15+
- name: Run static analysis
16+
uses: esp-cpp/StaticAnalysis@master
17+
with:
18+
# Do not build the project and do not use cmake to generate compile_commands.json
19+
use_cmake: false
20+
21+
# Use the 5.2 release version since it's what we build with
22+
esp_idf_version: release/v5.2
23+
24+
# (Optional) cppcheck args
25+
cppcheck_args: -i$GITHUB_WORKSPACE/lib -i$GITHUB_WORKSPACE/components/gbc/gnuboy -i$GITHUB_WORKSPACE/components/nes/nofrendo -i$GITHUB_WORKSPACE/components/gui/generated -i$GITHUB_WORKSPACE/components/menu/generated -i$GITHUB_WORKSPACE/components/jpegdec -i$GITHUB_WORKSPACE/components/codec -i$GITHUB_WORKSPACE/components/espp --force --enable=all --inline-suppr --inconclusive --platform=mips32 --suppressions-list=$GITHUB_WORKSPACE/suppressions.txt

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@
44
[submodule "components/jpegdec"]
55
path = components/jpegdec
66
url = git@github.com:bitbank2/JPEGDEC
7-
[submodule "components/jpegenc"]
8-
path = components/jpegenc
9-
url = git@github.com:esp-cpp/JPEGENC

components/box-emu-hal/src/i2s_audio.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ int get_audio_volume() {
7979

8080
static esp_err_t i2s_driver_init(void)
8181
{
82-
printf("initializing i2s driver...\n");
82+
fmt::print("initializing i2s driver...\n");
8383
auto ret_val = ESP_OK;
84-
printf("Using newer I2S standard\n");
84+
fmt::print("Using newer I2S standard\n");
8585
i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(i2s_port, I2S_ROLE_MASTER);
8686
chan_cfg.auto_clear = true; // Auto clear the legacy data in the DMA buffer
8787
ESP_ERROR_CHECK(i2s_new_channel(&chan_cfg, &tx_handle, &rx_handle));
@@ -114,7 +114,7 @@ static esp_err_t i2s_driver_init(void)
114114
// es7210 is for audio input codec
115115
static esp_err_t es7210_init_default(void)
116116
{
117-
printf("initializing es7210 codec...\n");
117+
fmt::print("initializing es7210 codec...\n");
118118
esp_err_t ret_val = ESP_OK;
119119
audio_hal_codec_config_t cfg;
120120
memset(&cfg, 0, sizeof(cfg));
@@ -131,7 +131,7 @@ static esp_err_t es7210_init_default(void)
131131
ret_val |= es7210_adc_ctrl_state(cfg.codec_mode, AUDIO_HAL_CTRL_START);
132132

133133
if (ESP_OK != ret_val) {
134-
printf("Failed initialize codec\n");
134+
fmt::print("Failed initialize codec\n");
135135
}
136136

137137
return ret_val;
@@ -140,7 +140,7 @@ static esp_err_t es7210_init_default(void)
140140
// es8311 is for audio output codec
141141
static esp_err_t es8311_init_default(void)
142142
{
143-
printf("initializing es8311 codec...\n");
143+
fmt::print("initializing es8311 codec...\n");
144144
esp_err_t ret_val = ESP_OK;
145145
audio_hal_codec_config_t cfg;
146146
memset(&cfg, 0, sizeof(cfg));
@@ -158,7 +158,7 @@ static esp_err_t es8311_init_default(void)
158158
ret_val |= es8311_codec_ctrl_state(cfg.codec_mode, AUDIO_HAL_CTRL_START);
159159

160160
if (ESP_OK != ret_val) {
161-
printf("Failed initialize codec\n");
161+
fmt::print("Failed initialize codec\n");
162162
}
163163

164164
return ret_val;
@@ -212,10 +212,10 @@ static void init_mute_button(void) {
212212
.callback = [](auto &m, auto&cv) -> bool {
213213
static gpio_num_t io_num;
214214
if (xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) {
215-
// invert the state since these are active low switches
216-
bool pressed = !gpio_get_level(io_num);
217215
// see if it's the mute button
218216
if (io_num == mute_pin) {
217+
// invert the state since these are active low switches
218+
bool pressed = !gpio_get_level(io_num);
219219
// NOTE: the MUTE is actually connected to a flip-flop which holds
220220
// state, so pressing it actually toggles the state that we see on
221221
// the ESP pin. Therefore, when we get an edge trigger, we should
@@ -251,7 +251,7 @@ void audio_init() {
251251

252252
/* Checko IO config result */
253253
if (ESP_OK != bsp_io_config_state) {
254-
printf("Failed initialize power control IO\n");
254+
fmt::print("Failed initialize power control IO\n");
255255
}
256256

257257
gpio_set_level(sound_power_pin, 1);
@@ -282,9 +282,9 @@ void audio_play_frame(uint8_t *data, uint32_t num_bytes) {
282282
auto err = ESP_OK;
283283
err = i2s_channel_write(tx_handle, data, num_bytes, &bytes_written, 1000);
284284
if(num_bytes != bytes_written) {
285-
printf("ERROR to write %ld != written %d\n", num_bytes, bytes_written);
285+
fmt::print("ERROR to write {} != written {}\n", num_bytes, bytes_written);
286286
}
287287
if (err != ESP_OK) {
288-
printf("ERROR writing i2s channel: %d, '%s'\n", err, esp_err_to_name(err));
288+
fmt::print("ERROR writing i2s channel: {}, '{}'\n", err, esp_err_to_name(err));
289289
}
290290
}

components/gbc/src/gameboy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ void start_gameboy_tasks() {
310310
}
311311

312312
std::vector<uint8_t> get_gameboy_video_buffer() {
313-
uint8_t* frame_buffer = get_frame_buffer0();
313+
const uint8_t* frame_buffer = get_frame_buffer0();
314314
// copy the frame buffer to a new buffer
315315
auto width = GAMEBOY_SCREEN_WIDTH;
316316
auto height = GAMEBOY_SCREEN_HEIGHT;

components/gui/include/gui.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Gui {
3333
espp::Logger::Verbosity log_level{espp::Logger::Verbosity::WARN};
3434
};
3535

36-
Gui(const Config& config)
36+
explicit Gui(const Config& config)
3737
: play_haptic_(config.play_haptic),
3838
set_waveform_(config.set_waveform),
3939
display_(config.display),
@@ -64,7 +64,7 @@ class Gui {
6464
ready_to_play_ = new_state;
6565
}
6666

67-
bool ready_to_play() {
67+
bool ready_to_play() const {
6868
return ready_to_play_;
6969
}
7070

@@ -84,7 +84,7 @@ class Gui {
8484

8585
void add_rom(const RomInfo& rom);
8686

87-
std::optional<const RomInfo*> get_selected_rom() {
87+
std::optional<const RomInfo*> get_selected_rom() const {
8888
if (focused_rom_ < 0 || focused_rom_ >= rom_infos_.size()) {
8989
return std::nullopt;
9090
}

components/jpeg/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
idf_component_register(
22
SRC_DIRS "src"
33
INCLUDE_DIRS "include"
4-
REQUIRES heap jpegdec format lvgl box-emu-hal)
4+
REQUIRES "heap" "jpegdec" "format" "lvgl" "box-emu-hal")

components/jpeg/include/jpeg.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "spi_lcd.h"
99

1010
#include "format.hpp"
11-
#include "jpegdec.h"
11+
#include "JPEGDEC.h"
1212

1313
class Jpeg {
1414
public:
@@ -76,7 +76,7 @@ class Jpeg {
7676
imgfile_.open(filename, std::ios::binary | std::ios::ate);
7777
if (!imgfile_.is_open()) {
7878
fmt::print("Couldn't open {}\n", filename);
79-
size = 0;
79+
*size = 0;
8080
return;
8181
}
8282
// get size from current location (end)
@@ -110,7 +110,7 @@ class Jpeg {
110110
auto ys = pDraw->y;
111111
auto ye = pDraw->y + height - 1;
112112
uint16_t *dst_buffer = (uint16_t*)decoded_data_;
113-
uint16_t *src_buffer = (uint16_t*)pDraw->pPixels;
113+
const uint16_t *src_buffer = (const uint16_t*)pDraw->pPixels;
114114
// two bytes per pixel for RGB565
115115
auto num_bytes_per_row = width * 2;
116116
for (int y=ys; y<=ye; y++) {

components/jpegenc

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)