Merge branch 'windows-msvc-compilation'

This commit is contained in:
Rogier 2016-05-31 21:50:42 +02:00
commit 5eb44bad4b
29 changed files with 2920 additions and 60 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

241
.gitignore vendored
View File

@ -6,8 +6,247 @@ CPack*
_CPack_Packages/ _CPack_Packages/
Makefile Makefile
cmake_install.cmake cmake_install.cmake
cmake_config.h build_config.h
*.deb *.deb
*.rpm *.rpm
*.tar.gz *.tar.gz
*~ *~
## The following lines where taken at 23.01.2016 from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/
MSVC/versioninfo.h
minetestmapper.VC.db

View File

@ -1,5 +1,5 @@
#include <BlockPos.h> #include "BlockPos.h"
void BlockPos::operator=(const std::string &s) void BlockPos::operator=(const std::string &s)
{ {

View File

@ -13,13 +13,9 @@ endif(WIN32)
# Obtain stored major version number # Obtain stored major version number
# Make sure cmake is rerun when version has changed # Make sure cmake is rerun when version has changed
configure_file(version version.dup COPYONLY) configure_file(base-version base-version.dup COPYONLY)
file(REMOVE version.dup) file(REMOVE base-version.dup)
if(EXISTS "${CMAKE_HOME_DIRECTORY}/version") file(STRINGS "${CMAKE_HOME_DIRECTORY}/base-version" VERSION_FROM_FILE)
file(STRINGS "${CMAKE_HOME_DIRECTORY}/version" VERSION_FROM_FILE)
else(EXISTS "${CMAKE_HOME_DIRECTORY}/version")
message(FATAL_ERROR "File '${CMAKE_HOME_DIRECTORY}/version' not found or not readable")
endif(EXISTS "${CMAKE_HOME_DIRECTORY}/version")
execute_process(COMMAND git describe --long "--match=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" --dirty=-WIP --abbrev=8 execute_process(COMMAND git describe --long "--match=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" --dirty=-WIP --abbrev=8
RESULT_VARIABLE VERSION_EXIT OUTPUT_VARIABLE GIT_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) RESULT_VARIABLE VERSION_EXIT OUTPUT_VARIABLE GIT_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -524,9 +520,15 @@ include(CPack)
# DO this near the end - to make sure all variables have been computed # DO this near the end - to make sure all variables have been computed
# and are final. # and are final.
set(INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(BUILD_CONFIG_GENTOOL CMake)
# CMake does not have a date format specifier for timezone...
execute_process(COMMAND date -R RESULT_VARIABLE DATE_EXITVAL OUTPUT_VARIABLE BUILD_CONFIG_GENDATE ERROR_FILE /dev/null OUTPUT_STRIP_TRAILING_WHITESPACE)
if(DATE_EXITVAL)
message(FATAL_ERROR "Failed to run command 'date -R'")
endif(DATE_EXITVAL)
configure_file( configure_file(
"${PROJECT_SOURCE_DIR}/cmake_config.h.in" "${PROJECT_SOURCE_DIR}/build_config.h.in"
"${PROJECT_BINARY_DIR}/cmake_config.h" "${PROJECT_BINARY_DIR}/build_config.h"
) )
add_definitions ( -DUSE_CMAKE_CONFIG_H )

View File

@ -4,6 +4,7 @@
Compatible with two previous unofficial implementations, by Compatible with two previous unofficial implementations, by
ShadowNinja and johnnyjoy. Support for these will be removed ShadowNinja and johnnyjoy. Support for these will be removed
in a future version of Minetestmapper. in a future version of Minetestmapper.
- Support for MSVC/Windows compilation (Thanks to adrido!)
Enhancements: Enhancements:
- Updated the included colors file with colors for the new tiles that - Updated the included colors file with colors for the new tiles that
were recently added to the default minetest game. were recently added to the default minetest game.
@ -13,6 +14,7 @@
in the different packages. in the different packages.
- Documented concurrent minetest & minetestmapper use. - Documented concurrent minetest & minetestmapper use.
- Documented the different geometries reported with --verbose - Documented the different geometries reported with --verbose
- Mentioned adrido's MinetestmapperGUI in the manual
- The option --prescan-world was added to force or disable scanning the - The option --prescan-world was added to force or disable scanning the
entire world (i.e. reading a full blocklist) entire world (i.e. reading a full blocklist)
(useful for postgresql, which doesn't do this by default). (useful for postgresql, which doesn't do this by default).

View File

@ -1,10 +1,10 @@
#include <iostream> #include <iostream>
#include "cmake_config.h" #include "build_config.h"
#include "CharEncodingConverter.h" #include "CharEncodingConverter.h"
#ifdef _WIN32 #ifdef _WIN32
#warning No standard charset converter defined for WIN32 - disabling conversion #pragma message ("No standard charset converter defined for WIN32 - disabling conversion")
#else #else
#include "CharEncodingConverterIConv.h" #include "CharEncodingConverterIConv.h"
#endif #endif

22
MSVC/dirent/LICENSE Normal file
View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Toni Rönkkö
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

8
MSVC/dirent/README.txt Normal file
View File

@ -0,0 +1,8 @@
The file include/dirent.h was taken at 29.12.2015 from https://github.com/tronkko/dirent
Its licened under MIT license. See the LICENSE file for details.
There are some reasons why foreign code is included here:
* To avoid build steps like "Copy file x from http:// and place it in direcory y ..." and so on.
* Nobody can give a guaranty that the source from the Internet are still aviable in some years.
Even github repos can be deleted.

View File

@ -0,0 +1,917 @@
/*
* Dirent interface for Microsoft Visual Studio
* Version 1.21
*
* Copyright (C) 2006-2012 Toni Ronkko
* This file is part of dirent. Dirent may be freely distributed
* under the MIT license. For all details and documentation, see
* https://github.com/tronkko/dirent
*/
#ifndef DIRENT_H
#define DIRENT_H
/*
* Define architecture flags so we don't need to include windows.h.
* Avoiding windows.h makes it simpler to use windows sockets in conjunction
* with dirent.h.
*/
#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86)
# define _X86_
#endif
#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_AMD64)
#define _AMD64_
#endif
#include <stdio.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wchar.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
/* Indicates that d_type field is available in dirent structure */
#define _DIRENT_HAVE_D_TYPE
/* Indicates that d_namlen field is available in dirent structure */
#define _DIRENT_HAVE_D_NAMLEN
/* Entries missing from MSVC 6.0 */
#if !defined(FILE_ATTRIBUTE_DEVICE)
# define FILE_ATTRIBUTE_DEVICE 0x40
#endif
/* File type and permission flags for stat(), general mask */
#if !defined(S_IFMT)
# define S_IFMT _S_IFMT
#endif
/* Directory bit */
#if !defined(S_IFDIR)
# define S_IFDIR _S_IFDIR
#endif
/* Character device bit */
#if !defined(S_IFCHR)
# define S_IFCHR _S_IFCHR
#endif
/* Pipe bit */
#if !defined(S_IFFIFO)
# define S_IFFIFO _S_IFFIFO
#endif
/* Regular file bit */
#if !defined(S_IFREG)
# define S_IFREG _S_IFREG
#endif
/* Read permission */
#if !defined(S_IREAD)
# define S_IREAD _S_IREAD
#endif
/* Write permission */
#if !defined(S_IWRITE)
# define S_IWRITE _S_IWRITE
#endif
/* Execute permission */
#if !defined(S_IEXEC)
# define S_IEXEC _S_IEXEC
#endif
/* Pipe */
#if !defined(S_IFIFO)
# define S_IFIFO _S_IFIFO
#endif
/* Block device */
#if !defined(S_IFBLK)
# define S_IFBLK 0
#endif
/* Link */
#if !defined(S_IFLNK)
# define S_IFLNK 0
#endif
/* Socket */
#if !defined(S_IFSOCK)
# define S_IFSOCK 0
#endif
/* Read user permission */
#if !defined(S_IRUSR)
# define S_IRUSR S_IREAD
#endif
/* Write user permission */
#if !defined(S_IWUSR)
# define S_IWUSR S_IWRITE
#endif
/* Execute user permission */
#if !defined(S_IXUSR)
# define S_IXUSR 0
#endif
/* Read group permission */
#if !defined(S_IRGRP)
# define S_IRGRP 0
#endif
/* Write group permission */
#if !defined(S_IWGRP)
# define S_IWGRP 0
#endif
/* Execute group permission */
#if !defined(S_IXGRP)
# define S_IXGRP 0
#endif
/* Read others permission */
#if !defined(S_IROTH)
# define S_IROTH 0
#endif
/* Write others permission */
#if !defined(S_IWOTH)
# define S_IWOTH 0
#endif
/* Execute others permission */
#if !defined(S_IXOTH)
# define S_IXOTH 0
#endif
/* Maximum length of file name */
#if !defined(PATH_MAX)
# define PATH_MAX MAX_PATH
#endif
#if !defined(FILENAME_MAX)
# define FILENAME_MAX MAX_PATH
#endif
#if !defined(NAME_MAX)
# define NAME_MAX FILENAME_MAX
#endif
/* File type flags for d_type */
#define DT_UNKNOWN 0
#define DT_REG S_IFREG
#define DT_DIR S_IFDIR
#define DT_FIFO S_IFIFO
#define DT_SOCK S_IFSOCK
#define DT_CHR S_IFCHR
#define DT_BLK S_IFBLK
#define DT_LNK S_IFLNK
/* Macros for converting between st_mode and d_type */
#define IFTODT(mode) ((mode) & S_IFMT)
#define DTTOIF(type) (type)
/*
* File type macros. Note that block devices, sockets and links cannot be
* distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
* only defined for compatibility. These macros should always return false
* on Windows.
*/
#if !defined(S_ISFIFO)
# define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
#endif
#if !defined(S_ISDIR)
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif
#if !defined(S_ISREG)
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#endif
#if !defined(S_ISLNK)
# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
#endif
#if !defined(S_ISSOCK)
# define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
#endif
#if !defined(S_ISCHR)
# define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
#endif
#if !defined(S_ISBLK)
# define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
#endif
/* Return the exact length of d_namlen without zero terminator */
#define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
/* Return number of bytes needed to store d_namlen */
#define _D_ALLOC_NAMLEN(p) (PATH_MAX)
#ifdef __cplusplus
extern "C" {
#endif
/* Wide-character version */
struct _wdirent {
/* Always zero */
long d_ino;
/* Structure size */
unsigned short d_reclen;
/* Length of name without \0 */
size_t d_namlen;
/* File type */
int d_type;
/* File name */
wchar_t d_name[PATH_MAX];
};
typedef struct _wdirent _wdirent;
struct _WDIR {
/* Current directory entry */
struct _wdirent ent;
/* Private file data */
WIN32_FIND_DATAW data;
/* True if data is valid */
int cached;
/* Win32 search handle */
HANDLE handle;
/* Initial directory name */
wchar_t *patt;
};
typedef struct _WDIR _WDIR;
static _WDIR *_wopendir (const wchar_t *dirname);
static struct _wdirent *_wreaddir (_WDIR *dirp);
static int _wclosedir (_WDIR *dirp);
static void _wrewinddir (_WDIR* dirp);
/* For compatibility with Symbian */
#define wdirent _wdirent
#define WDIR _WDIR
#define wopendir _wopendir
#define wreaddir _wreaddir
#define wclosedir _wclosedir
#define wrewinddir _wrewinddir
/* Multi-byte character versions */
struct dirent {
/* Always zero */
long d_ino;
/* Structure size */
unsigned short d_reclen;
/* Length of name without \0 */
size_t d_namlen;
/* File type */
int d_type;
/* File name */
char d_name[PATH_MAX];
};
typedef struct dirent dirent;
struct DIR {
struct dirent ent;
struct _WDIR *wdirp;
};
typedef struct DIR DIR;
static DIR *opendir (const char *dirname);
static struct dirent *readdir (DIR *dirp);
static int closedir (DIR *dirp);
static void rewinddir (DIR* dirp);
/* Internal utility functions */
static WIN32_FIND_DATAW *dirent_first (_WDIR *dirp);
static WIN32_FIND_DATAW *dirent_next (_WDIR *dirp);
static int dirent_mbstowcs_s(
size_t *pReturnValue,
wchar_t *wcstr,
size_t sizeInWords,
const char *mbstr,
size_t count);
static int dirent_wcstombs_s(
size_t *pReturnValue,
char *mbstr,
size_t sizeInBytes,
const wchar_t *wcstr,
size_t count);
static void dirent_set_errno (int error);
/*
* Open directory stream DIRNAME for read and return a pointer to the
* internal working area that is used to retrieve individual directory
* entries.
*/
static _WDIR*
_wopendir(
const wchar_t *dirname)
{
_WDIR *dirp = NULL;
int error;
/* Must have directory name */
if (dirname == NULL || dirname[0] == '\0') {
dirent_set_errno (ENOENT);
return NULL;
}
/* Allocate new _WDIR structure */
dirp = (_WDIR*) malloc (sizeof (struct _WDIR));
if (dirp != NULL) {
DWORD n;
/* Reset _WDIR structure */
dirp->handle = INVALID_HANDLE_VALUE;
dirp->patt = NULL;
dirp->cached = 0;
/* Compute the length of full path plus zero terminator */
n = GetFullPathNameW (dirname, 0, NULL, NULL);
/* Allocate room for absolute directory name and search pattern */
dirp->patt = (wchar_t*) malloc (sizeof (wchar_t) * n + 16);
if (dirp->patt) {
/*
* Convert relative directory name to an absolute one. This
* allows rewinddir() to function correctly even when current
* working directory is changed between opendir() and rewinddir().
*/
n = GetFullPathNameW (dirname, n, dirp->patt, NULL);
if (n > 0) {
wchar_t *p;
/* Append search pattern \* to the directory name */
p = dirp->patt + n;
if (dirp->patt < p) {
switch (p[-1]) {
case '\\':
case '/':
case ':':
/* Directory ends in path separator, e.g. c:\temp\ */
/*NOP*/;
break;
default:
/* Directory name doesn't end in path separator */
*p++ = '\\';
}
}
*p++ = '*';
*p = '\0';
/* Open directory stream and retrieve the first entry */
if (dirent_first (dirp)) {
/* Directory stream opened successfully */
error = 0;
} else {
/* Cannot retrieve first entry */
error = 1;
dirent_set_errno (ENOENT);
}
} else {
/* Cannot retrieve full path name */
dirent_set_errno (ENOENT);
error = 1;
}
} else {
/* Cannot allocate memory for search pattern */
error = 1;
}
} else {
/* Cannot allocate _WDIR structure */
error = 1;
}
/* Clean up in case of error */
if (error && dirp) {
_wclosedir (dirp);
dirp = NULL;
}
return dirp;
}
/*
* Read next directory entry. The directory entry is returned in dirent
* structure in the d_name field. Individual directory entries returned by
* this function include regular files, sub-directories, pseudo-directories
* "." and ".." as well as volume labels, hidden files and system files.
*/
static struct _wdirent*
_wreaddir(
_WDIR *dirp)
{
WIN32_FIND_DATAW *datap;
struct _wdirent *entp;
/* Read next directory entry */
datap = dirent_next (dirp);
if (datap) {
size_t n;
DWORD attr;
/* Pointer to directory entry to return */
entp = &dirp->ent;
/*
* Copy file name as wide-character string. If the file name is too
* long to fit in to the destination buffer, then truncate file name
* to PATH_MAX characters and zero-terminate the buffer.
*/
n = 0;
while (n + 1 < PATH_MAX && datap->cFileName[n] != 0) {
entp->d_name[n] = datap->cFileName[n];
n++;
}
dirp->ent.d_name[n] = 0;
/* Length of file name excluding zero terminator */
entp->d_namlen = n;
/* File type */
attr = datap->dwFileAttributes;
if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
entp->d_type = DT_CHR;
} else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
entp->d_type = DT_DIR;
} else {
entp->d_type = DT_REG;
}
/* Reset dummy fields */
entp->d_ino = 0;
entp->d_reclen = sizeof (struct _wdirent);
} else {
/* Last directory entry read */
entp = NULL;
}
return entp;
}
/*
* Close directory stream opened by opendir() function. This invalidates the
* DIR structure as well as any directory entry read previously by
* _wreaddir().
*/
static int
_wclosedir(
_WDIR *dirp)
{
int ok;
if (dirp) {
/* Release search handle */
if (dirp->handle != INVALID_HANDLE_VALUE) {
FindClose (dirp->handle);
dirp->handle = INVALID_HANDLE_VALUE;
}
/* Release search pattern */
if (dirp->patt) {
free (dirp->patt);
dirp->patt = NULL;
}
/* Release directory structure */
free (dirp);
ok = /*success*/0;
} else {
/* Invalid directory stream */
dirent_set_errno (EBADF);
ok = /*failure*/-1;
}
return ok;
}
/*
* Rewind directory stream such that _wreaddir() returns the very first
* file name again.
*/
static void
_wrewinddir(
_WDIR* dirp)
{
if (dirp) {
/* Release existing search handle */
if (dirp->handle != INVALID_HANDLE_VALUE) {
FindClose (dirp->handle);
}
/* Open new search handle */
dirent_first (dirp);
}
}
/* Get first directory entry (internal) */
static WIN32_FIND_DATAW*
dirent_first(
_WDIR *dirp)
{
WIN32_FIND_DATAW *datap;
/* Open directory and retrieve the first entry */
dirp->handle = FindFirstFileW (dirp->patt, &dirp->data);
if (dirp->handle != INVALID_HANDLE_VALUE) {
/* a directory entry is now waiting in memory */
datap = &dirp->data;
dirp->cached = 1;
} else {
/* Failed to re-open directory: no directory entry in memory */
dirp->cached = 0;
datap = NULL;
}
return datap;
}
/* Get next directory entry (internal) */
static WIN32_FIND_DATAW*
dirent_next(
_WDIR *dirp)
{
WIN32_FIND_DATAW *p;
/* Get next directory entry */
if (dirp->cached != 0) {
/* A valid directory entry already in memory */
p = &dirp->data;
dirp->cached = 0;
} else if (dirp->handle != INVALID_HANDLE_VALUE) {
/* Get the next directory entry from stream */
if (FindNextFileW (dirp->handle, &dirp->data) != FALSE) {
/* Got a file */
p = &dirp->data;
} else {
/* The very last entry has been processed or an error occured */
FindClose (dirp->handle);
dirp->handle = INVALID_HANDLE_VALUE;
p = NULL;
}
} else {
/* End of directory stream reached */
p = NULL;
}
return p;
}
/*
* Open directory stream using plain old C-string.
*/
static DIR*
opendir(
const char *dirname)
{
struct DIR *dirp;
int error;
/* Must have directory name */
if (dirname == NULL || dirname[0] == '\0') {
dirent_set_errno (ENOENT);
return NULL;
}
/* Allocate memory for DIR structure */
dirp = (DIR*) malloc (sizeof (struct DIR));
if (dirp) {
wchar_t wname[PATH_MAX];
size_t n;
/* Convert directory name to wide-character string */
error = dirent_mbstowcs_s (&n, wname, PATH_MAX, dirname, PATH_MAX);
if (!error) {
/* Open directory stream using wide-character name */
dirp->wdirp = _wopendir (wname);
if (dirp->wdirp) {
/* Directory stream opened */
error = 0;
} else {
/* Failed to open directory stream */
error = 1;
}
} else {
/*
* Cannot convert file name to wide-character string. This
* occurs if the string contains invalid multi-byte sequences or
* the output buffer is too small to contain the resulting
* string.
*/
error = 1;
}
} else {
/* Cannot allocate DIR structure */
error = 1;
}
/* Clean up in case of error */
if (error && dirp) {
free (dirp);
dirp = NULL;
}
return dirp;
}
/*
* Read next directory entry.
*
* When working with text consoles, please note that file names returned by
* readdir() are represented in the default ANSI code page while any output to
* console is typically formatted on another code page. Thus, non-ASCII
* characters in file names will not usually display correctly on console. The
* problem can be fixed in two ways: (1) change the character set of console
* to 1252 using chcp utility and use Lucida Console font, or (2) use
* _cprintf function when writing to console. The _cprinf() will re-encode
* ANSI strings to the console code page so many non-ASCII characters will
* display correcly.
*/
static struct dirent*
readdir(
DIR *dirp)
{
WIN32_FIND_DATAW *datap;
struct dirent *entp;
/* Read next directory entry */
datap = dirent_next (dirp->wdirp);
if (datap) {
size_t n;
int error;
/* Attempt to convert file name to multi-byte string */
error = dirent_wcstombs_s(
&n, dirp->ent.d_name, PATH_MAX, datap->cFileName, PATH_MAX);
/*
* If the file name cannot be represented by a multi-byte string,
* then attempt to use old 8+3 file name. This allows traditional
* Unix-code to access some file names despite of unicode
* characters, although file names may seem unfamiliar to the user.
*
* Be ware that the code below cannot come up with a short file
* name unless the file system provides one. At least
* VirtualBox shared folders fail to do this.
*/
if (error && datap->cAlternateFileName[0] != '\0') {
error = dirent_wcstombs_s(
&n, dirp->ent.d_name, PATH_MAX,
datap->cAlternateFileName, PATH_MAX);
}
if (!error) {
DWORD attr;
/* Initialize directory entry for return */
entp = &dirp->ent;
/* Length of file name excluding zero terminator */
entp->d_namlen = n - 1;
/* File attributes */
attr = datap->dwFileAttributes;
if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
entp->d_type = DT_CHR;
} else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
entp->d_type = DT_DIR;
} else {
entp->d_type = DT_REG;
}
/* Reset dummy fields */
entp->d_ino = 0;
entp->d_reclen = sizeof (struct dirent);
} else {
/*
* Cannot convert file name to multi-byte string so construct
* an errornous directory entry and return that. Note that
* we cannot return NULL as that would stop the processing
* of directory entries completely.
*/
entp = &dirp->ent;
entp->d_name[0] = '?';
entp->d_name[1] = '\0';
entp->d_namlen = 1;
entp->d_type = DT_UNKNOWN;
entp->d_ino = 0;
entp->d_reclen = 0;
}
} else {
/* No more directory entries */
entp = NULL;
}
return entp;
}
/*
* Close directory stream.
*/
static int
closedir(
DIR *dirp)
{
int ok;
if (dirp) {
/* Close wide-character directory stream */
ok = _wclosedir (dirp->wdirp);
dirp->wdirp = NULL;
/* Release multi-byte character version */
free (dirp);
} else {
/* Invalid directory stream */
dirent_set_errno (EBADF);
ok = /*failure*/-1;
}
return ok;
}
/*
* Rewind directory stream to beginning.
*/
static void
rewinddir(
DIR* dirp)
{
/* Rewind wide-character string directory stream */
_wrewinddir (dirp->wdirp);
}
/* Convert multi-byte string to wide character string */
static int
dirent_mbstowcs_s(
size_t *pReturnValue,
wchar_t *wcstr,
size_t sizeInWords,
const char *mbstr,
size_t count)
{
int error;
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Microsoft Visual Studio 2005 or later */
error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
#else
/* Older Visual Studio or non-Microsoft compiler */
size_t n;
/* Convert to wide-character string (or count characters) */
n = mbstowcs (wcstr, mbstr, sizeInWords);
if (!wcstr || n < count) {
/* Zero-terminate output buffer */
if (wcstr && sizeInWords) {
if (n >= sizeInWords) {
n = sizeInWords - 1;
}
wcstr[n] = 0;
}
/* Length of resuting multi-byte string WITH zero terminator */
if (pReturnValue) {
*pReturnValue = n + 1;
}
/* Success */
error = 0;
} else {
/* Could not convert string */
error = 1;
}
#endif
return error;
}
/* Convert wide-character string to multi-byte string */
static int
dirent_wcstombs_s(
size_t *pReturnValue,
char *mbstr,
size_t sizeInBytes, /* max size of mbstr */
const wchar_t *wcstr,
size_t count)
{
int error;
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Microsoft Visual Studio 2005 or later */
error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count);
#else
/* Older Visual Studio or non-Microsoft compiler */
size_t n;
/* Convert to multi-byte string (or count the number of bytes needed) */
n = wcstombs (mbstr, wcstr, sizeInBytes);
if (!mbstr || n < count) {
/* Zero-terminate output buffer */
if (mbstr && sizeInBytes) {
if (n >= sizeInBytes) {
n = sizeInBytes - 1;
}
mbstr[n] = '\0';
}
/* Length of resulting multi-bytes string WITH zero-terminator */
if (pReturnValue) {
*pReturnValue = n + 1;
}
/* Success */
error = 0;
} else {
/* Cannot convert string */
error = 1;
}
#endif
return error;
}
/* Set errno variable */
static void
dirent_set_errno(
int error)
{
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Microsoft Visual Studio 2005 and later */
_set_errno (error);
#else
/* Non-Microsoft compiler or older Microsoft compiler */
errno = error;
#endif
}
#ifdef __cplusplus
}
#endif
#endif /*DIRENT_H*/

