mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
chore: Add initial ESP32 docker build.
It won't actually run until we reduce memory consumption by 2 orders of magnitude, but that'll be the eventual goal.
This commit is contained in:
parent
3576df9d79
commit
d539e34f91
27
.github/workflows/docker.yml
vendored
27
.github/workflows/docker.yml
vendored
|
@ -111,6 +111,33 @@ jobs:
|
|||
cache-from: type=registry,ref=toxchat/c-toxcore:wasm
|
||||
cache-to: type=inline
|
||||
|
||||
docker-esp32:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
driver: docker
|
||||
- name: Login to DockerHub
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build toxchat/c-toxcore:sources
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
file: other/docker/sources/Dockerfile
|
||||
tags: toxchat/c-toxcore:sources
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
file: other/docker/esp32/Dockerfile
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
tags: toxchat/c-toxcore:esp32
|
||||
cache-from: type=registry,ref=toxchat/c-toxcore:esp32
|
||||
cache-to: type=inline
|
||||
|
||||
docker-win32:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
|
@ -1 +1 @@
|
|||
b3fb4157d7fc6cd3455f40020bb6b69e5bab4bbdb6ce66d5bc7095146ba5a49e /usr/local/bin/tox-bootstrapd
|
||||
4e6c181b03e20cdd0669296fae53a9433e31a7c37beed5430272fbefbf501bbb /usr/local/bin/tox-bootstrapd
|
||||
|
|
4
other/docker/esp32/CMakeLists.txt
Normal file
4
other/docker/esp32/CMakeLists.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(toxcore)
|
48
other/docker/esp32/Dockerfile
Normal file
48
other/docker/esp32/Dockerfile
Normal file
|
@ -0,0 +1,48 @@
|
|||
FROM toxchat/c-toxcore:sources AS src
|
||||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
|
||||
bison \
|
||||
ccache \
|
||||
cmake \
|
||||
flex \
|
||||
git \
|
||||
gperf \
|
||||
libncurses-dev \
|
||||
ninja-build \
|
||||
python \
|
||||
python-cryptography \
|
||||
python-future \
|
||||
python-pip \
|
||||
python-pyparsing \
|
||||
python-serial \
|
||||
python-setuptools \
|
||||
wget \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ESP32_TARBALL=xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0 \
|
||||
IDF_PATH="/root/esp/esp-idf" \
|
||||
PATH="/root/esp/esp-idf/tools:/root/esp/xtensa-esp32-elf/bin:$PATH"
|
||||
WORKDIR /root/esp
|
||||
RUN wget -q https://dl.espressif.com/dl/$ESP32_TARBALL.tar.gz \
|
||||
&& tar zxf $ESP32_TARBALL.tar.gz \
|
||||
&& rm -f $ESP32_TARBALL.tar.gz \
|
||||
&& git clone -b v3.3 --recursive --depth=1 --shallow-submodules https://github.com/espressif/esp-idf
|
||||
|
||||
# Build a hello world first, so the OS and libsodium etc. are compiled.
|
||||
WORKDIR /root/esp/toxcore
|
||||
COPY other/docker/esp32/CMakeLists.txt /root/esp/toxcore/
|
||||
COPY other/docker/esp32/hello/ /root/esp/toxcore/main/
|
||||
RUN idf.py build
|
||||
|
||||
# Then copy over the actual toxcore sources and build those.
|
||||
COPY --from=src /src/third_party/cmp/ /root/esp/toxcore/main/third_party/cmp/
|
||||
COPY --from=src /src/toxencryptsave/defines.h /root/esp/toxcore/main/toxencryptsave/
|
||||
COPY --from=src /src/toxcore/ /root/esp/toxcore/main/toxcore/
|
||||
COPY other/docker/esp32/toxcore/CMakeLists.txt /root/esp/toxcore/main/
|
||||
COPY other/docker/esp32/toxcore/toxcore_main.cc /root/esp/toxcore/main/other/docker/esp32/main/
|
||||
RUN idf.py build
|
||||
RUN ls -lh build/toxcore.bin \
|
||||
&& shasum build/toxcore.bin
|
4
other/docker/esp32/hello/CMakeLists.txt
Normal file
4
other/docker/esp32/hello/CMakeLists.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
set(COMPONENT_SRCS "hello_main.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "")
|
||||
|
||||
register_component()
|
6
other/docker/esp32/hello/hello_main.c
Normal file
6
other/docker/esp32/hello/hello_main.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
}
|
4
other/docker/esp32/run
Executable file
4
other/docker/esp32/run
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
docker build -t toxchat/c-toxcore:sources -f other/docker/sources/Dockerfile .
|
||||
docker build -t toxchat/c-toxcore:esp32 -f other/docker/esp32/Dockerfile .
|
12
other/docker/esp32/toxcore/CMakeLists.txt
Normal file
12
other/docker/esp32/toxcore/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers")
|
||||
|
||||
file(GLOB toxcore_SRCS "toxcore/*.[ch]" "toxcore/*/*.[ch]")
|
||||
set(COMPONENT_SRCS
|
||||
${toxcore_SRCS}
|
||||
other/docker/esp32/main/toxcore_main.cc
|
||||
third_party/cmp/cmp.c
|
||||
third_party/cmp/cmp.h
|
||||
toxencryptsave/defines.h)
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "")
|
||||
|
||||
register_component()
|
14
other/docker/esp32/toxcore/toxcore_main.cc
Normal file
14
other/docker/esp32/toxcore/toxcore_main.cc
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "../../../../toxcore/ccompat.h"
|
||||
#include "../../../../toxcore/tox.h"
|
||||
#include "../../../../toxcore/tox_events.h"
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
printf("Hello Tox!\n");
|
||||
|
||||
Tox *tox = tox_new(nullptr, nullptr);
|
||||
tox_events_free(tox_events_iterate(tox, true, nullptr));
|
||||
tox_kill(tox);
|
||||
}
|
|
@ -44,8 +44,10 @@ struct Mono_Time {
|
|||
bool last_clock_update;
|
||||
#endif
|
||||
|
||||
#ifndef ESP_PLATFORM
|
||||
/* protect `time` from concurrent access */
|
||||
pthread_rwlock_t *time_update_lock;
|
||||
#endif
|
||||
|
||||
mono_time_current_time_cb *current_time_callback;
|
||||
void *user_data;
|
||||
|
@ -128,6 +130,7 @@ Mono_Time *mono_time_new(mono_time_current_time_cb *current_time_callback, void
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
#ifndef ESP_PLATFORM
|
||||
mono_time->time_update_lock = (pthread_rwlock_t *)calloc(1, sizeof(pthread_rwlock_t));
|
||||
|
||||
if (mono_time->time_update_lock == nullptr) {
|
||||
|
@ -140,6 +143,7 @@ Mono_Time *mono_time_new(mono_time_current_time_cb *current_time_callback, void
|
|||
free(mono_time);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
mono_time_set_current_time_callback(mono_time, current_time_callback, user_data);
|
||||
|
||||
|
@ -177,8 +181,10 @@ void mono_time_free(Mono_Time *mono_time)
|
|||
#ifdef OS_WIN32
|
||||
pthread_mutex_destroy(&mono_time->last_clock_lock);
|
||||
#endif
|
||||
#ifndef ESP_PLATFORM
|
||||
pthread_rwlock_destroy(mono_time->time_update_lock);
|
||||
free(mono_time->time_update_lock);
|
||||
#endif
|
||||
free(mono_time);
|
||||
}
|
||||
|
||||
|
@ -196,9 +202,13 @@ void mono_time_update(Mono_Time *mono_time)
|
|||
pthread_mutex_unlock(&mono_time->last_clock_lock);
|
||||
#endif
|
||||
|
||||
#ifndef ESP_PLATFORM
|
||||
pthread_rwlock_wrlock(mono_time->time_update_lock);
|
||||
#endif
|
||||
mono_time->cur_time = cur_time;
|
||||
#ifndef ESP_PLATFORM
|
||||
pthread_rwlock_unlock(mono_time->time_update_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t mono_time_get(const Mono_Time *mono_time)
|
||||
|
@ -207,9 +217,13 @@ uint64_t mono_time_get(const Mono_Time *mono_time)
|
|||
// Fuzzing is only single thread for now, no locking needed */
|
||||
return mono_time->cur_time;
|
||||
#else
|
||||
#ifndef ESP_PLATFORM
|
||||
pthread_rwlock_rdlock(mono_time->time_update_lock);
|
||||
#endif
|
||||
const uint64_t cur_time = mono_time->cur_time;
|
||||
#ifndef ESP_PLATFORM
|
||||
pthread_rwlock_unlock(mono_time->time_update_lock);
|
||||
#endif
|
||||
return cur_time;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -370,7 +370,12 @@ IP4 get_ip4_loopback(void)
|
|||
IP6 get_ip6_loopback(void)
|
||||
{
|
||||
IP6 loopback;
|
||||
#ifdef ESP_PLATFORM
|
||||
loopback = empty_ip_port.ip.ip.v6;
|
||||
loopback.uint8[15] = 1;
|
||||
#else
|
||||
get_ip6(&loopback, &in6addr_loopback);
|
||||
#endif
|
||||
return loopback;
|
||||
}
|
||||
|
||||
|
@ -1196,6 +1201,7 @@ Networking_Core *new_networking_ex(
|
|||
LOGGER_ERROR(log, "Dual-stack socket failed to enable, won't be able to receive from/send to IPv4 addresses");
|
||||
}
|
||||
|
||||
#ifndef ESP_PLATFORM
|
||||
/* multicast local nodes */
|
||||
struct ipv6_mreq mreq;
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
|
@ -1216,6 +1222,7 @@ Networking_Core *new_networking_ex(
|
|||
}
|
||||
|
||||
net_kill_strerror(strerror);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* A hanging program or a different user might block the standard port.
|
||||
|
|
Loading…
Reference in New Issue
Block a user