Skip to content

Commit

Permalink
Merge pull request #149 from edmonds/main
Browse files Browse the repository at this point in the history
Meson build system
  • Loading branch information
jedisct1 authored Mar 3, 2024
2 parents 1580bc9 + 9819f69 commit 8672ac1
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 4 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,36 @@ jobs:
fail-fast: false
matrix:
language: [ 'c-cpp' ]
autobuild_force_build_system: ['cmake', 'make', 'meson']

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Maybe remove non-CMake build systems
if: matrix.autobuild_force_build_system == 'cmake'
run: |
rm -vrf Makefile* meson.build
- name: Maybe remove non-Make build systems
if: matrix.autobuild_force_build_system == 'make'
run: |
rm -vrf CMakeLists.txt cmake/ meson.build
- name: Maybe remove non-Meson build systems
if: matrix.autobuild_force_build_system == 'meson'
run: |
rm -vrf Makefile* CMakeLists.txt cmake/
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
67 changes: 67 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
project(
'libhydrogen',
'c',
license: 'ISC',
default_options: [
'buildtype=minsize',
'default_library=static',
'warning_level=2',
],
)

cc = meson.get_compiler('c')

cflags = cc.get_supported_arguments(
'-Wbad-function-cast',
'-Wcast-align',
'-Wcast-qual',
'-Wdiv-by-zero',
'-Wfloat-equal',
'-Wmissing-declarations',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wno-type-limits',
'-Wno-unknown-pragmas',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wstrict-prototypes',
'-Wswitch-enum',
'-fno-exceptions',
'-mtune=native',
)
add_project_arguments(cflags, language: 'c')

include_dirs = include_directories('.')

sources = files(
'hydrogen.c',
)

libhydrogen = library(
'hydrogen',
sources,
include_directories: include_dirs,
install: true,
)

tests = executable(
'tests',
files('tests/tests.c'),
link_with: libhydrogen,
)
test('tests', tests)

install_headers(files('hydrogen.h'))

pkgconfig = import('pkgconfig')
pkgconfig.generate(
libhydrogen,
name: 'libhydrogen',
description: 'Lightweight, secure, easy-to-use crypto library suitable for constrained environments.',
url: 'https://libhydrogen.org/',
)

libhydrogen_dep = declare_dependency(
include_directories: include_dirs,
link_with: libhydrogen,
)

0 comments on commit 8672ac1

Please sign in to comment.