CI Attempt
This commit is contained in:
parent
f5a2b25e85
commit
bfbb477f60
33
.gitea/workflows/build.yml
Normal file
33
.gitea/workflows/build.yml
Normal 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') }}
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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!");
|
||||
|
@ -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
|
||||
|
@ -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
13
scripts/install-dependencies.sh
Executable 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
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user