Compare commits

...

3 Commits

Author SHA1 Message Date
9a95dba138 first try at android ci
Some checks failed
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
ContinuousIntegration / linux (push) Successful in 4m7s
ContinuousDelivery / linux-ubuntu (push) Failing after 4m45s
ContinuousIntegration / android (push) Successful in 14m55s
2024-05-29 13:14:26 +02:00
ef79aa8b80 support building tomato as a lib/shared object 2024-05-29 10:38:57 +02:00
ba7188cf66 improve windows debug conformity
Some checks failed
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
ContinuousIntegration / linux (push) Successful in 4m3s
ContinuousDelivery / linux-ubuntu (push) Failing after 4m45s
2024-05-29 09:46:35 +02:00
10 changed files with 63 additions and 12 deletions

View File

@ -22,7 +22,7 @@ jobs:
submodules: recursive submodules: recursive
- name: Install Dependencies - name: Install Dependencies
run: sudo apt update && sudo apt -y install libsodium-dev run: sudo apt update && sudo apt -y install libsodium-dev cmake
- name: Configure CMake - name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

View File

@ -21,7 +21,7 @@ jobs:
submodules: recursive submodules: recursive
- name: Install Dependencies - name: Install Dependencies
run: sudo apt update && sudo apt -y install libsodium-dev run: sudo apt update && sudo apt -y install libsodium-dev cmake
- name: Configure CMake - name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
@ -29,6 +29,50 @@ jobs:
- name: Build - name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
android:
timeout-minutes: 30
# contains sections copied from sdl repo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: nttld/setup-ndk@v1
id: setup_ndk
with:
local-cache: true
ndk-version: r26d
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: update vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
- name: Install Dependencies (host)
run: sudo apt update && sudo apt -y install cmake pkg-config nasm
- name: Install Dependencies (target)
env:
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
run: vcpkg install --triplet arm64-android --overlay-ports=vcpkg/ports libsodium opus libvpx libpng libjpeg-turbo
# vcpkg scripts root /usr/local/share/vcpkg/scripts
- name: Configure CMake
env:
ANDROID_NDK_HOME: ${{steps.setup_ndk.outputs.ndk-path}}
#run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=23 -DANDROID_ABI=arm64-v8a
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-android -DANDROID=1 -DANDROID_PLATFORM=23 -DANDROID_ABI=arm64-v8a -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{steps.setup_ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake -DSDL3IMAGE_JPG_SHARED=OFF -DSDL3IMAGE_PNG_SHARED=OFF -DTOMATO_MAIN_SO=ON
- name: Build (tomato)
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
macos: macos:
timeout-minutes: 10 timeout-minutes: 10

View File

@ -18,6 +18,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
option(TOMATO_MAIN_SO "Build tomato as a shared object (for eg android apps)" ANDROID)
option(TOMATO_ASAN "Build tomato with asan (gcc/clang/msvc)" OFF) option(TOMATO_ASAN "Build tomato with asan (gcc/clang/msvc)" OFF)
if (TOMATO_ASAN) if (TOMATO_ASAN)

View File

@ -1,8 +1,15 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR) cmake_minimum_required(VERSION 3.9...3.24 FATAL_ERROR)
######################################## ########################################
add_executable(tomato if (TOMATO_MAIN_SO)
add_library(tomato MODULE)
target_compile_definitions(tomato PUBLIC TOMATO_MAIN_SO)
else()
add_executable(tomato)
endif()
target_sources(tomato PUBLIC
./main.cpp ./main.cpp
./icon.rc ./icon.rc

View File

@ -151,8 +151,7 @@ void SendImagePopup::sendMemory(
} }
// copy paste data to memory // copy paste data to memory
original_data.clear(); original_data = {data, data+data_size};
original_data.insert(original_data.begin(), data, data+data_size);
if (!load()) { if (!load()) {
std::cerr << "SIP: failed to load image from memory\n"; std::cerr << "SIP: failed to load image from memory\n";

View File

@ -41,7 +41,7 @@ ImageLoaderQOI::ImageResult ImageLoaderQOI::loadFromMemoryRGBA(const uint8_t* da
auto& new_frame = res.frames.emplace_back(); auto& new_frame = res.frames.emplace_back();
new_frame.ms = 0; new_frame.ms = 0;
new_frame.data.insert(new_frame.data.cbegin(), img_data, img_data+(desc.width*desc.height*4)); new_frame.data = {img_data, img_data+(desc.width*desc.height*4)};
free(img_data); free(img_data);
return res; return res;

View File

@ -47,7 +47,7 @@ ImageLoaderSDLBMP::ImageResult ImageLoaderSDLBMP::loadFromMemoryRGBA(const uint8
auto& new_frame = res.frames.emplace_back(); auto& new_frame = res.frames.emplace_back();
new_frame.ms = 0; new_frame.ms = 0;
new_frame.data.insert(new_frame.data.cbegin(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (surf->w*surf->h*4)); new_frame.data = {(const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (surf->w*surf->h*4)};
SDL_UnlockSurface(conv_surf); SDL_UnlockSurface(conv_surf);
SDL_DestroySurface(conv_surf); SDL_DestroySurface(conv_surf);

View File

@ -99,7 +99,7 @@ ImageLoaderSDLImage::ImageResult ImageLoaderSDLImage::loadFromMemoryRGBA(const u
auto& new_frame = res.frames.emplace_back(); auto& new_frame = res.frames.emplace_back();
new_frame.ms = anim->delays[i]; new_frame.ms = anim->delays[i];
new_frame.data.insert(new_frame.data.cbegin(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (anim->w*anim->h*4)); new_frame.data = {(const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (anim->w*anim->h*4)};
SDL_UnlockSurface(conv_surf); SDL_UnlockSurface(conv_surf);
SDL_DestroySurface(conv_surf); SDL_DestroySurface(conv_surf);

View File

@ -41,7 +41,7 @@ ImageLoaderSTB::ImageResult ImageLoaderSTB::loadFromMemoryRGBA(const uint8_t* da
for (int i = 0; i < z; i++) { for (int i = 0; i < z; i++) {
auto& new_frame = res.frames.emplace_back(); auto& new_frame = res.frames.emplace_back();
new_frame.ms = delays[i]; new_frame.ms = delays[i];
new_frame.data.insert(new_frame.data.cbegin(), img_data + (i*stride), img_data + ((i+1)*stride)); new_frame.data = {img_data + (i*stride), img_data + ((i+1)*stride)};
} }
stbi_image_free(delays); // hope this is right stbi_image_free(delays); // hope this is right
@ -62,7 +62,7 @@ ImageLoaderSTB::ImageResult ImageLoaderSTB::loadFromMemoryRGBA(const uint8_t* da
auto& new_frame = res.frames.emplace_back(); auto& new_frame = res.frames.emplace_back();
new_frame.ms = 0; new_frame.ms = 0;
new_frame.data.insert(new_frame.data.cbegin(), img_data, img_data+(x*y*4)); new_frame.data = {img_data, img_data+(x*y*4)};
stbi_image_free(img_data); stbi_image_free(img_data);
return res; return res;

View File

@ -78,7 +78,7 @@ ImageLoaderWebP::ImageResult ImageLoaderWebP::loadFromMemoryRGBA(const uint8_t*
auto& new_frame = res.frames.emplace_back(); auto& new_frame = res.frames.emplace_back();
new_frame.ms = timestamp-prev_timestamp; new_frame.ms = timestamp-prev_timestamp;
prev_timestamp = timestamp; prev_timestamp = timestamp;
new_frame.data.insert(new_frame.data.end(), buf, buf+(res.width*res.height*4)); new_frame.data = {buf, buf+(res.width*res.height*4)};
} }
assert(anim_info.frame_count == res.frames.size()); assert(anim_info.frame_count == res.frames.size());