-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is V5.0 pre-release. An official release will be made soon.
- Loading branch information
Showing
291 changed files
with
12,210 additions
and
30,414 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
misc/benchmarks/external/* linguist-vendored | ||
*.h linguist-language=C | ||
*.c linguist-language=C | ||
* text=auto | ||
|
||
*.h linguist-language=C | ||
*.c linguist-language=C |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
meson-build-and-tests: | ||
runs-on: ${{ matrix.platform }} | ||
name: ${{ matrix.platform }}, ${{ matrix.mode.name }} ${{ matrix.flavor }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
flavor: | ||
- debug | ||
- release | ||
mode: | ||
- name: default | ||
args: -Dtests=enabled | ||
extra_envs: {} | ||
|
||
# Alternative compiler setups | ||
- name: gcc | ||
args: -Dtests=enabled | ||
extra_envs: | ||
CC: gcc | ||
CXX: g++ | ||
- name: clang | ||
args: -Dtests=enabled | ||
extra_envs: | ||
CC: clang | ||
CXX: clang++ | ||
|
||
- name: sanitize | ||
args: >- | ||
"-Db_sanitize=address,undefined" | ||
extra_envs: {} | ||
|
||
# This is for MSVC, which only supports AddressSanitizer. | ||
# https://learn.microsoft.com/en-us/cpp/sanitizers/ | ||
- name: sanitize+asanonly | ||
args: -Db_sanitize=address | ||
extra_envs: | ||
ASAN_OPTIONS: report_globals=0:halt_on_error=1:abort_on_error=1:print_summary=1 | ||
|
||
- name: clang+sanitize | ||
args: >- | ||
"-Db_sanitize=address,undefined" | ||
extra_envs: | ||
CC: clang | ||
CXX: clang++ | ||
- name: clang+msan | ||
args: -Db_sanitize=memory | ||
extra_envs: | ||
CC: clang | ||
CXX: clang++ | ||
|
||
# default clang on GitHub hosted runners is from MSYS2. | ||
# Use Visual Studio supplied clang-cl instead. | ||
- name: clang-cl+sanitize | ||
args: >- | ||
"-Db_sanitize=address,undefined" | ||
extra_envs: | ||
CC: clang-cl | ||
CXX: clang-cl | ||
- name: clang-cl+msan | ||
args: -Db_sanitize=memory | ||
extra_envs: | ||
CC: clang-cl | ||
CXX: clang-cl | ||
platform: | ||
- ubuntu-22.04 | ||
- windows-2022 | ||
- macos-latest | ||
|
||
exclude: | ||
# clang-cl only makes sense on windows. | ||
- platform: ubuntu-22.04 | ||
mode: | ||
name: clang-cl+sanitize | ||
- platform: macos-latest | ||
mode: | ||
name: clang-cl+sanitize | ||
- platform: ubuntu-22.04 | ||
mode: | ||
name: clang-cl+msan | ||
- platform: macos-latest | ||
mode: | ||
name: clang-cl+msan | ||
|
||
# Use clang-cl instead of MSYS2 clang. | ||
# | ||
# we already tested clang+sanitize on linux, | ||
# if this doesn't work, it should be an issue for MSYS2 team to consider. | ||
- platform: windows-2022 | ||
mode: | ||
name: clang | ||
- platform: windows-2022 | ||
mode: | ||
name: clang+sanitize | ||
- platform: windows-2022 | ||
mode: | ||
name: clang+msan | ||
|
||
# MSVC-only sanitizers | ||
- platform: ubuntu-22.04 | ||
mode: | ||
name: sanitize+asanonly | ||
- platform: macos-latest | ||
mode: | ||
name: sanitize+asanonly | ||
- platform: windows-2022 | ||
mode: | ||
name: sanitize | ||
|
||
# clang is the default on macos | ||
# also gcc is an alias to clang | ||
- platform: macos-latest | ||
mode: | ||
name: clang | ||
- platform: macos-latest | ||
mode: | ||
name: gcc | ||
|
||
# gcc is the default on linux | ||
- platform: ubuntu-22.04 | ||
mode: | ||
name: gcc | ||
|
||
# only run sanitizer tests on linux | ||
# | ||
# gcc/clang's codegen shouldn't massively change across platforms, | ||
# and linux supports most of the sanitizers. | ||
- platform: macos-latest | ||
mode: | ||
name: clang+sanitize | ||
- platform: macos-latest | ||
mode: | ||
# macos does not support msan | ||
name: clang+msan | ||
- platform: macos-latest | ||
mode: | ||
name: sanitize | ||
steps: | ||
- name: Setup meson | ||
run: | | ||
pipx install meson ninja | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Activate MSVC and Configure | ||
if: ${{ matrix.platform == 'windows-2022' }} | ||
env: ${{ matrix.mode.extra_envs }} | ||
run: | | ||
meson setup build-${{ matrix.flavor }} --buildtype=${{ matrix.flavor }} ${{ matrix.mode.args }} --vsenv | ||
- name: Configuring | ||
if: ${{ matrix.platform != 'windows-2022' }} | ||
env: ${{ matrix.mode.extra_envs }} | ||
run: | | ||
meson setup build-${{ matrix.flavor }} --buildtype=${{ matrix.flavor }} ${{ matrix.mode.args }} | ||
- name: Building | ||
run: | | ||
meson compile -C build-${{ matrix.flavor }} | ||
- name: Running tests | ||
env: ${{ matrix.mode.extra_envs }} | ||
run: | | ||
meson test -C build-${{ matrix.flavor }} --timeout-multiplier 5 | ||
- uses: actions/upload-artifact@v4 | ||
if: failure() | ||
with: | ||
name: ${{ matrix.platform }}-${{ matrix.mode.name }}-${{ matrix.flavor }}-logs | ||
path: build-${{ matrix.flavor }}/meson-logs |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# Folders | ||
stuff/* | ||
misc/benchmarks/external/* | ||
|
||
# Prerequisites | ||
*.d | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# GNU Makefile for STC. Linux/Mac + Windows for gcc, clang and tcc (TinyC). | ||
# On Windows, makefile requires mkdir, rm, and printf, which are all | ||
# found in the C:\Program Files\Git\usr\bin folder. | ||
# Use 'make CC=gcc' (or clang or tcc), or set CC in the environment. | ||
# Currently only release build. | ||
|
||
ifeq ($(origin CC),default) | ||
CC := gcc | ||
endif | ||
ifeq ($(origin CXX),default) | ||
CXX := g++ | ||
endif | ||
|
||
CFLAGS ?= -std=c11 -Iinclude -MMD -O3 -Wpedantic -Wall -Wextra -Werror -Wno-missing-field-initializers | ||
CXXFLAGS ?= -std=c++20 -Iinclude -O3 -MMD -Wall | ||
LDFLAGS ?= | ||
ifeq ($(CC:.exe=),tcc) | ||
AR_RCS ?= tcc -ar rcs | ||
else | ||
AR_RCS ?= ar rcs | ||
endif | ||
MKDIR_P ?= mkdir -p | ||
RM_F ?= rm -f | ||
|
||
ifeq ($(OS),Windows_NT) | ||
DOTEXE := .exe | ||
BUILDDIR := bld_Windows/$(CC:.exe=) | ||
else | ||
BUILDDIR := bld_$(shell uname)/$(CC) | ||
LDFLAGS += -lm | ||
CFLAGS += -Wno-clobbered | ||
endif | ||
|
||
OBJ_DIR := $(BUILDDIR) | ||
|
||
LIB_NAME := stc | ||
LIB_LIST := cstr_core cstr_io cstr_utf8 cregex csview cspan fmt random stc_core | ||
LIB_SRCS := $(LIB_LIST:%=src/%.c) | ||
LIB_OBJS := $(LIB_SRCS:%.c=$(OBJ_DIR)/%.o) | ||
LIB_DEPS := $(LIB_SRCS:%.c=$(OBJ_DIR)/%.d) | ||
LIB_PATH := $(BUILDDIR)/lib$(LIB_NAME).a | ||
|
||
EX_SRCS := $(wildcard examples/*/*.c) | ||
EX_OBJS := $(EX_SRCS:%.c=$(OBJ_DIR)/%.o) | ||
EX_DEPS := $(EX_SRCS:%.c=$(OBJ_DIR)/%.d) | ||
EX_EXES := $(EX_SRCS:%.c=$(OBJ_DIR)/%$(DOTEXE)) | ||
|
||
TEST_SRCS := $(wildcard tests/*_test.c) tests/main.c | ||
TEST_OBJS := $(TEST_SRCS:%.c=$(OBJ_DIR)/%.o) | ||
TEST_DEPS := $(TEST_SRCS:%.c=$(OBJ_DIR)/%.d) | ||
TEST_EXE := $(OBJ_DIR)/tests/test_all$(DOTEXE) | ||
|
||
fast: | ||
@$(MAKE) -j --no-print-directory all | ||
|
||
all: $(LIB_PATH) $(EX_EXES) $(TEST_EXE) | ||
|
||
clean: | ||
@$(RM_F) $(LIB_OBJS) $(TEST_OBJS) $(EX_OBJS) $(LIB_DEPS) $(EX_DEPS) $(LIB_PATH) $(EX_EXES) $(TEST_EXE) | ||
@echo "Cleaned" | ||
|
||
distclean: | ||
$(RM_F) $(OBJ_DIR) | ||
|
||
lib: $(LIB_PATH) | ||
|
||
$(LIB_PATH): $(LIB_OBJS) | ||
@printf "\r\e[2K%s" "$(AR_RCS) $@" | ||
@$(AR_RCS) $@ $(LIB_OBJS) | ||
|
||
$(OBJ_DIR)/%.o: %.c | ||
@$(MKDIR_P) $(@D) | ||
@printf "\r\e[2K%s" "$(CC) $< -c -o $@" | ||
@$(CC) $< -c -o $@ $(CFLAGS) | ||
|
||
$(OBJ_DIR)/%.o: %.cpp | ||
@$(MKDIR_P) $(@D) | ||
@printf "\r\e[2K%s" "$(CXX) $< -c -o $@" | ||
@$(CXX) $< -c -o $@ $(CXXFLAGS) | ||
|
||
$(OBJ_DIR)/%$(DOTEXE): %.c $(LIB_PATH) | ||
@$(MKDIR_P) $(@D) | ||
@printf "\r\e[2K%s" "$(CC) -o $(@F) $< -s $(LDFLAGS) -L$(BUILDDIR) -l$(LIB_NAME)" | ||
@$(CC) -o $@ $(CFLAGS) -s $< $(LDFLAGS) -L$(BUILDDIR) -l$(LIB_NAME) | ||
|
||
$(TEST_EXE): $(TEST_OBJS) | ||
@printf "\r\e[2K%s" "$(CC) -o $@" | ||
@$(CC) -o $@ $(TEST_OBJS) -s $(LDFLAGS) -L$(BUILDDIR) -l$(LIB_NAME) | ||
|
||
|
||
.SECONDARY: $(EX_OBJS) # Prevent deleting objs after building | ||
.PHONY: fast all clean distclean lib | ||
|
||
-include $(LIB_DEPS) $(EX_DEPS) |
Oops, something went wrong.