Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update handling of build variables #422

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@ jobs:
fi
echo "CC=$CC" >> $GITHUB_ENV
- name: Build Debug Target
run: make CC="$CC" debug
run: make debug
- name: Build Release Target
if: ${{ !cancelled() }}
run: make CC="$CC"
run: make
- name: Build TLS Debug Target
if: matrix.arch == 'x64'
run: make CC="$CC" WEBUI_USE_TLS=1 debug
run: make WEBUI_USE_TLS=1 debug
- name: Build TLS Release Target
if: matrix.arch == 'x64'
run: make CC="$CC" WEBUI_USE_TLS=1
run: make WEBUI_USE_TLS=1
- name: Build Examples
if: matrix.arch == 'x64'
run: |
examples_base_dir=$(pwd)/examples/C
for example in $(find $examples_base_dir/* -maxdepth 0 -type d); do
echo "> $example"
cd $example || (exit_code=1 && continue)
if ! make CC="$CC"; then
if ! make; then
echo "Failed to build '$example'"
exit_code=1
continue
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ jobs:
fail-on-cache-miss: true
- name: Setup OpenSSL
run: |
echo "OPENSSL_CFLAGS=$(brew --cellar)/[email protected]/1.1.1w/include/" >> $GITHUB_ENV
echo "OPENSSL_LDFLAGS=$(brew --cellar)/[email protected]/1.1.1w/lib/" >> $GITHUB_ENV
echo "WEBUI_TLS_INCLUDE=$(brew --cellar)/[email protected]/1.1.1w/include/" >> $GITHUB_ENV
echo "WEBUI_TLS_LIB=$(brew --cellar)/[email protected]/1.1.1w/lib/" >> $GITHUB_ENV
- name: Build Debug Target
run: make ARCH_TARGET=${{ matrix.arch }} debug
- name: Build Release Target
if: ${{ !cancelled() }}
run: make ARCH_TARGET=${{ matrix.arch }}
- name: Build TLS Debug Target
run: make WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="$OPENSSL_CFLAGS" WEBUI_TLS_LIB="$OPENSSL_LDFLAGS" debug
run: make WEBUI_USE_TLS=1 debug
- name: Build TLS Release Target
run: make WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="$OPENSSL_CFLAGS" WEBUI_TLS_LIB="$OPENSSL_LDFLAGS"
run: make WEBUI_USE_TLS=1
- name: Build examples
run: |
examples_base_dir=$(pwd)/examples/C
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
fail-fast: false
env:
ARTIFACT: webui-windows-${{ matrix.cc }}-x64
WEBUI_TLS_INCLUDE: "C:\\Program Files\\OpenSSL\\include"
WEBUI_TLS_LIB: "C:\\Program Files\\OpenSSL\\lib"
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
Expand All @@ -54,9 +56,9 @@ jobs:
if: ${{ !cancelled() }}
run: ${{ matrix.make }}
- name: Build TLS Debug Target
run: ${{ matrix.make }} WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="C:\Program Files\OpenSSL\include" WEBUI_TLS_LIB="C:\Program Files\OpenSSL\lib" debug
run: ${{ matrix.make }} WEBUI_USE_TLS=1 debug
- name: Build TLS Release Target
run: ${{ matrix.make }} WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="C:\Program Files\OpenSSL\include" WEBUI_TLS_LIB="C:\Program Files\OpenSSL\lib"
run: ${{ matrix.make }} WEBUI_USE_TLS=1
- name: Build examples
run: |
$examples_base_dir = "$(Get-Location)/examples/C/"
Expand Down
15 changes: 9 additions & 6 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ WEBUI_OUT_LIB_NAME = webui-2

# TLS
WEBUI_USE_TLS =
WEBUI_TLS_INCLUDE = .
WEBUI_TLS_LIB = .
WEBUI_TLS_INCLUDE ?= .
WEBUI_TLS_LIB ?= .
TLS_CFLAG = -DNO_SSL
TLS_LDFLAG_DYNAMIC =
ifeq ($(WEBUI_USE_TLS), 1)
Expand All @@ -25,10 +25,13 @@ MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))
BUILD_DIR := $(MAKEFILE_DIR)/dist

# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
ifneq ($(filter $(CC),gcc clang aarch64-linux-gnu-gcc arm-linux-gnueabihf-gcc musl-gcc),$(CC))
$(error Invalid compiler specified: `$(CC)`)
CC ?= gcc
ifeq ($(CC), cc)
ifeq ($(shell uname),Darwin)
CC = clang
else
CC = gcc
endif
endif

# Allow to add arch-target for macOS CI cross compilation
Expand Down
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,37 @@
# == 1. VARIABLES =============================================================

WEBUI_OUT_LIB_NAME = webui-2

# TLS
WEBUI_USE_TLS =
WEBUI_TLS_INCLUDE = .
WEBUI_TLS_LIB = .
TLS_CFLAG = /D NO_SSL
TLS_LDFLAG_DYNAMIC =

# TLS Enabled
!IF "$(WEBUI_USE_TLS)" == "1"

WEBUI_OUT_LIB_NAME = webui-2-secure
TLS_CFLAG = /D WEBUI_TLS /D NO_SSL_DL /D OPENSSL_API_1_1
TLS_LDFLAG_DYNAMIC = libssl.lib libcrypto.lib

!IF "$(WEBUI_TLS_INCLUDE)" != ""
TLS_CFLAG = $(TLS_CFLAG) /I"$(WEBUI_TLS_INCLUDE)"
!ELSE
TLS_CFLAG = $(TLS_CFLAG) /I"."
!ENDIF

!IF "$(WEBUI_TLS_LIB)" != ""
TLS_LDFLAG_DYNAMIC = $(TLS_LDFLAG_DYNAMIC) /LIBPATH:"$(WEBUI_TLS_LIB)"
!ELSE
TLS_LDFLAG_DYNAMIC += $(TLS_LDFLAG_DYNAMIC) /LIBPATH:"."
!ENDIF

!ENDIF

# Build Flags
CIVETWEB_BUILD_FLAGS = /Fo"civetweb.obj" /c /EHsc "$(MAKEDIR)/src/civetweb/civetweb.c" /I"$(MAKEDIR)/src/civetweb/" /I"$(WEBUI_TLS_INCLUDE)"
CIVETWEB_DEFINE_FLAGS = /D NDEBUG /D NO_CACHING /D NO_CGI /D USE_WEBSOCKET $(TLS_CFLAG)
CIVETWEB_BUILD_FLAGS = /Fo"civetweb.obj" /c /EHsc "$(MAKEDIR)/src/civetweb/civetweb.c" /I"$(MAKEDIR)/src/civetweb/" $(TLS_CFLAG)
CIVETWEB_DEFINE_FLAGS = /D NDEBUG /D NO_CACHING /D NO_CGI /D USE_WEBSOCKET
WEBUI_BUILD_FLAGS = /Fo"webui.obj" /c /EHsc "$(MAKEDIR)/src/webui.c" /I"$(MAKEDIR)/include" /I"$(WEBUI_TLS_INCLUDE)" $(TLS_CFLAG)

# Output Commands
LIB_STATIC_OUT = /OUT:"$(WEBUI_OUT_LIB_NAME)-static.lib" "webui.obj" "civetweb.obj"
LIB_DYN_OUT = /DLL /OUT:"$(WEBUI_OUT_LIB_NAME).dll" "webui.obj" "civetweb.obj" user32.lib Advapi32.lib Shell32.lib Ole32.lib /LIBPATH:"$(WEBUI_TLS_LIB)" $(TLS_LDFLAG_DYNAMIC)
LIB_DYN_OUT = /DLL /OUT:"$(WEBUI_OUT_LIB_NAME).dll" "webui.obj" "civetweb.obj" user32.lib Advapi32.lib Shell32.lib Ole32.lib $(TLS_LDFLAG_DYNAMIC)

# == 2.TARGETS ================================================================

Expand Down