summaryrefslogtreecommitdiff
path: root/meson.build
blob: d43414f9dbf7b971e68019316080678799307f48 (plain)
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
project('vk', 'c')

c_files = [
  'src/main.c',
  'src/window.c',
  'src/render/renderer.c',
  'src/render/util.c',
  'src/render/shader.c',
  'src/render/mesh.c',
  'src/render/buffer.c'
]

shader_files = [
  'shaders/shader.vert',
  'shaders/shader.frag'
]

wl_protocols = dependency('wayland-protocols').get_variable('pkgdatadir')
wl_scanner = find_program(dependency('wayland-scanner').get_variable('wayland_scanner'))

protos = {
  'xdg-shell': wl_protocols / 'stable/xdg-shell/xdg-shell.xml',
  'xdg-decoration': wl_protocols / 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'
}

foreach name, path : protos
  c_files += custom_target(
    name.underscorify() + '_c',
    input: path,
    output: '@BASENAME@-protocol.c',
    command: [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@']
  )
  c_files += custom_target(
    name.underscorify() + '_h',
    input: path,
    output: '@BASENAME@-protocol.h',
    command: [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@']
  )
endforeach

libs = [
  dependency('vulkan'),
  dependency('wayland-client'),
  meson.get_compiler('c').find_library('m')
]

glslc = generator(
  find_program('glslc'),
  output: '@PLAINNAME@',
  arguments: ['@INPUT@', '-o', '@OUTPUT@.spv']
)

shaders = glslc.process(shader_files)

vert_shader = custom_target(
  input: 'shaders/shader.vert',
  output: '@PLAINNAME@',
  command: [find_program('glslc'), '@INPUT@', '-o', '@OUTPUT@']
)

frag_shader = custom_target(
  input: 'shaders/shader.frag',
  output: '@PLAINNAME@',
  command: [find_program('glslc'), '@INPUT@', '-o', '@OUTPUT@']
)

combine_vert = custom_target(
  input: 'shaders/combine.vert',
  output: '@PLAINNAME@',
  command: [find_program('glslc'), '@INPUT@', '-o', '@OUTPUT@']
)

combine_frag = custom_target(
  input: 'shaders/combine.frag',
  output: '@PLAINNAME@',
  command: [find_program('glslc'), '@INPUT@', '-o', '@OUTPUT@']
)

c_files += [ vert_shader, frag_shader, combine_vert, combine_frag ]

executable('vk', c_files, dependencies: libs, include_directories: ['include/'],
  c_args: [
    '-DVERTEX_SHADER="@0@"'.format(vert_shader.full_path()),
    '-DFRAGMENT_SHADER="@0@"'.format(frag_shader.full_path()),
    '-DBLEND_VERT="@0@"'.format(combine_vert.full_path()),
    '-DBLEND_FRAG="@0@"'.format(combine_frag.full_path())
  ])