https://github.com/geektree0101/sdlbazelexample
SDL Cube Bazel builder example
https://github.com/geektree0101/sdlbazelexample
Last synced: 3 months ago
JSON representation
SDL Cube Bazel builder example
- Host: GitHub
- URL: https://github.com/geektree0101/sdlbazelexample
- Owner: GeekTree0101
- Created: 2018-12-23T12:55:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-24T02:22:01.000Z (over 7 years ago)
- Last Synced: 2025-04-22T16:43:08.262Z (about 1 year ago)
- Language: C++
- Size: 78.1 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to make SDL application with Bazel Builder?

## 1. Install Bazel
```sh
brew tap bazelbuild/tap
brew tap-pin bazelbuild/tap
brew install bazelbuild/tap/bazel
```
https://docs.bazel.build/versions/master/install-os-x.html
## 2. Install SDL
```sh
brew install sdl2
```
## 3. Make WORKSPACE for SDL2
```py
new_local_repository(
name = "SDL2",
path = "/usr/local/Cellar/sdl2/2.0.9", # <----- SDL path
build_file = "sdl2.BUILD" # <------ SDL2 Build script!
)
```
## 4. Make SDL2 Build script
sdl2 dir
```sh
/usr/local/Cellar/sdl2/2.0.9
- include <----- @Important
- lib <----- @Important (header files located, SDL/*.h)
- TODO.txt
- INSTALL_RECEIPT.json
- bin
- share
- README.text
- COPYING.txt
```
sdl.BUILD script
```py
cc_library(
name = "SDL2",
hdrs = glob(["include/SDL2/*.h"]),
linkopts = [
"-L /usr/local/Cellar/sdl2/2.0.9/lib -l SDL2-2.0.0", # (-L lib-dir -l lib-name)
"-framework OpenGL" # (use OpenGL, )
],
strip_include_prefix = "include",
visibility = ["//visibility:public"], # Visibility is important!
)
```
## 5. Make Build script for application
Cube dir
```sh
Cube
- BUILD
- Cube.cpp
- Cube.h
- main.cpp
```
BUILD script
```py
cc_library(
name = "Lib",
srcs = ["Cube.cpp"],
hdrs = ["Cube.h"],
deps = ["@SDL2//:SDL2"], # <----- SDL2 library from sdl2.BUILD script
)
cc_binary(
name = "CubeExample",
srcs = ["main.cpp"],
deps = [":Lib"] . # <----- dep cc_library.Lib
)
```