Skip to content

Commit e5ef802

Browse files
authored
103 migrate the build system to build master (#104)
* VSC: Migrated build system to build master * [VSC] [No Functional Change] Removed stray files and some more tiny changes * [SGE] Migrated build system to build master (meson) * Updated README.md * [VSC] Removed unncessary headers and fixed build issues * [VSC] Added SC_RELEASE and SC_DEBUG defines in their respective build type * [VSC] Potential build fix, added defines for build and use of the library * [SGE] Fixed potential build issue, added library build and use defines. * [DISASM] Migrated build system to build master (meson) * [SGE] Added build_shaders.makefile, README.md improve, and other minor things
1 parent 134f531 commit e5ef802

File tree

243 files changed

+1453
-50137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

243 files changed

+1453
-50137
lines changed

README.md

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,20 @@ There are only C and C++ interface headers for now. <br>
7676
$ pacman -S git
7777
```
7878

79-
6. **glslc**, glslc can be installed as follows, run the following in MSYS2 MinGW shell <br>
79+
6. **glslc** and **shaderc**, glslc can be installed as follows, run the following in MSYS2 MinGW shell <br>
8080

8181
```
8282
$ pacman -S mingw-w64-x86_64-shaderc
8383
```
84+
7. **Freetype2**, run the following in MSYS2 MinGW shell <br>
85+
```
86+
$ pacman -S mingw-w64-x86_64-freetype
87+
```
88+
8. **Vulkan Headers**
89+
```
90+
meson wrap install vulkan-headers
91+
meson wrap install glfw
92+
```
8493

8594
### Requirements for building on Linux (Debian)
8695

@@ -153,11 +162,17 @@ There are only C and C++ interface headers for now. <br>
153162
$ sudo apt-get install libz-dev
154163
$ sudo apt-get install libpng-dev
155164
$ sudo apt-get install libbrotli-dev
165+
$ sudo apt-get install libfreetype-dev
156166
```
157167
7. On wayland you would need the following package:
158168
```
159169
$ sudo apt-get install libwayland-dev
160170
```
171+
8. **Vulkan Headers**
172+
```
173+
meson wrap install vulkan-headers
174+
meson wrap install glfw
175+
```
161176

162177
### Requirements for building on FreeBSD
163178
Currently you can't build the codebase in FreeBSD environment. There are many issues right now.
@@ -194,63 +209,62 @@ For now, you would need to do the following:
194209
4. Disk space - No data as of now
195210
5. Better to have Vulkan LunarG SDK installed for additional debugging and vulkan configuration (validation layers), but it is not a requirement because the static library and headers are already included in the repository and would be updated as new updates will come in future.
196211

197-
### Building steps
212+
### Building Shaders
213+
```
214+
$ make -f build_shaders.makefile all
215+
```
216+
217+
### Building and Installing SGE
198218

199219
1. Clone the repository by running the following command <br>
200220

201221
```
202222
$git clone https://github.com/ravi688/VulkanRenderer.git
203223
```
204224

205-
2. Change the working directory to `VulkanRenderer` and setup all the dependency git submodules by running the following command
225+
2. Change the working directory to `VulkanRenderer`
226+
3. Start building by running the following commands
206227

207228
```
208-
$cd VulkanRenderer
209-
$make -s setup
229+
$ meson setup build --buildtype=debug
230+
$ meson compile -C build
210231
```
211-
212-
3. Start building by running the following command
213-
232+
4. Install SGE as a Library (Usable via pkg-conf)
214233
```
215-
$make -s build
234+
$ meson install -C build
216235
```
217-
218-
OR
219-
236+
5. Verify Installation by running pkg-config as follows
220237
```
221-
$make -s build-debug
238+
pkg-config sge_static --cflags --libs
222239
```
223-
224-
For release mode
225-
240+
OR
226241
```
227-
$make -s build-release
242+
pkg-config sge_shared --cflags --libs
228243
```
244+
It must print include header and link libraries directories which you can pass into your gcc or clang compiler/linker.
229245

230-
### Building executable manually (Optional)
246+
### Using SGE as a meson dependency wrap
247+
Create a wrap file `sge_static.wrap` (for static library) in your meson project's `subprojects` directory.
248+
Populate it with the following content:
249+
```yaml
250+
[wrap-git]
251+
url = https://github.com/ravi688/VulkanRenderer.git
252+
revision = head
253+
depth = 1
231254

232-
1. Change the working directory to `VulkanRenderer` and build the `main` executable by running the following command
233-
234-
```
235-
$make -s debug
236-
```
237-
238-
2. Now run the `main` executable by running the following command
239-
240-
```
241-
$./main
242-
```
255+
[provide]
256+
sge_static = sge_static_dep
257+
```
243258

244259
### Test Run (Optional)
245260
There are several tests which you can try running by just passing arguments:
246261
```
247-
$cd <build directory>
248-
$./main CUBE
262+
$./build/main_test CUBE
249263
```
250264
The above set of commands would launch a window in which a white cube will be spinning.
251265
If you want to see all the possible test cases, you may launch the execution without any arguments and it would just print the list of possible test cases:
252266
```
253-
$./main
267+
$./build/main
254268
supported tests:
255269
DEPTH_RENDER_TEXTURE
256270
DEPTH_RENDER_TEXTURE_LOAD
@@ -286,13 +300,15 @@ supported tests:
286300
TID_48_CASE_5
287301
```
288302

289-
### Cleaning everything (Optional)
290-
291-
1. Change the working directory to `VulkanRenderer` and run the following command
292-
293-
```
294-
$make -s clean
295-
```
303+
### Cleaning SGE
304+
Change the working directory to `VulkanRenderer` and run the following command
305+
```
306+
$ meson setup build --wipe
307+
```
308+
### Cleaning Shaders
309+
```
310+
make -f build_shaders.makefile clean
311+
```
296312

297313
### Building SUTK (Spectrum UI Toolkit)
298314
#### On Windows (MSYS)

add_notice.makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#-----------------------------------------
2+
# Legal
3+
#-----------------------------------------
4+
5+
PYTHON:=python
6+
LEGAL_NOTICE_PYTHON_SCRIPT:=source/legal/legal_notice.py
7+
8+
.PHONY: legal
9+
10+
legal:
11+
$(PYTHON) $(LEGAL_NOTICE_PYTHON_SCRIPT)

build_master.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"project_name": "SGE",
3+
"description" : "Low level 2D and 3D Rendering Framework",
4+
"canonical_name": "sge",
5+
"dependencies" : [
6+
"shader_compiler",
7+
"common",
8+
"glslcommon",
9+
"hpml",
10+
"meshlib",
11+
"vulkanheaders",
12+
"freetype2",
13+
"glfw3",
14+
"ttf2mesh",
15+
"shaderc"
16+
],
17+
"install_header_dirs" : ["include/sge", "include/sge-cpp"],
18+
"include_dirs": "include",
19+
"defines" : [
20+
"-DSGE_VULKAN_DRIVER"
21+
],
22+
"debug_defines" : [
23+
"-DGLOBAL_DEBUG",
24+
"-DDEBUG",
25+
"-DSGE_DEBUG",
26+
"-DLOG_DEBUG"
27+
],
28+
"release_defines" : [
29+
"-DGLOBAL_RELEASE",
30+
"-DRELEASE",
31+
"-DSGE_RELEASE",
32+
"-DLOG_RELEASE"
33+
],
34+
"vars" :
35+
{
36+
"test_sources" : "run_command('find', 'source/tests', '-maxdepth', '1', '-type', 'f', check : false).stdout().strip().split()",
37+
"sge_sources" : "run_command('find', 'source/sge', '-maxdepth', '3', '-type', 'f', check : false).stdout().strip().split()",
38+
"sge_cpp_sources" : "run_command('find', 'source/sge-cpp', '-maxdepth', '3', '-type', 'f', check : false).stdout().strip().split()",
39+
"stb_sources" : "run_command('find', 'source/stb', '-maxdepth', '1', '-type', 'f', check : false).stdout().strip().split()",
40+
"vulkan_sdk_path" : "run_command(find_program('python'), '-c', 'import os; print(os.environ[\"VK_SDK_PATH\"])', check : false).stdout().strip()",
41+
"vulkan_libs_path" : "vulkan_sdk_path + '/Lib/'"
42+
},
43+
"windows_link_args" : ["link_dir: $vulkan_libs_path", "-lvulkan-1"],
44+
"linux_link_args" : ["link_dir: $vulkan_libs_path", "-lvulkan-1"],
45+
"targets": [
46+
{
47+
"name": "main_test",
48+
"description" : "Test Executable for SGE",
49+
"is_executable": true,
50+
"sources": [
51+
"source/main.c",
52+
"source/test.c",
53+
"source/legal/legal.c",
54+
"$test_sources"
55+
]
56+
},
57+
{
58+
"name" : "sge_static",
59+
"description" : "Static Library for SGE",
60+
"is_static_library" : true,
61+
"build_defines" : [ "-DSGE_BUILD_STATIC_LIBRARY" ],
62+
"use_defines" : [ "-DSGE_USE_STATIC_LIBRARY" ]
63+
},
64+
{
65+
"name" : "sge_shared",
66+
"description" : "Shared Library for SGE",
67+
"is_shared_library" : true,
68+
"build_defines" : [ "-DSGE_BUILD_DYNAMIC_LIBRARY" ],
69+
"use_defines" : [ "-DSGE_USE_DYNAMIC_LIBRARY" ]
70+
}
71+
],
72+
"sources" : [
73+
"$sge_sources",
74+
"$sge_cpp_sources",
75+
"$stb_sources"
76+
]
77+
}

