diff --git a/devel/Makefile b/devel/Makefile --- a/devel/Makefile +++ b/devel/Makefile @@ -166,6 +166,7 @@ SUBDIR += R-cran-zeallot SUBDIR += RStudio SUBDIR += SpecTcl + SUBDIR += STC SUBDIR += aarch64-none-elf-gcc SUBDIR += abi-compliance-checker SUBDIR += abseil diff --git a/devel/STC/Makefile b/devel/STC/Makefile new file mode 100644 --- /dev/null +++ b/devel/STC/Makefile @@ -0,0 +1,28 @@ +PORTNAME= STC +DISTVERSIONPREFIX= v +DISTVERSION= 5.0 +CATEGORIES= devel + +MAINTAINER= alven@FreeBSD.org +COMMENT= Modern, user friendly, generic, type-safe and fast C99 container library +WWW= https://github.com/stclib/STC/ + +LICENSE= MIT +LICENSE_FILE= ${WRKSRC}/LICENSE + +USES= meson +USE_GITHUB= yes +GH_ACCOUNT= stclib +USE_LDCONFIG= yes + +OPTIONS_DEFINE= DOCS EXAMPLES STATIC +OPTIONS_SUB= yes + +DOCS_MESON_ENABLED= docs +DOCS_MESON_ON= -Ddocsdir=${DOCSDIR} +EXAMPLES_MESON_ENABLED= examples +EXAMPLES_MESON_ON= -Dexamplesdir=${EXAMPLESDIR} +STATIC_MESON_ON= -Ddefault_library=both +STATIC_MESON_OFF= -Ddefault_library=shared + +.include diff --git a/devel/STC/distinfo b/devel/STC/distinfo new file mode 100644 --- /dev/null +++ b/devel/STC/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1736794242 +SHA256 (stclib-STC-v5.0_GH0.tar.gz) = d61353852b9d7ef69b56fa32edcbc7934f2153385f3778536234201ceebcc950 +SIZE (stclib-STC-v5.0_GH0.tar.gz) = 972147 diff --git a/devel/STC/files/patch-meson.build b/devel/STC/files/patch-meson.build new file mode 100644 --- /dev/null +++ b/devel/STC/files/patch-meson.build @@ -0,0 +1,47 @@ +--- meson.build.orig 2025-01-12 20:41:47 UTC ++++ meson.build +@@ -144,19 +144,33 @@ root = not meson.is_subproject() + endif + + root = not meson.is_subproject() +-subdir('tests') +-subdir('examples') + + if root +- datadir = get_option('datadir') +- docdir = get_option('docdir') +- if docdir == '' +- docdir = datadir / 'doc' / meson.project_name() ++ if get_option('docs').enabled() ++ docsdir = get_option('docsdir') ++ ++ install_data('README.md', install_dir: docsdir) ++ ++ install_subdir( ++ 'docs', ++ install_dir: docsdir, ++ strip_directory: true ++ ) + endif + +- install_subdir( +- 'docs', +- install_dir: docdir, +- strip_directory: true, +- ) ++ if get_option('examples').enabled() ++ examplesdir = get_option('examplesdir') ++ ++ subdir('examples') ++ ++ install_subdir( ++ 'examples', ++ install_dir: examplesdir, ++ strip_directory: true ++ ) ++ endif ++ ++ if get_option('tests').enabled() ++ subdir('tests') ++ endif + endif diff --git a/devel/STC/files/patch-meson__options.txt b/devel/STC/files/patch-meson__options.txt new file mode 100644 --- /dev/null +++ b/devel/STC/files/patch-meson__options.txt @@ -0,0 +1,29 @@ +--- meson_options.txt.orig 2025-01-14 15:37:45 UTC ++++ meson_options.txt +@@ -5,10 +5,10 @@ option( + description: 'Build checkscoped tool for c_guard* blocks', + ) + option( +- 'tests', ++ 'docs', + type: 'feature', + value: 'auto', +- description: 'Build tests and ctest', ++ description: 'Build documentation', + ) + option( + 'examples', +@@ -16,5 +16,12 @@ option( + value: 'auto', + description: 'Build examples', + ) ++option( ++ 'tests', ++ type: 'feature', ++ value: 'auto', ++ description: 'Build tests and ctest', ++) + +-option('docdir', type: 'string', description: 'documentation directory') ++option('docsdir', type: 'string', description: 'documentation directory') ++option('examplesdir', type: 'string', description: 'examples directory') diff --git a/devel/STC/pkg-descr b/devel/STC/pkg-descr new file mode 100644 --- /dev/null +++ b/devel/STC/pkg-descr @@ -0,0 +1,54 @@ +STC is a comprehensive, modern, typesafe and fast templated general purpose +container and algorithms library for C99. It aims to make C-programming even +more fun, more productive and safer. + +* Reasons why you want to you use STC: + +C is still among the most popular programming languages, despite the fact that +it was created as early as in 1972. That is a manifestation of how well the +language was designed for its time, and still is. However, times are changing, +and C is starting to lag behind many of the new upcoming system languages like +Zig, Odin and Rust with regard to features in the standard library, but also +when it comes to safety and vulnerabilities. STC aims to bridge some of that +gap, to let us have common modern features and added safety, while we still can +enjoy writing C. + +* Missing features in the C standard library, which STC provides: + +- A wide set of high performance, generic/templated typesafe container types, + including smart pointers and bitsets. +- String type with utf8 support and short string optimization (sso), plus two + string-view types. +- Typesafe and ergonomic sum type implementation, aka. tagged union or variant. +- A coroutine implementation with excellent ergonomics, error recovery and + cleanup support. +- Fast, modern regular expressions with full utf8 and a subset of unicode + character classes support. +- Ranges algorithms like iota and filter views like take, skip, take-while, + skip-while, map. +- Generic algorithms, iterators and loop abstactions. Blazing fast sort, binary + search and lower bound. +- Single/multi-dimensional generic span view with arbitrary array dimensions + (numpy array-like slicing). + +* Improved safety by using STC: + +- Abstractions for raw loops, ranged iteration over containers, and generic + ranges algorithms. All this reduces the chance of creating bugs, as user code + with raw loops and ad-hoc implementation of common algorithms and containers + is minimized/eliminated. +- STC is inherently type safe. Essentially, there are no opaque pointers or + casting away of type information. Only where neccesary, generic code will use + some macros to do compile-time type-checking before types are casted. Examples + are c_static_assert, c_const_cast, c_safe_cast and macros for safe integer + type casting. +- Containers and algorithms all use signed integers for indices and sizes, and + it encourange to use signed integers for quantities in general (unsigned + integers have valid usages as bitsets and in bit operations). This could + remove a wide range of bugs related to mixed unsigned-signed calculations and + comparisons, which intuitively gives the wrong answer in many cases. +- Tagged unions in C are common, but normally unsafely + implemented. Traditionally, it leaves the inactive payload data readily + accesible to user code, and there is no general way to ensure that the payload + is assigned along with the tag, or that they match. STC sum type is a typesafe + version of tagged unions which eliminates all those safety concerns. diff --git a/devel/STC/pkg-plist b/devel/STC/pkg-plist new file mode 100644 --- /dev/null +++ b/devel/STC/pkg-plist @@ -0,0 +1,183 @@ +include/c11/fmt.h +include/stc/algorithm.h +include/stc/arc.h +include/stc/box.h +include/stc/cbits.h +include/stc/common.h +include/stc/coption.h +include/stc/coroutine.h +include/stc/cregex.h +include/stc/cspan.h +include/stc/cstr.h +include/stc/csview.h +include/stc/ctest.h +include/stc/deque.h +include/stc/hmap.h +include/stc/hset.h +include/stc/list.h +include/stc/pqueue.h +include/stc/priv/cstr_prv.h +include/stc/priv/linkage.h +include/stc/priv/linkage2.h +include/stc/priv/queue_prv.h +include/stc/priv/sort_prv.h +include/stc/priv/template.h +include/stc/priv/template2.h +include/stc/priv/utf8_prv.h +include/stc/queue.h +include/stc/random.h +include/stc/smap.h +include/stc/sort.h +include/stc/sset.h +include/stc/stack.h +include/stc/sys/crange.h +include/stc/sys/filter.h +include/stc/sys/sumtype.h +include/stc/sys/utility.h +include/stc/types.h +include/stc/utf8.h +include/stc/vec.h +include/stc/zsview.h +%%STATIC%%lib/libstc.a +lib/libstc.so +lib/libstc.so.5 +%%PORTDOCS%%%%DOCSDIR%%/README.md +%%PORTDOCS%%%%DOCSDIR%%/algorithm_api.md +%%PORTDOCS%%%%DOCSDIR%%/arc_api.md +%%PORTDOCS%%%%DOCSDIR%%/box_api.md +%%PORTDOCS%%%%DOCSDIR%%/cbits_api.md +%%PORTDOCS%%%%DOCSDIR%%/coption_api.md +%%PORTDOCS%%%%DOCSDIR%%/coroutine_api.md +%%PORTDOCS%%%%DOCSDIR%%/cregex_api.md +%%PORTDOCS%%%%DOCSDIR%%/cspan_api.md +%%PORTDOCS%%%%DOCSDIR%%/cstr_api.md +%%PORTDOCS%%%%DOCSDIR%%/csview_api.md +%%PORTDOCS%%%%DOCSDIR%%/deq_api.md +%%PORTDOCS%%%%DOCSDIR%%/deque_api.md +%%PORTDOCS%%%%DOCSDIR%%/hmap_api.md +%%PORTDOCS%%%%DOCSDIR%%/hset_api.md +%%PORTDOCS%%%%DOCSDIR%%/list_api.md +%%PORTDOCS%%%%DOCSDIR%%/pics/Figure_1.png +%%PORTDOCS%%%%DOCSDIR%%/pics/array.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/bitset.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/containers.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/coroutine.png +%%PORTDOCS%%%%DOCSDIR%%/pics/deque.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/list.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/map.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/queue.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/random.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/set.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/smap.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/sset.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/stack.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/string.jpg +%%PORTDOCS%%%%DOCSDIR%%/pics/vector.jpg +%%PORTDOCS%%%%DOCSDIR%%/pqueue_api.md +%%PORTDOCS%%%%DOCSDIR%%/queue_api.md +%%PORTDOCS%%%%DOCSDIR%%/random_api.md +%%PORTDOCS%%%%DOCSDIR%%/smap_api.md +%%PORTDOCS%%%%DOCSDIR%%/sset_api.md +%%PORTDOCS%%%%DOCSDIR%%/stack_api.md +%%PORTDOCS%%%%DOCSDIR%%/utf8_api.md +%%PORTDOCS%%%%DOCSDIR%%/vec_api.md +%%PORTDOCS%%%%DOCSDIR%%/zsview_api.md +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/README.md +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/algorithms/filterdemos.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/algorithms/forloops.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/algorithms/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/algorithms/random.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/algorithms/shape.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/algorithms/shape.cpp +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/bitsets/bits.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/bitsets/bits2.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/bitsets/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/bitsets/prime.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/cointerleave.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/coread.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/coroutines.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/dining_philosophers.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/fibonacci.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/filetask.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/generator.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/producer.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/producer_task.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/scheduler.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/coroutines/triples.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hashmaps/birthday.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hashmaps/books.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hashmaps/hashmap.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hashmaps/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hashmaps/new_map.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hashmaps/phonebook.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hashmaps/unordered_set.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hashmaps/vikings.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/linkedlists/intrusive.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/linkedlists/list_erase.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/linkedlists/list_splice.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/linkedlists/lists.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/linkedlists/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/linkedlists/new_list.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/make.sh +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/mixed/astar.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/mixed/complex.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/mixed/convert.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/mixed/demos.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/mixed/inits.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/mixed/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/mixed/read.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/priorityqueues/functor.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/priorityqueues/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/priorityqueues/new_pqueue.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/priorityqueues/priority.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/queues/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/queues/new_queue.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/queues/queue.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/regularexpressions/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/regularexpressions/regex1.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/regularexpressions/regex2.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/regularexpressions/regex_match.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/regularexpressions/regex_replace.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/arc_containers.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/arc_demo.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/arcvec_erase.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/box.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/box2.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/map_box.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/map_ptr.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/music_arc.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/new_sptr.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/smartpointers/person_arc.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/gauss2.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/listmap.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/mapmap.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/multimap.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/new_smap.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/smap_erase.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/smap_find.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/smap_insert.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/sorted_map.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/sortedmaps/sset_erase.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/spans/matmult.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/spans/mdspan.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/spans/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/spans/multidim.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/spans/printspan.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/spans/submdspan.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/strings/cstr_match.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/strings/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/strings/replace.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/strings/splitstr.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/strings/sso_map.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/strings/sso_substr.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/strings/sview_split.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/strings/utf8replace_c.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/strings/utf8replace_rs.rs +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/vectors/lower_bound.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/vectors/meson.build +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/vectors/new_vec.c +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/vectors/stack.c