Skip to content

Commit

Permalink
support mingw
Browse files Browse the repository at this point in the history
  • Loading branch information
findstr committed Dec 27, 2024
1 parent bf9ecad commit 4ebe46b
Show file tree
Hide file tree
Showing 47 changed files with 3,209 additions and 488 deletions.
83 changes: 43 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,50 @@ name: CI

on: [push, pull_request]
jobs:
build:

runs-on: ubuntu-latest

build-windows:
runs-on: windows-latest
steps:
- name: Setup Redis
# You may pin to the exact commit or the version.
# uses: zhulik/redis-action@765216a54a1114f109ce90a1de4775080be16ea5
uses: zhulik/redis-action@1.1.0
- uses: msys2/setup-msys2@v2
with:
# Version of Redis to use
redis version: latest # optional, default is latest
# Number of Redis databases
number of databases: 16 # optional, default is 16
- name: Start MySQL
# You may pin to the exact commit or the version.
# uses: samin/mysql-action@4dd1210f1d6b9c2468adec44066ef4a97b8f07f3
uses: samin/mysql-action@v1.3
with:
# The port of host
host port: 3306 # optional, default is 3306
# The port of container
container port: 3306 # optional, default is 3306
# --character-set-server - The character set of MySQL server
character set server: utf8mb4 # optional, default is utf8mb4
# --collation-server - The character collation of MySQL server
collation server: utf8mb4_general_ci # optional, default is utf8mb4_general_ci
# Version of MySQL to use
mysql version: 5.7 # optional, default is latest
# MYSQL_ROOT_PASSWORD - root superuser password
mysql root password: root # optional, default is
# MYSQL_DATABASE - name for the default database that is created
mysql database: root # optional, default is
# MYSQL_USER - create the specified user with superuser power for created database
mysql user: root # optional, default is
# MYSQL_PASSWORD - specified superuser password which user is power for created database
mysql password: root # optional, default is
- uses: actions/checkout@v2
- name: enable TLS
update: true
install: >-
autotools
make
git
mingw-w64-x86_64-openssl
mingw-w64-x86_64-gcc
- uses: actions/checkout@v4
- shell: msys2 {0}
run: |
make testall
build-macosx:
runs-on: macos-latest
steps:
- name: Install dependencies
run: |
brew update
brew install openssl autoconf mysql redis
brew link openssl --force
pkg-config --cflags openssl
pkg-config --libs openssl
- name: Start MySQL and Redis services
run: |
brew services start mysql
brew services start redis
- uses: actions/checkout@v4
- name: make
run: make testall
build-linux:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev autoconf mysql-server redis-server
- name: Start MySQL and Redis services
run: |
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo service mysql start
sudo service redis-server start
- uses: actions/checkout@v4
- name: make
run: make test
run: make testall
62 changes: 0 additions & 62 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

##### Bug fixes:
##### New features:
- Add `mingw` support

## v0.6.0 (Dec 18, 2024)

##### Bug fixes:
Expand Down
86 changes: 43 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
.PNONY:all
.PNONY: all clean cleanall testall fmt

INCLUDE :=
#---------

TARGET ?= silly
TLS ?= ON
TEST ?= OFF
MALLOC ?= jemalloc
SRC_PATH = silly-src
LIB_PATH = lualib-src

#-----------platform

include Platform.mk

linux macosx: all

all:
#-----------library

#lua

#####lua
LUA_DIR=deps/lua
LUA_INC=$(LUA_DIR)
LUA_STATICLIB=$(LUA_DIR)/liblua.a

$(LUA_STATICLIB):
make -C $(LUA_DIR) $(PLAT) MYCFLAGS=-g
make -C $(LUA_DIR) $(LUA_PLAT) MYCFLAGS=-g

#malloc lib select
MALLOC_NAME=jemalloc
ifeq ($(MALLOC_NAME), jemalloc)
#####malloc lib select
ifeq ($(MALLOC), jemalloc)
JEMALLOC_DIR=deps/jemalloc
JEMALLOC_INC=$(JEMALLOC_DIR)/include
JEMALLOC_STATICLIB=$(JEMALLOC_DIR)/lib/libjemalloc.a
MALLOC_LIB:=$(JEMALLOC_DIR)/lib/$(LIBPREFIX)jemalloc.$(A)

$(JEMALLOC_STATICLIB):$(JEMALLOC_DIR)/Makefile
$(MALLOC_LIB):$(JEMALLOC_DIR)/Makefile
make -C $(JEMALLOC_DIR)

$(JEMALLOC_DIR)/Makefile:$(JEMALLOC_DIR)/autogen.sh
cd $(JEMALLOC_DIR)&&\
./autogen.sh --with-jemalloc-prefix=je_
$(JEMALLOC_DIR)/autogen.sh:
git submodule update --init
jemalloc:$(JEMALLOC_STATICLIB)
INCLUDE += -I $(JEMALLOC_INC)
MALLOC_STATICLIB := $(JEMALLOC_STATICLIB)
all:jemalloc
all:$(MALLOC_LIB)
else
CCFLAG += -DDISABLE_JEMALLOC
MALLOC_STATICLIB :=
CFLAGS += -DDISABLE_JEMALLOC
MALLOC_LIB :=
endif

#tls disable
Expand All @@ -54,8 +54,6 @@ endif

#-----------project
LUACLIB_PATH ?= luaclib
SRC_PATH = silly-src
LIB_PATH = lualib-src
INCLUDE += -I $(LUA_INC) -I $(SRC_PATH)
SRC_FILE = \
main.c \
Expand All @@ -70,6 +68,8 @@ SRC_FILE = \
silly_log.c \
silly_trace.c \
silly_monitor.c \
pipe.c \
event.c \

