Skip to content

Commit

Permalink
GH-19: Both mingw and msvc automatically pull their dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
negrutiu committed May 18, 2024
1 parent 2a563a5 commit 89bdb40
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 64 deletions.
30 changes: 0 additions & 30 deletions _acquire_pluginapi.bat

This file was deleted.

1 change: 0 additions & 1 deletion _build_Debug.cmd

This file was deleted.

12 changes: 0 additions & 12 deletions _build_Release_mingw.bat → _build_mingw_Release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ set ORIGINAL_PATH=%PATH%

cd /d "%~dp0"

:dependencies
call _acquire_pluginapi.bat || exit /b !errorlevel!
call _acquire_curl-ca-bundle.bat || exit /b !errorlevel!

REM | https://stackoverflow.com/questions/33584587/how-to-wait-all-batch-files-to-finish-before-exiting
echo Building vcpkg ...
(
start "vcpkg x86" cmd /C _build_vcpkg.bat Win32 mingw
start "vcpkg x64" cmd /C _build_vcpkg.bat x64 mingw
) | set /P "="
echo.

:x86
if not exist "%MINGW32%\bin\gcc.exe" echo ERROR: Missing "%MINGW32%" && pause && exit /B 2
set PATH=%MINGW32%\bin;%ORIGINAL_PATH%
Expand Down
1 change: 1 addition & 0 deletions _build_msvc_Debug.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@call "%~dp0_build_msvc_Release.cmd" Debug
13 changes: 0 additions & 13 deletions _build_Release.cmd → _build_msvc_Release.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ REM | script.bat [Release|Debug]
:CHDIR
cd /d "%~dp0"

:dependencies
call _acquire_pluginapi.bat || exit /b !errorlevel!
call _acquire_curl-ca-bundle.bat || exit /b !errorlevel!

REM | https://stackoverflow.com/questions/33584587/how-to-wait-all-batch-files-to-finish-before-exiting
echo Building vcpkg ...
(
start "vcpkg x86" cmd /C _build_vcpkg.bat Win32 msvc
start "vcpkg x64" cmd /C _build_vcpkg.bat x64 msvc
) | set /P "="
echo.


:DEFINITIONS
set BUILD_SOLUTION=%CD%\NScurl.sln
if "%1" neq "" set BUILD_CONFIG=%~1
Expand Down
12 changes: 10 additions & 2 deletions _build_vcpkg.bat
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ if /i "%compiler%" equ "msvc" if /i "%runtime%" equ "dynamic" set vcpkg_triplet=

set vcpkg_dir=%~dp0vcpkg\%vcpkg_triplet%

title vcpkg -^> %vcpkg_triplet%

REM | -------------------------------------------------------------------------

if /i "%compiler%" equ "mingw" if /i "%arch%" equ "x64" if exist "%SystemDrive%\msys64\mingw64\bin" set PATH=%SystemDrive%\msys64\mingw64\bin;%PATH%
Expand All @@ -41,13 +39,17 @@ if /i "%compiler%" equ "mingw" if /i "%arch%" equ "x86" if exist "%SystemDrive%\
REM | -------------------------------------------------------------------------

if exist "%vcpkg_dir%\.gitignore" (
echo Pull https://github.com/Microsoft/vcpkg.git ...
pushd "%vcpkg_dir%"
git pull --verbose || exit /b !errorlevel!
echo Bootstrapping vcpkg ...
call "%vcpkg_dir%\bootstrap-vcpkg.bat" -disableMetrics || exit /b !errorlevel!
popd
) else (
echo Clone https://github.com/Microsoft/vcpkg.git ...
pushd "%vcpkg_dir%\.."
git clone https://github.com/Microsoft/vcpkg.git "%vcpkg_dir%" || exit /b !errorlevel!
echo Bootstrapping vcpkg ...
call "%vcpkg_dir%\bootstrap-vcpkg.bat" -disableMetrics || exit /b !errorlevel!
popd
)
Expand All @@ -61,6 +63,10 @@ set vcpkg_packages=%vcpkg_dir%\packages
REM set vcpkg_archives=%vcpkg_dir%\archives
set vcpkg_archives=%~dp0vcpkg\archives

echo -------------------------------------------------------------------------
echo Build ^& install vcpkg ...
echo -------------------------------------------------------------------------

mkdir "%vcpkg_dir%" > nul 2> nul
pushd "%vcpkg_dir%"

Expand All @@ -75,4 +81,6 @@ vcpkg.exe ^
--no-print-usage

popd

echo -------------------------------------------------------------------------
exit /b %errorlevel%
16 changes: 14 additions & 2 deletions src/nscurl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,29 @@ RCFLAGS += \
$(CUSTOM_RCFLAGS)


.PHONY: clean all-before all all-after
.PHONY: clean all-before all all-after nsis-sdk curl-ca-bundle vcpkg-install

clean:
@echo.
if exist $(OUTDIR) rd /S /Q $(OUTDIR)

all: all-before $(_BIN) all-after
all: all-before nsis-sdk curl-ca-bundle vcpkg-install $(_BIN) all-after

all-before:
if not exist $(OUTDIR) mkdir $(OUTDIR)

