-
Notifications
You must be signed in to change notification settings - Fork 110
Add meson build system #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
elmarco
wants to merge
18
commits into
stefanberger:master
Choose a base branch
from
elmarco:meson
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8889e37
tests: fix gcc pragma dignostic name
elmarco da26c94
feat: Add initial Meson build system
elmarco 37b412f
meson: fix license
elmarco 9ef45de
feat: Add OpenSSL dependency and header installation
elmarco de29c4b
feat: Add build options for TPM1 and TPM2 support
elmarco d851618
feat: Add full source lists for TPM1 and TPM2
elmarco 60bd037
feat: Add compiler warning and hardening flags
elmarco 74b91be
feat: Add support for FreeBL crypto backend
elmarco 4bfb164
feat: Add option to enable/disable use of OpenSSL functions
elmarco 6162498
feat: Add man page generation to Meson build
elmarco 869b7c9
meson: fix build with tpm1/tpm2 flag
elmarco 1aa9449
meson: fix build with missing crypto flag
elmarco 9ab7ac1
feat: implement tests with meson
elmarco 86b5684
meson: add versioning and symbol exports
elmarco 814c817
meson: fix linking object_size
elmarco 18d4037
meson: cleanups & misc improvements
elmarco b479163
feat: Add meson build to GitHub CI
elmarco 80ef24a
meson: change format of source files
elmarco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| tpm_library_h = configure_file( | ||
| input: 'tpm_library.h.in', | ||
| output: 'tpm_library.h', | ||
| configuration: conf_data, | ||
| ) | ||
|
|
||
| install_headers( | ||
| 'tpm_error.h', | ||
| 'tpm_memory.h', | ||
| 'tpm_nvfilename.h', | ||
| 'tpm_tis.h', | ||
| 'tpm_types.h', | ||
| tpm_library_h, | ||
| subdir: 'libtpms' | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| subdir('libtpms') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| pod_files = [ | ||
| 'TPM_IO_Hash_Start.pod', | ||
| 'TPM_IO_TpmEstablished_Get.pod', | ||
| 'TPM_Malloc.pod', | ||
| 'TPMLIB_CancelCommand.pod', | ||
| 'TPMLIB_ChooseTPMVersion.pod', | ||
| 'TPMLIB_DecodeBlob.pod', | ||
| 'TPMLIB_GetInfo.pod', | ||
| 'TPMLIB_GetTPMProperty.pod', | ||
| 'TPMLIB_GetVersion.pod', | ||
| 'TPMLIB_MainInit.pod', | ||
| 'TPMLIB_Process.pod', | ||
| 'TPMLIB_RegisterCallbacks.pod', | ||
| 'TPMLIB_SetBufferSize.pod', | ||
| 'TPMLIB_SetDebugFD.pod', | ||
| 'TPMLIB_SetProfile.pod', | ||
| 'TPMLIB_SetState.pod', | ||
| 'TPMLIB_ValidateState.pod', | ||
| 'TPMLIB_VolatileAll_Store.pod', | ||
| 'TPMLIB_WasManufactured.pod', | ||
| ] | ||
|
|
||
| pod2man = find_program('pod2man', required: true) | ||
|
|
||
| foreach pod : pod_files | ||
| base_name = pod.split('.')[0] | ||
| target_name = base_name + '.3' | ||
|
|
||
| custom_target(target_name, | ||
| input: pod, | ||
| output: target_name, | ||
| command: [pod2man, '-r', 'libtpms', '-c', '""', '-n', base_name, '--section=3', '@INPUT@', '@OUTPUT@'], | ||
| capture: false, | ||
| install: true, | ||
| install_dir: get_option('mandir') / 'man3' | ||
| ) | ||
| endforeach |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| subdir('man3') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| project( | ||
| 'libtpms', ['c', 'cpp'], | ||
| version: '0.11.0', | ||
| license: 'BSD-3-Clause AND LicenseRef-TCGL', | ||
| default_options: ['c_std=c99', 'warning_level=1', 'werror=true'], | ||
| meson_version: '>=1.1', | ||
| ) | ||
|
|
||
| c_compiler = meson.get_compiler('c') | ||
|
|
||
| # Add an include directory that points to the build directory. | ||
| add_project_arguments('-I' + meson.current_build_dir(), language: 'c') | ||
|
|
||
| # Add common warning flags | ||
| warning_flags = [ | ||
| '-Wshadow', | ||
| '-Wreturn-type', | ||
| '-Wsign-compare', | ||
| '-Wno-self-assign', | ||
| '-Wmissing-prototypes' | ||
| ] | ||
| supported_warning_flags = c_compiler.get_supported_arguments(warning_flags) | ||
| add_project_arguments(supported_warning_flags, language: 'c') | ||
|
|
||
| # Get build options | ||
| with_tpm1 = get_option('tpm1') | ||
| with_tpm2 = get_option('tpm2') | ||
| crypto_backend = get_option('crypto_backend') | ||
|
|
||
| if crypto_backend == 'openssl' | ||
| add_project_arguments(['-DUSE_OPENSSL_CRYPTO_LIBRARY=1'], language: 'c') | ||
| else | ||
| add_project_arguments(['-DUSE_FREEBL_CRYPTO_LIBRARY=1'], language: 'c') | ||
| endif | ||
|
|
||
| # Add hardening flags for non-plain build types | ||
| if get_option('buildtype') != 'plain' | ||
| hardening_c_flags = [] | ||
| # Stack protector | ||
| if c_compiler.has_argument('-fstack-protector-strong') | ||
| hardening_c_flags += '-fstack-protector-strong' | ||
| elif c_compiler.has_argument('-fstack-protector') | ||
| hardening_c_flags += '-fstack-protector' | ||
| endif | ||
| # Fortify source only works with optimization | ||
| if get_option('optimization') != '0' | ||
| if c_compiler.has_argument('-D_FORTIFY_SOURCE=2') | ||
| hardening_c_flags += '-D_FORTIFY_SOURCE=2' | ||
| endif | ||
| endif | ||
| add_project_arguments(hardening_c_flags, language: 'c') | ||
|
|
||
| hardening_ld_flags = [] | ||
| # Linker hardening | ||
| if c_compiler.has_link_argument('-Wl,-z,relro') | ||
| hardening_ld_flags += '-Wl,-z,relro' | ||
| endif | ||
| if c_compiler.has_link_argument('-Wl,-z,now') | ||
| hardening_ld_flags += '-Wl,-z,now' | ||
| endif | ||
| add_project_link_arguments(hardening_ld_flags, language: 'c') | ||
| endif | ||
|
|
||
| # Versioning | ||
| libtpms_version = meson.project_version() | ||
| libtpms_version_arr = libtpms_version.split('.') | ||
| libtpms_ver_major = libtpms_version_arr[0].to_int() | ||
| libtpms_ver_minor = libtpms_version_arr[1].to_int() | ||
| libtpms_ver_micro = libtpms_version_arr[2].to_int() | ||
|
|
||
| # Create a configuration header file | ||
| conf_data = configuration_data() | ||
| conf_data.set('PACKAGE_VERSION', '"' + meson.project_version() + '"') | ||
| conf_data.set('LIBTPMS_VER_MAJOR', libtpms_ver_major) | ||
| conf_data.set('LIBTPMS_VER_MINOR', libtpms_ver_minor) | ||
| conf_data.set('LIBTPMS_VER_MICRO', libtpms_ver_micro) | ||
|
|
||
| # config.h could be dropped if when autotools is removed | ||
| configure_file( | ||
| output: 'config.h', | ||
| configuration: conf_data | ||
| ) | ||
|
|
||
| # Add subdirectories to the build | ||
| subdir('include') | ||
| subdir('src') | ||
| subdir('man') | ||
| subdir('tests') | ||
|
|
||
| summary_info = {} | ||
| summary_info += {'Build directory': meson.current_build_dir()} | ||
| summary_info += {'Source path': meson.current_source_dir()} | ||
| summary_info += {'TPM1': with_tpm1} | ||
| summary_info += {'TPM2': with_tpm2} | ||
| summary_info += {'Crypto backend': crypto_backend} | ||
|
|
||
| summary(summary_info, bool_yn: true, section: 'Build configuration') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
|
|
||
| option('tpm1', type: 'boolean', value: true, description: 'Build with TPM 1.2 support.') | ||
| option('tpm2', type: 'boolean', value: true, description: 'Build with TPM 2.0 support.') | ||
| option('crypto_backend', type: 'combo', choices: ['openssl', 'freebl'], value: 'openssl', description: 'Choose the cryptographic backend.') | ||
| option('use_openssl_functions', type: 'boolean', value: true, description: 'Use OpenSSL functions for crypto instead of internal code.') | ||
| option('fuzzing_engine', type: 'boolean', value: false, description: 'Build with fuzzing engine') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
pip install mesonhere maybe? Do we need ninja to build?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe we add link to https://mesonbuild.com/Quick-guide.html