build_shaders.makefile

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Platform Detection
2+
include platform.Makefile
3+
4+
#-------------------------------------------
5+
# Shader Compilation
6+
#-------------------------------------------
7+
SHADER_INCLUDES = -I$(wildcard shaders/include/)
8+
9+
VSC_BUILD_DIR := ./.shader_compiler.build
10+
VSC_SOURCE_DIR := ./toolchain/shader_compiler
11+
SHADER_COMPILER = $(VSC_BUILD_DIR)/vsc
12+
# toolchain/shader_compiler/makefile creates vsc.exe executable, while the targets 'shader-release' and 'shader-debug' check for 'vsc'
13+
# this leads to unconditionally compiling the .v3dshader files everytime 'make -s build' is triggered
14+
ifeq (Windows,$(PLATFORM))
15+
SHADER_COMPILER := $(addsuffix .exe,$(SHADER_COMPILER))
16+
endif
17+
SHADER_SOURCES = $(wildcard ./shaders/*/*.v3dshader ./shaders/*/*/*.v3dshader)
18+
SHADER_BINARIES = $(subst .v3dshader,.sb, $(SHADER_SOURCES))
19+
20+
SHADER_COMPILER_COMPILATION_MODE =
21+
22+
# Meson build system
23+
MESON := meson
24+
25+
$(SHADER_COMPILER):
26+
$(MESON) setup $(VSC_BUILD_DIR) $(VSC_SOURCE_DIR) --reconfigure --buildtype=$(SHADER_COMPILER_COMPILATION_MODE)
27+
$(MESON) compile -C $(VSC_BUILD_DIR)
28+
29+
%.sb: %.v3dshader $(SHADER_COMPILER)
30+
$(SHADER_COMPILER) $(SHADER_INCLUDES) $< $@
31+
32+
33+
.PHONY: vsc
34+
.PHONY: vsc-debug
35+
.PHONY: vsc-release
36+
.PHONY: vsc-clean
37+
38+
vsc: vsc-debug
39+
vsc-debug: SHADER_COMPILER_COMPILATION_MODE += debug
40+
vsc-debug: $(SHADER_COMPILER)
41+
vsc-release: SHADER_COMPILER_COMPILATION_MODE += release
42+
vsc-release: $(SHADER_COMPILER)
43+
44+
vsc-clean:
45+
$(RM) -rf $(VSC_BUILD_DIR)
46+
47+
.PHONY: shader-debug
48+
.PHONY: shader-release
49+
.PHONY: shader
50+
.PHONY: shader-clean
51+
52+
shader-debug: vsc-debug
53+
shader-debug: $(SHADER_BINARIES)
54+
shader-release: vsc-release
55+
shader-release: $(SHADER_BINARIES)
56+
shader: shader-debug
57+
58+
shader-clean:
59+
ifeq (Windows,$(PLATFORM))
60+
$(RM) $(subst /,\, $(SHADER_BINARIES))
61+
endif
62+
ifeq (Linux,$(PLATFORM))
63+
$(RM) $(SHADER_BINARIES)
64+
endif
65+
66+
67+
GLSL_SHADERS = $(wildcard shaders/*.frag shaders/*.vert shaders/*/*.frag shaders/*/*.vert shaders/*/*/*.frag shaders/*/*/*.vert shaders/*/*/*/*.frag shaders/*/*/*/*.vert)
68+
SPIRV_SHADERS = $(addsuffix .spv, $(GLSL_SHADERS))
69+
SPIRV_COMPILER = glslc
70+
71+
%.vert.spv: %.vert
72+
$(SPIRV_COMPILER) $(SHADER_INCLUDES) $< -o $@
73+
%.frag.spv: %.frag
74+
$(SPIRV_COMPILER) $(SHADER_INCLUDES) $< -o $@
75+
76+
.PHONY: glsl-shader
77+
.PHONY: glsl-shader-clean
78+
79+
glsl-shader: $(SPIRV_SHADERS)
80+
81+
glsl-shader-clean:
82+
ifeq (Windows,$(PLATFORM))
83+
$(RM) $(subst /,\, $(SPIRV_SHADERS))
84+
endif
85+
ifeq (Linux,$(PLATFORM))
86+
$(RM) $(SPIRV_SHADERS)
87+
endif
88+
89+
.PHONY: all
90+
all : glsl-shader shader-debug
91+
92+
.PHONY: clean
93+
94+
clean : glsl-shader-clean shader-clean vsc-clean
95+
96+
#-------------------------------------------

dependencies/Common

Submodule Common deleted from 3f55349

dependencies/ECS

Submodule ECS deleted from f24374d

dependencies/GLSLCommon

Submodule GLSLCommon deleted from e149138

dependencies/HPML

Submodule HPML deleted from ec3a2ce

dependencies/MeshLib

Submodule MeshLib deleted from 5297d5d

dependencies/PhyMacParser

Submodule PhyMacParser deleted from e292ffd

0 commit comments

Comments
 (0)