add docker setup
This commit is contained in:
parent
6756465ce8
commit
40bf42ecba
|
@ -0,0 +1 @@
|
||||||
|
*
|
|
@ -1,2 +1,2 @@
|
||||||
/dist/
|
/build/
|
||||||
.sconsign.dblite
|
.sconsign.dblite
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
FROM debian:bookworm
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y \
|
||||||
|
clang \
|
||||||
|
llvm \
|
||||||
|
scons
|
||||||
|
|
||||||
|
RUN useradd rt
|
||||||
|
USER rt
|
64
SConscript
64
SConscript
|
@ -1,64 +0,0 @@
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
llvm_flags = [
|
|
||||||
"-g",
|
|
||||||
"-Os",
|
|
||||||
"-ffunction-sections",
|
|
||||||
"-fdata-sections",
|
|
||||||
"-flto",
|
|
||||||
]
|
|
||||||
|
|
||||||
env = Environment(
|
|
||||||
CPPPATH=["include"],
|
|
||||||
CCFLAGS=llvm_flags,
|
|
||||||
CFLAGS=["-std=c99"],
|
|
||||||
LINKFLAGS=llvm_flags,
|
|
||||||
)
|
|
||||||
|
|
||||||
# for color terminal output when available
|
|
||||||
if "TERM" in os.environ:
|
|
||||||
env["ENV"]["TERM"] = os.environ["TERM"]
|
|
||||||
|
|
||||||
if "darwin" in sys.platform:
|
|
||||||
env["CC"] = "clang"
|
|
||||||
env.Append(
|
|
||||||
CCFLAGS=[
|
|
||||||
"-Weverything",
|
|
||||||
"-Werror",
|
|
||||||
"-Wno-padded",
|
|
||||||
"-Wno-poison-system-directories",
|
|
||||||
],
|
|
||||||
LINKFLAGS=["-dead_strip"],
|
|
||||||
)
|
|
||||||
elif "linux" in sys.platform:
|
|
||||||
env["CC"] = "gcc"
|
|
||||||
env.Append(CPPDEFINES=[("_POSIX_C_SOURCE", "200809L")])
|
|
||||||
env.Append(LINKFLAGS=["-Wl,--gc-sections"])
|
|
||||||
|
|
||||||
librt = env.StaticLibrary(
|
|
||||||
target="rt",
|
|
||||||
source=[
|
|
||||||
"src/rt.c",
|
|
||||||
"src/tick.c",
|
|
||||||
"src/critical.c",
|
|
||||||
"src/delay.c",
|
|
||||||
"src/queue.c",
|
|
||||||
"src/sem.c",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
posix_env = env.Clone()
|
|
||||||
posix_env.Append(
|
|
||||||
CCFLAGS="-pthread",
|
|
||||||
LINKFLAGS="-pthread",
|
|
||||||
)
|
|
||||||
|
|
||||||
posix_port = posix_env.Object("src/port/posix.c")
|
|
||||||
|
|
||||||
posix_simple = posix_env.Object(target="posix_simple", source="examples/simple.c")
|
|
||||||
posix_delay = posix_env.Object(target="posix_delay", source="examples/delay.c")
|
|
||||||
posix_queue = posix_env.Object(target="posix_queue", source="examples/queue.c")
|
|
||||||
posix_env.Program([posix_simple, librt, posix_port])
|
|
||||||
posix_env.Program([posix_delay, librt, posix_port])
|
|
||||||
posix_env.Program([posix_queue, librt, posix_port])
|
|
69
SConstruct
69
SConstruct
|
@ -1,5 +1,66 @@
|
||||||
SConscript(
|
import os
|
||||||
dirs=".",
|
import sys
|
||||||
variant_dir="dist",
|
|
||||||
duplicate=False,
|
llvm_flags = [
|
||||||
|
"-g",
|
||||||
|
"-Os",
|
||||||
|
"-ffunction-sections",
|
||||||
|
"-fdata-sections",
|
||||||
|
"-flto",
|
||||||
|
]
|
||||||
|
|
||||||
|
env = Environment(
|
||||||
|
CPPPATH=[Dir("include").srcnode()],
|
||||||
|
CCFLAGS=llvm_flags,
|
||||||
|
CFLAGS=["-std=c99"],
|
||||||
|
LINKFLAGS=llvm_flags,
|
||||||
|
)
|
||||||
|
|
||||||
|
# for color terminal output when available
|
||||||
|
if "TERM" in os.environ:
|
||||||
|
env["ENV"]["TERM"] = os.environ["TERM"]
|
||||||
|
|
||||||
|
env["CC"] = "clang"
|
||||||
|
env.Append(
|
||||||
|
CCFLAGS=[
|
||||||
|
"-Weverything",
|
||||||
|
"-Werror",
|
||||||
|
"-Wno-padded",
|
||||||
|
"-Wno-poison-system-directories",
|
||||||
|
"-Wno-declaration-after-statement",
|
||||||
|
"-Wno-disabled-macro-expansion",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
if "darwin" in sys.platform:
|
||||||
|
env.Append(
|
||||||
|
LINKFLAGS=["-dead_strip"],
|
||||||
|
)
|
||||||
|
elif "linux" in sys.platform:
|
||||||
|
env.Append(
|
||||||
|
CPPDEFINES={"_POSIX_C_SOURCE": "200809L"}, LINKFLAGS=["-Wl,--gc-sections"]
|
||||||
|
)
|
||||||
|
|
||||||
|
librt = SConscript(
|
||||||
|
dirs="src", variant_dir="build/lib", duplicate=False, exports=["env"]
|
||||||
|
)
|
||||||
|
|
||||||
|
posix_env = env.Clone()
|
||||||
|
posix_env.Append(
|
||||||
|
CCFLAGS="-pthread",
|
||||||
|
LINKFLAGS="-pthread",
|
||||||
|
)
|
||||||
|
|
||||||
|
libposix = SConscript(
|
||||||
|
"arch/posix/SConscript",
|
||||||
|
variant_dir="build/lib/posix",
|
||||||
|
duplicate=False,
|
||||||
|
exports={"env": posix_env},
|
||||||
|
)
|
||||||
|
|
||||||
|
example_env = posix_env.Clone()
|
||||||
|
example_env.Append(LIBS=[librt, libposix])
|
||||||
|
|
||||||
|
SConscript(
|
||||||
|
dirs="examples", variant_dir="build", duplicate=False, exports={"env": example_env}
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
Import("env")
|
||||||
|
|
||||||
|
libposix = env.StaticLibrary("posix.c")
|
||||||
|
|
||||||
|
Return("libposix")
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
name="rt"
|
||||||
|
image="$name-builder"
|
||||||
|
|
||||||
|
docker build --tag "$image" .
|
||||||
|
|
||||||
|
workdir="/home/$name/$name"
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
--rm \
|
||||||
|
--tty \
|
||||||
|
--interactive \
|
||||||
|
--volume "$(pwd):$workdir" \
|
||||||
|
--workdir "$workdir" \
|
||||||
|
--cap-add SYS_PTRACE \
|
||||||
|
"$image"
|
|
@ -0,0 +1,5 @@
|
||||||
|
Import("env")
|
||||||
|
|
||||||
|
env.Program("simple.c")
|
||||||
|
env.Program("delay.c")
|
||||||
|
env.Program("queue.c")
|
|
@ -0,0 +1,15 @@
|
||||||
|
Import("env")
|
||||||
|
|
||||||
|
librt = env.StaticLibrary(
|
||||||
|
target="rt",
|
||||||
|
source=[
|
||||||
|
"rt.c",
|
||||||
|
"tick.c",
|
||||||
|
"critical.c",
|
||||||
|
"delay.c",
|
||||||
|
"queue.c",
|
||||||
|
"sem.c",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
Return("librt")
|
|
@ -9,7 +9,7 @@ static rt_tick_t rt_ticks;
|
||||||
void rt_tick(void)
|
void rt_tick(void)
|
||||||
{
|
{
|
||||||
++rt_ticks;
|
++rt_ticks;
|
||||||
#if RT_LOG
|
#ifdef RT_LOG
|
||||||
printf("tick %lu\n", rt_ticks);
|
printf("tick %lu\n", rt_ticks);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue