gout

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

BUILD.gn (2296B)


      1 # Default language standards.
      2 config("compiler_std") {
      3   cflags_c = [ "-std=c17" ]
      4   cflags_cc = [ "-std=c++17" ]
      5   cflags_objcc = [ "-std=c++17" ]
      6 }
      7 
      8 config("posix_env") {
      9   defines = [
     10     "_POSIX_C_SOURCE=200809L",
     11     "_XOPEN_SOURCE=700",
     12   ]
     13 
     14   if (target_os == "linux") {
     15     defines += [ "_DEFAULT_SOURCE" ]
     16   } else if (target_os == "mac") {
     17     defines += [ "_DARWIN_C_SOURCE" ]
     18   } else if (target_os == "openbsd") {
     19     defines += [ "_BSD_SOURCE" ]
     20   }
     21 }
     22 
     23 # Default compiler warnings.
     24 config("compiler_warnings") {
     25   cflags = [
     26     "-Wall",
     27     "-Wextra",
     28     "-Werror",
     29   ]
     30   cflags_cc = []
     31   cflags_objcc = []
     32 }
     33 
     34 config("strict_prototypes") {
     35   cflags = [
     36     "-Wmissing-prototypes",
     37     "-Wstrict-prototypes",
     38   ]
     39 }
     40 
     41 # Test-specific warnings (relaxed for test fixtures).
     42 config("test_warnings") {
     43   cflags = [
     44     "-Wno-unused-parameter",
     45   ]
     46 }
     47 
     48 # Debug mode build.
     49 config("debug") {
     50   defines = [ "_DEBUG" ]
     51 }
     52 
     53 # Release mode build.
     54 config("release") {
     55   defines = [ "NDEBUG" ]
     56 }
     57 
     58 # Disable optimisations.
     59 config("no_optimize") {
     60   cflags = [ "-O0" ]
     61 }
     62 
     63 # Optimise for time performance.
     64 config("optimize") {
     65   cflags = [ "-O2" ]
     66 }
     67 
     68 # Optimise for size.
     69 config("optimize_size") {
     70   cflags = [ "-Os" ]
     71 
     72   if (current_os == "mac" || current_os == "ios") {
     73     ldflags = [
     74       "-Wl,-dead_strip",  # Mac equivalent of --gc-sections
     75       "-Wl,-S",  # Strip debug symbols
     76       "-Wl,-x",  # Strip local symbols
     77     ]
     78   } else {
     79     # OpenBSD / Linux / etc.
     80     cflags += [
     81       "-ffunction-sections",
     82       "-fdata-sections",
     83     ]
     84     ldflags = [
     85       "-Wl,--gc-sections",
     86       "-s",
     87     ]
     88   }
     89 }
     90 
     91 # Enable link-time-optimisation.
     92 config("lto") {
     93   cflags = [ "-flto" ]
     94   ldflags = [ "-flto" ]
     95 }
     96 
     97 # Disable exceptions.
     98 config("no_exceptions") {
     99   cflags = [ "-fno-exceptions" ]
    100   ldflags = [ "-fno-exceptions" ]
    101 }
    102 
    103 # Disable runttime type information.
    104 config("no_rtti") {
    105   cflags = [ "-fno-rtti" ]
    106   ldflags = [ "-fno-rtti" ]
    107 }
    108 
    109 # Regular build with symbols.
    110 config("symbols") {
    111   cflags = [ "-g2" ]
    112 }
    113 
    114 # Minimal symbols, typically just enough for backtraces.
    115 config("min_symbols") {
    116   cflags = [ "-g1" ]
    117 }
    118 
    119 # No symbols.
    120 config("no_symbols") {
    121   cflags = [ "-g0" ]
    122 }
    123 
    124 # Address Sanitizer
    125 config("asan") {
    126   cflags = [ "-fsanitize=address" ]
    127   ldflags = [ "-fsanitize=address" ]
    128 }