Skip to content

Commit

Permalink
lib: monkey: add missing files
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Jan 8, 2025
1 parent c62b427 commit c98ed65
Show file tree
Hide file tree
Showing 11 changed files with 2,882 additions and 0 deletions.
69 changes: 69 additions & 0 deletions lib/monkey/.github/workflows/build-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build PR(s)
on:
push:
branches:
- master
pull_request:
branches:
- master
types: [opened, edited, synchronize]
jobs:
build-windows:
name: Build sources on ${{ matrix.config.arch }} for ${{ matrix.config.os }}
runs-on: ${{ matrix.config.os }}
strategy:
max-parallel: 48
fail-fast: false
matrix:
config:
- name: "Windows 64bit"
arch: x64
cmake_additional_opt: ""
os: windows-latest
- name: "Windows 64bit (ARM)"
arch: amd64_arm64
cmake_additional_opt: "-G \"NMake Makefiles\" -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_SYSTEM_PROCESSOR=ARM64"
os: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}

- name: Set up with Developer Command Prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.config.arch }}

- name: Build on ${{ matrix.os }} with vs-2019
run: |
mkdir build
cd build
cmake -DMK_DEBUG=On -DMK_WITHOUT_BIN=On -DMK_WITHOUT_CONF=On -DMK_LIB_ONLY=On ${{ matrix.config.cmake_additional_opt }} ..\
cmake --build . --config Release
build-unix:
name: Build sources on amd64 for ${{ matrix.os }} - ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 48
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
compiler: [ gcc, clang ]
exclude:
- os: windows-latest
compiler: gcc
- os: windows-latest
compiler: clang
steps:
- uses: actions/checkout@v2
- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
run: |
mkdir build
cd build
echo "CC = $CC, CXX = $CXX"
cmake -DMK_DEBUG=On -DMK_WITHOUT_BIN=On -DMK_WITHOUT_CONF=On -DMK_LIB_ONLY=On ../
cmake --build .
env:
CC: ${{ matrix.compiler }}
27 changes: 27 additions & 0 deletions lib/monkey/ARDUINO_YUN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Monkey + Arduino YUN toolchain

Short instructions to build with Arduino YUN toolchain:

## Get the toolchain

```shell
$ git clone https://github.com/MatteoRagni/ArduinoYun-x86_64-OpenWRT-mips-linux-toolchain.git
```

The content downloaded is the toolchain required, the absolute path of this directory is required in the next step:

### Compile Monkey

Make sure to replace the right values for CMAKE_INSTALL_PREFIX and _YUN_ROOT_:

```
$ rm -rf monkey/build
$ cd monkey/build
$ cmake -DCMAKE_TOOLCHAIN_FILE=cmake/arduino-yun.cmake \
-DWITH_SYSTEM_MALLOC=ON -DWITH_BACKTRACE=OFF \
-DCMAKE_INSTALL_PREFIX=/opt/monkey \
-DYUN_ROOT=/path/to/ArduinoYun-x86_64-OpenWRT-mips-linux-toolchain \
../
$ make
$ make install
```
19 changes: 19 additions & 0 deletions lib/monkey/cmake/arduino-yun.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Arduino YUN toolchain helper file
include(CMakeForceCompiler)

if(NOT YUN_ROOT)
set(YUN_ROOT /home/edsiper/coding/ArduinoYun-x86_64-OpenWRT-mips-linux-toolchain)
endif()

set(YUN_TC ${YUN_ROOT}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR mips)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_C_COMPILER ${YUN_TC}/bin/mips-openwrt-linux-uclibc-gcc)

# where is the target environment
set(CMAKE_FIND_ROOT_PATH ${YUN_ROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
48 changes: 48 additions & 0 deletions lib/monkey/include/monkey/mk_core/mk_event_poll.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* Monkey HTTP Server
* ==================
* Copyright 2001-2024 Eduardo Silva <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <poll.h>

#ifndef MK_EVENT_POLL_H
#define MK_EVENT_POLL_H

struct mk_event_ctx {
int queue_size;
struct mk_event **events;
struct mk_event *fired; /* used to create iteration array */
struct pollfd *pfds;
};

#define mk_event_foreach(event, evl) \
int __i; \
struct mk_event_ctx *__ctx = evl->data; \
\
if (evl->n_events > 0) { \
event = __ctx->fired[0].data; \
} \
\
for (__i = 0; \
__i < evl->n_events; \
__i++, \
event = ((__i < evl->n_events) ? __ctx->fired[__i].data : NULL) \
)

#endif


Loading

0 comments on commit c98ed65

Please sign in to comment.