Build with Meson instead of CMake

dblsaiko
Nov 30, 2024, 10:13 PM
N2RTQC4PEXZEGZPWHYJHIXS6LOI3EFYDYATNG4HMCR6JGDI3NZ6QC

Dependencies

  • [2] KAVSKDAY Explicitly link against needed Nix libraries to fix compilation on Mac
  • [3] O5ZJE5FM Remove Clang workaround as clangStdenv is now at least 17
  • [4] 4OTS5CAK Version 0.1.2
  • [5] ZZW47X5H Version 0.1.1
  • [6] FYYWB54C Fix conflicts
  • [7] XGCRPWKL Move repo interaction into separate source file
  • [8] GCOWWL5G Crusty debug header
  • [9] DYNXZQZV Uncouple some of the logic from Nix library and add basic tests
  • [10] 72KPLIMX Store version in central file
  • [11] XXCRSVXO
  • [12] KEPVL66D Partially fix build on Mac
  • [13] SGQQ6LNZ Attach Boost and SYSTEM def to Nix target instead of plugin
  • [14] NQT3HEZH Add README.md
  • [15] 7YS2X7JJ Fix compilation against older Nix versions (tested with 2.13.6)
  • [16] 22Y4O5IR Add LICENSE
  • [17] 3KEFKH5F Import existing code
  • [18] UZYI7CB2 Fix compile errors on macOS in dev shell
  • [19] GIEUXXMH Initial commit

