Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

minimize build #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

subprojects/*
!subprojects/*.wrap
!subprojects/packagefiles

.clang_complete
*.o
Expand Down
33 changes: 2 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,5 @@ OpenGL-based renderer. We want to use the newer OpenGL extenstion
functionalities, so we create a GLEW renderer with a similar API to the
existing GLES2 renderer.

## Building & Install

Build

```shell
meson build # this may take few minutes
ninja -C build # this may emit several warnings when compiling src_glew.c.o
```

Install like so

(*_**You don't need to install subprojects**_)

```
sudo meson install -C build --skip-subprojects
```

## Usage

```c
#include <wlr/renderer/glew.h>

struct wlr_renderer* renderer = wlr_glew_renderer_create_with_drm_fd(drm_fd);
```

## Notion

We build and use GLEW as a static library to ensure that we can use GLEW with
egl. (Patches that add an option to use GLEW as a dynamic library are also
welcome!)
Therefore, when using this renderer, do not link additional GLEW library.
This repository is intended to be used only as a meson subproject
in this organization, and will not be installed as a library on the system.
1 change: 0 additions & 1 deletion include/meson.build

This file was deleted.

41 changes: 28 additions & 13 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ project(
],
)

so_version = '1.0'

little_endian = host_machine.endian() == 'little'
big_endian = host_machine.endian() == 'big'

Expand Down Expand Up @@ -86,7 +84,7 @@ wlroots_proj = subproject(
required: true,
version: '0.15.1',
)
wlroots = wlroots_proj.get_variable('wlroots')
wlr_inc = wlroots_proj.get_variable('wlr_inc')

glew_proj = subproject(
'glew',
Expand All @@ -98,18 +96,35 @@ glew_proj = subproject(
'werror=false',
]
)
glew = glew_proj.get_variable('glew_dep')
glew_dep = glew_proj.get_variable('glew_dep')

pixman_dep = dependency('pixman-1')
drm_dep = dependency('libdrm')

inc = include_directories('include')

subdir('include')
subdir('src')
sources = [
'src/pixel_format.c',
'src/renderer.c',
'src/shaders.c',
'src/texture.c'
]

dependencies = [
drm_dep,
glew_dep,
pixman_dep,
]

wlr_glew_renderer_lib = static_library(
meson.project_name(), sources,
dependencies: dependencies,
include_directories: [inc, wlr_inc],
install: false,
)

pkgconfig = import('pkgconfig')
pkgconfig.generate(
lib_wlr_glew_renderer,
version: meson.project_version(),
filebase: meson.project_name(),
name: meson.project_name(),
description: 'GLEW renderer for wlroots',
wlr_glew_renderer_dep = declare_dependency(
link_with: wlr_glew_renderer_lib,
dependencies: dependencies,
include_directories: inc,
)
19 changes: 0 additions & 19 deletions src/meson.build

This file was deleted.

8 changes: 1 addition & 7 deletions subprojects/glew.wrap
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
; obtained from official wrapDB https://mesonbuild.com/Wrapdb-projects.html
[wrap-file]
directory = glew-2.2.0
source_url = http://downloads.sourceforge.net/glew/glew-2.2.0.tgz
source_filename = glew-2.2.0.tgz
source_hash = d4fc82893cfb00109578d0a1a2337fb8ca335b3ceccf97b97e5cc7f08e4353e1
patch_filename = glew_2.2.0-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/glew_2.2.0-1/get_patch
patch_hash = 2775568e65a72fa7a5a6fafc9066cb88be91638f8a5ca99a02b90a3d82c0e7f2
wrapdb_version = 2.2.0-1

[provide]
glew = glew_dep
patch_directory = glew-2.2.0
92 changes: 92 additions & 0 deletions subprojects/packagefiles/glew-2.2.0/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
project(
'glew',
'c',
version : '2.2.0',
license: ['MIT', 'BSD-3'],
meson_version : '>= 0.43.0'
)

cc = meson.get_compiler('c')
host_system = host_machine.system()

user_args = []

c_args = [
'-DGLEW_NO_GLU',
]
ld_args = []
glew_sources = [
'include/GL/wglew.h',
'include/GL/glew.h',
'include/GL/glxew.h',
'src/glew.c',
]

if get_option('default_library') == 'shared'
c_args += '-DGLEW_BUILD'
else
c_args += '-DGLEW_STATIC'
user_args += '-DGLEW_STATIC'
endif

if host_system == 'windows'
dep_gl = cc.find_library('opengl32')
else
dep_gl = dependency('gl')
endif

if host_system == 'windows'
windows = import('windows')

glew_sources += windows.compile_resources('build/glew.rc')
name = 'glew32'

if cc.get_id() == 'msvc'
c_args += [
'-DVC_EXTRALEAN',
'-GS-',
]
ld_args += [
'-BASE:0x62AA0000',
'-nodefaultlib',
'-noentry',
]
else
c_args += [
'-fno-builtin',
'-fno-stack-protector',
]
ld_args += '-nostdlib'
endif
else
name = 'GLEW'
c_args = cc.get_supported_arguments(['-ansi', '-W', '-Wcast-qual', '-fno-stack-protector'])
endif

if get_option('egl')
dep_egl = dependency('egl')
c_args += '-DGLEW_EGL'
else
dep_egl = dependency('', required: false)
endif

glew_include = include_directories('include')

# The windows version shoould not have a version set
libglew = library(
name,
glew_sources,
c_args : c_args,
link_args : ld_args,
include_directories : glew_include,
dependencies : [dep_gl, dep_egl],
version : meson.project_version(),
install : false,
)

glew_dep = declare_dependency(
link_with : libglew,
compile_args: user_args,
include_directories : glew_include,
dependencies : [dep_gl, dep_egl],
)
1 change: 1 addition & 0 deletions subprojects/packagefiles/glew-2.2.0/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('egl', type : 'boolean', value : false, description : 'build support for egl')
15 changes: 15 additions & 0 deletions subprojects/packagefiles/wlroots/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
project(
'wlroots',
'c',
version: '0.15.1',
license: 'MIT',
meson_version: '>=0.58.1',
default_options: [
'c_std=c11',
'warning_level=2',
'werror=true',
],
)


wlr_inc = include_directories('include')
2 changes: 2 additions & 0 deletions subprojects/wlroots.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
url = https://gitlab.freedesktop.org/wlroots/wlroots.git
revision = 0.15.1
depth = 1

patch_directory = wlroots