mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 06:20:56 +00:00
Fix compilation in Win32
Currently, libgit2 compiles and passes all tests under MinGW, and compiles but fails the test suite on MSVC 2010. Signed-off-by: Vicent Marti <tanoku@gmail.com>
This commit is contained in:
parent
e06551e51c
commit
5dc2bee153
112
wscript
112
wscript
@ -2,8 +2,10 @@ from waflib.Context import Context
|
|||||||
from waflib.Build import BuildContext, CleanContext, \
|
from waflib.Build import BuildContext, CleanContext, \
|
||||||
InstallContext, UninstallContext
|
InstallContext, UninstallContext
|
||||||
|
|
||||||
CFLAGS = ["-g", "-O2", "-Wall", "-Wextra"]
|
CFLAGS_UNIX = ["-g", "-O2", "-Wall", "-Wextra"]
|
||||||
ALL_LIBS = ['z', 'crypto']
|
CFLAGS_WIN32 = ['/TC', '/W4', '/RTC1', '/Zi', '/nologo']
|
||||||
|
|
||||||
|
ALL_LIBS = ['z', 'crypto', 'pthread']
|
||||||
|
|
||||||
def options(opt):
|
def options(opt):
|
||||||
opt.load('compiler_c')
|
opt.load('compiler_c')
|
||||||
@ -15,8 +17,26 @@ def configure(conf):
|
|||||||
# default configuration for C programs
|
# default configuration for C programs
|
||||||
conf.load('compiler_c')
|
conf.load('compiler_c')
|
||||||
|
|
||||||
|
zlib_name = 'z'
|
||||||
|
|
||||||
|
conf.env.CFLAGS = CFLAGS_UNIX
|
||||||
|
|
||||||
|
if conf.env.DEST_OS == 'win32':
|
||||||
|
conf.env.PLATFORM = 'win32'
|
||||||
|
|
||||||
|
if conf.env.CC_NAME == 'msvc':
|
||||||
|
conf.env.CFLAGS = CFLAGS_WIN32
|
||||||
|
conf.env.DEFINES += ['WIN32', '_DEBUG', '_LIB']
|
||||||
|
zlib_name = 'zdll'
|
||||||
|
|
||||||
|
elif conf.env.CC_NAME == 'gcc':
|
||||||
|
conf.check(features='c cprogram', lib='pthread', uselib_store='pthread')
|
||||||
|
|
||||||
|
else:
|
||||||
|
conf.env.PLATFORM = 'unix'
|
||||||
|
|
||||||
# check for Z lib
|
# check for Z lib
|
||||||
conf.check(features='c cprogram', lib='z', uselib_store='z')
|
conf.check(features='c cprogram', lib=zlib_name, uselib_store='z')
|
||||||
|
|
||||||
if conf.options.sha1 not in ['openssl', 'ppc', 'builtin']:
|
if conf.options.sha1 not in ['openssl', 'ppc', 'builtin']:
|
||||||
ctx.fatal('Invalid SHA1 option')
|
ctx.fatal('Invalid SHA1 option')
|
||||||
@ -24,6 +44,10 @@ def configure(conf):
|
|||||||
# check for libcrypto (openssl) if we are using its SHA1 functions
|
# check for libcrypto (openssl) if we are using its SHA1 functions
|
||||||
if conf.options.sha1 == 'openssl':
|
if conf.options.sha1 == 'openssl':
|
||||||
conf.check_cfg(package='libcrypto', args=['--cflags', '--libs'], uselib_store='crypto')
|
conf.check_cfg(package='libcrypto', args=['--cflags', '--libs'], uselib_store='crypto')
|
||||||
|
conf.env.DEFINES += ['OPENSSL_SHA1']
|
||||||
|
|
||||||
|
elif conf.options.sha1 == 'ppc':
|
||||||
|
conf.env.DEFINES += ['PPC_SHA1']
|
||||||
|
|
||||||
conf.env.sha1 = conf.options.sha1
|
conf.env.sha1 = conf.options.sha1
|
||||||
|
|
||||||
@ -48,70 +72,21 @@ def build(bld):
|
|||||||
Options.commands = [bld.cmd + '-shared', bld.cmd + '-static'] + Options.commands
|
Options.commands = [bld.cmd + '-shared', bld.cmd + '-static'] + Options.commands
|
||||||
|
|
||||||
def build_library(bld, lib_str):
|
def build_library(bld, lib_str):
|
||||||
import sys
|
|
||||||
|
|
||||||
directory = bld.path
|
directory = bld.path
|
||||||
|
|
||||||
#------------------------------
|
|
||||||
# Default values
|
|
||||||
#------------------------------
|
|
||||||
|
|
||||||
sources = directory.ant_glob('src/*.c')
|
sources = directory.ant_glob('src/*.c')
|
||||||
flags = CFLAGS
|
|
||||||
defines = []
|
|
||||||
visibility = True
|
|
||||||
os = 'unix'
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------
|
|
||||||
# OS-dependant configuration
|
|
||||||
#------------------------------
|
|
||||||
|
|
||||||
# Windows 32 (MSVC) platform configuration
|
|
||||||
if sys.platform == 'win32':
|
|
||||||
# windows configuration
|
|
||||||
flags = flags + ['-TC', '-W4', '-RTC1', '-Zi']
|
|
||||||
defines = defines = ['WIN32', '_DEBUG', '_LIB']
|
|
||||||
visibility = False
|
|
||||||
os = 'win32'
|
|
||||||
|
|
||||||
# Windows 32 Cygwin configuration
|
|
||||||
# (assume a POSIX-compilant system)
|
|
||||||
elif sys.platform == 'cygwin':
|
|
||||||
visibility = False
|
|
||||||
|
|
||||||
# Windows 32 MinGW configuration (TODO)
|
|
||||||
elif sys.platform == 'mingw':
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Compile platform-dependant code
|
# Compile platform-dependant code
|
||||||
# E.g. src/unix/*.c
|
# E.g. src/unix/*.c
|
||||||
# src/win32/*.c
|
# src/win32/*.c
|
||||||
sources = sources + directory.ant_glob('src/%s/*.c' % os)
|
sources = sources + directory.ant_glob('src/%s/*.c' % bld.env.PLATFORM)
|
||||||
|
|
||||||
# Disable visibility on W32 platform
|
# SHA1 methods source
|
||||||
if not visibility:
|
if bld.env.sha1 == "ppc":
|
||||||
flags.append('-fvisibility=hidden')
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------
|
|
||||||
# SHA1 Methods Source
|
|
||||||
#------------------------------
|
|
||||||
|
|
||||||
# OpenSSL library
|
|
||||||
if bld.env.sha1 == "openssl":
|
|
||||||
defines.append('OPENSSL_SHA1')
|
|
||||||
|
|
||||||
# builtin PPC methods
|
|
||||||
elif bld.env.sha1 == "ppc":
|
|
||||||
defines.append('PPC_SHA1')
|
|
||||||
sources.append('src/ppc/sha1.c')
|
sources.append('src/ppc/sha1.c')
|
||||||
|
|
||||||
# default builtins
|
|
||||||
else:
|
else:
|
||||||
sources.append('src/block-sha1/sha1.c')
|
sources.append('src/block-sha1/sha1.c')
|
||||||
|
|
||||||
|
|
||||||
#------------------------------
|
#------------------------------
|
||||||
# Build the main library
|
# Build the main library
|
||||||
#------------------------------
|
#------------------------------
|
||||||
@ -121,16 +96,12 @@ def build_library(bld, lib_str):
|
|||||||
source=sources,
|
source=sources,
|
||||||
target='git2',
|
target='git2',
|
||||||
includes='src',
|
includes='src',
|
||||||
cflags=flags,
|
|
||||||
defines=defines,
|
|
||||||
install_path='${LIBDIR}',
|
install_path='${LIBDIR}',
|
||||||
use=ALL_LIBS # link with all the libs we know (z, openssl);
|
use=ALL_LIBS #if lib_str == 'cshlib' else []
|
||||||
# this is ignored for static builds
|
|
||||||
# and for libraries which have been disabled
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# On Unix systems, build the Pkg-config entry file
|
# On Unix systems, build the Pkg-config entry file
|
||||||
if os == 'unix':
|
if bld.env.PLATFORM == 'unix':
|
||||||
bld(rule="""sed -e 's#@prefix@#$(prefix)#' -e 's#@libdir@#$(libdir)#' < ${SRC} > ${TGT}""",
|
bld(rule="""sed -e 's#@prefix@#$(prefix)#' -e 's#@libdir@#$(libdir)#' < ${SRC} > ${TGT}""",
|
||||||
source='libgit2.pc.in',
|
source='libgit2.pc.in',
|
||||||
target='libgit2.pc',
|
target='libgit2.pc',
|
||||||
@ -171,7 +142,7 @@ def build_tests(bld):
|
|||||||
includes=['src', 'tests'],
|
includes=['src', 'tests'],
|
||||||
defines=['TEST_TOC="%s.toc"' % test_name],
|
defines=['TEST_TOC="%s.toc"' % test_name],
|
||||||
stlib=['git2'], # link with the git2 static lib we've just compiled'
|
stlib=['git2'], # link with the git2 static lib we've just compiled'
|
||||||
stlibpath=directory.find_node('build/static/').abspath(),
|
stlibpath=[directory.find_node('build/static/').abspath(), directory.abspath()],
|
||||||
use=['test_helper'] + ALL_LIBS # link with all the libs we know
|
use=['test_helper'] + ALL_LIBS # link with all the libs we know
|
||||||
# libraries which are not enabled won't link
|
# libraries which are not enabled won't link
|
||||||
)
|
)
|
||||||
@ -191,17 +162,22 @@ class _run_tests(Context):
|
|||||||
fun = 'run_tests'
|
fun = 'run_tests'
|
||||||
|
|
||||||
def run_tests(ctx):
|
def run_tests(ctx):
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
failed = False
|
||||||
test_folder = ctx.path.make_node('tests/tmp/')
|
test_folder = ctx.path.make_node('tests/tmp/')
|
||||||
|
test_folder.mkdir()
|
||||||
|
test_glob = 'build/tests/t????-*'
|
||||||
|
|
||||||
for test in ctx.path.ant_glob('build/tests/t????-*'):
|
for test in ctx.path.ant_glob(test_glob, excl='build/tests/*.manifest'):
|
||||||
test_folder.delete()
|
|
||||||
test_folder.mkdir()
|
|
||||||
|
|
||||||
if ctx.exec_command(test.abspath(), cwd=test_folder.abspath()) != 0:
|
if ctx.exec_command(test.abspath(), cwd=test_folder.abspath()) != 0:
|
||||||
ctx.fatal('Test run failed')
|
failed = True
|
||||||
break
|
break
|
||||||
|
|
||||||
test_folder.delete()
|
shutil.rmtree(test_folder.abspath())
|
||||||
|
|
||||||
|
if failed:
|
||||||
|
ctx.fatal('Test run failed')
|
||||||
|
|
||||||
|
|
||||||
CONTEXTS = {
|
CONTEXTS = {
|
||||||
|
Loading…
Reference in New Issue
Block a user