nsis-sdk:
REM ----- NSIS SDK ------------------------------------------------------------
call _acquire_pluginapi.bat

curl-ca-bundle:
REM ----- curl-ca-bundle.crt --------------------------------------------------
call _acquire_curl-ca-bundle.bat

vcpkg-install:
REM ----- vcpkg install -------------------------------------------------------
call ..\..\_build_vcpkg.bat $(ARCH) mingw static

# Link
$(_BIN): $(_OBJ)
@echo.
Expand Down
16 changes: 16 additions & 0 deletions src/nscurl/NScurl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>version.lib;libcurl-d.lib;libcrypto.lib;libssl.lib;nghttp2.lib;zlibd.lib;zstd.lib;brotlicommon.lib;brotlidec.lib;ws2_32.lib;Wldap32.lib;Crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>call _acquire_pluginapi.bat &amp;&amp; call _acquire_curl-ca-bundle.bat &amp;&amp; call "$(SolutionDir)_build_vcpkg.bat" $(Platform) msvc static
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand All @@ -112,6 +116,10 @@
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>version.lib;libcurl-d.lib;libcrypto.lib;libssl.lib;nghttp2.lib;zlibd.lib;zstd.lib;brotlicommon.lib;brotlidec.lib;ws2_32.lib;Wldap32.lib;Crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>call _acquire_pluginapi.bat &amp;&amp; call _acquire_curl-ca-bundle.bat &amp;&amp; call "$(SolutionDir)_build_vcpkg.bat" $(Platform) msvc static
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
Expand All @@ -128,6 +136,10 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>version.lib;libcurl.lib;libcrypto.lib;libssl.lib;nghttp2.lib;zlib.lib;zstd.lib;brotlicommon.lib;brotlidec.lib;ws2_32.lib;Wldap32.lib;Crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>call _acquire_pluginapi.bat &amp;&amp; call _acquire_curl-ca-bundle.bat &amp;&amp; call "$(SolutionDir)_build_vcpkg.bat" $(Platform) msvc static
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
Expand All @@ -143,6 +155,10 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>version.lib;libcurl.lib;libcrypto.lib;libssl.lib;nghttp2.lib;zlib.lib;zstd.lib;brotlicommon.lib;brotlidec.lib;ws2_32.lib;Wldap32.lib;Crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>call _acquire_pluginapi.bat &amp;&amp; call _acquire_curl-ca-bundle.bat &amp;&amp; call "$(SolutionDir)_build_vcpkg.bat" $(Platform) msvc static
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="crypto.c" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@echo off
setlocal enabledelayedexpansion

set outdir=%~dp0src/nscurl
set outdir=%~dp0

echo Downloading curl-ca-bundle.crt ...
echo Downloading https://curl.se/ca/cacert.pem ...
curl --no-progress-meter -L -f -o "%outdir%/curl-ca-bundle.crt" -z "%outdir%/curl-ca-bundle.crt" https://curl.se/ca/cacert.pem || exit /b !errorlevel!

echo.
24 changes: 24 additions & 0 deletions src/nscurl/_acquire_pluginapi.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@echo off
setlocal enabledelayedexpansion

set outdir=%~dp0\nsis
mkdir "%outdir%" > nul 2> nul

if exist "%outdir%/pluginapi.h" if exist "%outdir%/pluginapi.c" if exist "%outdir%/nsis_tchar.h" if exist "%outdir%/api.h" (
echo Use existing NSIS SDK...
exit /b 0
)

set nsis_gitroot=%~dp0..\..\..\..
if exist "%nsis_gitroot%\Source\exehead\api.h" (
echo Copying NSIS SDK...
xcopy "%nsis_gitroot%\Contrib\ExDLL\pluginapi.*" "%outdir%\" /DYI || exit /b !errorlevel!
xcopy "%nsis_gitroot%\Contrib\ExDLL\nsis_tchar.h" "%outdir%\" /DYI || exit /b !errorlevel!
xcopy "%nsis_gitroot%\Source\exehead\api.h" "%outdir%\" /DYI || exit /b !errorlevel!
) else (
echo Downloading NSIS SDK...
curl --no-progress-meter -L -f -o "%outdir%/pluginapi.h" -z "%outdir%/pluginapi.h" https://raw.githubusercontent.com/kichik/nsis/master/Contrib/ExDLL/pluginapi.h || exit /b !errorlevel!
curl --no-progress-meter -L -f -o "%outdir%/pluginapi.c" -z "%outdir%/pluginapi.c" https://raw.githubusercontent.com/kichik/nsis/master/Contrib/ExDLL/pluginapi.c || exit /b !errorlevel!
curl --no-progress-meter -L -f -o "%outdir%/nsis_tchar.h" -z "%outdir%/nsis_tchar.h" https://raw.githubusercontent.com/kichik/nsis/master/Contrib/ExDLL/nsis_tchar.h || exit /b !errorlevel!
curl --no-progress-meter -L -f -o "%outdir%/api.h" -z "%outdir%/api.h" https://raw.githubusercontent.com/kichik/nsis/master/Source/exehead/api.h || exit /b !errorlevel!
)

0 comments on commit 89bdb40

Please sign in to comment.