gout

A static git page generator
git clone https://git.bracken.jp/gout.git
Log | Files | Refs | README | LICENSE

commit 0c4663793cbeaf895e903e17fa10f5525cace9ae
parent b89c1315f79c1617cb8966de023a11167d3371c8
Author: Chris Bracken <chris@bracken.jp>
Date:   Thu, 26 Feb 2026 08:54:08 +0900

build: extract posix_env config

Moves definitions like _POSIX_C_SOURCE and _XOPEN_SOURCE to a posix_env
config, and enables macOS/Linux-specific extensions only for those
platforms.

We can also remove _BSD_SOURCE since as of POSIX 2008, _DEFAULT_SOURCE
replaces it and gives us everything we need.

Diffstat:
MBUILD.gn | 8+-------
Mbuild/BUILD.gn | 13+++++++++++++
2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/BUILD.gn b/BUILD.gn @@ -4,13 +4,6 @@ config("gout_config") { "//src", ] + system_include_dirs lib_dirs = [] + system_lib_dirs - defines = [ - "_POSIX_C_SOURCE=200809L", - "_XOPEN_SOURCE=700", - "_DEFAULT_SOURCE", - "_BSD_SOURCE", - "_DARWIN_C_SOURCE", - ] libs = [ "git2" ] configs = [ "//build:compiler_std", @@ -18,6 +11,7 @@ config("gout_config") { "//build:strict_prototypes", "//build:no_exceptions", "//build:no_rtti", + "//build:posix_env", ] if (is_debug) { configs += [ diff --git a/build/BUILD.gn b/build/BUILD.gn @@ -5,6 +5,19 @@ config("compiler_std") { cflags_objcc = [ "-std=c++17" ] } +config("posix_env") { + defines = [ + "_POSIX_C_SOURCE=200809L", + "_XOPEN_SOURCE=700", + ] + + if (target_os == "linux") { + defines += [ "_DEFAULT_SOURCE" ] + } else if (target_os == "mac") { + defines += [ "_DARWIN_C_SOURCE" ] + } +} + # Default compiler warnings. config("compiler_warnings") { cflags = [