Skip to content

Commit

Permalink
Merge branch 'master' into attr2
Browse files Browse the repository at this point in the history
  • Loading branch information
xiyoo0812 committed May 29, 2024
2 parents ec9e538 + 220f512 commit e9e2729
Show file tree
Hide file tree
Showing 22 changed files with 13,680 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ stds.quanta = {
"import", "class", "enum", "mixin", "property", "singleton", "super", "implemented",
"logfeature", "db_property", "classof", "is_class", "is_subclass", "instanceof", "conv_class", "class_review",
"codec", "stdfs", "luabus", "luakit", "json", "protobuf", "timer", "aoi", "log", "worker", "http", "bson",
"detour", "lmdb", "unqlite", "sqlite", "ssl", "xml", "zip"
"detour", "lmdb", "unqlite", "sqlite", "ssl", "xml", "zip", "yaml"
}
}
std = "max+quanta"
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ luaext:
cd extend/luaxml; make SOLUTION_DIR=$(CUR_DIR) -f luaxml.mak;
cd extend/lunqlite; make SOLUTION_DIR=$(CUR_DIR) -f lunqlite.mak;
cd extend/lworker; make SOLUTION_DIR=$(CUR_DIR) -f lworker.mak;
cd extend/lyaml; make SOLUTION_DIR=$(CUR_DIR) -f lyaml.mak;