329
MSVC/gen-build-config.bat Normal file
View File

@ -0,0 +1,329 @@
@ECHO OFF
SETLOCAL
GOTO START
:: Script for generating build_config.h and versioninfo.h
::
:: Copyright (C) 2016 Rogier <rogier777@gmail.com>
::
:: This program is free software; you can redistribute it and/or modify
:: it under the terms of the GNU Lesser General Public License as published by
:: the Free Software Foundation; either version 2.1 of the License, or
:: (at your option) any later version.
::
:: This program is distributed in the hope that it will be useful,
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
:: GNU Lesser General Public License for more details.
::
:: You should have received a copy of the GNU Lesser General Public License along
:: with this program; if not, write to the Free Software Foundation, Inc.,
:: 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
:USAGE
ECHO Usage^: %~nx0 [options] -p PROJECTDIR
ECHO.
ECHO Options^:
ECHO -h^|--help ^: Print this message
ECHO -v^|--verbose ^: Print minetestmapper version info
ECHO --test ^: Instead of creating the configuration files,
ECHO print their would-be contents to the console.
ECHO --use-sqlite3 ^: Make minetestmapper understand SQLite3
ECHO --use-postgresql ^: Make minetestmapper understand PostgreSQL
ECHO --use-leveldb ^: Make minetestmapper understand LevelDB
ECHO --use-redis ^: Make minetestmapper understand Redis
ECHO -p PROJECTDIR ^: Specify the base directory of the project
ECHO ^(this option is mandatory^)
ECHO.
ECHO NOTE^: At least one of the databases must be enabled.
EXIT /B 0
:START
SET $MYNAME=%~nx0
SET $MYPATH=%~p0
SET $BASE_VERSION_FILE=base-version
SET $BUILDCONFIG_TEMPLATE=build_config.h.in
SET $BUILDCONFIG_FILE=build_config.h
SET $VERSIONINFO_FILE=MSVC\versioninfo.h
SET $USE_SQLITE3=0
SET $USE_POSTGRESQL=0
SET $USE_LEVELDB=0
SET $USE_REDIS=0
SET $USE_ICONV=0
SET $PACKAGING_FLAT=1
SET $INSTALL_PREFIX=\\
SET $PROJECTDIR=""
SET $USE_ANY=0
SET $VERBOSE=0
SET $TEST=0
:: Command-line argument parsing
:PARSEARGS
SET $OPT=%~1
IF /I "%$OPT%"=="-h" (
CALL :USAGE
EXIT /B 0
) ELSE IF /I "%$OPT%"=="--help" (
CALL :USAGE
EXIT /B 0
) ELSE IF /I "%$OPT%"=="-v" (
SET $VERBOSE=1
) ELSE IF /I "%$OPT%"=="--verbose" (
SET $VERBOSE=1
) ELSE IF /I "%$OPT%"=="--test" (
SET $TEST=1
) ELSE IF /I "%$OPT%"=="--use-sqlite3" (
SET $USE_SQLITE3=1
SET $USE_ANY=1
) ELSE IF /I "%$OPT%"=="--use-postgresql" (
SET $USE_POSTGRESQL=1
SET $USE_ANY=1
) ELSE IF /I "%$OPT%"=="--use-leveldb" (
SET $USE_LEVELDB=1
SET $USE_ANY=1
) ELSE IF /I "%$OPT%"=="--use-redis" (
SET $USE_REDIS=1
SET $USE_ANY=1
) ELSE IF /I "%$OPT%"=="-p" (
SET $PROJECTDIR=%~f2
:: SHIFT because we took a second argument here.
SHIFT
) ELSE IF /I "%$OPT:~0,1%"=="-" (
ECHO %$MYNAME%^: Error^: unrecognised option^: %$OPT%
CALL :USAGE
EXIT /B 1
) ELSE (
GOTO GEN_CONFIG
)
SHIFT
GOTO PARSEARGS
:GEN_CONFIG
IF NOT "%1"=="" (
ECHO %$MYNAME%^: Error^: too many arguments ^(%*^)
CALL :USAGE
EXIT /B 1
)
IF NOT %$USE_ANY%==1 (
ECHO %$MYNAME%^: Error^: at least one --use-^<database^> option must be given
CALL :USAGE
EXIT /B 1
)
IF %$PROJECTDIR%=="" (
ECHO %$MYNAME%^: Error^: PROJECTDIR argument is required
CALL :USAGE
EXIT /B 1
)
CALL :CHECK_FOR_GIT
IF ERRORLEVEL 1 (
CALL :GET_NONGIT_VERSION
) ELSE (
CALL :GET_GIT_VERSION
)
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%
CALL :COMPUTE_BINARY_VERSION
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%
IF %$VERBOSE%==1 (
CALL :REPORT_VERSION
)
set $EXITVAL=0
CALL :WRITE_BUILDCONFIG
IF ERRORLEVEL 1 SET $EXITVAL=%ERRORLEVEL%
CALL :WRITE_VERSIONINFO
IF ERRORLEVEL 1 SET $EXITVAL=%ERRORLEVEL%
:: End of main script code.
:: Remaining code consists of functions only
EXIT /B %$EXITVAL%
:: Check for git. This does two things:
:: - verify that git is installed
:: - verify that we are in a git tree (instead of just an unpacked archive)
:CHECK_FOR_GIT
CALL git describe > NUL 2>&1
EXIT /B %ERRORLEVEL%
:: Obtain the git version information
:GET_GIT_VERSION
FOR /F "usebackq tokens=*" %%V IN (`git describe --long "--match=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" "--dirty=-WIP" "--abbrev=8"`) DO (
SET $VERSION_FULL=%%V
)
FOR /F "tokens=1 delims=-" %%M in ("%$VERSION_FULL%") DO (
SET $VERSION_MAJOR=%%M
)
FOR /F "tokens=2 delims=-" %%M in ("%$VERSION_FULL%") DO (
SET $VERSION_MINOR_COMMITS=%%M
)
FOR /F "tokens=3 delims=-" %%M in ("%$VERSION_FULL%") DO (
SET $VERSION_MINOR_SHA1=%%M
)
FOR /F "tokens=4 delims=-" %%M in ("%$VERSION_FULL%") DO (
SET $VERSION_MINOR_WIP=%%M
)
IF DEFINED $VERSION_MINOR_WIP (
SET $VERSION_MINOR=%$VERSION_MINOR_COMMITS%-%$VERSION_MINOR_SHA1%-%$VERSION_MINOR_WIP%
) ELSE (
SET $VERSION_MINOR=%$VERSION_MINOR_COMMITS%-%$VERSION_MINOR_SHA1%
)
EXIT /B 0
:: Obtain version information when git cannot be used
:GET_NONGIT_VERSION
IF NOT EXIST %$PROJECTDIR%\%$BASE_VERSION_FILE% (
ECHO %$MYNAME%^: Error^: base version file ^(%$PROJECTDIR%\%$BASE_VERSION_FILE%^) not found.
EXIT /B 2
)
FOR /F "tokens=*" %%V IN (%$PROJECTDIR%\%$BASE_VERSION_FILE%) DO (
SET $VERSION_MAJOR=%%V
)
SET $VERSION_MINOR=-X
EXIT /B 0
:: Compute binary version for MSVC
:COMPUTE_BINARY_VERSION
:: This assumes the version is of the form:
:: YYYYMMDD-nn-cccccccc[-WIP]
:: or:
:: YYYYMMDD-X
:: Binary version consists of 4 16-bit numbers.
:: Conversion:
:: - 1st 16-bit number: 0
:: - 2st 16-bit number: 1024*YY+32*MM+DD (usable until 2064)
:: - 3nd 16-bit number: 2 * nn (# commits since major version)
:: 2 * nn + 1 if the working tree was dirty ('-WIP')
:: 65535 if unknown ('X')
:: - 4rd 16-bit number: 1st 4 hex digits of cccccccc (commit SHA1)
SET /A $BV2=1024*%$VERSION_MAJOR:~2,2%+32*%$VERSION_MAJOR:~4,2%+%$VERSION_MAJOR:~6,2%
IF /I "%$VERSION_MINOR_COMMITS%"=="X" (
SET /A $BV3=65535
) ELSE IF DEFINED $VERSION_MINOR_WIP (
SET /A $BV3=2*%$VERSION_MINOR_COMMITS%+1
) ELSE (
SET /A $BV3=2*%$VERSION_MINOR_COMMITS%
)
IF /I "%$VERSION_MINOR_COMMITS%"=="X" (
SET /A $BV4=0
) ELSE (
SET /A $BV4=0x%$VERSION_MINOR_SHA1:~1,4%
)
SET $VERSION_BINARY=0,%$BV2%,%$BV3%,%$BV4%
EXIT /B 0
:: Report version info to the console
:REPORT_VERSION
ECHO Minetestmapper version information^:
ECHO.
IF /I "%$VERSION_MINOR_COMMITS%"=="X" (
ECHO WARNING^: git executable not found, or no git tree found.
ECHO No exact version information could be obtained.
ECHO.
)
ECHO Full version^: %$VERSION_FULL%
ECHO Major version^: %$VERSION_MAJOR%
ECHO Minor version^: %$VERSION_MINOR%
IF /I NOT "%$VERSION_MINOR_COMMITS%"=="X" (
ECHO Commits since full version^: %$VERSION_MINOR_COMMITS%
ECHO Latest commit SHA1 id ^(short^)^: %$VERSION_MINOR_SHA1%
IF DEFINED $VERSION_MINOR_WIP (
ECHO Working tree is clean^: NO
) ELSE (
ECHO Working tree is clean^: YES
)
)
ECHO Binary version^: %$VERSION_BINARY%
EXIT /B 0
:: Create the build file
:WRITE_BUILDCONFIG
SET "$INDENT="
IF NOT EXIST %$PROJECTDIR%\%$BUILDCONFIG_TEMPLATE% (
ECHO %$MYNAME%^: Error^: template file ^(%$PROJECTDIR%\%$BUILDCONFIG_TEMPLATE%^) not found.
EXIT /B 2
)
IF %$VERBOSE%==1 (
ECHO ---- Generating %$PROJECTDIR%\%$BUILDCONFIG_FILE%
)
SET $OUTPUT=%$PROJECTDIR%\%$BUILDCONFIG_FILE%
IF %$TEST%==1 (
ECHO The build config file ^(%$BUILDCONFIG_FILE%^) contents would be^:
SET "$INDENT= "
SET $OUTPUT=CON
) ELSE (
:: If not in testmode, delete the file, because its regenerated
COPY NUL "%$OUTPUT%" >NUL
)
FOR /F "tokens=*" %%L in (%$PROJECTDIR%\%$BUILDCONFIG_TEMPLATE%) DO CALL :WRITE_LINE %%L
EXIT /B 0
:: This funktion writes 1 line with the correct build parameter into the build_config.h file.
:: Usage: CALL :WRITE_LINE <string>
:WRITE_LINE
SETLOCAL ENABLEDELAYEDEXPANSION
SET $LINE=%*
SET $LINE=!$LINE:@BUILD_CONFIG_GENDATE@=%DATE% %TIME%!
SET $LINE=!$LINE:@BUILD_CONFIG_GENTOOL@=%$MYNAME%!
SET $LINE=!$LINE:@USE_SQLITE3@=%$USE_SQLITE3%!
SET $LINE=!$LINE:@USE_POSTGRESQL@=%$USE_POSTGRESQL%!
SET $LINE=!$LINE:@USE_LEVELDB@=%$USE_LEVELDB%!
SET $LINE=!$LINE:@USE_REDIS@=%$USE_REDIS%!
SET $LINE=!$LINE:@USE_ICONV@=%$USE_ICONV%!
SET $LINE=!$LINE:@VERSION_MAJOR@=%$VERSION_MAJOR%!
SET $LINE=!$LINE:@VERSION_MINOR@=%$VERSION_MINOR%!
SET $LINE=!$LINE:@PACKAGING_FLAT@=%$PACKAGING_FLAT%!
SET $LINE=!$LINE:@INSTALL_PREFIX@=%$INSTALL_PREFIX%!
ECHO %$INDENT%%$LINE% >> %$OUTPUT%
ENDLOCAL
EXIT /B 0
:: Create the versioninfo file
:WRITE_VERSIONINFO
SETLOCAL
SET "$INDENT="
IF %$VERBOSE%==1 (
ECHO ---- Generating %$PROJECTDIR%\%$VERSIONINFO_FILE%%
)
SET $OUTPUT=%$PROJECTDIR%\%$VERSIONINFO_FILE%
IF %$TEST%==1 (
ECHO The versioninfo file ^(%$VERSIONINFO_FILE%^) contents would be^:
SET "$INDENT= "
SET $OUTPUT=CON
)
> %$OUTPUT% (
ECHO %$INDENT%// This file is auto-generated. Any changes to it will be overwritten.
ECHO %$INDENT%// Modify the following build-system specific script instead^:
ECHO %$INDENT%// MSVC/generate_build_config.bat
ECHO.
ECHO %$INDENT%#define MINETESTMAPPER_VERSION_FULL "%$VERSION_FULL%"
ECHO %$INDENT%#define MINETESTMAPPER_VERSION_MAJOR "%$VERSION_MAJOR%"
ECHO %$INDENT%#define MINETESTMAPPER_VERSION_MINOR "%$VERSION_MINOR%"
ECHO %$INDENT%#define MINETESTMAPPER_VERSION_BINARY %$VERSION_BINARY%
IF DEFINED $VERSION_MINOR_WIP (
ECHO %$INDENT%#define MINETESTMAPPER_WIP_FLAG ^| VS_FF_PATCHED
) ELSE (
:: Clear 'VS_FF_PATCHED' only if the WIP part is empty
ECHO %$INDENT%#define MINETESTMAPPER_WIP_FLAG
)
ECHO.
ECHO %$INDENT%#ifdef _DEBUG
ECHO %$INDENT%#define MINETESTMAPPER_DEBUG_FLAG ^| VS_FF_DEBUG
ECHO %$INDENT%#else
ECHO %$INDENT%#define MINETESTMAPPER_DEBUG_FLAG
ECHO %$INDENT%#endif
)
ENDLOCAL
EXIT /B 0

85
MSVC/minetestmapper.rc Normal file
View File

@ -0,0 +1,85 @@
// Microsoft Visual C++ generated resource script.
//
#include "versioninfo.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"versioninfo.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION MINETESTMAPPER_VERSION_BINARY
PRODUCTVERSION MINETESTMAPPER_VERSION_BINARY
FILEFLAGSMASK 0x3fL
FILEFLAGS (0 MINETESTMAPPER_DEBUG_FLAG MINETESTMAPPER_WIP_FLAG)
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "Generates maps of minetest and freeminer worlds "
VALUE "FileVersion", MINETESTMAPPER_VERSION_BINARY
VALUE "InternalName", "minetestmapper.exe"
VALUE "LegalCopyright", "LGPLv2.1+/ BSD 2-clause license"
VALUE "OriginalFilename", "minetestmapper.exe"
VALUE "ProductName", "Minetestmapper"
VALUE "ProductVersion", MINETESTMAPPER_VERSION_FULL
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

228
MSVC/minetestmapper.vcxproj Normal file
View File

@ -0,0 +1,228 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LevelDB.1.16.0.5\build\native\LevelDB.props" Condition="Exists('..\packages\LevelDB.1.16.0.5\build\native\LevelDB.props')" />
<Import Project="..\packages\Snappy.1.1.1.7\build\native\Snappy.props" Condition="Exists('..\packages\Snappy.1.1.1.7\build\native\Snappy.props')" />
<Import Project="..\packages\Crc32C.1.0.4\build\native\Crc32C.props" Condition="Exists('..\packages\Crc32C.1.0.4\build\native\Crc32C.props')" />
<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>{3F30298F-2395-4811-A79E-EBB603F42948}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>minetestmapper</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</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>
<LibraryPath>D:\libs\gd\Win32\RelWithDebInfo;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<LibraryPath>D:\libs\gd\Win32\RelWithDebInfo;$(LibraryPath)</LibraryPath>
</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;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>D:\libs\gd\include;$(ProjectDir)dirent\include;$(ProjectDir)wingetopt\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libgd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>CALL $(SolutionDir)MSVC\gen-build-config.bat --use-sqlite3 --use-leveldb -p "$(SolutionDir)"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>D:\libs\gd\include;$(ProjectDir)dirent\include;$(ProjectDir)wingetopt\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libgd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>CALL $(SolutionDir)MSVC\gen-build-config.bat --use-sqlite3 --use-leveldb -p "$(SolutionDir)"</Command>
</PreBuildEvent>
</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;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>D:\libs\gd\include;$(ProjectDir)dirent\include;$(ProjectDir)wingetopt\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libgd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>CALL $(SolutionDir)MSVC\gen-build-config.bat --use-sqlite3 --use-leveldb -p "$(SolutionDir)"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>D:\libs\gd\include;$(ProjectDir)dirent\include;$(ProjectDir)wingetopt\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libgd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>CALL $(SolutionDir)MSVC\gen-build-config.bat --use-sqlite3 --use-leveldb -p "$(SolutionDir)"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\BlockPos.h" />
<ClInclude Include="..\CharEncodingConverter.h" />
<ClInclude Include="..\Color.h" />
<ClInclude Include="..\config.h" />
<ClInclude Include="..\db-leveldb.h" />
<ClInclude Include="..\db-sqlite3.h" />
<ClInclude Include="..\db.h" />
<ClInclude Include="..\minetest-database.h" />
<ClInclude Include="..\PixelAttributes.h" />
<ClInclude Include="..\PlayerAttributes.h" />
<ClInclude Include="..\porting.h" />
<ClInclude Include="..\Settings.h" />
<ClInclude Include="..\TileGenerator.h" />
<ClInclude Include="..\types.h" />
<ClInclude Include="..\ZlibDecompressor.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="minetestmapper.rc" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\BlockPos.cpp" />
<ClCompile Include="..\CharEncodingConverter.cpp" />
<ClCompile Include="..\Color.cpp" />
<ClCompile Include="..\db-leveldb.cpp" />
<ClCompile Include="..\db-sqlite3.cpp" />
<ClCompile Include="..\mapper.cpp" />
<ClCompile Include="..\PixelAttributes.cpp" />
<ClCompile Include="..\PlayerAttributes.cpp" />
<ClCompile Include="..\Settings.cpp" />
<ClCompile Include="..\TileGenerator.cpp" />
<ClCompile Include="..\ZlibDecompressor.cpp" />
<ClCompile Include="wingetopt\src\getopt.c" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" />
<Import Project="..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets')" />
<Import Project="..\packages\sqlite.redist.3.8.4.2\build\native\sqlite.redist.targets" Condition="Exists('..\packages\sqlite.redist.3.8.4.2\build\native\sqlite.redist.targets')" />
<Import Project="..\packages\sqlite.3.8.4.2\build\native\sqlite.targets" Condition="Exists('..\packages\sqlite.3.8.4.2\build\native\sqlite.targets')" />
<Import Project="..\packages\libpng.redist.1.6.20.1\build\native\libpng.redist.targets" Condition="Exists('..\packages\libpng.redist.1.6.20.1\build\native\libpng.redist.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This projekt requires at least one NuGet-Package which is missing on this Computer. Use Restore NuGet Packages to download the missing files. More informations are aviable under "http://go.microsoft.com/fwlink/?LinkID=322105". The missing file is "{0}".</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets'))" />
<Error Condition="!Exists('..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets'))" />
<Error Condition="!Exists('..\packages\sqlite.redist.3.8.4.2\build\native\sqlite.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\sqlite.redist.3.8.4.2\build\native\sqlite.redist.targets'))" />
<Error Condition="!Exists('..\packages\sqlite.3.8.4.2\build\native\sqlite.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\sqlite.3.8.4.2\build\native\sqlite.targets'))" />
<Error Condition="!Exists('..\packages\Crc32C.1.0.4\build\native\Crc32C.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Crc32C.1.0.4\build\native\Crc32C.props'))" />
<Error Condition="!Exists('..\packages\Snappy.1.1.1.7\build\native\Snappy.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Snappy.1.1.1.7\build\native\Snappy.props'))" />
<Error Condition="!Exists('..\packages\LevelDB.1.16.0.5\build\native\LevelDB.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LevelDB.1.16.0.5\build\native\LevelDB.props'))" />
<Error Condition="!Exists('..\packages\libpng.redist.1.6.20.1\build\native\libpng.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\libpng.redist.1.6.20.1\build\native\libpng.redist.targets'))" />
</Target>
</Project>

View File

@ -0,0 +1,122 @@
<?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="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>
<Filter Include="Header files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\BlockPos.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\Color.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\config.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\db.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\db-leveldb.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\db-sqlite3.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\minetest-database.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\PixelAttributes.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\PlayerAttributes.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\TileGenerator.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\types.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\ZlibDecompressor.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\porting.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\Settings.h">
<Filter>Header files</Filter>
</ClInclude>
<ClInclude Include="..\CharEncodingConverter.h">
<Filter>Header files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="minetestmapper.rc">
<Filter>Resource files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\BlockPos.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\Color.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\db-leveldb.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\db-sqlite3.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\mapper.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\PixelAttributes.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\PlayerAttributes.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\TileGenerator.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\ZlibDecompressor.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\leveldb-single-file.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\snappy-single-file.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\crc32c.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="wingetopt\src\getopt.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\Settings.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\CharEncodingConverter.cpp">
<Filter>Source files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

12
MSVC/packages.config Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Crc32C" version="1.0.4" targetFramework="native" />
<package id="LevelDB" version="1.16.0.5" targetFramework="native" />
<package id="libpng.redist" version="1.6.20.1" targetFramework="native" />
<package id="Snappy" version="1.1.1.7" targetFramework="native" />
<package id="sqlite" version="3.8.4.2" targetFramework="native" />
<package id="sqlite.redist" version="3.8.4.2" targetFramework="native" />
<package id="zlib" version="1.2.8.8" targetFramework="native" />
<package id="zlib.v120.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" targetFramework="native" />
<package id="zlib.v140.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" targetFramework="native" />
</packages>

View File

@ -0,0 +1,47 @@
Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Sponsored in part by the Defense Advanced Research Projects
Agency (DARPA) and Air Force Research Laboratory, Air Force
Materiel Command, USAF, under agreement number F39502-99-1-0512.
***
Copyright (c) 2000 The NetBSD Foundation, Inc.
All rights reserved.
This code is derived from software contributed to The NetBSD Foundation
by Dieter Baron and Thomas Klausner.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,2 @@
The files src/getopt.h and src/getopt.c were taken at 29.12.2015 from https://github.com/alex85k/wingetopt
For license information please look into LICENSE.txt

562
MSVC/wingetopt/src/getopt.c Normal file
View File

@ -0,0 +1,562 @@
/* $OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $ */
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
/*
* Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Dieter Baron and Thomas Klausner.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */
#ifdef REPLACE_GETOPT
int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */
int optopt = '?'; /* character checked for validity */
#undef optreset /* see getopt.h */
#define optreset __mingw_optreset
int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#endif
#define PRINT_ERROR ((opterr) && (*options != ':'))
#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
/* return values */
#define BADCH (int)'?'
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
#ifndef __CYGWIN__
#define __progname __argv[0]
#else
extern char __declspec(dllimport) *__progname;
#endif
#ifdef __CYGWIN__
static char EMSG[] = "";
#else
#define EMSG ""
#endif
static int getopt_internal(int, char * const *, const char *,
const struct option *, int *, int);
static int parse_long_options(char * const *, const char *,
const struct option *, int *, int);
static int gcd(int, int);
static void permute_args(int, int, int, char * const *);
static char *place = EMSG; /* option letter processing */
/* XXX: set optreset to 1 rather than these two */
static int nonopt_start = -1; /* first non option argument (for permute) */
static int nonopt_end = -1; /* first option after non options (for permute) */
/* Error messages */
static const char recargchar[] = "option requires an argument -- %c";
static const char recargstring[] = "option requires an argument -- %s";
static const char ambig[] = "ambiguous option -- %.*s";
static const char noarg[] = "option doesn't take an argument -- %.*s";
static const char illoptchar[] = "unknown option -- %c";
static const char illoptstring[] = "unknown option -- %s";
static void
_vwarnx(const char *fmt,va_list ap)
{
(void)fprintf(stderr,"%s: ",__progname);
if (fmt != NULL)
(void)vfprintf(stderr,fmt,ap);
(void)fprintf(stderr,"\n");
}
static void
warnx(const char *fmt,...)
{
va_list ap;
va_start(ap,fmt);
_vwarnx(fmt,ap);
va_end(ap);
}
/*
* Compute the greatest common divisor of a and b.
*/
static int
gcd(int a, int b)
{
int c;
c = a % b;
while (c != 0) {
a = b;
b = c;
c = a % b;
}
return (b);
}
/*
* Exchange the block from nonopt_start to nonopt_end with the block
* from nonopt_end to opt_end (keeping the same order of arguments
* in each block).
*/
static void
permute_args(int panonopt_start, int panonopt_end, int opt_end,
char * const *nargv)
{
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
char *swap;
/*
* compute lengths of blocks and number and size of cycles
*/
nnonopts = panonopt_end - panonopt_start;
nopts = opt_end - panonopt_end;
ncycle = gcd(nnonopts, nopts);
cyclelen = (opt_end - panonopt_start) / ncycle;
for (i = 0; i < ncycle; i++) {
cstart = panonopt_end+i;
pos = cstart;
for (j = 0; j < cyclelen; j++) {
if (pos >= panonopt_end)
pos -= nnonopts;
else
pos += nopts;
swap = nargv[pos];
/* LINTED const cast */
((char **) nargv)[pos] = nargv[cstart];
/* LINTED const cast */
((char **)nargv)[cstart] = swap;
}
}
}
/*
* parse_long_options --
* Parse long options in argc/argv argument vector.
* Returns -1 if short_too is set and the option does not match long_options.
*/
static int
parse_long_options(char * const *nargv, const char *options,
const struct option *long_options, int *idx, int short_too)
{
char *current_argv, *has_equal;
size_t current_argv_len;
int i, ambiguous, match;
#define IDENTICAL_INTERPRETATION(_x, _y) \
(long_options[(_x)].has_arg == long_options[(_y)].has_arg && \
long_options[(_x)].flag == long_options[(_y)].flag && \
long_options[(_x)].val == long_options[(_y)].val)
current_argv = place;
match = -1;
ambiguous = 0;
optind++;
if ((has_equal = strchr(current_argv, '=')) != NULL) {
/* argument found (--option=arg) */
current_argv_len = has_equal - current_argv;
has_equal++;
} else
current_argv_len = strlen(current_argv);
for (i = 0; long_options[i].name; i++) {
/* find matching long option */
if (strncmp(current_argv, long_options[i].name,
current_argv_len))
continue;
if (strlen(long_options[i].name) == current_argv_len) {
/* exact match */
match = i;
ambiguous = 0;
break;
}
/*
* If this is a known short option, don't allow
* a partial match of a single character.
*/
if (short_too && current_argv_len == 1)
continue;
if (match == -1) /* partial match */
match = i;
else if (!IDENTICAL_INTERPRETATION(i, match))
ambiguous = 1;
}
if (ambiguous) {
/* ambiguous abbreviation */
if (PRINT_ERROR)
warnx(ambig, (int)current_argv_len,
current_argv);
optopt = 0;
return (BADCH);
}
if (match != -1) { /* option found */
if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
warnx(noarg, (int)current_argv_len,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
return (BADARG);
}
if (long_options[match].has_arg == required_argument ||
long_options[match].has_arg == optional_argument) {
if (has_equal)
optarg = has_equal;
else if (long_options[match].has_arg ==
required_argument) {
/*
* optional argument doesn't use next nargv
*/
optarg = nargv[optind++];
}
}
if ((long_options[match].has_arg == required_argument)
&& (optarg == NULL)) {
/*
* Missing argument; leading ':' indicates no error
* should be generated.
*/
if (PRINT_ERROR)
warnx(recargstring,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
--optind;
return (BADARG);
}
} else { /* unknown option */
if (short_too) {
--optind;
return (-1);
}
if (PRINT_ERROR)
warnx(illoptstring, current_argv);
optopt = 0;
return (BADCH);
}
if (idx)
*idx = match;
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
return (0);
} else
return (long_options[match].val);
#undef IDENTICAL_INTERPRETATION
}
/*
* getopt_internal --
* Parse argc/argv argument vector. Called by user level routines.
*/
static int
getopt_internal(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx, int flags)
{
char *oli; /* option letter list index */
int optchar, short_too;
static int posixly_correct = -1;
if (options == NULL)
return (-1);
/*
* XXX Some GNU programs (like cvs) set optind to 0 instead of
* XXX using optreset. Work around this braindamage.
*/
if (optind == 0)
optind = optreset = 1;
/*
* Disable GNU extensions if POSIXLY_CORRECT is set or options
* string begins with a '+'.
*
* CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or
* optreset != 0 for GNU compatibility.
*/
if (posixly_correct == -1 || optreset != 0)
posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
if (*options == '-')
flags |= FLAG_ALLARGS;
else if (posixly_correct || *options == '+')
flags &= ~FLAG_PERMUTE;
if (*options == '+' || *options == '-')
options++;
optarg = NULL;
if (optreset)
nonopt_start = nonopt_end = -1;
start:
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc) { /* end of argument vector */
place = EMSG;
if (nonopt_end != -1) {
/* do permutation, if we have to */
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
else if (nonopt_start != -1) {
/*
* If we skipped non-options, set optind
* to the first of them.
*/
optind = nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
if (*(place = nargv[optind]) != '-' ||
(place[1] == '\0' && strchr(options, '-') == NULL)) {
place = EMSG; /* found non-option */
if (flags & FLAG_ALLARGS) {
/*
* GNU extension:
* return non-option as argument to option 1
*/
optarg = nargv[optind++];
return (INORDER);
}
if (!(flags & FLAG_PERMUTE)) {
/*
* If no permutation wanted, stop parsing
* at first non-option.
*/
return (-1);
}
/* do permutation */
if (nonopt_start == -1)
nonopt_start = optind;
else if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
nonopt_start = optind -
(nonopt_end - nonopt_start);
nonopt_end = -1;
}
optind++;
/* process next argument */
goto start;
}
if (nonopt_start != -1 && nonopt_end == -1)
nonopt_end = optind;
/*
* If we have "-" do nothing, if "--" we are done.
*/
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
optind++;
place = EMSG;
/*
* We found an option (--), so if we skipped
* non-options, we have to permute.
*/
if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
}
/*
* Check long options if:
* 1) we were passed some
* 2) the arg is not just "-"
* 3) either the arg starts with -- we are getopt_long_only()
*/
if (long_options != NULL && place != nargv[optind] &&
(*place == '-' || (flags & FLAG_LONGONLY))) {
short_too = 0;
if (*place == '-')
place++; /* --foo long option */
else if (*place != ':' && strchr(options, *place) != NULL)
short_too = 1; /* could be short option too */
optchar = parse_long_options(nargv, options, long_options,
idx, short_too);
if (optchar != -1) {
place = EMSG;
return (optchar);
}
}
if ((optchar = (int)*place++) == (int)':' ||
(optchar == (int)'-' && *place != '\0') ||
(oli = strchr(options, optchar)) == NULL) {
/*
* If the user specified "-" and '-' isn't listed in
* options, return -1 (non-option) as per POSIX.
* Otherwise, it is an unknown option character (or ':').
*/
if (optchar == (int)'-' && *place == '\0')
return (-1);
if (!*place)
++optind;
if (PRINT_ERROR)
warnx(illoptchar, optchar);
optopt = optchar;
return (BADCH);
}
if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
/* -W long-option */
if (*place) /* no space */
/* NOTHING */;
else if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else /* white space */
place = nargv[optind];
optchar = parse_long_options(nargv, options, long_options,
idx, 0);
place = EMSG;
return (optchar);
}
if (*++oli != ':') { /* doesn't take argument */
if (!*place)
++optind;
} else { /* takes (optional) argument */
optarg = NULL;
if (*place) /* no white space */
optarg = place;
else if (oli[1] != ':') { /* arg not optional */
if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else
optarg = nargv[optind];
}
place = EMSG;
++optind;
}
/* dump back option letter */
return (optchar);
}
#ifdef REPLACE_GETOPT
/*
* getopt --
* Parse argc/argv argument vector.
*
* [eventually this will replace the BSD getopt]
*/
int
getopt(int nargc, char * const *nargv, const char *options)
{
/*
* We don't pass FLAG_PERMUTE to getopt_internal() since
* the BSD getopt(3) (unlike GNU) has never done this.
*
* Furthermore, since many privileged programs call getopt()
* before dropping privileges it makes sense to keep things
* as simple (and bug-free) as possible.
*/
return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
}
#endif /* REPLACE_GETOPT */
/*
* getopt_long --
* Parse argc/argv argument vector.
*/
int
getopt_long(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE));
}
/*
* getopt_long_only --
* Parse argc/argv argument vector.
*/
int
getopt_long_only(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE|FLAG_LONGONLY));
}

