Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
119 changes: 63 additions & 56 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
if (WIN32)
set(WINDOWS_VS_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/win32/output/bin)
set(WINDOWS_VS_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/win32/output/bin)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})

foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
endif(WIN32)

add_library(ds3 SHARED
Expand All @@ -25,57 +25,64 @@ add_library(ds3 SHARED

if (WIN32)

add_definitions(-DLIBRARY_EXPORTS -DCURL_STATICLIB -Dinline=__inline)
set_property(TARGET ds3 PROPERTY _CRT_SECURE_NO_WARNINGS)
SET_SOURCE_FILES_PROPERTIES(ds3.c PROPERTIES LANGUAGE CXX)
add_definitions(-DLIBRARY_EXPORTS -DCURL_STATICLIB -Dinline=__inline)
set_property(TARGET ds3 PROPERTY _CRT_SECURE_NO_WARNINGS)
set_source_files_properties(ds3.c PROPERTIES LANGUAGE CXX)

include_directories(
../win32/deps/install/include
../win32/deps/install/include/glib-2.0
../win32/deps/install/lib/glib-2.0/include
../win32/compatibility_includes)
target_link_libraries(ds3
../win32/deps/install/lib/libcurl_a
../win32/deps/install/lib/zlib_a
../win32/deps/install/lib/libxml2_a
../win32/deps/install/lib/glib-2.0
Ws2_32)
file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/win32" WINDOWS_DIR)
file(TO_NATIVE_PATH "${WINDOWS_DIR}/deps/install" WINDOWS_INSTALL_DIR)
file(TO_NATIVE_PATH "${WINDOWS_INSTALL_DIR}/lib" WINDOWS_INSTALL_LIB_DIR)
file(TO_NATIVE_PATH "${WINDOWS_INSTALL_DIR}/include" WINDOWS_INSTALL_INCLUDE_DIR)

file(TO_NATIVE_PATH ${WINDOWS_VS_OUTPUT_DIR}/ds3.dll DLL_LOCATION)
file(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR}/test/bin UNIT_TEST_DIR)
ADD_CUSTOM_COMMAND(TARGET ds3 POST_BUILD
COMMAND copy
${DLL_LOCATION} ${UNIT_TEST_DIR})
include_directories(
${WINDOWS_INSTALL_INCLUDE_DIR}
${WINDOWS_INSTALL_INCLUDE_DIR}/glib-2.0
${WINDOWS_INSTALL_INCLUDE_DIR}/glib-2.0/glib
${WINDOWS_INSTALL_LIB_DIR}/glib-2.0/include
${WINDOWS_DIR}/compatibility_includes)

target_link_libraries(ds3
${WINDOWS_INSTALL_LIB_DIR}/libcurl_a.lib
${WINDOWS_INSTALL_LIB_DIR}/zlib_a.lib
${WINDOWS_INSTALL_LIB_DIR}/libxml2_a.lib
${WINDOWS_INSTALL_LIB_DIR}/glib-2.0.lib
Ws2_32)

file(TO_NATIVE_PATH "${WINDOWS_VS_OUTPUT_DIR}/ds3.dll" DLL_LOCATION)
file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/test/bin" UNIT_TEST_DIR)
add_custom_command(TARGET ds3 POST_BUILD
COMMAND copy
${DLL_LOCATION} ${UNIT_TEST_DIR})
else(WIN32)
find_package(LibXml2 2.9 REQUIRED)
find_package(CURL 7.31 REQUIRED)
find_package(GLIB2 2.34 REQUIRED)
find_package(LibXml2 2.9 REQUIRED)
find_package(CURL 7.31 REQUIRED)
find_package(GLIB2 2.34 REQUIRED)

if (LIBXML2_FOUND)
include_directories(${LIBXML2_INCLUDE_DIR})
target_link_libraries (ds3 ${LIBXML2_LIBRARIES})
endif (LIBXML2_FOUND)
if (LIBXML2_FOUND)
include_directories(${LIBXML2_INCLUDE_DIR})
target_link_libraries (ds3 ${LIBXML2_LIBRARIES})
endif (LIBXML2_FOUND)

if (CURL_FOUND)
include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries (ds3 ${CURL_LIBRARIES})
endif (CURL_FOUND)
if (CURL_FOUND)
include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries (ds3 ${CURL_LIBRARIES})
endif (CURL_FOUND)

if (GLIB2_FOUND)
include_directories(${GLIB2_INCLUDE_DIRS})
target_link_libraries (ds3 ${GLIB2_LIBRARIES})
endif(GLIB2_FOUND)
if (GLIB2_FOUND)
include_directories(${GLIB2_INCLUDE_DIRS})
target_link_libraries (ds3 ${GLIB2_LIBRARIES})
endif(GLIB2_FOUND)

install(FILES
"ds3.h"
"ds3_connection.h"
"ds3_net.h"
"ds3_request.h"
"ds3_string.h"
"ds3_string_multimap.h"
"ds3_string_multimap_impl.h"
"ds3_utils.h"
DESTINATION
"/usr/local/include")
install(TARGETS ds3 DESTINATION lib)
install(FILES
"ds3.h"
"ds3_connection.h"
"ds3_net.h"
"ds3_request.h"
"ds3_string.h"
"ds3_string_multimap.h"
"ds3_string_multimap_impl.h"
"ds3_utils.h"
DESTINATION
"/usr/local/include")
install(TARGETS ds3 DESTINATION lib)
endif(WIN32)
48 changes: 0 additions & 48 deletions win32/Makefile.vc

This file was deleted.

52 changes: 24 additions & 28 deletions win32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,42 @@ Overview
--------

This directory contains all of the files needed to build under Windows.
Currently we build using cmake and MSVC 2015 and above.
Currently we build using CMake and MSVC 2015 and above.

Prerequisites
-------------

1. Boost C++ library installed to a default location on the machine
2. PowerShell 3+
3. If you don't already have 7zip, it will be downloaded and placed in the Windows Temp directory to untar glib.

Dependencies
------------

The SDK depends upon several open source libraries.

To acquire the dependencies, follow the following procedure:

1. Ensure the built dependency directory at `/win32/deps/install` is empty.
2. Download and extract the dependency library packages. Depending on whether you want 32 or 64 bit libs, run one of the following:
* `\win32\deps\build\download_and_unzip.bat`
* `\win32\deps\build\download_and_unzip_64.bat`
* You can also manually download the URLs and extract using whatever utility you like. Note that the glib package must be extracted to `/win32/deps/build/prebuilt`.
3. The Windows batch file `/win32/deps/install(_64).bat` compiles and installs the dependencies into the `/win32/deps/install` directory. It executes the Visual Studio 14 2015 Command Prompt environment script, so if you're using a different version you'll have to modify the Visual Studio install path inside of `install(_64).bat`.

Basic Build

Build
-----------

To build the client library


1. Open a new Visual Studio Command Prompt.
2. Navigate to the ds3_c_sdk directory.
3. Run the following command: `cmake -G "Visual Studio 14 2015"`
4. Either open the resulting 'libds3.sln' in Visual Studio and build it from
there, or run the command 'msbuild libds3.sln' from the command prompt.
2. Navigate to the ds3_c_sdk\win32 directory.
3. Run `package(_64).bat`, which will use CMake to create a Visual Studio 14 2015 solution, and then compile from the command line using msbuild, and compress all requiredSDK dependencies into a `ds3_win(32 or 64).zip`
3. Run the following command: `cmake .. -G "Visual Studio 14 2015 {Win64}"`
4. Either open the resulting `libds3.sln` in Visual Studio and build it from
there, or run the command `msbuild libds3.sln` from the command prompt.
This should build the libds3 library, which is placed in the directory '<root of repo>/win32/output/bin'


Expand All @@ -29,31 +46,10 @@ Unit Tests

1. Open a new Visual Studio Command Prompt.
2. Navigate to the ds3_c_sdk/test directory.
3. Run the following command: `cmake -G "Visual Studio 14 2015"`
3. Run the following command: `cmake ..\.. -G "Visual Studio 14 2015 {Win64}"`
4. Either open the resulting 'libds3_tests.sln' in Visual Studio and build it
from there, or run the command 'msbuild libds3_tests.sln' from the command
prompt. This should build the libds3 library, which is placed in the directory
'<root of repo>/tests/bin'


Dependencies
------------

The SDK depends upon several open source libraries. For convenience we
redistribute these dependencies in the `/win32/deps/install` directory,
except for the Boost library headers.

To re-build the dependencies, follow the following procedure:

1. Delete the built dependency directory at `/win32/deps/install`.
2. Download and extract the dependency library packages.
* The Unix shell script at `/win32/deps/build/download_and_unzip.sh` can do
this for you, but you don't strictly need to use it. You can also manually
download the URLs and extract using whatever utility you like. Note that
the glib package must be extracted to `/win32/deps/build/prebuilt`.
3. The Windows batch file `/win32/deps/install.bat` compiles and installs the
dependencies into the `/win32/deps/install` directory. It executes the
Visual Studio 2012 Command Prompt environment script, so if you're using a
different version you'll have to modify the Visual Studio install path inside
of `install.bat`.

2 changes: 2 additions & 0 deletions win32/deps/build/download_and_unzip.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
powershell -ExecutionPolicy RemoteSigned -File download_and_unzip.ps1
27 changes: 27 additions & 0 deletions win32/deps/build/download_and_unzip.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# download 32bit library dependencies and put into expected layout for install.

. "$PSScriptRoot\util.ps1" # provides Unzip and Untar

(new-object System.Net.WebClient).DownloadFile(
'http://curl.haxx.se/download/curl-7.37.0.zip',
'curl-7.37.0.zip')
Unzip curl-7.37.0.zip .
Remove-Item curl-7.37.0.zip

(new-object System.Net.WebClient).DownloadFile(
'http://zlib.net/zlib128.zip',
'zlib128.zip')
Unzip zlib128.zip .
Remove-Item zlib128.zip

(new-object System.Net.WebClient).DownloadFile(
'ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz',
'libxml2-2.9.4.tar.gz')
Untar libxml2-2.9.4.tar.gz .
Remove-Item libxml2-2.9.4.tar.gz

(new-object System.Net.WebClient).DownloadFile(
'http://win32builder.gnome.org/gtk+-bundle_3.6.4-20130921_win32.zip',
'gtk+-bundle_3.6.4-20130921_win32.zip')
Unzip gtk+-bundle_3.6.4-20130921_win32.zip prebuilt
Remove-Item gtk+-bundle_3.6.4-20130921_win32.zip
2 changes: 2 additions & 0 deletions win32/deps/build/download_and_unzip_64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
powershell -ExecutionPolicy RemoteSigned -File download_and_unzip_64.ps1
19 changes: 19 additions & 0 deletions win32/deps/build/download_and_unzip_64.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# download 64bit library dependencies and put into expected layout for install.

. "$PSScriptRoot\util.ps1" # provides Unzip and Untar

(new-object System.Net.WebClient).DownloadFile('http://curl.haxx.se/download/curl-7.37.0.zip','curl-7.37.0.zip')
Unzip curl-7.37.0.zip .
Remove-Item curl-7.37.0.zip

(new-object System.Net.WebClient).DownloadFile('http://zlib.net/zlib128.zip','zlib128.zip')
Unzip zlib128.zip .
Remove-Item zlib128.zip

(new-object System.Net.WebClient).DownloadFile('ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz','libxml2-2.9.4.tar.gz')
Untar libxml2-2.9.4.tar.gz .
Remove-Item libxml2-2.9.4.tar.gz

(new-object System.Net.WebClient).DownloadFile('http://win32builder.gnome.org/gtk+-bundle_3.6.4-20131201_win64.zip','gtk+-bundle_3.6.4-20131201_win64.zip')
Unzip gtk+-bundle_3.6.4-20131201_win64.zip prebuilt
Remove-Item gtk+-bundle_3.6.4-20131201_win64.zip
47 changes: 47 additions & 0 deletions win32/deps/build/util.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param(
[Parameter(Mandatory=$true)][string]$zipfile,
[Parameter(Mandatory=$true)][string]$outpath
)

[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}

function Untar() {
param(
[Parameter(Mandatory=$true)][string]$archive,
[Parameter(Mandatory=$true)][string]$outpath
)

$7z_path = "$env:TEMP\7z"
if (!(test-path $7z_path) -or !(test-path "$7z_path\7za.exe")) {
if (!(test-path $7z_path)) { md $7z_path | out-null }
push-location $7z_path
try {
write-host "Downloading 7zip" -foregroundcolor cyan

$7zip_dl = "http://www.7-zip.org/a/7za920.zip"
(new-object System.Net.WebClient).DownloadFile("$7zip_dl", "$7z_path\7za.zip")

write-host "done." -foregroundcolor green

Unzip "$7z_path\7za.zip" "$7z_path"
del "$7z_path\7za.zip"
}
finally { pop-location }
}
write-host $7za_path
$7za_exe = "$7z_path" + '\7za.exe'
write-host $7za_exe

if ($archive.endswith('.tar.gz') -or $archive.endswith('.tgz')) {
$x = "cmd.exe"
# Properly handle paths and archives with spaces in names
$y = "/C `"^`"$7za_exe^`" e ^`"$archive^`" -so | ^`"$7za_exe^`" x -aoa -si -ttar -o^`"$outpath^`""
& $x $y | findstr /v /b /c:"Extracting " # suppress noisy per file msg
} else {
& "$7za_exe" x $archive -y -o"$outpath" | findstr /v /b /c:"Extracting " # suppress noisy per file msg
}
}
Binary file removed win32/deps/install/bin/libglib-2.0-0.dll
Binary file not shown.
Binary file removed win32/deps/install/bin/libiconv-2.dll
Binary file not shown.
Binary file removed win32/deps/install/bin/libintl-8.dll
Binary file not shown.
Binary file removed win32/deps/install/bin/pthreadGC2.dll
Binary file not shown.
Loading