Skip to content

Commit

Permalink
Added ability to use system curl
Browse files Browse the repository at this point in the history
  • Loading branch information
samsinsane committed Oct 3, 2024
1 parent e306e42 commit 72c6f24
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 29 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ jobs:
matrix:
config: [debug, release]
platform: [x64]
depsrc: [none, contrib, system]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
if: matrix.depsrc == 'system'
run: sudo apt-get install libcurl4-openssl-dev
- name: Build
run: make -f Bootstrap.mak linux PLATFORM=${{ matrix.platform }} CONFIG=${{ matrix.config }}
run: make -f Bootstrap.mak linux PLATFORM=${{ matrix.platform }} CONFIG=${{ matrix.config }} PREMAKE_OPTS="--curl-src=${{ matrix.depsrc }}"
- name: Test
run: bin/${{ matrix.config }}/premake5 test --test-all
- name: Docs check
run: bin/${{ matrix.config }}/premake5 docs-check
- name: Upload Artifacts
if: matrix.config == 'release'
if: matrix.config == 'release' && matrix.depsrc == 'contrib'
uses: actions/upload-artifact@v4
with:
name: premake-linux-${{ matrix.platform }}
Expand Down
15 changes: 8 additions & 7 deletions Bootstrap.mak
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CONFIG = release
PLATFORM = x86
LUA_DIR = contrib/lua/src
LUASHIM_DIR = contrib/luashim
PREMAKE_OPTS =

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

macosx: osx
Expand All @@ -100,7 +101,7 @@ osx: osx-clean
mkdir -p build/bootstrap
$(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)
./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap gmake2
./build/bootstrap/premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap $(PREMAKE_OPTS) gmake2
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)

linux-clean: nix-clean
Expand All @@ -109,7 +110,7 @@ linux: linux-clean
mkdir -p build/bootstrap
$(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
./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
./build/bootstrap/premake_bootstrap --to=build/bootstrap $(PREMAKE_OPTS) gmake2
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)

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

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

haiku-clean: nix-clean
Expand All @@ -136,14 +137,14 @@ haiku: haiku-clean
mkdir -p build/bootstrap
$(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
./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2
./build/bootstrap/premake_bootstrap --to=build/bootstrap $(PREMAKE_OPTS) gmake2
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)

windows-base: windows-clean
if not exist build\bootstrap (mkdir build\bootstrap)
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)
.\build\bootstrap\premake_bootstrap.exe embed
.\build\bootstrap\premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap $(MSDEV)
.\build\bootstrap\premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap $(PREMAKE_OPTS) $(MSDEV)

windows: windows-base
devenv .\build\bootstrap\Premake5.sln /Upgrade
Expand Down
8 changes: 4 additions & 4 deletions modules/vstudio/tests/cs2005/test_assembly_refs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
-- NuGet packages should get references.
--

if _OPTIONS["test-all"] then
if http ~= nil and _OPTIONS["test-all"] then
function suite.nuGetPackages_net45()
dotnetframework "4.5"
nuget { "Newtonsoft.Json:10.0.2" }
Expand Down Expand Up @@ -250,7 +250,7 @@ end
-- referenced.
--

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

if _OPTIONS["test-all"] then
if http ~= nil and _OPTIONS["test-all"] then
function suite.nugetPackages_onNoCopyLocal()
dotnetframework "2.0"
nuget { "NUnit:3.6.1" }
Expand Down Expand Up @@ -380,7 +380,7 @@ end
-- properly.
--

if _OPTIONS["test-all"] then
if http ~= nil and _OPTIONS["test-all"] then
function suite.nuGetPackages_netFolder()
dotnetframework "4.5"
nuget { "MetroModernUI:1.4.0" }
Expand Down
2 changes: 1 addition & 1 deletion modules/vstudio/tests/cs2005/test_nuget_references.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
-- Check that we process Unix-style paths correctly.
--