View File

@ -0,0 +1,95 @@
#ifndef __GETOPT_H__
/**
* DISCLAIMER
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the w64 mingw-runtime package.
*
* The w64 mingw-runtime package and its code is distributed in the hope that it
* will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
* IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
* warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#define __GETOPT_H__
/* All the headers include this file. */
#include <crtdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int optind; /* index of first non-option in argv */
extern int optopt; /* single option character, as parsed */
extern int opterr; /* flag to enable built-in diagnostics... */
/* (user may set to zero, to suppress) */
extern char *optarg; /* pointer to argument of current option */
extern int getopt(int nargc, char * const *nargv, const char *options);
#ifdef _BSD_SOURCE
/*
* BSD adds the non-standard `optreset' feature, for reinitialisation
* of `getopt' parsing. We support this feature, for applications which
* proclaim their BSD heritage, before including this header; however,
* to maintain portability, developers are advised to avoid it.
*/
# define optreset __mingw_optreset
extern int optreset;
#endif
#ifdef __cplusplus
}
#endif
/*
* POSIX requires the `getopt' API to be specified in `unistd.h';
* thus, `unistd.h' includes this header. However, we do not want
* to expose the `getopt_long' or `getopt_long_only' APIs, when
* included in this manner. Thus, close the standard __GETOPT_H__
* declarations block, and open an additional __GETOPT_LONG_H__
* specific block, only when *not* __UNISTD_H_SOURCED__, in which
* to declare the extended API.
*/
#endif /* !defined(__GETOPT_H__) */
#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
#define __GETOPT_LONG_H__
#ifdef __cplusplus
extern "C" {
#endif
struct option /* specification for a long form option... */
{
const char *name; /* option name, without leading hyphens */
int has_arg; /* does it take an argument? */
int *flag; /* where to save its status, or NULL */
int val; /* its associated status value */
};
enum /* permitted values for its `has_arg' field... */
{
no_argument = 0, /* option never takes an argument */
required_argument, /* option always requires an argument */
optional_argument /* option may take an argument */
};
extern int getopt_long(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx);
extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx);
/*
* Previous MinGW implementation had...
*/
#ifndef HAVE_DECL_GETOPT
/*
* ...for the long form API only; keep this for compatibility.
*/
# define HAVE_DECL_GETOPT 1
#endif
#ifdef __cplusplus
}
#endif
#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */

