~rycwo/forge

ref: 5f26ce94ed885c67590d71e8ae28a29613c4ef2c forge/meson.build -rw-r--r-- 3.6 KiB
5f26ce94Ryan Chan Apply active gui transform before pushing prims 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
project(
    'forge',
    'c',
    version : '0.1.0',
    license : 'GPL-3.0-only',
    meson_version: '>=0.54.0',
    default_options : [
        'warning_level=3',  # Enables -Wall, -Wextra, etc.
        'c_std=c11',
    ])

deps = [
    dependency('GL'),
    dependency('glew', version : '>=2.1.0'),
]

# https://mesonbuild.com/howtox.html#add-math-library-lm-portably
cc = meson.get_compiler('c')

deps += cc.find_library('m', required : false)

jemalloc_dep = dependency(
    'jemalloc',
    version : '>=5.2.0',
    required : get_option('use_jemalloc'))

if jemalloc_dep.found()
    deps += jemalloc_dep
    add_project_arguments('-DFORGE_USE_JEMALLOC', language : 'c')
endif

includes = include_directories('include')

# Pre-compile shaders into SPIR-V IR to be included directly in the binary.
# TODO(rycwo): Add support for machines using OpenGL 3.3 and above.
glsl_validator = find_program('glslangValidator')

glsl_validator_args = ['-G', '-x']

optimization = get_option('optimization')

if get_option('debug') or optimization == 'g'
    glsl_validator_args += ['-g']
endif

if optimization != 'g'
    if optimization == 's'
        glsl_validator_args += ['-Os']
    elif optimization.to_int() == 0
        glsl_validator_args += ['-Od']
    endif
endif

spirv_gen = generator(
    glsl_validator,
    output : '@PLAINNAME@.spv',
    arguments : glsl_validator_args + ['-o', '@OUTPUT@', '@INPUT@'])

spirv_binary = spirv_gen.process(
    files([
        'shader/gui_rect.vert.glsl',
        'shader/gui_rect.frag.glsl'
    ]))

lib = library(
    meson.project_name(),
    files([
        'src/almost_equal.c',
        'src/clamp.c',
        'src/gui_basic.c',
        'src/gui_context.c',
        'src/gui_draw.c',
        'src/gui_graph.c',
        'src/gui_input.c',
        'src/gui_layout.c',
        'src/gui_opengl_46.c',
        'src/gui_util.c',
        'src/gui_window.c',
        'src/hash_table.c',
        'src/memory_pool.c',
        'src/murmur_hash.c',
        'src/pcg_basic.c',
        'src/seed.c',
        'src/shader.c',
        'src/stb_sprintf.c',
    ]),
    spirv_binary,
    version : meson.project_version(),
    dependencies : deps,
    include_directories : includes,
    install : true)

forge_dep = declare_dependency(
    link_with : lib,
    version : meson.project_version(),
    dependencies : deps,
    include_directories : includes)

install_headers(
    files([
        'include/forge/allocator.h',
        'include/forge/almost_equal.h',
        'include/forge/collection.h',
        'include/forge/expect.h',
        'include/forge/gui.h',
        'include/forge/gui_basic.h',
        'include/forge/gui_context.h',
        'include/forge/gui_draw.h',
        'include/forge/gui_graph.h',
        'include/forge/gui_input.h',
        'include/forge/gui_layout.h',
        'include/forge/gui_type.h',
        'include/forge/gui_util.h',
        'include/forge/gui_window.h',
        'include/forge/hash_table.h',
        'include/forge/input.h',
        'include/forge/matrix.h',
        'include/forge/memory_pool.h',
        'include/forge/murmur_hash.h',
        'include/forge/pcg_basic.h',
        'include/forge/seed.h',
        'include/forge/shader.h',
        'include/forge/stb_sprintf.h',
        'include/forge/stretchy_buffer.h',
        'include/forge/type.h',
        'include/forge/vector.h',
    ]),
    subdir : meson.project_name())

pkgconfig = import('pkgconfig')
pkgconfig.generate(
    libraries : lib,
    name : lib.name(),
    version : meson.project_version(),
    filebase : meson.project_name(),
    description : 'Foundation library for Forge tools.',
    url : 'https://git.sr.ht/~rycwo/forge/')

subdir('test')