Skip to content

Commit 80863ea

Browse files
committed
build: 🔨 add just release-plugin
\
1 parent 937fe8a commit 80863ea

File tree

18 files changed

+101
-30
lines changed

18 files changed

+101
-30
lines changed

judger/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
*.log
55
/config.toml
66
/judger.proto
7-
/config
7+
/config
8+
/plugins-out

judger/justfile

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ release-docker:
66

77
build-plugin:
88
cd plugins && sh build-all.sh
9+
10+
release-plugin:
11+
just build-plugin
12+
cd plugins sh export-all.sh
13+
914

1015
build-nsjail:
1116
cd nsjail-docker && make nsjail-3.1
@@ -14,10 +19,7 @@ build-nsjail:
1419
prepare:
1520
just build-nsjail
1621
just build-plugin
17-
mkdir -p config
18-
19-
debian-deps:
20-
echo todo!()
22+
mkdir -p config plugins-out
2123

2224
feodra-deps:
2325
sudo dnf install protobuf-devel autoconf gettext libtool gcc libcap-devel systemd-devel yajl-devel libgcrypt-devel glibc-static libseccomp-devel python36 git
@@ -40,9 +42,3 @@ run:
4042
mkdir -p .temp
4143
cargo run
4244

43-
# podman-run:
44-
# # recreate cgroup of mdoj for normal user
45-
# sudo rm -rf /sys/fs/cgroup/mdoj
46-
# sudo cgcreate -a $USER -t $USER -g memory,cpu,cpuset:mdoj
47-
# # run podman
48-
# podman-compose up
File renamed without changes.
File renamed without changes.

judger/plugins/c-11/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mkdir -p rootfs
2+
docker build -t c-11-mdoj-plugin .
3+
docker export $(docker create c-11-mdoj-plugin) | tar -C rootfs -xvf -

judger/plugins/c-11/compile.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
#include <stdlib.h>
4+
#include <unistd.h>
5+
#include <spawn.h>
6+
#include <errno.h>
7+
#include <sys/wait.h>
8+
#define CC "/usr/local/bin/g++"
9+
#define SRC "/src/src.c"
10+
#define OUT "/src/src.out"
11+
#define MAX_SIZE 131072
12+
13+
int main()
14+
{
15+
FILE *source = fopen(SRC, "w");
16+
if (source == NULL)
17+
{
18+
printf("2: %m\n", errno);
19+
return 1;
20+
}
21+
else
22+
printf("1: success create file!\n");
23+
24+
char *code = malloc(MAX_SIZE * sizeof(char));
25+
size_t len = fread(code, sizeof(char), MAX_SIZE, stdin);
26+
27+
fwrite(code, sizeof(char), len, source);
28+
fclose(source);
29+
30+
char *args[] = {CC, "-x", "c", SRC, "-lm", "-o", OUT, NULL};
31+
int pid, status;
32+
if (execvp(CC, args) != -1)
33+
{
34+
printf("1: success execv!\n");
35+
if (wait(NULL) != -1)
36+
{
37+
printf("0: success!\n");
38+
return 0;
39+
}
40+
}
41+
printf("4: %m\n", errno);
42+
return 1;
43+
}
File renamed without changes.

judger/plugins/gcc-13/spec.toml renamed to judger/plugins/c-11/spec.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# memory in byte, time in microsecond
22
info = "gcc 13.2.0 (G++)"
33
extension = "cpp" # same extension means same language
4-
name = "gcc-13" # must be same as dictionary name
4+
name = "c-11" # must be same as dictionary name
55
uid = "8a9e1daf-ff89-42c3-b011-bf6fb4bd8b26" # be sure it's unique
66

77
[compile]

judger/plugins/cpp-11/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/rootfs
2+
/src.cpp
3+
/src.out
4+
/compile

judger/plugins/cpp-11/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM gcc:13
2+
WORKDIR /
3+
COPY compile.c .
4+
COPY execute.sh /
5+
RUN gcc compile.c -o compile
6+
RUN rm compile.c

judger/plugins/cpp-11/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mkdir -p rootfs
2+
docker build -t cpp-11-mdoj-plugin .
3+
docker export $(docker create cpp-11-mdoj-plugin) | tar -C rootfs -xvf -

judger/plugins/gcc-13/compile.c renamed to judger/plugins/cpp-11/compile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ int main()
1717
{
1818
printf("2: %m\n", errno);
1919
return 1;
20-
}else
20+
}
21+
else
2122
printf("1: success create file!\n");
2223

2324
char *code = malloc(MAX_SIZE * sizeof(char));

judger/plugins/cpp-11/execute.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
/src/src.out

judger/plugins/cpp-11/spec.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# memory in byte, time in microsecond
2+
info = "gcc 13.2.0 (G++)"
3+
extension = "cpp" # same extension means same language
4+
name = "cpp-11" # must be same as dictionary name
5+
uid = "8a9e1daf-ff89-42c3-b011-bf6fb4bd8b26" # be sure it's unique
6+
7+
[compile]
8+
lockdown = true
9+
command = ["/compile"]
10+
kernel_mem = 67108864
11+
user_mem = 268435456
12+
rt_time = 1000000
13+
cpu_time = 10000000
14+
total_time = 10000000
15+
16+
[judge]
17+
command = ["/execute.sh"]
18+
kernel_mem = 67108864
19+
multiplier_memory = 1 # user_mem
20+
rt_time = 1000000
21+
multiplier_cpu = 1 # cpu_time

judger/plugins/export-all.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
for entry in ./*
2+
do
3+
if [ -f "$entry"/spec.toml ]; then
4+
echo "exporting plugin $entry"
5+
sh -c "tar -czvf \"..\\$entry.tar.gz\" \"$entry\spec.toml\" \"$entry\rootfs\"
6+
fi
7+
done

judger/plugins/gcc-13/build.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

judger/plugins/rlua-54/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Compact Rusty Lua 5.4 VM
22

3+
A Lua 5.4 runtime build both real workloads and sandbox tests

readme.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,6 @@ See [wiki](https://github.com/mdcpp/mdoj/wiki) for more details.
4444

4545
If you prefer to use default config, you can skip step 2 and 3.
4646

47-
## Full Setup(Standalone)
48-
49-
> For details of config.toml, please follow the document in ``./backend`` and ``./judger``.
50-
51-
1. Download `judger`, `backend` and `dist.tar.gz`.
52-
2. create `./config` directory for both `judger` and `backend`.
53-
3. Start `judger` and `backend`, it should generate config.
54-
4. Edit config.
55-
5. create `.temp` for backend.
56-
7. start both judger and backend.
57-
8. configure reverse proxy to proxy every request with prefix `/api` to router, and reverse proxy should also trust certification of backend.
58-
9. Configure proxy to serve static file for request not match prefix of `/api`
59-
60-
> backend should only start after judger is online, or you might see a warning from console, and judger is only available after next health check(default to 60 seconds if previous health check fail)
6147

6248
## Setup for development
6349

0 commit comments

Comments
 (0)