-
-
Save jan-bar/d61352f2ec1268a64cfb3e1c784e4c66 to your computer and use it in GitHub Desktop.
7-zip build script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableExtensions EnableDelayedExpansion | |
pushd "%~dp0" | |
:Download_7zip | |
set version=7z1803 | |
appveyor DownloadFile https://www.7-zip.org/a/%version%-src.7z | |
7z x %version%-src.7z | |
:Patch | |
C:\msys64\usr\bin\bash -lc "cd \"$APPVEYOR_BUILD_FOLDER\" && exec ./7-zip-patch.sh" | |
:Init_VC_LTL | |
git clone https://github.com/Chuyu-Team/VC-LTL.git --depth=1 | |
set "VC_LTL_PATH=%CD%\VC-LTL" | |
set "CL_VER=14.0.24210" | |
set "SDK_VER=10.0.10240.0" | |
:Env_x64 | |
call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" amd64 | |
set BITS=x64 | |
set "PATH=%VC_LTL_PATH%;%VC_LTL_PATH%\VC\%CL_VER%\include;%VC_LTL_PATH%\%BITS%;%VC_LTL_PATH%\VC\%CL_VER%\lib\%BITS%;%PATH%" | |
set "INCLUDE=%VC_LTL_PATH%\VC\%CL_VER%\include;%INCLUDE%" | |
set "LIB=%VC_LTL_PATH%\%BITS%;%VC_LTL_PATH%\VC\%CL_VER%\lib\%BITS%;%VC_LTL_PATH%\ucrt\%SDK_VER%\lib\%BITS%;%LIB%" | |
:Build_x64 | |
cd CPP\7zip | |
nmake NEW_COMPILER=1 CPU=AMD64 | |
cd ..\..\C\Util\7z | |
nmake NEW_COMPILER=1 CPU=AMD64 | |
cd ..\7zipInstall | |
nmake NEW_COMPILER=1 CPU=AMD64 | |
cd ..\7zipUninstall | |
nmake NEW_COMPILER=1 CPU=AMD64 | |
cd ..\SfxSetup | |
nmake NEW_COMPILER=1 CPU=AMD64 | |
nmake /F makefile_con NEW_COMPILER=1 CPU=AMD64 | |
:Env_x86 | |
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat" | |
set BITS=x86 | |
set "PATH=%VC_LTL_PATH%;%VC_LTL_PATH%\VC\%CL_VER%\include;%VC_LTL_PATH%\%BITS%;%VC_LTL_PATH%\VC\%CL_VER%\lib\%BITS%;%PATH%" | |
set "INCLUDE=%VC_LTL_PATH%\VC\%CL_VER%\include;%INCLUDE%" | |
set "LIB=%VC_LTL_PATH%\%BITS%;%VC_LTL_PATH%\VC\%CL_VER%\lib\%BITS%;%VC_LTL_PATH%\ucrt\%SDK_VER%\lib\%BITS%;%LIB%" | |
:Build_x86 | |
nmake NEW_COMPILER=1 | |
nmake /F makefile_con NEW_COMPILER=1 | |
cd ..\7z | |
nmake NEW_COMPILER=1 | |
cd ..\7zipInstall | |
nmake NEW_COMPILER=1 | |
cd ..\7zipUninstall | |
nmake NEW_COMPILER=1 | |
cd ..\.. | |
7z a -mx9 -r ..\%version%.7z *.dll *.exe *.efi *.sfx | |
cd ..\CPP\7zip | |
nmake NEW_COMPILER=1 | |
:Package | |
REM 7-zip extra | |
mkdir 7-zip-extra-x86 | |
mkdir 7-zip-extra-x64 | |
for /f "tokens=* eol=; delims=" %%i in (..\..\pack-7-zip-extra-x86.txt) do if exist "%%~i" move /Y "%%~i" 7-zip-extra-x86\ | |
for /f "tokens=* eol=; delims=" %%i in (..\..\pack-7-zip-extra-x64.txt) do if exist "%%~i" move /Y "%%~i" 7-zip-extra-x64\ | |
REM 7-zip | |
mkdir 7-zip-x86 | |
mkdir 7-zip-x86\Lang | |
mkdir 7-zip-x64 | |
mkdir 7-zip-x64\Lang | |
for /f "tokens=* eol=; delims=" %%i in (..\..\pack-7-zip-x86.txt) do if exist "%%~i" move /Y "%%~i" 7-zip-x86\ | |
for /f "tokens=* eol=; delims=" %%i in (..\..\pack-7-zip-x64.txt) do if exist "%%~i" move /Y "%%~i" 7-zip-x64\ | |
if exist 7-zip-x86\7-zip.dll copy 7-zip-x86\7-zip.dll 7-zip-x64\7-zip32.dll | |
mkdir installer | |
cd installer | |
appveyor DownloadFile https://www.7-zip.org/a/%version%-x64.exe | |
7z x %version%-x64.exe | |
xcopy /S /G /H /R /Y /Q .\Lang ..\7-zip-x86\Lang | |
xcopy /S /G /H /R /Y /Q .\Lang ..\7-zip-x64\Lang | |
for /f "tokens=* eol=; delims=" %%i in (..\..\..\pack-7-zip-common.txt) do if exist "%%~i" copy /Y "%%~i" ..\7-zip-x86\ | |
for /f "tokens=* eol=; delims=" %%i in (..\..\..\pack-7-zip-common.txt) do if exist "%%~i" copy /Y "%%~i" ..\7-zip-x64\ | |
cd .. | |
del /f /s /q installer\* >nul | |
rd /s /q installer | |
move /Y .\7-zip-x64\7zipUninstall.exe .\7-zip-x64\Uninstall.exe | |
move /Y .\7-zip-x86\7zipUninstall.exe .\7-zip-x86\Uninstall.exe | |
7z a -mx9 -r ..\..\%version%.7z *.dll *.exe *.efi *.sfx 7-zip-x86\* 7-zip-x64\* 7-zip-extra-x86\* 7-zip-extra-x64\* | |
7z a -m0=lzma -mx9 ..\..\%version%-x64.7z .\7-zip-x64\* | |
7z a -m0=lzma -mx9 ..\..\%version%-x86.7z .\7-zip-x86\* | |
cd ..\.. | |
copy /b .\C\Util\7zipInstall\AMD64\7zipInstall.exe /b + %version%-x64.7z /b %version%-x64.exe | |
copy /b .\C\Util\7zipInstall\O\7zipInstall.exe /b + %version%-x86.7z /b %version%-x86.exe | |
:Upload | |
appveyor PushArtifact %version%-x64.exe | |
appveyor PushArtifact %version%-x86.exe | |
appveyor PushArtifact %version%.7z |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# remove -OPT:NOWIN98 flag in Build.mak | |
# http://www.ski-epic.com/2012_compiling_7zip_on_windows_with_visual_studio_10/index.html | |
sed -i '/LFLAGS = $(LFLAGS) -OPT:NOWIN98/ c\LFLAGS = $(LFLAGS)\' CPP/Build.mak | |
# patch NsisIn.h to enable NSIS script decompiling | |
# https://sourceforge.net/p/sevenzip/discussion/45797/thread/5d10a376/ | |
# insert #define NSIS_SCRIPT before the 19th line using sed | |
sed -i '19 i #define NSIS_SCRIPT' CPP/7zip/Archive/Nsis/NsisIn.h | |
# drop -WX option in Build.mak | |
# workaround error C2220: warning treated as error | |
# since warning C4456: declaration of '&1' hides previous local declaration | |
# introduced by NSIS_SCRIPT | |
sed -i 's/ -WX//g' CPP/Build.mak | |
# MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; | |
# add /LTCG to the link command line to improve linker performance | |
sed -i '1 a LFLAGS = $(LFLAGS) /LTCG' CPP/Build.mak | |
# VC-LTL | |
# https://github.com/Chuyu-Team/VC-LTL | |
# reduces binary size | |
sed -i '2 a LIBS = msvcrt_light.obj ltl.lib vc.lib ucrt.lib $(LIBS)' CPP/Build.mak | |
sed -i '3 a CFLAGS = $(CFLAGS) /D_NO_CRT_STDIO_INLINE=1 /D_Build_By_LTL=1 /D_DISABLE_DEPRECATE_STATIC_CPPLIB=1 /D_STATIC_CPPLIB=1' CPP/Build.mak |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
安装vs,选择“使用C++的桌面开发” | |
下载源码 | |
7z2106-src\CPP\7zip\Bundles\SFXWin\makefile,加上下面最后一行 | |
CFLAGS = $(CFLAGS) \ | |
-DNO_REGISTRY \ | |
-DEXTRACT_ONLY \ | |
-DNO_READ_FROM_CODER \ | |
-D_SFX \ | |
-DWIN_LONG_PATH \ | |
搜索vcvars64.bat,找到绝对路径,在cmd中执行 | |
进入7z2106-src\CPP\7zip,执行下面命令就可以编译 | |
nmake CPU=AMD64 NEW_COMPILER=1 MY_STATIC_LINK=1 | |
下面是编译脚本 | |
if not exist build_7z ( | |
set version=7z2106 | |
wget -nc https://www.7-zip.org/a/%version%-src.7z | |
wget -nc https://www.7-zip.org/a/%version%-x64.exe | |
7za x -obuild_7z %version%-src.7z | |
7za x -o7-zip-x64 %version%-x64.exe Lang 7-zip.chm descript.ion License.txt readme.txt | |
) | |
REM D:\code_project\VisualStudio\ide\VC\Auxiliary\Build\vcvars64.bat | |
set build=%cd%\build_7z | |
set create=%cd%\7-zip-x64 | |
cd %build%\CPP\7zip | |
nmake CPU=AMD64 NEW_COMPILER=1 MY_STATIC_LINK=1 | |
cd %build%\C\Util\7z | |
nmake CPU=AMD64 NEW_COMPILER=1 MY_STATIC_LINK=1 | |
cd %build%\C\Util\7zipInstall | |
nmake CPU=AMD64 NEW_COMPILER=1 MY_STATIC_LINK=1 | |
cd %build%\C\Util\7zipUninstall | |
nmake CPU=AMD64 NEW_COMPILER=1 MY_STATIC_LINK=1 | |
cd %build%\C\Util\SfxSetup | |
nmake CPU=AMD64 NEW_COMPILER=1 MY_STATIC_LINK=1 | |
nmake /F makefile_con CPU=AMD64 NEW_COMPILER=1 MY_STATIC_LINK=1 | |
move /Y %build%\CPP\7zip\UI\Console\x64\7z.exe %create% | |
move /Y %build%\CPP\7zip\UI\Explorer\x64\7-zip.dll %create% | |
move /Y %build%\CPP\7zip\UI\FileManager\x64\7zFM.exe %create% | |
move /Y %build%\CPP\7zip\UI\GUI\x64\7zG.exe %create% | |
move /Y %build%\CPP\7zip\Bundles\Format7zF\x64\7z.dll %create% | |
move /Y %build%\CPP\7zip\Bundles\SFXCon\x64\7zCon.sfx %create% | |
move /Y %build%\CPP\7zip\Bundles\SFXWin\x64\7z.sfx %create% | |
move /Y %build%\C\Util\7zipUninstall\x64\7zipUninstall.exe %create%\Uninstall.exe | |
cd %build%\.. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 18.03-{build} | |
build_script: | |
- cmd: >- | |
7-zip-build.bat | |
test: off |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7-zip.chm | |
descript.ion | |
History.txt | |
License.txt | |
readme.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UI\Far\AMD64\7-ZipFar.dll | |
Bundles\Format7z\AMD64\7za.dll | |
Bundles\Format7zExtract\AMD64\7zxa.dll | |
Bundles\Alone\AMD64\7za.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UI\Far\O\7-ZipFar.dll | |
Bundles\Format7z\O\7za.dll | |
Bundles\Format7zExtract\O\7zxa.dll | |
Bundles\Alone\O\7za.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UI\Console\AMD64\7z.exe | |
UI\Explorer\AMD64\7-zip.dll | |
UI\FileManager\AMD64\7zFM.exe | |
UI\GUI\AMD64\7zG.exe | |
Bundles\Format7zF\AMD64\7z.dll | |
Bundles\SFXCon\AMD64\7zCon.sfx | |
Bundles\SFXWin\AMD64\7z.sfx | |
..\..\C\Util\7zipUninstall\AMD64\7zipUninstall.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UI\Console\O\7z.exe | |
UI\Explorer\O\7-zip.dll | |
UI\FileManager\O\7zFM.exe | |
UI\GUI\O\7zG.exe | |
Bundles\Format7zF\O\7z.dll | |
Bundles\SFXCon\O\7zCon.sfx | |
Bundles\SFXWin\O\7z.sfx | |
..\..\C\Util\7zipUninstall\O\7zipUninstall.exe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment