Skip to content

Commit

Permalink
Merge pull request #4 from kadir014/rewrite
Browse files Browse the repository at this point in the history
Rewrite
  • Loading branch information
kadir014 authored Sep 2, 2024
2 parents 4b1726c + 4264110 commit 0ee4319
Show file tree
Hide file tree
Showing 169 changed files with 48,989 additions and 15,856 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
.vscode/
nova-physics-ws.code-workspace

# Meson
subprojects/
reconfigure/

# Project testing & debugging
cache/
.cache/
test.c
pytest/
SDL2/
Expand Down Expand Up @@ -70,6 +75,7 @@ lib
*.so
*.so.*
*.dylib
.DS_Store

# Executables
*.exe
Expand Down
233 changes: 30 additions & 203 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,218 +1,45 @@
# Nova Physics Build System Guidance
Welcome to the Nova Physics building guide.
# Building Nova Physics
Nova Physics uses [Meson](https://mesonbuild.com/) as its build system.

Nova Physics uses a dependency-free Python script to simplify and organize building.

You can use `python nova_builder.py --help` to see the usage manual. Only requirement is to have Python 3.9 or higher installed on the system.


**What you can do with the build system:**
- [Build Nova Physics library](#building-nova-physics-static-libraries)
- [Build & run example demos](#running-nova-physics-example-demos)
- [Build & run benchmarks](#running-nova-physics-benchmarks)
- [Build & run the test suite](#running-nova-physics-test-suite)


<br><br><br>


# Building Nova Physics Static Libraries
This section covers building and generating static libraries yourself (in case you don't use the already-built archives from the [latest release.](https://github.com/kadir014/nova-physics/releases/latest))

## <img src="https://i.imgur.com/lyTfWAN.png" width=20> Windows
**Prerequisite**: Make sure you have either MinGW (GCC) or Visual Studio build tools installed.

Download or clone the repository.
```
git clone https://github.com/kadir014/nova-physics.git
```

Set working directory as Nova Physics directory.
```
cd "C:\...\nova-physics"
```

Run Nova Physics's build system with `build` command to start building. To see options and arguments you can utilize for building use `--help`.
```
python nova_builder.py build
```

If successful, you should see the generated static libraries in the `nova-physics\build` sub-directory.


## <img src="https://i.imgur.com/J3TG2gm.png" width=20> Linux

**Prerequisite**: Make sure you have GCC installed

<br>

Download or clone the repository.
```
$ git clone https://github.com/kadir014/nova-physics.git
```

Set working directory as Nova Physics directory.
```
$ cd ./.../nova-physics
```

Run Nova Physics's build system with `build` command to start building. (Can also be `py` or `python3` depending on the platform) To see options and arguments you can utilize for building use `--help`.
```
$ python nova_builder.py build
```

If successful, you should see the generated static libraries in `nova-physics/build` sub-directory.


<br><br><br>


# Running Nova Physics Example Demos
This section covers building & running examples.

## <img src="https://i.imgur.com/lyTfWAN.png" width=20> Windows
**Prerequisite**: Make sure you have MinGW (GCC) or Visual Studio build tools installed. Dependencies like SDL2 will be installed automatically by the script.

Download or clone the repository.
```
git clone https://github.com/kadir014/nova-physics.git
If you're on macOS, install HomeBrew and Nova Physics's developer dependencies.
```sh
$ brew install glfw mesa sdl2 meson
```

Set working directory as the Nova Physics directory.
```
cd "C:\...\nova-physics"
Install meson. (if you have any issues refer to [meson's installation guide](https://mesonbuild.com/Getting-meson.html))
```sh
$ pip install meson
```

Run Nova Physics's build system with `examples` command, it will detect the missing dependencies and download them on the fly. To see options and arguments you can utilize for building use `--help`.
```
python nova_builder.py examples
Change working dir to repository root.
```sh
$ cd path/to/nova-physics
```

If successful, the example demos will be ran and you will see an SDL2 window open.

## <img src="https://i.imgur.com/J3TG2gm.png" width=20> Linux
**Prerequisite**: Make sure you have GCC, SDL2 and SDL2-ttf development libraries installed via your package manager.
Here are two sources explaining how to install SDL2 and the extensions on Linux:
- https://wiki.libsdl.org/SDL2/Installation
- https://lazyfoo.net/tutorials/SDL/01_hello_SDL/linux/index.php

<br>

After installing the dependencies, download or clone the repository.
```
$ git clone https://github.com/kadir014/nova-physics.git
Create a `build` directory for meson.
```sh
$ mkdir build
```

Set working directory as Nova Physics directory
```
$ cd ./.../nova-physics
Setup meson configuration. For the other type of build types (optimization levels) see [here.](https://mesonbuild.com/Builtin-options.html#details-for-buildtype)
```sh
$ meson setup build --buildtype=debug
```

Then run the build system with the `examples` command. (Can also be `py` or `python3` depending on the platform) To see options and arguments you can utilize for building use `--help`.
We can finally start compiling. If successful you should see the built targets in `build` directory.
```sh
$ meson compile -C build
```
$ python nova_builder.py examples
```

If successful, the example demos will be ran and you will see an SDL2 window open.


<br><br><br>


# Running Nova Physics Benchmarks
This section covers building & running benchmarks.

## <img src="https://i.imgur.com/lyTfWAN.png" width=20> Windows
**Prerequisite**: Make sure you have either MinGW (GCC) or Visual Studio build tools installed.
# Building Options
While in the `build` dir (not root dir) you can use `$ meson configure` to see all building options and change them with `$ meson configure -Doption=nv_bool`

Download or clone the repository.
```
git clone https://github.com/kadir014/nova-physics.git
```

Set working directory as Nova Physics directory.
```
cd "C:\...\nova-physics"
```

Run Nova Physics's build system with `bench` command with a benchmark argument (e.g `boxes.c`) to start benchmarking. To see options and arguments you can utilize for building use `--help`.
```
python nova_builder.py bench <benchmark_source>
```

If successful, the benchmark will start running, you can see the progress and remaining time on terminal.


## <img src="https://i.imgur.com/J3TG2gm.png" width=20> Linux

**Prerequisite**: Make sure you have GCC installed

<br>

Download or clone the repository.
```
$ git clone https://github.com/kadir014/nova-physics.git
```

Set working directory as Nova Physics directory.
```
$ cd ./.../nova-physics
```

Run Nova Physics's build system with `bench` command with a benchmark argument (e.g `boxes.c`) to start benchmarking. (Can also be `py` or `python3` depending on the platform) To see options and arguments you can utilize for building use `--help`.
```
$ python nova_builder.py bench <benchmark_source>
```

If successful, the benchmark will start running, you can see the progress and remaining time on terminal.


<br><br><br>


# Running Nova Physics Test Suite
This section covers building & running unit tests.

## <img src="https://i.imgur.com/lyTfWAN.png" width=20> Windows
**Prerequisite**: Make sure you have either MinGW (GCC) or Visual Studio build tools installed.

Download or clone the repository.
```
git clone https://github.com/kadir014/nova-physics.git
```

Set working directory as Nova Physics directory.
```
cd "C:\...\nova-physics"
```

Run Nova Physics's build system with `tests` command to start running the test suite. To see options and arguments you can utilize for building use `--help`.
```
python nova_builder.py tests
```

If successful, the unit tests will be run and results will be shown on the terminal.


## <img src="https://i.imgur.com/J3TG2gm.png" width=20> Linux

**Prerequisite**: Make sure you have GCC installed

<br>

Download or clone the repository.
```
$ git clone https://github.com/kadir014/nova-physics.git
```

Set working directory as Nova Physics directory.
```
$ cd ./.../nova-physics
```

Run Nova Physics's build system with `tests` command to start running the test suite. (Can also be `py` or `python3` depending on the platform) To see options and arguments you can utilize for building use `--help`.
```
$ python nova_builder.py tests
```
Here's a list of our custom build options (You can also check `meson.options` file):
- `build_examples`: Build example demos, installs SDL2. On by default.
- `build_benchmarks`: Build bechmarks. Off by default.
- `build_tests`: Build unit tests. On by default.
- `enable_profiler`: Enable built-in profiler. If enabled, `<windows.h>` can be included. (Defines NV_ENABLE_PROFILER, on by default)
- `enable_simd`: Enable usage of any SIMD extension. (Defines NV_ENABLE_SIMD, on by default)
- `use_doubles`: Use double-precision floats. (Defines NV_USE_DOUBLE_PRECISION, off by default)

If successful, the unit tests will be run and results will be shown on the terminal.
For instance, if you didn't want to build example demos and just the static library, you could do `$ meson configure -Dbuild_examples=false`.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ void nv_some_function(...);
// Enums are in PascalCase, with their fields being the enum name + field name in full caps
typedef enum {
nv_SomeEnum_FIELD1,
nv_SomeEnum_FIELD2,
nvSomeEnum_FIELD1,
nvSomeEnum_FIELD2,
...
} nv_SomeEnum;
} nvSomeEnum;
```
Loading

0 comments on commit 0ee4319

Please sign in to comment.