Skip to content

Commit

Permalink
added meson build
Browse files Browse the repository at this point in the history
  • Loading branch information
polar committed Mar 24, 2024
1 parent bbd9566 commit a401adf
Show file tree
Hide file tree
Showing 106 changed files with 3,539 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /usr/bin/env bash

export PKG_CONFIG_PATH="/usr/lib/pkgconfig/;/lib/pkgconfig/;/usr/share/pkgconfig/"

# Delete existing buildfiles
#---------------------------------------------------
rm -rf build


# Call meson
#---------------------------------------------------
meson setup build -Dprefix="/usr"


# Build nix
#---------------------------------------------------
cd build
ninja
7 changes: 7 additions & 0 deletions dependencies/archive/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# LibArchive Dependency File
#============================================================================


# Look for libarchive, a required dependency
#--------------------------------------------------
libarchive_dep = cpp.find_library('archive')
82 changes: 82 additions & 0 deletions dependencies/aws-sdk-cpp/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# aws s3 Dependency File
#============================================================================

#--------------------------------------------------
# FIXME: aws-cpp-sdk should be an optional dependency Unfortunately, importing
# it using the pkg-config option, which could be optional, fails because of
# the cflags in the pkg-config. They contain "-fno-exceptions -std=c++11",
# both of which break existing Nix code.
#--------------------------------------------------

# Look for aws-cpp-sdk
#--------------------------------------------------
aws_sdk_cpp_core_dep = declare_dependency(
dependencies : cpp.find_library('aws-cpp-sdk-core',
dirs : get_option('aws_sdk_cpp_lib_dir')),
include_directories : include_directories(
get_option('aws_sdk_cpp_include_dir')))

aws_sdk_cpp_s3_dep = declare_dependency(
dependencies : cpp.find_library('aws-cpp-sdk-s3',
dirs : get_option('aws_sdk_cpp_lib_dir')),
include_directories : include_directories(
get_option('aws_sdk_cpp_include_dir')))

aws_sdk_cpp_transfer_dep = declare_dependency(
dependencies : cpp.find_library('aws-cpp-sdk-transfer',
dirs : get_option('aws_sdk_cpp_lib_dir')),
include_directories : include_directories(
get_option('aws_sdk_cpp_include_dir')))


aws_sdk_cpp_dep = [
aws_sdk_cpp_core_dep,
aws_sdk_cpp_s3_dep,
aws_sdk_cpp_transfer_dep,
]

# check if dependencies are found
#--------------------------------------------------
have_aws_sdk_cpp = true
foreach dep : aws_sdk_cpp_dep
if not dep.found()
have_aws_sdk_cpp = false
endif
endforeach


# set config variable(s)
#--------------------------------------------------
config_h.set(
'ENABLE_S3',
have_aws_sdk_cpp.to_int(),
description : 'Whether to enable S3 support via aws-sdk-cpp.')

if have_aws_sdk_cpp
check_s3client = cpp.check_header(
'aws/s3/S3Client.h',
dependencies: aws_sdk_cpp_dep)

if check_s3client
config_h.set(
'HAVE_AWS_S3_S3CLIENT_H', 1,
description : 'Whether to enable S3 support via aws-sdk-cpp.')
endif

aws_version = meson.get_compiler('cpp').get_define(
'AWS_SDK_VERSION_STRING',
prefix : '#include <aws/core/VersionConfig.h>'
).strip('"').split('.')

config_h.set(
'AWS_VERSION_MAJOR', aws_version[0],
description : 'Major version of aws-sdk-cpp.')

config_h.set(
'AWS_VERSION_MINOR', aws_version[1],
description : 'Minor version of aws-sdk-cpp.')
config_h.set(
'AWS_VERSION_PATCH', aws_version[2],
description : 'Patch version of aws-sdk-cpp.')

endif
13 changes: 13 additions & 0 deletions dependencies/bdw-gc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Boehm-gc Dependency File
#============================================================================


# Look for Boehm garbage collector, an optional dependency
#--------------------------------------------------
gc_dep = dependency('bdw-gc', required: get_option('gc'))


config_h.set(
'HAVE_BOEHMGC',
gc_dep.found().to_int(),
description : 'Whether to use the Boehm garbage collector.')
22 changes: 22 additions & 0 deletions dependencies/boost/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Boost Dependency File
#============================================================================


# Look for boost, a required dependency
#----------------------------------------------------
boost_mod_list = [
'system',
'context',
'thread']


boost_dep = dependency(
'boost',
modules: boost_mod_list)


# set config variable(s)
#--------------------------------------------------
config_h.set(
'HAVE_BOOST', 1,
description : 'Define if the Boost library is available.')
17 changes: 17 additions & 0 deletions dependencies/brotli/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# LibBrotli Dependency File
#============================================================================


# Look for libbrotli{enc,dec}, a required dependency
#--------------------------------------------------
libbrotli_dep = declare_dependency(
dependencies: [
dependency('libbrotlienc'),
dependency('libbrotlidec')])


# set config variable(s)
#--------------------------------------------------
config_h.set(
'HAVE_BROTLI', 1,
description : 'Define if the brotli library is available.')
13 changes: 13 additions & 0 deletions dependencies/cpuid/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# cpuid Dependency File
#============================================================================


