Skip to content

Commit 0d7437f

Browse files
authored
Merge pull request #10 from Hakkadaikon/develop
develop -> main
2 parents 1c8ac4b + ecd6c9a commit 0d7437f

File tree

5 files changed

+159
-14
lines changed

5 files changed

+159
-14
lines changed

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,40 @@
77

88
Websocket server that complies with RFC6455.(The WebSocket Protocol)
99

10-
![icon](https://github.com/user-attachments/assets/f4b92376-17db-4979-897a-b005ed421e22)
10+
![icon](https://github.com/user-attachments/assets/7f02a1de-a4cf-456f-b833-30b2e1c440d1)
1111

1212
# Usage
1313
## Build
1414

1515
```shell
16-
# release build
16+
# library build (host/release)
17+
# output : build/lib/
1718
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
1819
cmake --build build
19-
make BUILD=release -C examples/echoback
2020

21-
# debug build
21+
# library build (host/debug)
22+
# output : build/lib/
2223
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
2324
cmake --build build
24-
make BUILD=debug -C examples/echoback
2525

26-
# musl build (release) (x86/64 & linux only)
26+
27+
# library build (nix/release)
28+
# output : result/lib/
29+
nix build
30+
31+
# library build (nix/debug)
32+
# output : result/lib/
33+
nix build .#debug
34+
35+
# sample build (debug)
36+
# LDLIB : build/lib/
37+
make BUILD=debug -C examples/echoback
38+
39+
# sample build (release)
40+
# LDLIB : build/lib/
41+
make BUILD=release -C examples/echoback
42+
43+
# musl build with example/echoback (release & x86/64 & linux only)
2744
./shell/musl_build.sh
2845
```
2946

examples/echoback/Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ endif
2626
SRCROOT := .
2727
OBJROOT := ./obj
2828
BINROOT := ./bin
29+
LDLIBS := -L../../build/lib
2930

3031
#------------------------------------------------------------------------------
3132
# Files
@@ -45,7 +46,6 @@ CFLAGS := \
4546
-g \
4647
-DLOG_LEVEL_DEBUG
4748

48-
LDLIBS := -L../../build/lib
4949
LDFLAGS := -lwsserver
5050
else
5151
CFLAGS := \
@@ -56,7 +56,6 @@ CFLAGS := \
5656
-fPIC \
5757
-DLOG_LEVEL_DEBUG
5858

59-
LDLIBS := -L../../build/lib
6059
LDFLAGS := -lwsserver
6160
endif
6261

@@ -73,7 +72,6 @@ CFLAGS := \
7372
-falign-functions \
7473
-DLOG_LEVEL_ERROR
7574

76-
LDLIBS := -L../../build/lib
7775
LDFLAGS := -flto -lwsserver
7876
else
7977
CFLAGS := \
@@ -88,7 +86,6 @@ CFLAGS := \
8886
-DLOG_LEVEL_ERROR
8987
endif
9088

91-
LDLIBS := -L../../build/lib
9289
LDFLAGS := -lwsserver -static
9390
endif
9491
endif
@@ -113,7 +110,6 @@ all:
113110

114111
clean:
115112
rm -f $(BINROOT)/$(PROGRAM)
116-
rm -rf $(OBJROOT)/*
117113
rm -rf $(DEPENDFILES)
118114

119115
ifneq "$(MAKECMDGOALS)" "clean"

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
description = "wsserver flake: build a WebSocket server library with CMake";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = import nixpkgs { inherit system; };
13+
14+
wsserverRelease = pkgs.stdenv.mkDerivation {
15+
pname = "wsserver-release";
16+
version = "2.1.3";
17+
src = self;
18+
nativeBuildInputs = [ pkgs.cmake pkgs.gnumake ];
19+
20+
buildPhase = ''
21+
cd $TMPDIR
22+
cmake -S $src -B build -DCMAKE_BUILD_TYPE=Release
23+
cmake --build build
24+
'';
25+
26+
installPhase = ''
27+
mkdir -p $out/lib/ $out/include/
28+
cp $TMPDIR/build/lib/libwsserver.a $out/lib/
29+
cp $src/src/websocket/websocket.h $out/include/
30+
'';
31+
32+
meta = with pkgs.lib; {
33+
description = "WebSocket server library";
34+
license = licenses.mit;
35+
platforms = platforms.linux;
36+
};
37+
};
38+
39+
wsserverDebug = pkgs.stdenv.mkDerivation {
40+
pname = "wsserver-debug";
41+
version = "2.1.3";
42+
src = self;
43+
nativeBuildInputs = [ pkgs.cmake pkgs.gnumake ];
44+
45+
buildPhase = ''
46+
cd $TMPDIR
47+
cmake -S $src -B build -DCMAKE_BUILD_TYPE=Debug
48+
cmake --build build
49+
'';
50+
51+
installPhase = ''
52+
mkdir -p $out/lib/ $out/include/
53+
cp $TMPDIR/build/lib/libwsserver.a $out/lib/
54+
cp $src/src/websocket/websocket.h $out/include/
55+
'';
56+
57+
meta = with pkgs.lib; {
58+
description = "WebSocket server library (debug)";
59+
license = licenses.mit;
60+
platforms = platforms.linux;
61+
};
62+
};
63+
in {
64+
packages.release = wsserverRelease;
65+
packages.debug = wsserverDebug;
66+
packages.default = wsserverRelease;
67+
68+
devShell = pkgs.mkShell {
69+
buildInputs = [ pkgs.cmake pkgs.gnumake ];
70+
};
71+
}
72+
);
73+
}
74+

src/arch/linux/errno.c

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

0 commit comments

Comments
 (0)