Skip to content

Commit c98ed65

Browse files
committed
lib: monkey: add missing files
Signed-off-by: Eduardo Silva <[email protected]>
1 parent c62b427 commit c98ed65

File tree

11 files changed

+2882
-0
lines changed

11 files changed

+2882
-0
lines changed
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build PR(s)
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
types: [opened, edited, synchronize]
10+
jobs:
11+
build-windows:
12+
name: Build sources on ${{ matrix.config.arch }} for ${{ matrix.config.os }}
13+
runs-on: ${{ matrix.config.os }}
14+
strategy:
15+
max-parallel: 48
16+
fail-fast: false
17+
matrix:
18+
config:
19+
- name: "Windows 64bit"
20+
arch: x64
21+
cmake_additional_opt: ""
22+
os: windows-latest
23+
- name: "Windows 64bit (ARM)"
24+
arch: amd64_arm64
25+
cmake_additional_opt: "-G \"NMake Makefiles\" -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_SYSTEM_PROCESSOR=ARM64"
26+
os: windows-latest
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
with:
31+
ref: ${{ inputs.ref }}
32+
33+
- name: Set up with Developer Command Prompt for Microsoft Visual C++
34+
uses: ilammy/msvc-dev-cmd@v1
35+
with:
36+
arch: ${{ matrix.config.arch }}
37+
38+
- name: Build on ${{ matrix.os }} with vs-2019
39+
run: |
40+
mkdir build
41+
cd build
42+
cmake -DMK_DEBUG=On -DMK_WITHOUT_BIN=On -DMK_WITHOUT_CONF=On -DMK_LIB_ONLY=On ${{ matrix.config.cmake_additional_opt }} ..\
43+
cmake --build . --config Release
44+
45+
build-unix:
46+
name: Build sources on amd64 for ${{ matrix.os }} - ${{ matrix.compiler }}
47+
runs-on: ${{ matrix.os }}
48+
strategy:
49+
max-parallel: 48
50+
fail-fast: false
51+
matrix:
52+
os: [ubuntu-latest, macos-latest]
53+
compiler: [ gcc, clang ]
54+
exclude:
55+
- os: windows-latest
56+
compiler: gcc
57+
- os: windows-latest
58+
compiler: clang
59+
steps:
60+
- uses: actions/checkout@v2
61+
- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
62+
run: |
63+
mkdir build
64+
cd build
65+
echo "CC = $CC, CXX = $CXX"
66+
cmake -DMK_DEBUG=On -DMK_WITHOUT_BIN=On -DMK_WITHOUT_CONF=On -DMK_LIB_ONLY=On ../
67+
cmake --build .
68+
env:
69+
CC: ${{ matrix.compiler }}

lib/monkey/ARDUINO_YUN.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Monkey + Arduino YUN toolchain
2+
3+
Short instructions to build with Arduino YUN toolchain:
4+
5+
## Get the toolchain
6+
7+
```shell
8+
$ git clone https://github.com/MatteoRagni/ArduinoYun-x86_64-OpenWRT-mips-linux-toolchain.git
9+
```
10+
11+
The content downloaded is the toolchain required, the absolute path of this directory is required in the next step:
12+
13+
### Compile Monkey
14+
15+
Make sure to replace the right values for CMAKE_INSTALL_PREFIX and _YUN_ROOT_:
16+
17+
```
18+
$ rm -rf monkey/build
19+
$ cd monkey/build
20+
$ cmake -DCMAKE_TOOLCHAIN_FILE=cmake/arduino-yun.cmake \
21+
-DWITH_SYSTEM_MALLOC=ON -DWITH_BACKTRACE=OFF \
22+
-DCMAKE_INSTALL_PREFIX=/opt/monkey \
23+
-DYUN_ROOT=/path/to/ArduinoYun-x86_64-OpenWRT-mips-linux-toolchain \
24+
../
25+
$ make
26+
$ make install
27+
```

lib/monkey/cmake/arduino-yun.cmake

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Arduino YUN toolchain helper file
2+
include(CMakeForceCompiler)
3+
4+
if(NOT YUN_ROOT)
5+
set(YUN_ROOT /home/edsiper/coding/ArduinoYun-x86_64-OpenWRT-mips-linux-toolchain)
6+
endif()
7+
8+
set(YUN_TC ${YUN_ROOT}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2)
9+
10+
set(CMAKE_SYSTEM_NAME Linux)
11+
set(CMAKE_SYSTEM_PROCESSOR mips)
12+
set(CMAKE_SYSTEM_VERSION 1)
13+
set(CMAKE_C_COMPILER ${YUN_TC}/bin/mips-openwrt-linux-uclibc-gcc)
14+
15+
# where is the target environment
16+
set(CMAKE_FIND_ROOT_PATH ${YUN_ROOT})
17+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
18+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
19+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
3+
/* Monkey HTTP Server
4+
* ==================
5+
* Copyright 2001-2024 Eduardo Silva <[email protected]>
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#include <poll.h>
21+
22+
#ifndef MK_EVENT_POLL_H
23+
#define MK_EVENT_POLL_H
24+
25+
struct mk_event_ctx {
26+
int queue_size;
27+
struct mk_event **events;
28+
struct mk_event *fired; /* used to create iteration array */
29+
struct pollfd *pfds;
30+
};
31+
32+
#define mk_event_foreach(event, evl) \
33+
int __i; \
34+
struct mk_event_ctx *__ctx = evl->data; \
35+
\
36+
if (evl->n_events > 0) { \
37+
event = __ctx->fired[0].data; \
38+
} \
39+
\
40+
for (__i = 0; \
41+
__i < evl->n_events; \
42+
__i++, \
43+
event = ((__i < evl->n_events) ? __ctx->fired[__i].data : NULL) \
44+
)
45+
46+
#endif
47+
48+

0 commit comments

Comments
 (0)