2014-03-25 09:09:53 +04:00
|
|
|
from unzip import unzip
|
2014-03-25 09:38:45 +04:00
|
|
|
from untar import untar
|
2015-06-20 06:43:14 +03:00
|
|
|
import os
|
2014-03-25 09:09:53 +04:00
|
|
|
|
2018-08-24 13:12:12 +03:00
|
|
|
from fetch import fetch
|
2018-10-08 11:43:11 +03:00
|
|
|
from config import (compilers, all_compilers, compiler_from_env, bit_from_env,
|
|
|
|
libs)
|
|
|
|
from build import vc_setup
|
2014-03-25 09:09:53 +04:00
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2014-03-25 09:09:53 +04:00
|
|
|
def _relpath(*args):
|
2015-06-20 06:43:14 +03:00
|
|
|
return os.path.join(os.getcwd(), *args)
|
|
|
|
|
2014-03-25 09:09:53 +04:00
|
|
|
|
|
|
|
build_dir = _relpath('build')
|
|
|
|
inc_dir = _relpath('depends')
|
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2014-03-25 09:09:53 +04:00
|
|
|
def check_sig(filename, signame):
|
2015-06-20 06:43:14 +03:00
|
|
|
# UNDONE -- need gpg
|
2014-03-25 09:09:53 +04:00
|
|
|
return filename
|
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2014-03-25 09:09:53 +04:00
|
|
|
def mkdirs():
|
|
|
|
try:
|
|
|
|
os.mkdir(build_dir)
|
2015-06-20 04:34:34 +03:00
|
|
|
except OSError:
|
2014-03-25 09:09:53 +04:00
|
|
|
pass
|
|
|
|
try:
|
|
|
|
os.mkdir(inc_dir)
|
2015-06-20 04:34:34 +03:00
|
|
|
except OSError:
|
2014-03-25 09:09:53 +04:00
|
|
|
pass
|
2018-10-08 11:43:11 +03:00
|
|
|
for compiler in all_compilers():
|
2014-06-11 10:36:03 +04:00
|
|
|
try:
|
|
|
|
os.mkdir(os.path.join(inc_dir, compiler['inc_dir']))
|
2015-06-20 04:34:34 +03:00
|
|
|
except OSError:
|
2014-06-11 10:36:03 +04:00
|
|
|
pass
|
2014-03-25 09:09:53 +04:00
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2014-03-25 09:38:45 +04:00
|
|
|
def extract(src, dest):
|
|
|
|
if '.zip' in src:
|
|
|
|
return unzip(src, dest)
|
|
|
|
if '.tar.gz' in src or '.tgz' in src:
|
|
|
|
return untar(src, dest)
|
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2016-08-29 14:53:48 +03:00
|
|
|
def extract_libs():
|
2015-06-20 06:43:14 +03:00
|
|
|
for name, lib in libs.items():
|
2017-03-27 01:08:16 +03:00
|
|
|
filename = lib['filename']
|
2018-08-24 13:12:12 +03:00
|
|
|
if not os.path.exists(filename):
|
|
|
|
filename = fetch(lib['url'])
|
2014-06-06 02:17:47 +04:00
|
|
|
if name == 'openjpeg':
|
2018-10-08 11:43:11 +03:00
|
|
|
for compiler in all_compilers():
|
2015-06-26 10:39:13 +03:00
|
|
|
if not os.path.exists(os.path.join(
|
|
|
|
build_dir, lib['dir']+compiler['inc_dir'])):
|
2014-06-06 02:17:47 +04:00
|
|
|
extract(filename, build_dir)
|
2015-06-20 06:43:14 +03:00
|
|
|
os.rename(os.path.join(build_dir, lib['dir']),
|
2015-06-26 10:39:13 +03:00
|
|
|
os.path.join(
|
|
|
|
build_dir, lib['dir']+compiler['inc_dir']))
|
2014-06-06 02:17:47 +04:00
|
|
|
else:
|
2017-03-27 01:08:16 +03:00
|
|
|
extract(filename, build_dir)
|
2014-06-11 10:36:03 +04:00
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2014-06-11 10:36:03 +04:00
|
|
|
def extract_openjpeg(compiler):
|
|
|
|
return r"""
|
|
|
|
rem build openjpeg
|
|
|
|
setlocal
|
|
|
|
@echo on
|
|
|
|
cd %%BUILD%%
|
|
|
|
mkdir %%INCLIB%%\openjpeg-2.0
|
|
|
|
copy /Y /B openjpeg-2.0.0-win32-x86\include\openjpeg-2.0 %%INCLIB%%\openjpeg-2.0
|
|
|
|
copy /Y /B openjpeg-2.0.0-win32-x86\bin\ %%INCLIB%%
|
|
|
|
copy /Y /B openjpeg-2.0.0-win32-x86\lib\ %%INCLIB%%
|
|
|
|
endlocal
|
|
|
|
""" % compiler
|
2015-06-20 06:43:14 +03:00
|
|
|
|
|
|
|
|
2015-06-26 20:08:40 +03:00
|
|
|
def cp_tk(ver_85, ver_86):
|
2015-08-25 15:27:18 +03:00
|
|
|
versions = {'ver_85': ver_85, 'ver_86': ver_86}
|
2014-03-25 09:09:53 +04:00
|
|
|
return r"""
|
2015-06-26 20:08:40 +03:00
|
|
|
mkdir %%INCLIB%%\tcl85\include\X11
|
|
|
|
copy /Y /B %%BUILD%%\tcl%(ver_85)s\generic\*.h %%INCLIB%%\tcl85\include\
|
|
|
|
copy /Y /B %%BUILD%%\tk%(ver_85)s\generic\*.h %%INCLIB%%\tcl85\include\
|
|
|
|
copy /Y /B %%BUILD%%\tk%(ver_85)s\xlib\X11\* %%INCLIB%%\tcl85\include\X11\
|
|
|
|
|
|
|
|
mkdir %%INCLIB%%\tcl86\include\X11
|
|
|
|
copy /Y /B %%BUILD%%\tcl%(ver_86)s\generic\*.h %%INCLIB%%\tcl86\include\
|
|
|
|
copy /Y /B %%BUILD%%\tk%(ver_86)s\generic\*.h %%INCLIB%%\tcl86\include\
|
|
|
|
copy /Y /B %%BUILD%%\tk%(ver_86)s\xlib\X11\* %%INCLIB%%\tcl86\include\X11\
|
|
|
|
""" % versions
|
2014-03-25 09:09:53 +04:00
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2014-03-25 09:09:53 +04:00
|
|
|
def header():
|
|
|
|
return r"""setlocal
|
|
|
|
set MSBUILD=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
|
2015-06-11 01:03:32 +03:00
|
|
|
set CMAKE="cmake.exe"
|
2014-03-25 09:09:53 +04:00
|
|
|
set INCLIB=%~dp0\depends
|
|
|
|
set BUILD=%~dp0\build
|
2017-01-12 22:28:24 +03:00
|
|
|
""" + "\n".join(r'set %s=%%BUILD%%\%s' % (k.upper(), v['dir'])
|
2015-06-20 06:43:14 +03:00
|
|
|
for (k, v) in libs.items() if v['dir'])
|
|
|
|
|
|
|
|
|
2014-03-25 09:09:53 +04:00
|
|
|
def setup_compiler(compiler):
|
|
|
|
return r"""setlocal EnableDelayedExpansion
|
|
|
|
call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s
|
|
|
|
set INCLIB=%%INCLIB%%\%(inc_dir)s
|
2018-11-11 23:50:12 +03:00
|
|
|
""" % compiler # noqa: E501
|
2014-03-25 09:09:53 +04:00
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2014-03-25 09:09:53 +04:00
|
|
|
def end_compiler():
|
|
|
|
return """
|
|
|
|
endlocal
|
|
|
|
"""
|
2015-06-20 06:43:14 +03:00
|
|
|
|
|
|
|
|
2019-04-17 13:55:31 +03:00
|
|
|
def nmake_openjpeg(compiler, bit):
|
|
|
|
if compiler['env_version'] == 'v7.0':
|
|
|
|
return ""
|
|
|
|
|
|
|
|
atts = {'op_ver': '2.3.1'}
|
2014-08-23 03:14:19 +04:00
|
|
|
atts.update(compiler)
|
2014-06-06 02:17:47 +04:00
|
|
|
return r"""
|
|
|
|
rem build openjpeg
|
|
|
|
setlocal
|
2019-04-17 13:55:31 +03:00
|
|
|
""" + vc_setup(compiler, bit) + r"""
|
2014-06-06 02:17:47 +04:00
|
|
|
@echo on
|
|
|
|
cd /D %%OPENJPEG%%%(inc_dir)s
|
2014-08-23 03:14:19 +04:00
|
|
|
|
2019-04-17 13:55:31 +03:00
|
|
|
%%CMAKE%% -DBUILD_THIRDPARTY:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -G "NMake Makefiles" .
|
2014-08-23 03:14:19 +04:00
|
|
|
nmake -f Makefile clean
|
|
|
|
nmake -f Makefile
|
|
|
|
copy /Y /B bin\* %%INCLIB%%
|
|
|
|
mkdir %%INCLIB%%\openjpeg-%(op_ver)s
|
|
|
|
copy /Y /B src\lib\openjp2\*.h %%INCLIB%%\openjpeg-%(op_ver)s
|
|
|
|
endlocal
|
2019-04-17 13:55:31 +03:00
|
|
|
""" % atts # noqa: E501
|
2014-08-23 03:14:19 +04:00
|
|
|
|
|
|
|
|
2018-10-08 11:43:11 +03:00
|
|
|
def nmake_libs(compiler, bit):
|
2014-03-25 09:09:53 +04:00
|
|
|
# undone -- pre, makes, headers, libs
|
2018-10-08 11:43:11 +03:00
|
|
|
script = r"""
|
2014-03-25 09:09:53 +04:00
|
|
|
rem Build libjpeg
|
|
|
|
setlocal
|
2018-10-08 11:43:11 +03:00
|
|
|
""" + vc_setup(compiler, bit) + r"""
|
2014-03-25 09:38:45 +04:00
|
|
|
cd /D %%JPEG%%
|
2014-03-25 09:09:53 +04:00
|
|
|
nmake -f makefile.vc setup-vc6
|
|
|
|
nmake -f makefile.vc clean
|
2014-08-23 08:35:56 +04:00
|
|
|
nmake -f makefile.vc libjpeg.lib
|
2014-03-25 09:09:53 +04:00
|
|
|
copy /Y /B *.dll %%INCLIB%%
|
|
|
|
copy /Y /B *.lib %%INCLIB%%
|
|
|
|
copy /Y /B j*.h %%INCLIB%%
|
|
|
|
endlocal
|
|
|
|
|
|
|
|
rem Build zlib
|
|
|
|
setlocal
|
2014-03-25 09:38:45 +04:00
|
|
|
cd /D %%ZLIB%%
|
2014-03-25 09:09:53 +04:00
|
|
|
nmake -f win32\Makefile.msc clean
|
2014-08-23 08:35:56 +04:00
|
|
|
nmake -f win32\Makefile.msc zlib.lib
|
2014-03-25 09:09:53 +04:00
|
|
|
copy /Y /B *.dll %%INCLIB%%
|
|
|
|
copy /Y /B *.lib %%INCLIB%%
|
|
|
|
copy /Y /B zlib.lib %%INCLIB%%\z.lib
|
|
|
|
copy /Y /B zlib.h %%INCLIB%%
|
|
|
|
copy /Y /B zconf.h %%INCLIB%%
|
|
|
|
endlocal
|
|
|
|
|
2014-03-25 09:38:45 +04:00
|
|
|
rem Build webp
|
|
|
|
setlocal
|
2018-10-08 11:43:11 +03:00
|
|
|
""" + vc_setup(compiler, bit) + r"""
|
2014-03-25 09:38:45 +04:00
|
|
|
cd /D %%WEBP%%
|
2014-08-23 04:06:11 +04:00
|
|
|
rd /S /Q %%WEBP%%\output\release-static
|
|
|
|
nmake -f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output all
|
2015-06-19 07:43:11 +03:00
|
|
|
copy /Y /B output\release-static\%(webp_platform)s\lib\* %%INCLIB%%
|
2014-08-23 04:06:11 +04:00
|
|
|
mkdir %%INCLIB%%\webp
|
|
|
|
copy /Y /B src\webp\*.h %%INCLIB%%\\webp
|
2014-03-25 09:38:45 +04:00
|
|
|
endlocal
|
|
|
|
|
2014-03-25 09:09:53 +04:00
|
|
|
rem Build libtiff
|
|
|
|
setlocal
|
2018-10-08 11:43:11 +03:00
|
|
|
""" + vc_setup(compiler, bit) + r"""
|
2014-03-25 09:09:53 +04:00
|
|
|
rem do after building jpeg and zlib
|
2014-03-25 09:38:45 +04:00
|
|
|
copy %%~dp0\nmake.opt %%TIFF%%
|
2014-03-25 09:09:53 +04:00
|
|
|
|
2014-03-25 09:38:45 +04:00
|
|
|
cd /D %%TIFF%%
|
2014-03-25 09:09:53 +04:00
|
|
|
nmake -f makefile.vc clean
|
2014-08-23 04:06:30 +04:00
|
|
|
nmake -f makefile.vc lib
|
2014-03-25 09:09:53 +04:00
|
|
|
copy /Y /B libtiff\*.dll %%INCLIB%%
|
|
|
|
copy /Y /B libtiff\*.lib %%INCLIB%%
|
|
|
|
copy /Y /B libtiff\tiff*.h %%INCLIB%%
|
|
|
|
endlocal
|
2018-10-08 11:43:11 +03:00
|
|
|
"""
|
|
|
|
return script % compiler
|
2015-06-20 06:43:14 +03:00
|
|
|
|
|
|
|
|
2019-04-06 04:56:29 +03:00
|
|
|
def msbuild_freetype(compiler, bit):
|
|
|
|
script = r"""
|
2014-03-25 09:09:53 +04:00
|
|
|
rem Build freetype
|
|
|
|
setlocal
|
|
|
|
rd /S /Q %%FREETYPE%%\objs
|
2019-04-06 04:56:29 +03:00
|
|
|
set DefaultPlatformToolset=v100
|
|
|
|
"""
|
|
|
|
properties = r"""/p:Configuration="Release" /p:Platform=%(platform)s"""
|
|
|
|
if bit == 64:
|
|
|
|
script += r'copy /Y /B ' +\
|
|
|
|
r'"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64\*.Lib" ' +\
|
|
|
|
r'%%FREETYPE%%\builds\windows\vc2010'
|
|
|
|
properties += r" /p:_IsNativeEnvironment=false"
|
|
|
|
script += r"""
|
|
|
|
%%MSBUILD%% %%FREETYPE%%\builds\windows\vc2010\freetype.sln /t:Clean;Build """+properties+r""" /m
|
2014-04-01 06:50:52 +04:00
|
|
|
xcopy /Y /E /Q %%FREETYPE%%\include %%INCLIB%%
|
2019-04-06 04:56:29 +03:00
|
|
|
"""
|
|
|
|
freetypeReleaseDir = r"%%FREETYPE%%\objs\%(platform)s\Release"
|
|
|
|
script += r"""
|
|
|
|
copy /Y /B """+freetypeReleaseDir+r"""\freetype.lib %%INCLIB%%\freetype.lib
|
|
|
|
copy /Y /B """+freetypeReleaseDir+r"""\freetype.dll %%INCLIB%%\..\freetype.dll
|
2014-03-25 09:09:53 +04:00
|
|
|
endlocal
|
2019-04-06 04:56:29 +03:00
|
|
|
"""
|
|
|
|
return script % compiler # noqa: E501
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2014-03-25 09:09:53 +04:00
|
|
|
|
2014-08-23 03:14:19 +04:00
|
|
|
def build_lcms2(compiler):
|
2015-06-20 06:43:14 +03:00
|
|
|
if compiler['env_version'] == 'v7.1':
|
|
|
|
return build_lcms_71(compiler)
|
|
|
|
return build_lcms_70(compiler)
|
|
|
|
|
2015-06-20 01:32:08 +03:00
|
|
|
|
|
|
|
def build_lcms_70(compiler):
|
|
|
|
"""Link error here on x64"""
|
2015-06-20 06:43:14 +03:00
|
|
|
if compiler['platform'] == 'x64':
|
|
|
|
return ''
|
|
|
|
|
2015-06-20 01:32:08 +03:00
|
|
|
"""Build LCMS on VC2008. This version is only 32bit/Win32"""
|
2014-08-23 03:14:19 +04:00
|
|
|
return r"""
|
2014-03-25 09:09:53 +04:00
|
|
|
rem Build lcms2
|
|
|
|
setlocal
|
2014-08-23 03:14:19 +04:00
|
|
|
rd /S /Q %%LCMS%%\Lib
|
2014-08-23 04:07:08 +04:00
|
|
|
rd /S /Q %%LCMS%%\Projects\VC%(vc_version)s\Release
|
2018-11-11 23:50:12 +03:00
|
|
|
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean /p:Configuration="Release" /p:Platform=Win32 /m
|
2019-04-06 04:41:59 +03:00
|
|
|
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:lcms2_static /p:Configuration="Release" /p:Platform=Win32 /p:PlatformToolset=v90 /m
|
2014-04-01 06:50:52 +04:00
|
|
|
xcopy /Y /E /Q %%LCMS%%\include %%INCLIB%%
|
2019-04-06 04:41:59 +03:00
|
|
|
copy /Y /B %%LCMS%%\Lib\MS\*.lib %%INCLIB%%
|
2015-06-20 01:32:08 +03:00
|
|
|
endlocal
|
2018-11-11 23:50:12 +03:00
|
|
|
""" % compiler # noqa: E501
|
2015-06-20 01:32:08 +03:00
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
|
2015-06-20 01:32:08 +03:00
|
|
|
def build_lcms_71(compiler):
|
|
|
|
return r"""
|
|
|
|
rem Build lcms2
|
|
|
|
setlocal
|
|
|
|
rd /S /Q %%LCMS%%\Lib
|
|
|
|
rd /S /Q %%LCMS%%\Projects\VC%(vc_version)s\Release
|
2018-11-11 23:50:12 +03:00
|
|
|
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean /p:Configuration="Release" /p:Platform=%(platform)s /m
|
|
|
|
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:lcms2_static /p:Configuration="Release" /p:Platform=%(platform)s /m
|
2015-06-20 01:32:08 +03:00
|
|
|
xcopy /Y /E /Q %%LCMS%%\include %%INCLIB%%
|
2014-08-23 03:14:19 +04:00
|
|
|
copy /Y /B %%LCMS%%\Lib\MS\*.lib %%INCLIB%%
|
2014-03-25 09:09:53 +04:00
|
|
|
endlocal
|
2018-11-11 23:50:12 +03:00
|
|
|
""" % compiler # noqa: E501
|
2014-03-25 09:09:53 +04:00
|
|
|
|
2019-01-27 12:38:33 +03:00
|
|
|
|
2019-01-17 03:15:42 +03:00
|
|
|
def build_ghostscript(compiler, bit):
|
|
|
|
script = r"""
|
|
|
|
rem Build gs
|
|
|
|
setlocal
|
|
|
|
""" + vc_setup(compiler, bit) + r"""
|
|
|
|
set MSVC_VERSION=""" + {
|
2019-04-06 04:41:59 +03:00
|
|
|
"2010": "90",
|
2019-01-27 12:38:33 +03:00
|
|
|
"2015": "14"
|
|
|
|
}[compiler['vc_version']] + r"""
|
2019-01-17 03:15:42 +03:00
|
|
|
set RCOMP="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\RC.Exe"
|
|
|
|
cd /D %%GHOSTSCRIPT%%
|
|
|
|
"""
|
|
|
|
if bit == 64:
|
|
|
|
script += r"""
|
|
|
|
set WIN64=""
|
|
|
|
"""
|
|
|
|
script += r"""
|
|
|
|
nmake -f psi/msvc.mak
|
|
|
|
copy /Y /B bin\ C:\Python27\
|
|
|
|
endlocal
|
|
|
|
"""
|
|
|
|
return script % compiler # noqa: E501
|
2014-03-25 09:09:53 +04:00
|
|
|
|
2019-01-27 12:38:33 +03:00
|
|
|
|
2018-10-08 11:43:11 +03:00
|
|
|
def add_compiler(compiler, bit):
|
2014-03-25 09:09:53 +04:00
|
|
|
script.append(setup_compiler(compiler))
|
2018-10-08 11:43:11 +03:00
|
|
|
script.append(nmake_libs(compiler, bit))
|
2014-08-23 03:14:19 +04:00
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
# script.append(extract_openjpeg(compiler))
|
|
|
|
|
2019-04-06 04:56:29 +03:00
|
|
|
script.append(msbuild_freetype(compiler, bit))
|
2015-06-20 01:32:08 +03:00
|
|
|
script.append(build_lcms2(compiler))
|
2019-04-17 13:55:31 +03:00
|
|
|
script.append(nmake_openjpeg(compiler, bit))
|
2019-01-17 03:15:42 +03:00
|
|
|
script.append(build_ghostscript(compiler, bit))
|
2014-03-25 09:09:53 +04:00
|
|
|
script.append(end_compiler())
|
2014-04-01 06:50:52 +04:00
|
|
|
|
2015-06-11 02:42:12 +03:00
|
|
|
|
|
|
|
mkdirs()
|
2016-08-29 14:53:48 +03:00
|
|
|
extract_libs()
|
2016-08-29 15:06:48 +03:00
|
|
|
script = [header(),
|
|
|
|
cp_tk(libs['tk-8.5']['version'],
|
|
|
|
libs['tk-8.6']['version'])]
|
2015-06-11 02:42:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
if 'PYTHON' in os.environ:
|
2018-10-08 11:43:11 +03:00
|
|
|
add_compiler(compiler_from_env(), bit_from_env())
|
2015-06-11 02:42:12 +03:00
|
|
|
else:
|
2018-10-08 11:43:11 +03:00
|
|
|
# for compiler in all_compilers():
|
2019-01-30 12:38:19 +03:00
|
|
|
# add_compiler(compiler)
|
2019-04-06 04:41:59 +03:00
|
|
|
add_compiler(compilers[7.0][2010][32], 32)
|
2015-06-11 02:42:12 +03:00
|
|
|
|
2015-06-20 06:43:14 +03:00
|
|
|
with open('build_deps.cmd', 'w') as f:
|
|
|
|
f.write("\n".join(script))
|