# Look for cpuid, a required dependency
#--------------------------------------------------
libcpuid_dep = dependency('libcpuid')

# set config variable(s)
#--------------------------------------------------
config_h.set(
'HAVE_LIBCPUID', 1,
description : 'Define if the CPUID is available.')
14 changes: 14 additions & 0 deletions dependencies/curl/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# LibCurl Dependency File
#============================================================================


# Look for libcurl, a required dependency
#--------------------------------------------------
libcurl_dep = dependency('libcurl')


# set config variable(s)
#--------------------------------------------------
config_h.set(
'HAVE_CURL', 1,
description : 'Define if the curl library is available.')
7 changes: 7 additions & 0 deletions dependencies/dl/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# libdl Dependency File
#============================================================================


# Look for libdl, a required dependency
#--------------------------------------------------
libdl_dep = cpp.find_library('dl')
35 changes: 35 additions & 0 deletions dependencies/editline/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Editline Dependency File
#============================================================================


# Look for editline, a required dependency
#--------------------------------------------------
# NOTE: The the libeditline.pc file was added only in libeditline >= 1.15.2, see
# https://github.com/troglobit/editline/commit/0a8f2ef4203c3a4a4726b9dd1336869cd0da8607,
# but e.g. Ubuntu 16.04 has an older version, so we fall back to searching for
# editline.h when the pkg-config approach fails.

editline_dep = cpp.find_library('editline')

if not (
cpp.has_header(
'editline.h',
dependencies : editline_dep))
error('Nix requires editline.h; however the header was not found.')
endif


if not (
cpp.has_function(
'read_history',
prefix : '#include <stdio.h>\n#include "editline.h"',
dependencies : editline_dep))
error('Nix requires libeditline; However, required functions do not work.' +\
'Maybe libeditline version is too old? >= 1.14 is required.')
endif

# set config variable(s)
#--------------------------------------------------
config_h.set(
'HAVE_EDITLINE_H', 1,
description : 'Define to 1 if you have the <editline.h> header file.')
40 changes: 40 additions & 0 deletions dependencies/functions/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# nix check functions
#============================================================================


# check for required functions
#--------------------------------------------------
required_functions = [
'lutimes',
'lchown',
'pipe2',
'posix_fallocate',
'setresuid',
'setreuid',
'statvfs',
'strsignal',
'sysconf']

foreach f : required_functions
if cpp.has_function(f)
config_h.set(
'HAVE_@0@'.format(f.to_upper()), 1,
description : 'Define to 1 if you have the `@0@` function.'.format(f))
endif
endforeach


# compiler check for pubsetbuff
#--------------------------------------------------
pubsetbuff_c = '''
#include <iostream>
using namespace std;
static char buf[1024];
void func() {
cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
}'''

check_pubsetbuff = meson.get_compiler('cpp').compiles(pubsetbuff_c, name : 'pubsetbuf')
config_h.set(
'HAVE_PUBSETBUF', check_pubsetbuff.to_int(),
description : 'Define to 1 if you have the `pubsetbuf` function.')
24 changes: 24 additions & 0 deletions dependencies/gtest/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# gtest Dependency File
#========================================================================


# check if gtest is already installed
#---------------------------------------------------
gtest_dep = dependency(
'gtest',
main : true,
required : false)

gmock_dep = dependency(
'gmock',
main : true,
required : false)


# If not, include the submodule
#---------------------------------------------------
if not gtest_dep.found()
gtest_proj = subproject('gtest')
gtest_dep = gtest_proj.get_variable('gtest_main_dep')
gmock_dep = gtest_proj.get_variable('gmock_dep')
endif
45 changes: 45 additions & 0 deletions dependencies/headers/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# nix check headers
#============================================================================

# check for various headers
#--------------------------------------------------
project_header_deps = [
'sys/stat.h',
'sys/types.h',
'sys/dir.h',
'sys/ndir.h',
'dirent.h',
'locale.h',
'unistd.h',
'stdint.h',
'stdlib.h',
'strings.h',
'string.h',
'inttypes.h',
'memory.h']

foreach f : project_header_deps
if cpp.has_header(f)
config_h.set(
'HAVE_@0@'.format(f.to_upper().underscorify()), 1,
description : 'Define to 1 if you have the `<@0@>` header file..'.format(f))
endif
endforeach


# TODO: this was carried over from the autotools buildsystem,
# but i think it may no longer be needed.

# compiler check for dirent.h
#--------------------------------------------------
dirent_h_prefix = '''
#include <sys/types.h>
#include <dirent.h>
'''

check_struct_dirent = meson.get_compiler('cpp').has_member(
'struct dirent', 'd_type', prefix: dirent_h_prefix)

if ((config_h.get('HAVE_DIRENT_H') == 1) and (check_struct_dirent))
config_h.set('HAVE_STRUCT_DIRENT_D_TYPE', 1)
endif
11 changes: 11 additions & 0 deletions dependencies/lowdown/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# lowdown Dependency File
#============================================================================


# FIXME !! lowdown is seemingly a required dependency for building, but
# it isn't listed anywhere on documentation that i could find. dependency
# object needs to be added to meson.

# Look for lowdown, a required dependency
#--------------------------------------------------
liblowdown_dep = dependency('lowdown')
Loading

0 comments on commit a401adf

Please sign in to comment.