Skip to content

Commit

Permalink
Merge pull request #5 from mac-can/development
Browse files Browse the repository at this point in the history
Release candidate 2 for version 1.0
  • Loading branch information
mac-can authored Mar 31, 2024
2 parents 992d5e2 + a5db412 commit 1aa4761
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macOS-Build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: macOS CI
name: macOS Build

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/msbuild-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Add MSBuild to PATH
uses: microsoft/[email protected]

- name: Build for x64 Architecture
- name: Build for x64
working-directory: ${{env.GITHUB_WORKSPACE}}
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
Expand Down
15 changes: 8 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@ Trial/x86
Trial/Debug
Trial/Release
Trial/slcan_test
Trial/slcan_test.exe
Trial/*.sln
Trial/*.vcxproj.user
Library/.objects
Library/*.dylib
Library/*.so.*
Library/*.a
Library/.vs
Library/x64
Library/x86
Library/Debug_dll
Library/Debug_lib
Library/Release_dll
Library/Release_lib
Library/Debug_*
Library/Release_*
Library/uvslcan
Library/*.so.*
Library/*.dylib
Library/*.sln
Library/*.aps
Library/*.vcxproj.user
slcan-cppcheck-build-dir
checker.txt
artifacts
Binaries
Includes
Testing
.vscode
*.exe
*.log
*.pdf
6 changes: 0 additions & 6 deletions Library/.gitignore

This file was deleted.

9 changes: 6 additions & 3 deletions Sources/logger_w.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
*
* @remarks Windows compatible variant (_WIN32 and _WIN64)
*
* @author $Author: haumea $
* @author $Author: quaoar $
*
* @version $Rev: 802 $
* @version $Rev: 809 $
*
* @addtogroup logger
* @{
Expand Down Expand Up @@ -100,7 +100,7 @@ static HANDLE hThread = NULL;
static HANDLE hMutex = NULL;
static HANDLE hPipo, hPipi;
static FILE *logger = NULL;
static int running = 0;
static volatile int running = 0;


/* ----------- functions ----------------------------------------------
Expand Down Expand Up @@ -146,6 +146,7 @@ int log_init(const char *pathname/*, flags*/)
if (pathname) {
if ((fopen_s(&logger, pathname, "w+")) != 0) {
/* errno set */
CloseHandle(hThread);
CloseHandle(hMutex);
CloseHandle(hPipi);
CloseHandle(hPipo);
Expand Down Expand Up @@ -174,8 +175,10 @@ int log_exit(void)
}
/* kill the logging thread and release all resources */
running = 0;
(void)CancelIoEx(hPipo, NULL); // to cancel ReadPipe
(void)SetEvent(hThread);
(void)WaitForSingleObject(hThread, 3000);
(void)CloseHandle(hThread);
(void)CloseHandle(hMutex);
(void)CloseHandle(hPipi);
(void)CloseHandle(hPipo);
Expand Down
29 changes: 23 additions & 6 deletions Trial/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ OBJECTS = $(OUTDIR)/slcan.o $(OUTDIR)/serial.o \
$(OUTDIR)/buffer.o $(OUTDIR)/queue.o $(OUTDIR)/logger.o \
$(OUTDIR)/main.o

DEFINES = -DOPTION_SERIAL_DEBUG_LEVEL=1 \
DEFINES = -DOPTION_SERIAL_DEBUG_LEVEL=3 \
-DOPTION_SLCAN_DEBUG_LEVEL=1

HEADERS = -I$(SOURCE_DIR) \
-I$(MAIN_DIR)

LIBRARIES = -lpthread

ifeq ($(current_OS),Darwin) # macOS - libSLCAN.dylib

CFLAGS += -O2 -Wall -Wno-parentheses \
-fno-strict-aliasing \
Expand All @@ -46,28 +47,44 @@ CXXFLAGS += -g -Wall -Wextra -pthread \

LDFLAGS +=

ifeq ($(current_OS),Darwin) # macOS - libSLCAN.dylib
ifeq ($(BINARY),UNIVERSAL)
CFLAGS += -arch arm64 -arch x86_64
CXXFLAGS += -arch arm64 -arch x86_64
LDFLAGS += -arch arm64 -arch x86_64
endif

LIBRARIES = -lpthread

CHECKER = warning,information
IGNORE = -i *_w.c
IGNORE = -i serial_w.c -i buffer_w.c -i queue_w.c -i logger_w.c
ifeq ($(HUNTER),BUGS)
CHECKER += --bug-hunting
endif
endif
ifeq ($(current_OS),Darwin) # macOS - libSLCAN.dylib

CXX = clang++
CC = clang
LD = clang++

else # Linux, Cygwin - libslcan.so

CFLAGS += -O2 -Wall -Wno-parentheses \
-fno-strict-aliasing \
$(DEFINES) \
$(HEADERS)

CXXFLAGS += -g -Wall -Wextra -pthread \
$(DEFINES) \
$(HEADERS)

LDFLAGS +=

LIBRARIES = -lpthread

CXX = g++
CC = gcc
LD = g++
endif

RM = rm -f
CP = cp -f

Expand Down
66 changes: 2 additions & 64 deletions Trial/slcan_test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Sources\buffer_w.c" />
Expand Down Expand Up @@ -50,26 +42,12 @@
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
Expand All @@ -78,73 +56,33 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);OPTION_SLCAN_DEBUG_LEVEL=3</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>.\Sources;..\Sources;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);OPTION_SERIAL_DEBUG_LEVEL=3;OPTION_SLCAN_DEBUG_LEVEL=1</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>.\Sources;..\Sources;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);OPTION_SLCAN_DEBUG_LEVEL=3</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>.\Sources;..\Sources;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);OPTION_SERIAL_DEBUG_LEVEL=3;OPTION_SLCAN_DEBUG_LEVEL=1</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>.\Sources;..\Sources;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
Expand Down
52 changes: 32 additions & 20 deletions x64_build.bat
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
@echo off