View File

@ -39,6 +39,10 @@ Map Generation Features
Build Features Build Features
-------------- --------------
* Supports both the gcc and clang compiler suites * Supports both the gcc and clang compiler suites
* Supports MSVC building on Windows (with SQLite3 and LevelDB)
* With automatic downloading of all but one of the required libraries.
* Build rpm, deb and/or tar.gz installation * Build rpm, deb and/or tar.gz installation
packages. Or simply type 'make install'. packages. Or simply type 'make install'.
@ -51,6 +55,9 @@ Windows
Check the download page to obtain a compiled version: Check the download page to obtain a compiled version:
`<https://github.com/Rogier-5/minetest-mapper-cpp/wiki/Downloads>`_ `<https://github.com/Rogier-5/minetest-mapper-cpp/wiki/Downloads>`_
Or check the building instructions for compiling using MSVC:
`<doc/build-instructions.rst>`_.
Install Dependencies Install Dependencies
-------------------- --------------------

25
build_config.h.in Normal file
View File

@ -0,0 +1,25 @@
// The file 'build_config.h' is auto-generated. Any changes to it
// will be overwritten.
//
// Modify the file build_config.h.in instead.
//
// This file was generated on @BUILD_CONFIG_GENDATE@ by @BUILD_CONFIG_GENTOOL@
#ifndef BUILD_CONFIG_H
#define BUILD_CONFIG_H
#define USE_SQLITE3 @USE_SQLITE3@
#define USE_POSTGRESQL @USE_POSTGRESQL@
#define USE_LEVELDB @USE_LEVELDB@
#define USE_REDIS @USE_REDIS@
#define USE_ICONV @USE_ICONV@
#define VERSION_MAJOR "@VERSION_MAJOR@"
#define VERSION_MINOR "@VERSION_MINOR@"
#define PACKAGING_FLAT @PACKAGING_FLAT@
#define INSTALL_PREFIX "@INSTALL_PREFIX@"
#endif

