CI Attempt
Some checks failed
CI / Test (ARM64) (push) Failing after 2m58s
CI / Test (AMD64) (push) Failing after 2m48s

This commit is contained in:
TheBrokenRail 2025-02-15 00:03:19 -05:00
parent f5a2b25e85
commit bfbb477f60
8 changed files with 59 additions and 6 deletions

View File

@ -0,0 +1,33 @@
name: 'CI'
on:
push:
branches:
- master
# Jobs
jobs:
# Test Project
test:
strategy:
fail-fast: false
matrix:
arch:
- AMD64
- ARM64
name: Test
runs-on: ${{ startsWith(matrix.arch, 'ARM') && 'raspberry-pi' || 'ubuntu-latest' }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
# Dependencies
- name: Install Dependencies
run: ./scripts/install-dependencies.sh
# Build
- name: Build
run: ./example/build.sh
# Test
- name: Test (Pipe-Based)
run: MCPI_USE_PIPE_TRAMPOLINE=1 ./example/run.sh
- name: Test (Syscall-Based)
run: ./example/run.sh
if: ${{ ! startsWith(matrix.arch, 'ARM') }}

View File

@ -3,7 +3,7 @@ This is a simple program allowing ARM32 code to easily call "native" code.
By running an ARM32 program inside this runtime, it gains the ability to call `raw_trampoline()`. This function copies its arguments and passes them to the "host" code.
The runtime also automatically uses QEMU on x86_64 systems.
The runtime also automatically uses QEMU on non-ARM systems.
## Terminology
- "Guest" code is the main ARM32 program. It is running inside the runtime.

View File

@ -1,6 +1,7 @@
#!/bin/sh
set -e
cd "$(dirname "$0")"
# Run Script
RUN="$(pwd)/run.sh"
@ -10,6 +11,7 @@ out() {
}
out '#!/bin/sh'
out 'set -e'
out 'cd "$(dirname "$0")"'
chmod +x "${RUN}"
# Create Build Directory

View File

@ -16,6 +16,8 @@ void run(uint32_t cmd, const char *str) {
// Main
#define INFO(str) fprintf(stderr, "==== %s ====\n", str)
int main() {
// Check Trampoline Type
fprintf(stderr, "Using Pipe-Based Trampoline: %i\n", is_trampoline_pipe_based());
// Normal Calls
INFO("Testing Normal Trampoline Calls");
run(0, "Hello World!");

View File

@ -1,6 +1,7 @@
#pragma once
#include <stdint.h>
#include <stdlib.h>
// C++ Support
#ifdef __cplusplus
@ -30,11 +31,13 @@ typedef trampoline_raw_t *trampoline_t;
#endif
// Environmental Variables
#ifdef __cplusplus
#define ENV(name, ...) constexpr const char *name##_ENV = #name;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#define ENV(name, ...) static const char *name##_ENV = #name;
#include "env-list.h"
#undef ENV
#endif
#pragma GCC diagnostic pop
#define is_trampoline_pipe_based() (getenv(MCPI_USE_PIPE_TRAMPOLINE_ENV) != NULL)
// Call Trampoline From Guest Code
#ifndef MCPI_BUILD_RUNTIME

View File

@ -5,7 +5,7 @@
// Check
bool SyscallTrampoline::should_use() {
return getenv(MCPI_USE_PIPE_TRAMPOLINE_ENV) == nullptr;
return !is_trampoline_pipe_based();
}
// Call

13
scripts/install-dependencies.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
set -e
apt-get update
apt-get install -y --no-install-recommends \
cmake \
ninja-build \
gcc g++ \
python3 \
python3-venv \
python3-tomli \
libglib2.0-dev

View File

@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
// Create Implementation
Implementation *impl = new PipeImplementation;
#ifdef MCPI_HAS_QEMU
if (getenv(MCPI_USE_PIPE_TRAMPOLINE_ENV) == nullptr) {
if (!is_trampoline_pipe_based()) {
delete impl;
impl = new SyscallImplementation;
}