rem parse arguments: [[NOVARS] NOTRIAL]
if "%1" == "NOVARS" (
set VCVARS="False"
) else (
set VCVARS="True"
)
set VCVARS="True"
set TRIAL="True"
set LIBD="False"

rem parse arguments: [NOVARS] [NOTRIAL] [DEBUG]
:LOOP
if "%1" == "NOVARS" set VCVARS="False"
if "%1" == "NOTRIAL" set TRIAL="False"
if "%1" == "DEBUG" set LIBD="True"
SHIFT
if "%1" == "NOTRIAL" (
set TRIAL="False"
) else (
set TRIAL="True"
)
if not "%1" == "" goto LOOP

rem set MSBuild environment variables
if %VCVARS% == "True" (
Expand All @@ -33,26 +32,39 @@ rem build the SLCAN library (dynamic and static)
call msbuild.exe .\Library\uvslcan.vcxproj /t:Clean;Build /p:"Configuration=Release_dll";"Platform=x64"
if errorlevel 1 goto end

call msbuild.exe .\Library\uvslcan.vcxproj /t:Clean;Build /p:"Configuration=Debug_lib";"Platform=x64"
call msbuild.exe .\Library\uvslcan.vcxproj /t:Clean;Build /p:"Configuration=Release_lib";"Platform=x64"
if errorlevel 1 goto end

if %LIBD% == "True" (
call msbuild.exe .\Library\uvslcan.vcxproj /t:Clean;Build /p:"Configuration=Debug_lib";"Platform=x64"
if errorlevel 1 goto end
)
rem copy the arifacts into the Binaries folder
echo Copying artifacts...
set BIN=".\Binaries"
set BIN=.\Binaries
if not exist %BIN% mkdir %BIN%
set BIN="%BIN%\x64"
set BIN=%BIN%\x64
if not exist %BIN% mkdir %BIN%
copy /Y .\Library\x64\Release_dll\uvslcan.dll %BIN%
copy /Y .\Library\x64\Release_dll\uvslcan.exp %BIN%
copy /Y .\Library\x64\Release_dll\uvslcan.lib %BIN%
set BIN="%BIN%\lib"
copy /Y .\Library\x64\Release_dll\uvslcan.pdb %BIN%
set BIN=%BIN%\lib
if not exist %BIN% mkdir %BIN%
copy /Y .\Library\x64\Debug_lib\uvslcan.lib %BIN%
copy /Y .\Library\x64\Debug_lib\uvslcan.pdb %BIN%
echo Static libraries (x86) > %BIN%\readme.txt

copy /Y .\Library\x64\Release_lib\uvslcan.lib %BIN%
copy /Y .\Library\x64\Release_lib\uvslcan.pdb %BIN%
echo "Static library (x64)" > %BIN%\readme.txt
set BIN=%BIN%\Debug
if %LIBD% == "True" (
if not exist %BIN% mkdir %BIN%
copy /Y .\Library\x64\Debug_lib\uvslcan.lib %BIN%
copy /Y .\Library\x64\Debug_lib\uvslcan.pdb %BIN%
copy /Y .\Library\x64\Debug_lib\uvslcan.idb %BIN%
echo "Static debug library (x64)" > %BIN%\readme.txt
)
rem copy the header files into the Includes folder
echo Copying header files...
set INC=".\Includes"
set INC=.\Includes
if not exist %INC% mkdir %INC%
copy /Y .\Sources\slcan.h %INC%
copy /Y .\Sources\serial_attr.h %INC%
Expand Down
Loading

0 comments on commit 1aa4761

Please sign in to comment.