SRC = $(addprefix $(SRC_PATH)/, $(SRC_FILE))
OBJS = $(patsubst %.c,%.o,$(SRC))
Expand All @@ -89,28 +89,28 @@ LIB_SRC = lualib-core.c \
all: \
fmt \
$(TARGET) \
$(LUACLIB_PATH)/core.so \
$(LUACLIB_PATH)/zproto.so \
$(LUACLIB_PATH)/http2.so \
$(LUACLIB_PATH)/pb.so \
$(LUACLIB_PATH)/test.so \
$(LUACLIB_PATH)/core.$(SO) \
$(LUACLIB_PATH)/zproto.$(SO) \
$(LUACLIB_PATH)/http2.$(SO) \
$(LUACLIB_PATH)/pb.$(SO) \
$(LUACLIB_PATH)/test.$(SO) \

$(TARGET):$(OBJS) $(LUA_STATICLIB) $(MALLOC_STATICLIB)
$(LD) -o $@ $^ $(LDFLAG)
$(TARGET):$(OBJS) $(LUA_STATICLIB) $(MALLOC_LIB)
$(LD) -o $@ $^ $(LDFLAGS)

$(LUACLIB_PATH):
mkdir $(LUACLIB_PATH)

$(LUACLIB_PATH)/core.so: $(addprefix $(LIB_PATH)/, $(LIB_SRC)) | $(LUACLIB_PATH)
$(CC) $(CCFLAG) $(INCLUDE) -o $@ $^ $(SHARED) $(TLSFLAG)
$(LUACLIB_PATH)/zproto.so: $(LIB_PATH)/zproto/lzproto.c $(LIB_PATH)/zproto/zproto.c | $(LUACLIB_PATH)
$(CC) $(CCFLAG) $(INCLUDE) -o $@ $^ $(SHARED)
$(LUACLIB_PATH)/http2.so: $(LIB_PATH)/lualib-http2.c | $(LUACLIB_PATH)
$(CC) $(CCFLAG) $(INCLUDE) -o $@ $^ $(SHARED)
$(LUACLIB_PATH)/pb.so: $(LIB_PATH)/pb.c | $(LUACLIB_PATH)
$(CC) $(CCFLAG) $(INCLUDE) -DPB_IMPLEMENTATION -o $@ $^ $(SHARED)
$(LUACLIB_PATH)/test.so: $(LIB_PATH)/lualib-test.c | $(LUACLIB_PATH)
$(CC) $(CCFLAG) $(INCLUDE) -o $@ $^ $(SHARED)
$(LUACLIB_PATH)/core.$(SO): $(addprefix $(LIB_PATH)/, $(LIB_SRC)) | $(LUACLIB_PATH)
$(CC) $(CFLAGS) $(INCLUDE) -o $@ $^ $(SHARED) $(TLSFLAG)
$(LUACLIB_PATH)/zproto.$(SO): $(LIB_PATH)/zproto/lzproto.c $(LIB_PATH)/zproto/zproto.c | $(LUACLIB_PATH)
$(CC) $(CFLAGS) $(INCLUDE) -o $@ $^ $(SHARED)
$(LUACLIB_PATH)/http2.$(SO): $(LIB_PATH)/lualib-http2.c | $(LUACLIB_PATH)
$(CC) $(CFLAGS) $(INCLUDE) -o $@ $^ $(SHARED)
$(LUACLIB_PATH)/pb.$(SO): $(LIB_PATH)/pb.c | $(LUACLIB_PATH)
$(CC) $(CFLAGS) $(INCLUDE) -DPB_IMPLEMENTATION -o $@ $^ $(SHARED)
$(LUACLIB_PATH)/test.$(SO): $(LIB_PATH)/lualib-test.c | $(LUACLIB_PATH)
$(CC) $(CFLAGS) $(INCLUDE) -o $@ $^ $(SHARED)

.depend:
@$(CC) $(INCLUDE) -MM $(SRC) 2>/dev/null |\
Expand All @@ -119,26 +119,26 @@ $(LUACLIB_PATH)/test.so: $(LIB_PATH)/lualib-test.c | $(LUACLIB_PATH)
-include .depend

%.o:%.c
$(CC) $(CCFLAG) $(INCLUDE) -c -o $@ $<
$(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $<

test: CCFLAG += -fsanitize=address -fno-omit-frame-pointer -DSILLY_TEST
test: LDFLAG += -fsanitize=address -fno-omit-frame-pointer
test: $(PLATS)
testall:
make TEST=ON all
./$(TARGET) test/test.lua --lualib_path="test/?.lua"

clean:
-rm $(SRC:.c=.o) *.so $(TARGET)
-rm -rf $(LUACLIB_PATH)
-rm .depend
-rm $(SRC_PATH)/*.lib

cleanall: clean
make -C $(LUA_DIR) clean
ifneq (,$(wildcard $(JEMALLOC_DIR)/Makefile))
cd $(JEMALLOC_DIR)&&make clean&&rm Makefile
make -C $(JEMALLOC_DIR) clean rm $(JEMALLOC_DIR)/Makefile
endif

fmt:
clang-format -i silly-src/*.h
clang-format -i silly-src/*.c
clang-format -i lualib-src/lua*.c
-clang-format -i silly-src/*.h
-clang-format -i silly-src/*.c
-clang-format -i lualib-src/lua*.c

Loading

0 comments on commit 4ebe46b

Please sign in to comment.