View File

@ -1,20 +0,0 @@
// Filled in by the build system
#ifndef CMAKE_CONFIG_H
#define CMAKE_CONFIG_H
#define USE_SQLITE3 @USE_SQLITE3@
#define USE_POSTGRESQL @USE_POSTGRESQL@
#define USE_LEVELDB @USE_LEVELDB@
#define USE_REDIS @USE_REDIS@
#define USE_ICONV @USE_ICONV@
#define VERSION_MAJOR "@VERSION_MAJOR@"
#define VERSION_MINOR "@VERSION_MINOR@"
#define PACKAGING_FLAT @PACKAGING_FLAT@
#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#endif

View File

@ -7,6 +7,8 @@
* ===================================================================== * =====================================================================
*/ */
#include "build_config.h"
#if MSDOS || __OS2__ || __NT__ || _WIN32 #if MSDOS || __OS2__ || __NT__ || _WIN32
#define PATH_SEPARATOR '\\' #define PATH_SEPARATOR '\\'
#else #else
@ -21,14 +23,6 @@
// Max number of node name -> color mappings stored in a mapblock // Max number of node name -> color mappings stored in a mapblock
#define MAPBLOCK_MAXCOLORS 65536 #define MAPBLOCK_MAXCOLORS 65536
#ifdef USE_CMAKE_CONFIG_H
#include "cmake_config.h"
#else
#define USE_SQLITE3 1
#define USE_LEVELDB 0
#define USE_REDIS 0
#endif
// List of possible database names (for usage message) // List of possible database names (for usage message)
#if USE_SQLITE3 #if USE_SQLITE3
#define USAGE_NAME_SQLITE "/sqlite3" #define USAGE_NAME_SQLITE "/sqlite3"

