Skip to content

Commit 26aa954

Browse files
committed
Initial stages of the large refactor and cleanup
0 parents  commit 26aa954

22 files changed

+458
-0
lines changed

.gitconfig

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[pull]
2+
rebase = merges
3+
[rebase]
4+
autoStash = true

.github/FUNDING.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: lethalbit
2+
patreon: lethalbit

.github/workflows/build-docs.yml

Whitespace-only changes.

.github/workflows/build-linux.yml

Whitespace-only changes.

.github/workflows/build-macos.yml

Whitespace-only changes.

.github/workflows/build-windows.yml

Whitespace-only changes.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
.vscode/

LICENSE

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2022, All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice,
7+
this list of conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in the
11+
documentation and/or other materials provided with the distribution.
12+
13+
3. Neither the name of ORGANIZATION nor the names of
14+
its contributors may be used to endorse or promote products derived from
15+
this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
POSSIBILITY OF SUCH DAMAGE.

README.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# libfortress
2+
3+
libfortress is a C++ library designed to facilitate with the parsing and generation of various debug info formats.
4+
5+
The sister library for parsing and generating object file formats can be found at [lethalbit/libalfheim](https://github.com/lethalbit/libalfheim).
6+
7+
## Configuring and Building
8+
9+
The following steps describe how to build libfortress, it should be consistent for both Linux and Windows, but Windows remains untested.
10+
11+
### Prerequisites
12+
13+
To build libfortress, ensure you have the following build time dependencies:
14+
* git
15+
* meson
16+
* ninja
17+
* zlib >=1.2.12
18+
* g++ >= 11 or clang++ >= 11
19+
20+
Optionally, when also building with binding support (which is the default) you also need:
21+
* python >= 3.9
22+
* pybind11 >= 2.7.0
23+
24+
25+
### Configuring
26+
27+
You can build libfortress with the default options, all of which can be found in [`meson_options.txt`](meson_options.txt). You can change these by specifying `-D<OPTION_NAME>=<VALUE>` at initial meson invocation time, or with `meson configure` in the build directory post initial configure.
28+
29+
To change the install prefix, which is `/usr/local` by default ensure to pass `--prefix <PREFIX>` when running meson for the first time.
30+
31+
In either case, simply running `meson build` from the root of the repository will be sufficient and place all of the build files in the `build` subdirectory.
32+
33+
### Building
34+
35+
Once you have configured libfortress appropriately, to simply build and install simply run the following:
36+
37+
```
38+
$ ninja -C build
39+
$ ninja -C build install
40+
```
41+
42+
This will build and install libfortress into the default prefix which is `/usr/local`, to change that see the configuration steps above.
43+
44+
### Notes to Package Maintainers
45+
46+
If you are building libfortress for inclusion in a distributions package system then ensure to set `DESTDIR` prior to running meson install.
47+
48+
There is also a `bugreport_url` configuration option that is set to this repositories issues tracker by default, it is recommended to change it to your distributions bug tracking page.
49+
50+
## License
51+
52+
libfortress is licensed under the [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html) and can be found in [LICENSE](https://github.com/lethalbit/libfortress/tree/main/LICENSE).

deps/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*
2+
!.gitignore
3+
!zlib.wrap
4+
!pybind11.wrap

deps/pybind11.wrap

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[wrap-file]
2+
directory = pybind11-2.9.0
3+
source_url = https://github.com/pybind/pybind11/archive/refs/tags/v2.9.0.tar.gz
4+
source_filename = pybind11-2.9.0.tar.gz
5+
source_hash = 057fb68dafd972bc13afb855f3b0d8cf0fa1a78ef053e815d9af79be7ff567cb
6+
patch_filename = pybind11_2.9.0-1_patch.zip
7+
patch_url = https://wrapdb.mesonbuild.com/v2/pybind11_2.9.0-1/get_patch
8+
patch_hash = a96220bde795f16c23d45148acc3798ec763b84542b651b3c4b9b977bc5712ba
9+
10+
[provide]
11+
pybind11 = pybind11_dep

deps/zlib.wrap

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[wrap-file]
2+
directory = zlib-1.2.12
3+
source_url = http://zlib.net/fossils/zlib-1.2.12.tar.gz
4+
source_filename = zlib-1.2.12.tar.gz
5+
source_hash = 91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9
6+
patch_filename = zlib_1.2.12-1_patch.zip
7+
patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.2.12-1/get_patch
8+
patch_hash = 8ec8344f3fe7b06ad4be768fd416694bc56cb4545ce78b0f1c18b3e72b3ec936
9+
10+
[provide]
11+
zlib = zlib_dep
12+

examples/meson.build

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
3+
message('Building examples')

meson.build

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
project(
3+
'libfortress',
4+
'cpp',
5+
default_options: [
6+
'cpp_std=c++17',
7+
'warning_level=3',
8+
'build.cpp_std=c++17',
9+
'buildtype=debugoptimized',
10+
'strip=true',
11+
'b_ndebug=if-release',
12+
'b_lto=true'
13+
],
14+
subproject_dir: 'deps',
15+
version: '0.0.1',
16+
license: [
17+
'BSD-3-Clause',
18+
],
19+
meson_version: '>=0.59.0',
20+
)
21+
22+
cxx = meson.get_compiler('cpp')
23+
24+
if get_option('cpp_std') not in ['c++17', 'c++20', 'c++23', 'gnu++17', 'gnu++20', 'gnu++23']
25+
error('Unsupported C++ Version @0@, must be c++17/gnu++17 or newer'.format(get_option('cpp_std')))
26+
endif
27+
28+
extended_warnings = [
29+
'-Wdouble-promotion',
30+
'-Wformat=2',
31+
'-Wformat-overflow=2',
32+
'-Wformat-signedness',
33+
'-Wformat-truncation',
34+
'-Wnull-dereference',
35+
'-Wmissing-attributes',
36+
'-Wmissing-braces',
37+
'-Wsequence-point',
38+
'-Wreturn-type',
39+
'-Wunused',
40+
'-Wunused-local-typedefs',
41+
'-Wunused-const-variable=2',
42+
'-Wmaybe-uninitialized',
43+
'-Wunknown-pragmas',
44+
'-Wstrict-aliasing',
45+
'-Wstrict-overflow=3',
46+
'-Wstring-compare',
47+
'-Wstringop-overflow',
48+
'-Warith-conversion',
49+
'-Wvla-parameter',
50+
'-Wduplicated-branches',
51+
'-Wshadow=local',
52+
'-Wunsafe-loop-optimizations',
53+
'-Wbad-function-cast',
54+
'-Wcast-qual',
55+
'-Wcast-align=strict',
56+
'-Wcast-function-type',
57+
'-Wconversion',
58+
'-Wdangling-else',
59+
'-Wsign-conversion',
60+
'-Wfloat-conversion',
61+
'-Wpacked',
62+
'-Wpadded',
63+
'-Wredundant-decls',
64+
'-Winline',
65+
'-Wvla',
66+
'-Wstack-protector',
67+
'-Wunsuffixed-float-constant',
68+
'-Wimplicit-fallthrough',
69+
]
70+
71+
add_project_arguments(
72+
cxx.get_supported_arguments(extended_warnings),
73+
language: 'cpp'
74+
)
75+
76+
zlib = dependency('zlib', required: false, version: '>=1.2.12')
77+
78+
if not zlib.found()
79+
message('Did not find local zlib install, bundling')
80+
zlib_wrap = subproject('zlib', default_options: [])
81+
zlib = zlib_wrap.get_variable('zlib_dep')
82+
endif
83+
84+
85+
subdir('src')
86+
87+
if get_option('build_tests')
88+
subdir('tests')
89+
endif
90+
91+
if get_option('build_examples')
92+
subdir('examples')
93+
endif

meson_options.txt

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
option(
2+
'bugreport_url',
3+
type: 'string',
4+
value: 'https://github.com/lethalbit/libalfheim/issues',
5+
description: 'URL for bug report submissions'
6+
)
7+
8+
option(
9+
'build_bindings',
10+
type: 'boolean',
11+
value: true,
12+
description: 'Build the library with bindings'
13+
)
14+
15+
option(
16+
'build_tests',
17+
type: 'boolean',
18+
value: true,
19+
description: 'Build the library with tests'
20+
)
21+
22+
option(
23+
'build_examples',
24+
type: 'boolean',
25+
value: true,
26+
description: 'Build the library with examples'
27+
)
28+
29+
option(
30+
'bindings_python',
31+
type: 'boolean',
32+
value: true,
33+
description: 'Build the python bindings (only if build_bindings is enabled)'
34+
)
35+
36+
option(
37+
'formats',
38+
type: 'array',
39+
choices: [
40+
'dwarf', 'stabs', 'pdb', 'vms'
41+
],
42+
value: [
43+
'dwarf', 'stabs', 'pdb', 'vms'
44+
],
45+
description: 'Debug formats to build support for (defaults to all)'
46+
)

src/bindings/meson.build

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
3+
message('Building bindings')
4+
5+
if get_option('bindings_python')
6+
subdir('python')
7+
endif

src/bindings/python/libfortress.cc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
3+
#include <libfortress/config.hh>
4+
5+
#include <pybind11/pybind11.h>
6+
7+
namespace py = pybind11;
8+
9+
PYBIND11_MODULE(libfortress, m) {
10+
11+
m.doc() = "A library for parsing and generating various debug file formats.";
12+
m.attr("__version__") = Fortress::Config::version;
13+
14+
}

src/bindings/python/meson.build

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
3+
message('Building bindings: Python')
4+
5+
py = import('python')
6+
py = py.find_installation(
7+
'python3',
8+
required: false,
9+
modules: []
10+
)
11+
12+
pybind11 = dependency('pybind11', required: false, version: '>=2.7.0')
13+
if not pybind11.found()
14+
message('Did not find local pybind11 install, bundling')
15+
pybind11_wrap = subproject('pybind11', default_options: [])
16+
pybind11 = pybind11_wrap.get_variable('pybind11_dep')
17+
endif
18+
19+
libfortress_py = py.extension_module(
20+
'libfortress',
21+
files([
22+
'libfortress.cc'
23+
]),
24+
25+
include_directories: [
26+
library_inc,
27+
],
28+
29+
dependencies: [
30+
pybind11
31+
],
32+
33+
link_with: [
34+
libfortress,
35+
],
36+
37+
cpp_args: [
38+
'-DLIBFORTRESS_BINDINGS_PYTHON'
39+
],
40+
41+
install: (not meson.is_subproject())
42+
)

src/libfortress/config.hh.in

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
/* config.hh - Build-time configuration */
3+
@AUTOGEN_HEADER@
4+
#pragma once
5+
#if !defined(libfortress_config_hh)
6+
#define libfortress_config_hh
7+
8+
#include <string_view>
9+
using namespace std::literals::string_view_literals;
10+
11+
namespace Fortress::Config {
12+
/* Version Information */
13+
constexpr static auto version{"@VERSION_NUMBER@"sv};
14+
constexpr static auto git_hash{"@GIT_HASH@"sv};
15+
constexpr static auto compiler_name{"@COMPILER_NAME@"sv};
16+
constexpr static auto compiler_version{"@COMPILER_VERSION@"sv};
17+
18+
/* Platform Information */
19+
constexpr static auto target_system{"@TARGET_SYS@"sv};
20+
constexpr static auto target_arch{"@TARGET_ARCH@"sv};
21+
22+
constexpr static auto build_system{"@BUILD_SYS@"sv};
23+
constexpr static auto build_arch{"@BUILD_ARCH@"sv};
24+
25+
26+
/* Misc */
27+
constexpr static auto bugreport_url{"@BUGREPORT_URL@"sv};
28+
}
29+
30+
#endif /* libfortress_config_hh */

0 commit comments

Comments
 (0)