share:
cd extend/mimalloc; make SOLUTION_DIR=$(CUR_DIR) -f mimalloc.mak;
Expand Down
4 changes: 2 additions & 2 deletions extend/luaxml/src/luaxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ namespace luaxml {

extern "C" {
LUALIB_API int luaopen_luaxml(lua_State* L) {
auto luaxlsx = luaxml::open_luaxml(L);
return luaxlsx.push_stack();
auto lxml = luaxml::open_luaxml(L);
return lxml.push_stack();
}
}
37 changes: 37 additions & 0 deletions extend/lyaml/lyaml.lmak
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--工程名字
PROJECT_NAME = "lyaml"

--目标名字
TARGET_NAME = "lyaml"

----工程类型: static/dynamic/exe
PROJECT_TYPE = "dynamic"

--需要的include目录
INCLUDES = {
"./src",
"../lua/lua",
"../luakit/include"
}

DEFINES = {
"YAML_DECLARE_EXPORT"
}

--需要连接的库文件
LIBS = {
"lua"
}

--WINDOWS需要定义的选项
WINDOWS_DEFINES = {
"LUA_BUILD_AS_DLL"
}

--依赖项目
DEPS = {
"lualib"
}

--分组定义
GROUP = "luaext"
138 changes: 138 additions & 0 deletions extend/lyaml/lyaml.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#工程名字
PROJECT_NAME = lyaml

#目标名字
TARGET_NAME = lyaml

#系统环境
UNAME_S = $(shell uname -s)

#伪目标
.PHONY: clean all target pre_build post_build
all : pre_build target post_build

#CFLAG
MYCFLAGS =

#需要定义的FLAG
MYCFLAGS += -Wno-sign-compare
MYCFLAGS += -Wno-unused-variable
MYCFLAGS += -Wno-unused-parameter
MYCFLAGS += -Wno-unused-but-set-variable
MYCFLAGS += -Wno-unused-but-set-parameter

#c标准库版本
#gnu99/gnu11/gnu17
STDC = -std=gnu99

#c++标准库版本
#c++11/c++14/c++17/c++20
STDCPP = -std=c++17

#需要的include目录
MYCFLAGS += -I./src
MYCFLAGS += -I../lua/lua
MYCFLAGS += -I../luakit/include

#需要定义的选项
MYCFLAGS += -DYAML_DECLARE_EXPORT

#LDFLAGS
LDFLAGS =


#需要连接的库文件
LIBS =
ifneq ($(UNAME_S), Darwin)
#是否启用mimalloc库
LIBS += -lmimalloc
MYCFLAGS += -I$(SOLUTION_DIR)extend/mimalloc/mimalloc/include -include ../../mimalloc-ex.h
endif
#自定义库
LIBS += -llua
#系统库
LIBS += -lm -ldl -lstdc++ -lpthread

#定义基础的编译选项
ifndef CC
CC = gcc
endif
ifndef CX
CX = c++
endif
CFLAGS = -g -O2 -Wall -Wno-deprecated $(STDC) $(MYCFLAGS)
CXXFLAGS = -g -O2 -Wall -Wno-deprecated $(STDCPP) $(MYCFLAGS)

#项目目录
ifndef SOLUTION_DIR
SOLUTION_DIR=./
endif

#临时文件目录
INT_DIR = $(SOLUTION_DIR)temp/$(PROJECT_NAME)

#目标文件前缀,定义则.so和.a加lib前缀,否则不加
PROJECT_PREFIX =

#目标定义
MYCFLAGS += -fPIC
TARGET_DIR = $(SOLUTION_DIR)bin
TARGET_DYNAMIC = $(TARGET_DIR)/$(PROJECT_PREFIX)$(TARGET_NAME).so
#soname
ifeq ($(UNAME_S), Linux)
LDFLAGS += -Wl,-soname,$(PROJECT_PREFIX)$(TARGET_NAME).so
endif
#install_name
ifeq ($(UNAME_S), Darwin)
LDFLAGS += -Wl,-install_name,$(PROJECT_PREFIX)$(TARGET_NAME).so
endif

#link添加.so目录
LDFLAGS += -L$(SOLUTION_DIR)bin
LDFLAGS += -L$(SOLUTION_DIR)library

#自动生成目标
SOURCES =
SOURCES += src/api.c
SOURCES += src/dumper.c
SOURCES += src/emitter.c
SOURCES += src/loader.c
SOURCES += src/lyaml.cpp
SOURCES += src/parser.c
SOURCES += src/reader.c
SOURCES += src/scanner.c
SOURCES += src/writer.c

CSOURCES = $(patsubst %.c, $(INT_DIR)/%.o, $(SOURCES))
MSOURCES = $(patsubst %.m, $(INT_DIR)/%.o, $(CSOURCES))
CCSOURCES = $(patsubst %.cc, $(INT_DIR)/%.o, $(MSOURCES))
OBJS = $(patsubst %.cpp, $(INT_DIR)/%.o, $(CCSOURCES))

# 编译所有源文件
$(INT_DIR)/%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(INT_DIR)/%.o : %.m
$(CC) $(CFLAGS) -c $< -o $@
$(INT_DIR)/%.o : %.cc
$(CX) $(CXXFLAGS) -c $< -o $@
$(INT_DIR)/%.o : %.cpp
$(CX) $(CXXFLAGS) -c $< -o $@

$(TARGET_DYNAMIC) : $(OBJS)
$(CC) -o $@ -shared $(OBJS) $(LDFLAGS) $(LIBS)

#target伪目标
target : $(TARGET_DYNAMIC)

#clean伪目标
clean :
rm -rf $(INT_DIR)

#预编译
pre_build:
mkdir -p $(INT_DIR)
mkdir -p $(TARGET_DIR)
mkdir -p $(INT_DIR)/src

#后编译
post_build:
87 changes: 87 additions & 0 deletions extend/lyaml/lyaml.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Develop|x64">
<Configuration>Develop</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\yaml.h" />
<ClInclude Include="src\yaml_private.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\api.c" />
<ClCompile Include="src\dumper.c" />
<ClCompile Include="src\emitter.c" />
<ClCompile Include="src\loader.c" />
<ClCompile Include="src\lyaml.cpp" />
<ClCompile Include="src\parser.c" />
<ClCompile Include="src\reader.c" />
<ClCompile Include="src\scanner.c" />
<ClCompile Include="src\writer.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E106F499-F29A-DCCA-08A2-AFC056FA9905}</ProjectGuid>
<RootNamespace>lyaml</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>lyaml</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<TargetName>lyaml</TargetName>
<OutDir>$(SolutionDir)temp\bin\$(Platform)\</OutDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\src;..\lua\lua;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;YAML_DECLARE_EXPORT;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader></PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<ForcedIncludeFiles>..\..\mimalloc-ex.h</ForcedIncludeFiles>
<LanguageStandard>stdcpp17</LanguageStandard>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<AdditionalLibraryDirectories>$(SolutionDir)library\$(Platform);;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<ImportLibrary>$(SolutionDir)library\$(Platform)\$(TargetName).lib</ImportLibrary>
<ProgramDatabaseFile>$(SolutionDir)temp\$(ProjectName)\$(Platform)\$(TargetName).pdb</ProgramDatabaseFile>
<AdditionalDependencies>lua.lib;mimalloc.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ForceFileOutput>
</ForceFileOutput>
</Link>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy /y $(TargetPath) $(SolutionDir)bin</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
45 changes: 45 additions & 0 deletions extend/lyaml/lyaml.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="src\yaml.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="src\yaml_private.h">
<Filter>src</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\api.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\dumper.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\emitter.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\loader.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\lyaml.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\parser.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\reader.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\scanner.c">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\writer.c">
<Filter>src</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="src">
<UniqueIdentifier>{25D902C2-4283-AB8C-FBAC-54DFA101AD31}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
Loading

0 comments on commit e9e2729

Please sign in to comment.