View File

@ -1,6 +1,6 @@
#include "db-sqlite3.h" #include "db-sqlite3.h"
#include <stdexcept> #include <stdexcept>
#include <unistd.h> // for usleep #include "porting.h"
#include "types.h" #include "types.h"
#define BLOCKPOSLIST_STATEMENT "SELECT pos, rowid FROM blocks" #define BLOCKPOSLIST_STATEMENT "SELECT pos, rowid FROM blocks"
@ -58,7 +58,7 @@ const DB::BlockPosList &DBSQLite3::getBlockPosList() {
sqlite3_int64 rowid = sqlite3_column_int64(m_blockPosListStatement, 1); sqlite3_int64 rowid = sqlite3_column_int64(m_blockPosListStatement, 1);
m_BlockPosList.push_back(BlockPos(blocknum, rowid)); m_BlockPosList.push_back(BlockPos(blocknum, rowid));
} else if (result == SQLITE_BUSY) // Wait some time and try again } else if (result == SQLITE_BUSY) // Wait some time and try again
usleep(10000); sleepMs(10);
else else
break; break;
} }
@ -96,7 +96,7 @@ DB::Block DBSQLite3::getBlockOnPos(const BlockPos &pos)
m_blocksReadCount++; m_blocksReadCount++;
break; break;
} else if (result == SQLITE_BUSY) { // Wait some time and try again } else if (result == SQLITE_BUSY) { // Wait some time and try again
usleep(10000); sleepMs(10);
} else { } else {
break; break;
} }

