Skip to content

Commit 5c1c591

Browse files
authored
Added ability to use system curl (#2275)
1 parent ffcb779 commit 5c1c591

File tree

11 files changed

+59
-33
lines changed

11 files changed

+59
-33
lines changed

.github/workflows/ci-workflow.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@ jobs:
99
matrix:
1010
config: [debug, release]
1111
platform: [x64]
12+
depsrc: [none, contrib, system]
1213
steps:
1314
- name: Checkout
1415
uses: actions/checkout@v4
16+
- name: Install dependencies
17+
if: matrix.depsrc == 'system'
18+
run: sudo apt-get install libcurl4-openssl-dev
1519
- name: Build
16-
run: PLATFORM=${{ matrix.platform }} CONFIG=${{ matrix.config }} ./Bootstrap.sh
20+
run: PLATFORM=${{ matrix.platform }} CONFIG=${{ matrix.config }} PREMAKE_OPTS="--curl-src=${{ matrix.depsrc }}" ./Bootstrap.sh
1721
- name: Test
1822
run: bin/${{ matrix.config }}/premake5 test --test-all
1923
- name: Docs check
2024
run: bin/${{ matrix.config }}/premake5 docs-check
2125
- name: Upload Artifacts
22-
if: matrix.config == 'release'
26+
if: matrix.config == 'release' && matrix.depsrc == 'contrib'
2327
uses: actions/upload-artifact@v4
2428
with:
2529
name: premake-linux-${{ matrix.platform }}

Bootstrap.mak

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CONFIG = release
33
PLATFORM = x86
44
LUA_DIR = contrib/lua/src
55
LUASHIM_DIR = contrib/luashim
6+
PREMAKE_OPTS =
67

78
SRC = src/host/*.c \
89
$(LUA_DIR)/lapi.c \
@@ -87,7 +88,7 @@ mingw: mingw-clean
8788
mkdir -p build/bootstrap
8889
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lole32 -lversion
8990
./build/bootstrap/premake_bootstrap embed
90-
./build/bootstrap/premake_bootstrap --arch=$(PLATFORM) --os=windows --to=build/bootstrap --cc=mingw gmake2
91+
./build/bootstrap/premake_bootstrap --arch=$(PLATFORM) --os=windows --to=build/bootstrap --cc=mingw $(PREMAKE_OPTS) gmake2
9192
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)_$(PLATFORM:x86=win32)
9293

9394
macosx: osx
@@ -100,7 +101,7 @@ osx: osx-clean
100101
mkdir -p build/bootstrap
101102
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_MACOSX -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" -framework CoreServices -framework Foundation -framework Security -lreadline $(SRC)
102103
./build/bootstrap/premake_bootstrap embed
103-
./build/bootstrap/premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap gmake2
104+
./build/bootstrap/premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap $(PREMAKE_OPTS) gmake2
104105
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)
105106

106107
linux-clean: nix-clean
@@ -109,7 +110,7 @@ linux: linux-clean
109110
mkdir -p build/bootstrap
110111
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lm -ldl -lrt -luuid
111112
./build/bootstrap/premake_bootstrap embed
112-
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
113+
./build/bootstrap/premake_bootstrap --to=build/bootstrap $(PREMAKE_OPTS) gmake2
113114
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)
114115

115116
bsd-clean: nix-clean
@@ -118,7 +119,7 @@ bsd: bsd-clean
118119
mkdir -p build/bootstrap
119120
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lm
120121
./build/bootstrap/premake_bootstrap embed
121-
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
122+
./build/bootstrap/premake_bootstrap --to=build/bootstrap $(PREMAKE_OPTS) gmake2
122123
$(MAKE) -C build/bootstrap -j`getconf NPROCESSORS_ONLN` config=$(CONFIG)
123124

124125
solaris-clean: nix-clean
@@ -127,7 +128,7 @@ solaris: solaris-clean
127128
mkdir -p build/bootstrap
128129
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lm
129130
./build/bootstrap/premake_bootstrap embed
130-
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
131+
./build/bootstrap/premake_bootstrap --to=build/bootstrap $(PREMAKE_OPTS) gmake2
131132
$(MAKE) -C build/bootstrap -j`getconf NPROCESSORS_ONLN` config=$(CONFIG)
132133

133134
haiku-clean: nix-clean
@@ -136,14 +137,14 @@ haiku: haiku-clean
136137
mkdir -p build/bootstrap
137138
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_BSD_SOURCE -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lbsd
138139
./build/bootstrap/premake_bootstrap embed
139-
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
140+
./build/bootstrap/premake_bootstrap --to=build/bootstrap $(PREMAKE_OPTS) gmake2
140141
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)
141142

142143
windows-base: windows-clean
143144
if not exist build\bootstrap (mkdir build\bootstrap)
144145
cl /Fo.\build\bootstrap\ /Fe.\build\bootstrap\premake_bootstrap.exe /DPREMAKE_NO_BUILTIN_SCRIPTS /I"$(LUA_DIR)" /I"$(LUASHIM_DIR)" user32.lib ole32.lib advapi32.lib $(SRC)
145146
.\build\bootstrap\premake_bootstrap.exe embed
146-
.\build\bootstrap\premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap $(MSDEV)
147+
.\build\bootstrap\premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap $(PREMAKE_OPTS) $(MSDEV)
147148

148149
windows: windows-base
149150
devenv .\build\bootstrap\Premake5.sln /Upgrade

Bootstrap.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ done
1313

1414
PLATFORM_ARG=""
1515
CONFIG_ARG=""
16+
PREMAKE_OPTS_ARG=""
1617

1718
if [ -n "$PLATFORM" ]; then
1819
PLATFORM_ARG="PLATFORM=$PLATFORM"
@@ -22,21 +23,25 @@ if [ -n "$CONFIG" ]; then
2223
CONFIG_ARG="CONFIG=$CONFIG"
2324
fi
2425

26+
if [ -n "$PREMAKE_OPTS" ]; then
27+
PREMAKE_OPTS_ARG="PREMAKE_OPTS=$PREMAKE_OPTS"
28+
fi
29+
2530
case "$(uname -s)" in
2631
Linux)
2732
NPROC=$(nproc --all)
28-
make -f Bootstrap.mak ${COSMO_FLAG:-linux} $PLATFORM_ARG $CONFIG_ARG -j$NPROC
33+
make -f Bootstrap.mak ${COSMO_FLAG:-linux} $PLATFORM_ARG $CONFIG_ARG $PREMAKE_OPTS_ARG -j$NPROC
2934
;;
3035
Darwin)
3136
NPROC=$(sysctl -n hw.ncpu)
32-
make -f Bootstrap.mak ${COSMO_FLAG:-osx} $PLATFORM_ARG $CONFIG_ARG -j$NPROC
37+
make -f Bootstrap.mak ${COSMO_FLAG:-osx} $PLATFORM_ARG $CONFIG_ARG $PREMAKE_OPTS_ARG -j$NPROC
3338
;;
3439
FreeBSD|OpenBSD|NetBSD)
3540
NPROC=$(sysctl -n hw.ncpu)
36-
make -f Bootstrap.mak ${COSMO_FLAG:-bsd} $PLATFORM_ARG $CONFIG_ARG -j$NPROC
41+
make -f Bootstrap.mak ${COSMO_FLAG:-bsd} $PLATFORM_ARG $CONFIG_ARG $PREMAKE_OPTS_ARG -j$NPROC
3742
;;
3843
CYGWIN*|MINGW32*|MSYS*|MINGW*)
39-
make -f Bootstrap.mak ${COSMO_FLAG:-mingw} $PLATFORM_ARG $CONFIG_ARG -j$NPROC
44+
make -f Bootstrap.mak ${COSMO_FLAG:-mingw} $PLATFORM_ARG $CONFIG_ARG $PREMAKE_OPTS_ARG -j$NPROC
4045
;;
4146
*)
4247
echo "Unsupported platform"

modules/vstudio/tests/cs2005/test_assembly_refs.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
-- NuGet packages should get references.
203203
--
204204

205-
if _OPTIONS["test-all"] then
205+
if http ~= nil and _OPTIONS["test-all"] then
206206
function suite.nuGetPackages_net45()
207207
dotnetframework "4.5"
208208
nuget { "Newtonsoft.Json:10.0.2" }
@@ -250,7 +250,7 @@ end
250250
-- referenced.
251251
--
252252

253-
if _OPTIONS["test-all"] then
253+
if http ~= nil and _OPTIONS["test-all"] then
254254
function suite.nuGetPackages_multipleAssemblies()
255255
dotnetframework "2.0"
256256
nuget { "NUnit:3.6.1" }
@@ -285,7 +285,7 @@ end
285285
-- NuGet packages should respect copylocal() and the NoCopyLocal flag.
286286
--
287287

288-
if _OPTIONS["test-all"] then
288+
if http ~= nil and _OPTIONS["test-all"] then
289289
function suite.nugetPackages_onNoCopyLocal()
290290
dotnetframework "2.0"
291291
nuget { "NUnit:3.6.1" }
@@ -380,7 +380,7 @@ end
380380
-- properly.
381381
--
382382

383-
if _OPTIONS["test-all"] then
383+
if http ~= nil and _OPTIONS["test-all"] then
384384
function suite.nuGetPackages_netFolder()
385385
dotnetframework "4.5"
386386
nuget { "MetroModernUI:1.4.0" }

modules/vstudio/tests/cs2005/test_nuget_references.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
-- Check that we process Unix-style paths correctly.
3333
--
3434

35-
if _OPTIONS["test-all"] then
35+
if http ~= nil and _OPTIONS["test-all"] then
3636
function suite.unixPaths()
3737
dotnetframework "4.6"
3838
nuget "Mono.Cecil:0.9.6.4"

modules/vstudio/tests/vc2010/test_ensure_nuget_imports.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
-- Writes the pre-build check that makes sure that all packages are installed.
4343
--
4444

45-
if _OPTIONS["test-all"] then
45+
if http ~= nil and _OPTIONS["test-all"] then
4646
function suite.structureIsCorrect()
4747
nuget { "boost:1.59.0-b1", "sdl2.v140:2.0.3", "sdl2.v140.redist:2.0.3", "WinPixEventRuntime:1.0.220810001", "Microsoft.Direct3D.D3D12:1.608.2" }
4848
prepare()

modules/vstudio/tests/vc2010/test_extension_settings.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
-- Writes entries only for nuget packages with props files.
3333
--
3434

35-
if _OPTIONS["test-all"] then
35+
if http ~= nil and _OPTIONS["test-all"] then
3636
function suite.importOnlyNugetPackagesWithProps()
3737
nuget { "boost:1.59.0-b1", "sdl2.v140:2.0.3", "sdl2.v140.redist:2.0.3", "WinPixEventRuntime:1.0.220810001", "Microsoft.Direct3D.D3D12:1.608.2" }
3838
prepare()

modules/vstudio/tests/vc2010/test_extension_targets.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
-- Writes entries for NuGet packages.
6464
--
6565

66-
if _OPTIONS["test-all"] then
66+
if http ~= nil and _OPTIONS["test-all"] then
6767
function suite.addsImport_onEachNuGetPackage()
6868
nuget { "boost:1.59.0-b1", "sdl2.v140:2.0.3", "sdl2.v140.redist:2.0.3", "WinPixEventRuntime:1.0.220810001", "Microsoft.Direct3D.D3D12:1.608.2" }
6969
prepare()

modules/vstudio/vs2010_nuget.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@
410410

411411
function nuget2010.NuGetHasHTTP(prj)
412412
if not http and #prj.nuget > 0 and not nuget2010.supportsPackageReferences(prj) then
413-
p.error("Premake was compiled with --no-curl, but Curl is required for NuGet support (project '%s' is referencing NuGet packages)", prj.name)
413+
p.error("Premake was compiled with --curl-src=none, but Curl is required for NuGet support (project '%s' is referencing NuGet packages)", prj.name)
414414
end
415415
end
416416

premake5.lua

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,25 @@
7878
}
7979

8080

81+
newoption {
82+
trigger = "curl-src",
83+
description = "Specify the source of the Curl 3rd party library",
84+
allowed = {
85+
{ "none", "Disables Curl" },
86+
{ "contrib", "Uses Curl in contrib folder" },
87+
{ "system", "Uses Curl from the host system" },
88+
},
89+
default = "contrib",
90+
}
91+
8192
newoption {
8293
trigger = "no-curl",
8394
description = "Disable Curl 3rd party lib"
8495
}
96+
if _OPTIONS["no-curl"] then
97+
premake.warn("--no-curl is deprecated, please use --curl-src=none")
98+
_OPTIONS["curl-src"] = "none"
99+
end
85100

86101

87102
newoption {
@@ -139,9 +154,10 @@
139154
defines { "PREMAKE_COMPRESSION" }
140155
end
141156

142-
if not _OPTIONS["no-curl"] then
143-
defines { "CURL_STATICLIB", "PREMAKE_CURL"}
144-
end
157+
filter { "options:not curl-src=none" }
158+
defines { "PREMAKE_CURL" }
159+
filter { "options:curl-src=contrib" }
160+
defines { "CURL_STATICLIB" }
145161

146162
filter { "system:macosx", "options:arch=ARM or arch=ARM64" }
147163
buildoptions { "-arch arm64" }
@@ -206,10 +222,12 @@
206222
links { "zip-lib", "zlib-lib" }
207223
end
208224

209-
if not _OPTIONS["no-curl"] then
225+
filter { "options:curl-src=contrib" }
210226
includedirs { "contrib/curl/include" }
211227
links { "curl-lib" }
212-
end
228+
filter { "options:curl-src=system" }
229+
links { "curl" }
230+
filter {}
213231

214232
files
215233
{
@@ -247,10 +265,8 @@
247265
filter "system:linux or hurd"
248266
links { "dl", "rt" }
249267

250-
filter { "system:not windows", "system:not macosx" }
251-
if not _OPTIONS["no-curl"] then
252-
links { "mbedtls-lib" }
253-
end
268+
filter { "system:not windows", "system:not macosx", "options:curl-src=contrib" }
269+
links { "mbedtls-lib" }
254270

255271
filter "system:macosx"
256272
defines { "LUA_USE_MACOSX" }
@@ -303,7 +319,7 @@ end
303319
include "contrib/libzip"
304320
end
305321

306-
if not _OPTIONS["no-curl"] then
322+
if _OPTIONS["curl-src"] == "contrib" then
307323
include "contrib/mbedtls"
308324
include "contrib/curl"
309325
end

0 commit comments

Comments
 (0)