Skip to content

Commit

Permalink
Merge pull request #12 from tkren/msbuild
Browse files Browse the repository at this point in the history
add MS Visual Studio solution and windows sockets
  • Loading branch information
nomis52 authored Sep 6, 2016
2 parents ba9e7ee + b4f13c6 commit 61878f9
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 15 deletions.
17 changes: 17 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,20 @@ for a 64-bit build: --host=x86_64-w64-mingw32
for a 32-bit build: --host=i686-w64-mingw32

./configure ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes --host=x86_64-w64-mingw32 --prefix=/some/path/prefix


Building libartnet with MS Visual Studio:

either open msvc\libartnet\libartnet.sln with devenv.exe or use msbuild:

for 64-bit build: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
for 32-bit build: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

build libartnet:

cd msvc\libartnet

for 64-bit Release build: msbuild libartnet.sln /t:libartnet /p:Configuration=Release /p:Platform=x64
for 32-bit Release build: msbuild libartnet.sln /t:libartnet /p:Configuration=Release /p:Platform=x86
for 64-bit Debug build: msbuild libartnet.sln /t:libartnet /p:Configuration=Debug /p:Platform=x64
for 32-bit Debug build: msbuild libartnet.sln /t:libartnet /p:Configuration=Debug /p:Platform=x86
2 changes: 1 addition & 1 deletion artnet/artnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ int artnet_dump_config(artnet_node vn) {
* @param socket the index of the socket descriptor to fetch (0 or 1)
* @return the socket descriptor
*/
int artnet_get_sd(artnet_node vn) {
artnet_socket_t artnet_get_sd(artnet_node vn) {
node n = (node) vn;
check_nullnode(vn);

Expand Down
12 changes: 9 additions & 3 deletions artnet/artnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// order is important here for osx
#include <sys/types.h>

#ifndef WIN32
#if !defined(WIN32) && !defined(_MSC_VER)
#include <sys/select.h>
#else
#include <winsock2.h>
Expand Down Expand Up @@ -210,6 +210,12 @@ typedef void *artnet_node;
/** A list of remote ArtNet nodes */
typedef void *artnet_node_list;

#if !defined(WIN32) && !defined(_MSC_VER)
typedef int artnet_socket_t;
#else
typedef SOCKET artnet_socket_t;
#endif

// node control functions
EXTERN artnet_node artnet_new(const char *ip, int verbose);
EXTERN int artnet_setoem(artnet_node vn, uint8_t hi, uint8_t lo);
Expand Down Expand Up @@ -334,10 +340,10 @@ EXTERN int artnet_nl_get_length(artnet_node_list nl);
// misc
EXTERN int artnet_dump_config(artnet_node n);
EXTERN int artnet_get_config(artnet_node n, artnet_node_config_t *config);
EXTERN int artnet_get_sd(artnet_node n);
EXTERN artnet_socket_t artnet_get_sd(artnet_node n);
EXTERN int artnet_set_fdset(artnet_node vn, fd_set *fdset);

char *artnet_strerror();
EXTERN char *artnet_strerror();

#ifdef __cplusplus
}
Expand Down
8 changes: 4 additions & 4 deletions artnet/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <errno.h>

#ifndef WIN32
#if !defined(WIN32) && !defined(_MSC_VER)
#include <sys/socket.h> // socket before net/if.h for mac
#include <net/if.h>
#include <sys/ioctl.h>
Expand Down Expand Up @@ -480,7 +480,7 @@ e_return :
* Start listening on the socket
*/
int artnet_net_start(node n) {
int sock;
artnet_socket_t sock;
struct sockaddr_in servAddr;
int true_flag = TRUE;
node tmp;
Expand All @@ -501,7 +501,7 @@ int artnet_net_start(node n) {
// create socket
sock = socket(PF_INET, SOCK_DGRAM, 0);

if (sock < 0) {
if (sock == INVALID_SOCKET) {
artnet_error("Could not create socket %s", artnet_net_last_error());
return ARTNET_ENET;
}
Expand Down Expand Up @@ -715,7 +715,7 @@ int artnet_net_set_fdset(node n, fd_set *fdset) {
/*
* Close a socket
*/
int artnet_net_close(int sock) {
int artnet_net_close(artnet_socket_t sock) {
#ifdef WIN32
shutdown(sock, SD_BOTH);
closesocket(sock);
Expand Down
10 changes: 3 additions & 7 deletions artnet/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# include <config.h>
#endif

#ifndef WIN32
#if !defined(WIN32) && !defined(_MSC_VER)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
Expand Down Expand Up @@ -445,11 +445,7 @@ typedef struct {
* The main node structure
*/
typedef struct artnet_node_s{
#ifdef WIN32
SOCKET sd;
#else
int sd; // the two sockets
#endif
artnet_socket_t sd; // the two sockets
node_state_t state; // the state struct
node_callbacks_t callbacks; // the callbacks struct
struct ports_s {
Expand Down Expand Up @@ -501,7 +497,7 @@ int artnet_net_send(node n, artnet_packet p);
int artnet_net_set_non_block(node n);
int artnet_net_init(node n, const char *ip);
int artnet_net_start(node n);
int artnet_net_close(int sock);
int artnet_net_close(artnet_socket_t sock);
int artnet_net_join(node n1, node n2);
int artnet_net_set_fdset(node n, fd_set *fdset);
int artnet_net_inet_aton(const char *ip_address, struct in_addr *address);
Expand Down
28 changes: 28 additions & 0 deletions msvc/libartnet/libartnet.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libartnet", "libartnet.vcxproj", "{DD027993-DEB3-4224-AB3A-3F86585A8913}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DD027993-DEB3-4224-AB3A-3F86585A8913}.Debug|x64.ActiveCfg = Debug|x64
{DD027993-DEB3-4224-AB3A-3F86585A8913}.Debug|x64.Build.0 = Debug|x64
{DD027993-DEB3-4224-AB3A-3F86585A8913}.Debug|x86.ActiveCfg = Debug|Win32
{DD027993-DEB3-4224-AB3A-3F86585A8913}.Debug|x86.Build.0 = Debug|Win32
{DD027993-DEB3-4224-AB3A-3F86585A8913}.Release|x64.ActiveCfg = Release|x64
{DD027993-DEB3-4224-AB3A-3F86585A8913}.Release|x64.Build.0 = Release|x64
{DD027993-DEB3-4224-AB3A-3F86585A8913}.Release|x86.ActiveCfg = Release|Win32
{DD027993-DEB3-4224-AB3A-3F86585A8913}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
175 changes: 175 additions & 0 deletions msvc/libartnet/libartnet.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<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>
<PropertyGroup Label="Globals">
<ProjectGuid>{DD027993-DEB3-4224-AB3A-3F86585A8913}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>libartnet</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<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" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBARTNET_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;MSW;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)\..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;LIBARTNET_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;MSW;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)\..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBARTNET_EXPORTS;MSW;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)\..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;LIBARTNET_EXPORTS;MSW;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)\..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\artnet\artnet.c" />
<ClCompile Include="..\..\artnet\misc.c" />
<ClCompile Include="..\..\artnet\network.c" />
<ClCompile Include="..\..\artnet\receive.c" />
<ClCompile Include="..\..\artnet\tod.c" />
<ClCompile Include="..\..\artnet\transmit.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\artnet\artnet.h" />
<ClInclude Include="..\..\artnet\common.h" />
<ClInclude Include="..\..\artnet\misc.h" />
<ClInclude Include="..\..\artnet\packets.h" />
<ClInclude Include="..\..\artnet\private.h" />
<ClInclude Include="..\..\artnet\tod.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
57 changes: 57 additions & 0 deletions msvc/libartnet/libartnet.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\artnet\artnet.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\artnet\misc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\artnet\network.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\artnet\receive.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\artnet\tod.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\artnet\transmit.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\artnet\artnet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\artnet\common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\artnet\misc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\artnet\packets.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\artnet\private.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\artnet\tod.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

0 comments on commit 61878f9

Please sign in to comment.