View File

@ -8,9 +8,9 @@ Not all platforms receive the same amount of testing:
* Gcc and clang builds on Linux are frequently tested. * Gcc and clang builds on Linux are frequently tested.
* The BSD family should also give little trouble. It is not tested that I know of. * The BSD family should also give little trouble. It is not tested that I know of.
* Windows building using MinGW is also regularly tested and should work. * MSVC on Windows is tested.
* MSVC on Windows has not been tested recently. * Windows building using MinGW is tested intermittently and should work.
* Building on OSX has not been tested recently. * Building on OSX has not been tested recently and may not work.
Please let me know how you fared on your platform (when you encounter problems, Please let me know how you fared on your platform (when you encounter problems,
but also when you're successful - so I can update this text with the latest but also when you're successful - so I can update this text with the latest
@ -34,12 +34,18 @@ Libraries
At least one of ``sqlite3``, ``postgresql``, ``leveldb`` and ``hiredis`` is required. At least one of ``sqlite3``, ``postgresql``, ``leveldb`` and ``hiredis`` is required.
Check the minetest worlds that will be mapped to know which ones should be included. Check the minetest worlds that will be mapped to know which ones should be included.
Not all database backend libraries may be obtainable for all platforms (in particular
for Windows).
The current build scripts for MSVC on windows support the SQLite3 and LevelDB backends out
of the box. Compiling with Redis or PostgreSQL support will require some extra work.
Build Environment Build Environment
----------------- -----------------
* C++ compiler suite (clang or gcc (including mingw); msvc has not recently been tested) * C++ compiler suite (clang or gcc (including mingw); msvc on Windows)
* cmake * cmake (not for msvc)
* make * make (not for msvc)
Documentation Documentation
------------- -------------
@ -135,13 +141,33 @@ Linux Mint
---------- ----------
See `Debian and Derivatives`_ See `Debian and Derivatives`_
Windows Windows (MinGW)
------- ---------------
You're probably in for a lot of work, downloading software, and You're probably in for a lot of work, downloading software, and
probably compiling at least some of the direct and indirect dependencies. probably compiling at least some of the direct and indirect dependencies.
At the moment, regrettably, detailed instructions are not available. At the moment, regrettably, detailed instructions are not available.
Windows (MSVC)
--------------
The following must be installed to successfully compile minetestmapper using MSVC:
* Visual Studio 2015 or 2013 (lower may not work). VS Community can be obtained here:
https://www.visualstudio.com/
* A precompiled version of the gd library. A suitable version can be downloaded from
https://github.com/Rogier-5/minetest-mapper-cpp/wiki/Downloads#the-gd-library-for-compiling-minetestmapper-with-msvc
Alternatively, the gd sources can be downloaded from https://github.com/libgd/libgd.
They must be compiled using the same version of zlib that will be used when compiling
minetestmapper.
Version 2.2.1 of gd is verified to work, but any version 2.2.x should also work.
And presumably any version 2.x later than 2.2 should work as well.
All other required dependencies will be downloaded automatically by MSVC.
Other Other
----- -----
@ -177,10 +203,49 @@ Create native installation package(s):
See `CMake Variables`_ for more CMake options. See `CMake Variables`_ for more CMake options.
Windows Windows (MinGW)
------- ---------------
Unfortunately, at the moment no instructions for Windows building are available. Unfortunately, at the moment no instructions are available for Windows building using MinGW.
Windows (MSVC)
--------------
Setting up the IDE
..................
1. Open ``minetestmapper.sln`` or ``MSVC\mintestmapper.vcxproj`` with Visual Studio.
2. Configure the gd libary:
1. Open projectsettings `ALT+F7`.
2. Select `All Configurations` and `All Platforms`.
3. Click `C/C++` -> `additional include directories` and enter the path to the include directory of libGD.
4. Click `Apply`
5. Select a configuration (``Debug|Release``) and a platform (``x86|x64``)
6. Click `Linker` --> `additional libary directories` Enter the path to libgd that fits to your configuration and platform.
Do this step for all configurations and platforms you want to use.
WARNING: You will get a linker error if you select a version of libgd that does not fit to your configuration and platform.
Building Minetestmapper
.......................
With everything set up, Minetestmapper can be built.
Building for 64-bit may fail due to a `bug in snappy`__. If this happens,
the following steps will solve this:
1. Open ``packages\Snappy.1.1.1.7\lib\native\src\snappy.cc``
2. Change line 955 from ``#ifndef WIN32`` to ``#ifndef _WIN32``
__ https://bitbucket.org/robertvazan/snappy-visual-cpp/issues/1/snappycc-will-not-compile-on-windows-x64
Debugging Minetestmapper
........................
1. In projectsettings (`ALT+F7`) click `Debugging`.
2. Specify the Arguments in `Command arguments`.
3. Every time you launch the debugger, minetstmapper will be executed with those arguments.
OSX OSX
--- ---

View File

@ -23,6 +23,10 @@ Major Features
Build Features Build Features
============== ==============
* Supports both the gcc and clang compiler suites * Supports both the gcc and clang compiler suites
* Supports MSVC building on Windows (with SQLite3 and LevelDB)
* With automatic downloading of all but one of the required libraries.
* Build rpm, deb and/or tar.gz installation * Build rpm, deb and/or tar.gz installation
packages. Or simply type 'make install'. packages. Or simply type 'make install'.
@ -71,6 +75,7 @@ Differences From Stock Minetestmapper
* Block numbers are shown on the scale as well * Block numbers are shown on the scale as well
* Optionally, avoid reading the block list from the database * Optionally, avoid reading the block list from the database
(dramatically speeds up generating maps of small parts of large worlds) (dramatically speeds up generating maps of small parts of large worlds)
* Compiles using MSVC on windows.
In addition a number bugs have been fixed. As bugs are also getting In addition a number bugs have been fixed. As bugs are also getting
fixed in the stock version of minetestmapper, no accurate list fixed in the stock version of minetestmapper, no accurate list

View File

@ -17,8 +17,8 @@
#include <cstring> #include <cstring>
#include <stdexcept> #include <stdexcept>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include "porting.h"
#include "TileGenerator.h" #include "TileGenerator.h"
#include "PixelAttributes.h" #include "PixelAttributes.h"
#include "util.h" #include "util.h"
@ -200,9 +200,8 @@ void parseDataFile(TileGenerator &generator, const string &input, string dataFil
// Check if input/../.. looks like a valid minetest directory // Check if input/../.. looks like a valid minetest directory
string minetestPath = input + PATH_SEPARATOR + ".." + PATH_SEPARATOR + ".."; string minetestPath = input + PATH_SEPARATOR + ".." + PATH_SEPARATOR + "..";
string minetestConf = minetestPath + PATH_SEPARATOR + "minetest.conf"; string minetestConf = minetestPath + PATH_SEPARATOR + "minetest.conf";
int fd; if (FILE *file = fopen(minetestConf.c_str(), "r")) {
if (0 <= (fd = open(minetestConf.c_str(), O_RDONLY))) { fclose(file);
close(fd);
colorPaths.push_back(minetestPath); colorPaths.push_back(minetestPath);
} }
char *homedir; char *homedir;

28
minetestmapper.sln Normal file
View File

@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minetestmapper", "MSVC\minetestmapper.vcxproj", "{3F30298F-2395-4811-A79E-EBB603F42948}"
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
{3F30298F-2395-4811-A79E-EBB603F42948}.Debug|x64.ActiveCfg = Debug|x64
{3F30298F-2395-4811-A79E-EBB603F42948}.Debug|x64.Build.0 = Debug|x64
{3F30298F-2395-4811-A79E-EBB603F42948}.Debug|x86.ActiveCfg = Debug|Win32
{3F30298F-2395-4811-A79E-EBB603F42948}.Debug|x86.Build.0 = Debug|Win32
{3F30298F-2395-4811-A79E-EBB603F42948}.Release|x64.ActiveCfg = Release|x64
{3F30298F-2395-4811-A79E-EBB603F42948}.Release|x64.Build.0 = Release|x64
{3F30298F-2395-4811-A79E-EBB603F42948}.Release|x86.ActiveCfg = Release|Win32
{3F30298F-2395-4811-A79E-EBB603F42948}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

22
porting.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef _PORTING_H
#define _PORTING_H
#ifdef _WIN32
#include <windows.h>
#define sleepMs(x) Sleep(x)
#else
#include <unistd.h>
#define sleepMs(x) usleep(x*1000)
#endif
#ifdef _MSC_VER
#define strcasecmp(a, b) _stricmp(a, b)
#endif
#endif // _PORTING_H