if _OPTIONS["test-all"] then
if http ~= nil and _OPTIONS["test-all"] then
function suite.unixPaths()
dotnetframework "4.6"
nuget "Mono.Cecil:0.9.6.4"
Expand Down
2 changes: 1 addition & 1 deletion modules/vstudio/tests/vc2010/test_ensure_nuget_imports.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
-- Writes the pre-build check that makes sure that all packages are installed.
--

if _OPTIONS["test-all"] then
if http ~= nil and _OPTIONS["test-all"] then
function suite.structureIsCorrect()
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" }
prepare()
Expand Down
2 changes: 1 addition & 1 deletion modules/vstudio/tests/vc2010/test_extension_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
-- Writes entries only for nuget packages with props files.
--

if _OPTIONS["test-all"] then
if http ~= nil and _OPTIONS["test-all"] then
function suite.importOnlyNugetPackagesWithProps()
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" }
prepare()
Expand Down
2 changes: 1 addition & 1 deletion modules/vstudio/tests/vc2010/test_extension_targets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
-- Writes entries for NuGet packages.
--

if _OPTIONS["test-all"] then
if http ~= nil and _OPTIONS["test-all"] then
function suite.addsImport_onEachNuGetPackage()
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" }
prepare()
Expand Down
2 changes: 1 addition & 1 deletion modules/vstudio/vs2010_nuget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@

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

Expand Down
36 changes: 26 additions & 10 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,25 @@
}


newoption {
trigger = "curl-src",
description = "Specify the source of the Curl 3rd party library",
allowed = {
{ "none", "Disables Curl" },
{ "contrib", "Uses Curl in contrib folder" },
{ "system", "Uses Curl from the host system" },
},
default = "contrib",
}

newoption {
trigger = "no-curl",
description = "Disable Curl 3rd party lib"
}
if _OPTIONS["no-curl"] then
premake.warn("--no-curl is deprecated, please use --curl-src=none")
_OPTIONS["curl-src"] = "none"
end


newoption {
Expand Down Expand Up @@ -139,9 +154,10 @@
defines { "PREMAKE_COMPRESSION" }
end

if not _OPTIONS["no-curl"] then
defines { "CURL_STATICLIB", "PREMAKE_CURL"}
end
filter { "options:not curl-src=none" }
defines { "PREMAKE_CURL" }
filter { "options:curl-src=contrib" }
defines { "CURL_STATICLIB" }

filter { "system:macosx", "options:arch=ARM or arch=ARM64" }
buildoptions { "-arch arm64" }
Expand Down Expand Up @@ -206,10 +222,12 @@
links { "zip-lib", "zlib-lib" }
end

if not _OPTIONS["no-curl"] then
filter { "options:curl-src=contrib" }
includedirs { "contrib/curl/include" }
links { "curl-lib" }
end
filter { "options:curl-src=system" }
links { "curl" }
filter {}

files
{
Expand Down Expand Up @@ -247,10 +265,8 @@
filter "system:linux or hurd"
links { "dl", "rt" }

filter { "system:not windows", "system:not macosx" }
if not _OPTIONS["no-curl"] then
links { "mbedtls-lib" }
end
filter { "system:not windows", "system:not macosx", "options:curl-src=contrib" }
links { "mbedtls-lib" }

filter "system:macosx"
defines { "LUA_USE_MACOSX" }
Expand Down Expand Up @@ -284,7 +300,7 @@
include "contrib/libzip"
end

if not _OPTIONS["no-curl"] then
if _OPTIONS["curl-src"] == "contrib" then
include "contrib/mbedtls"
include "contrib/curl"
end
Expand Down
2 changes: 1 addition & 1 deletion tests/base/test_http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-- Copyright (c) 2016, 2020 Jason Perkins and the Premake project
--

if http.get ~= nil and _OPTIONS["test-all"] then
if http ~= nil and http.get ~= nil and _OPTIONS["test-all"] then
local p = premake

local suite = test.declare("premake_http")
Expand Down

0 comments on commit 72c6f24

Please sign in to comment.