Change contents

  • file deletion: CMakeLists.txt (----------)
    [4.1][4.13775:13813](),[4.13813][4.13814:13814]()
    cmake_minimum_required(VERSION 3.23)
    set(CMAKE_CXX_STANDARD 20)
    set(CMAKE_C_STANDARD 17)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
    set(CMAKE_SHARED_MODULE_PREFIX)
    include(GNUInstallDirs)
    find_package(PkgConfig REQUIRED)
    find_package(Boost REQUIRED)
    find_package(date REQUIRED)
    add_subdirectory(src)
    set(Nix_VERSION ${Nix_nix-main_VERSION})
    string(REPLACE "." ";" VERSION_LIST ${Nix_VERSION})
    list(GET VERSION_LIST 0 Nix_MAJOR_VERSION)
    list(GET VERSION_LIST 1 Nix_MINOR_VERSION)
    list(GET VERSION_LIST 2 Nix_PATCH_VERSION)
    target_compile_definitions(PkgConfig::Nix
    INTERFACE
    "NIX_MAJOR_VERSION=(${Nix_MAJOR_VERSION})"
    "NIX_MINOR_VERSION=(${Nix_MINOR_VERSION})"
    "NIX_PATCH_VERSION=(${Nix_PATCH_VERSION})"
    add_subdirectory(autotests)
    "NIX_VERSION=(((0x${Nix_MAJOR_VERSION})<<16) | ((0x${Nix_MINOR_VERSION})<<8) | (0x${Nix_PATCH_VERSION}))"
    SYSTEM="")
    target_link_libraries(PkgConfig::Nix
    INTERFACE
    Boost::headers
    date::date
    nlohmann_json)
    add_compile_options(-Wall -Werror)
    pkg_check_modules(Nix REQUIRED IMPORTED_TARGET nix-main nix-store)
    find_library(nixfetchers_LIBRARY nixfetchers REQUIRED)
    target_link_libraries(PkgConfig::Nix INTERFACE ${nixfetchers_LIBRARY})
    find_package(nlohmann_json REQUIRED)
    include(CTest)
    file(STRINGS VERSION _version)
    project(nix-plugin-pijul VERSION ${_version})
  • file deletion: CMakeLists.txt (----------)
    [4.15][4.12980:13018](),[4.13018][4.13019:13019]()
    add_library(pijul MODULE)
    install(TARGETS pijul DESTINATION ${CMAKE_INSTALL_LIBDIR}/nix/plugins)
    target_sources(pijul PRIVATE ${SRC})
    target_sources(PijulTesting PRIVATE ${SRC})
    target_include_directories(PijulTesting PUBLIC ${CMAKE_CURRENT_LIST_DIR})
    target_compile_options(PijulTesting PUBLIC -O1 -ggdb)
    target_link_libraries(PijulTesting PRIVATE date::date)
    target_link_libraries(pijul
    PUBLIC
    PkgConfig::Nix)
    fetcher.cpp
    repo.cpp
    repo.h)
    set(SRC
    compat.cpp
    compat.h
    add_library(PijulTesting STATIC)
  • file addition: meson.build (----------)
    [4.15]
    lib_src = files(
    'compat.cpp',
    'fetcher.cpp',
    'repo.cpp',
    )
    lib_inc = include_directories('.')
    # Nix uses these macros that are only defined in its own build
    lib_extra_cppflags = ['-DSYSTEM=""']
    if nix_main_dep.version().version_compare('<=2.22')
    lib_extra_cppflags += ['-DHAVE_STRUCT_DIRENT_D_TYPE']
    endif
    lib = shared_module(
    'pijul',
    lib_src,
    dependencies: [
    nix_main_dep,
    nix_store_dep,
    ],
    cpp_args: [
    f'-DNIX_MAJOR_VERSION=(@nix_major_version@)',
    f'-DNIX_MINOR_VERSION=(@nix_minor_version@)',
    f'-DNIX_PATCH_VERSION=(@nix_patch_version@)',
    f'-DNIX_VERSION=(((0x@nix_major_version@)<<16) | ((0x@nix_minor_version@)<<8) | (0x@nix_patch_version@))',
    ] + lib_extra_cppflags,
    include_directories: lib_inc,
    install: true,
    install_dir: get_option('libdir') / 'nix/plugins',
    name_prefix: '',
    )
    test_lib = static_library(
    'testsupport',
    lib_src,
    include_directories: lib_inc,
    )
  • replacement in package.nix at line 4
    [4.114][4.13355:13364](),[4.13355][4.13355:13364]()
    cmake,
    [4.13355]
    [4.13364]
    meson,
    ninja,
  • replacement in package.nix at line 18
    [3.134][3.134:144]()
    cmake
    [3.134]
    [3.144]
    meson
    ninja
  • file addition: meson.build (----------)
    [4.1]
    project(
    'nix-plugin-pijul',
    'cpp',
    license: 'LGPL-3.0',
    license_files: ['LICENSE'],
    version: configure_file(input: 'VERSION', output: 'VERSION', copy: true),
    default_options: {
    'cpp_std': 'c++20',
    'werror': true,
    }
    )
    nix_main_dep = dependency('nix-main', required: true)
    nix_store_dep = dependency('nix-store', required: true)
    nix_version_components = nix_main_dep.version().split('.')
    nix_major_version = nix_version_components[0]
    nix_minor_version = nix_version_components[1]
    nix_patch_version = nix_version_components[2]
    if nix_patch_version.contains('_')
    nix_patch_version = '99'
    endif
    subdir('src')
    subdir('autotests')
  • file deletion: CMakeLists.txt (----------)
    [4.7869][4.9654:9692](),[4.9692][4.9693:9693]()
    add_compile_options(-O1 -ggdb)
    add_executable(DateTest datetest.cpp)
    target_link_libraries(DateTest PUBLIC PijulTesting)
    add_test(NAME DateTest COMMAND DateTest)
    add_executable(RepoTest repotest.cpp)
    target_link_libraries(RepoTest PUBLIC PijulTesting)
    add_test(NAME RepoTest COMMAND RepoTest)
  • file addition: meson.build (----------)
    [4.7869]
    datetest_exe = executable(
    'datetest',
    ['datetest.cpp'],
    link_with: [test_lib],
    include_directories: [lib_inc],
    )
    test('date', datetest_exe)
    repotest_exe = executable(
    'repotest',
    ['repotest.cpp'],
    link_with: [test_lib],
    include_directories: [lib_inc],
    )
    test('repo', repotest_exe)