Skip to content
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

Ref/packaged lib #32

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,3 @@ FetchContent_Declare(
GIT_TAG 10.1.0
)
FetchContent_MakeAvailable( fmt )

FetchContent_Declare(
ctre
GIT_REPOSITORY https://github.com/hanickadot/compile-time-regular-expressions
GIT_TAG v3.8.1
)
FetchContent_MakeAvailable( ctre )
4 changes: 2 additions & 2 deletions nix/dependencies/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{pkgs}: {
tl-optional = pkgs.callPackage ./tl-optional {version = "1.1.0";};
tl-expected = pkgs.callPackage ./tl-expected {version = "1.1.0";};
tl-optional = pkgs.callPackage ./tl-optional {};
tl-expected = pkgs.callPackage ./tl-expected {};
}
27 changes: 17 additions & 10 deletions nix/dependencies/tl-expected/default.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
{
pkgs,
version,
stdenv,
cmake,
fetchFromGitHub
}:
pkgs.stdenv.mkDerivation {
stdenv.mkDerivation (self: {
pname = "expected";
inherit version;
version = "1.1.0";

src = pkgs.fetchFromGitHub {
src = fetchFromGitHub {
owner = "TartanLlama";
repo = "expected";
rev = "v${version}";
rev = "v${self.version}";
sha256 = "sha256-AuRU8VI5l7Th9fJ5jIc/6mPm0Vqbbt6rY8QCCNDOU50=";
};

nativeBuildInputs = [pkgs.cmake];
strictDeps = true;

strictDeps = true;
nativeBuildInputs = [cmake];

postInstall = ''
install -Dm644 ${./expected.pc} $out/lib/pkgconfig/expected.pc
mkdir -p $out/lib/pkgconfig

substitute \
${./expected.pc} \
$out/lib/pkgconfig/expected.pc \
--subst-var out \
--subst-var version
'';
}
})
2 changes: 1 addition & 1 deletion nix/dependencies/tl-expected/expected.pc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ includedir=${prefix}/include

Name: expected
Description: TartanLlama's expected
Version: 1.1.0
Version: @version@
Cflags: -I${includedir}/
25 changes: 16 additions & 9 deletions nix/dependencies/tl-optional/default.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
{
pkgs,
version,
stdenv,
cmake,
fetchFromGitHub
}:
pkgs.stdenv.mkDerivation {
stdenv.mkDerivation (self: {
pname = "optional";
inherit version;
version = "1.1.0";

src = pkgs.fetchFromGitHub {
src = fetchFromGitHub {
owner = "TartanLlama";
repo = "optional";
rev = "v${version}";
rev = "v${self.version}";
sha256 = "sha256-WPTXTQmzJjAIJI1zM6svZZTO8gP/jt5xDHHRCCu9cmI=";
};

strictDeps = true;

nativeBuildInputs = [pkgs.cmake];
nativeBuildInputs = [cmake];

postInstall = ''
install -Dm644 ${./optional.pc} $out/lib/pkgconfig/optional.pc
mkdir -p $out/lib/pkgconfig

substitute \
${./optional.pc} \
$out/lib/pkgconfig/optional.pc \
--subst-var out \
--subst-var version
'';
}
})
2 changes: 1 addition & 1 deletion nix/dependencies/tl-optional/optional.pc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ includedir=${prefix}/include

Name: optional
Description: TartanLlama's optional
Version: 1.1.0
Version: @version@
Cflags: -I${includedir}/
14 changes: 3 additions & 11 deletions nix/package/package.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
rootDir,
version,

stdenv,
meson,
ninja,
pkg-config,
ctre,
catch2_3,
tl-optional,
tl-expected,
Expand All @@ -29,7 +29,6 @@ stdenv.mkDerivation {
];

buildInputs = [
ctre
catch2_3
fmt
tl-optional
Expand All @@ -51,15 +50,8 @@ stdenv.mkDerivation {
"-Dstrip=true"
];

buildPhase = ''
meson compile dire
'';

installPhase = ''
mkdir -p {$dev,$out}/lib $dev/lib/pkgconfig $dev/include

cp src/lib/libdire.a $out/lib
cp src/lib/libdire.a $dev/lib
postInstall = ''
mkdir -p $dev/lib/pkgconfig $dev/include

cp -r $src/src/lib/include/* $dev/include

Expand Down
2 changes: 0 additions & 2 deletions nix/shell/shells.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
meson,
ninja,
pkg-config,
ctre,
catch2_3,
fmt,
tl-optional,
Expand Down Expand Up @@ -39,7 +38,6 @@
ninja
pkg-config

ctre
catch2_3
fmt
tl-optional
Expand Down
2 changes: 0 additions & 2 deletions src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ if(WIN32)
target_compile_definitions(dire-common INTERFACE WIN32_LEAN_AND_MEAN NOMINMAX)
endif()

target_link_libraries(dire-common INTERFACE ctre)

if (DIRE_USE_TL_LIBS)
target_compile_definitions(dire-common INTERFACE DIRE_USE_TL_LIBS)
target_link_libraries(dire-common INTERFACE tl::optional tl::expected)
Expand Down
12 changes: 1 addition & 11 deletions src/lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@ cmake = import('cmake')
build_type_opts = cmake.subproject_options()
build_type_opts.add_cmake_defines( { 'CMAKE_BUILD_TYPE': get_option('buildtype').to_upper() } )

ctre = dependency('ctre', version: '3.8.1', required: false)
if not ctre.found()
ctre_sub = cmake.subproject('ctre', options: build_type_opts, required: true)
message('ctre targets:\n - ' + '\n - '.join(ctre_sub.target_list()))

ctre = ctre_sub.dependency('ctre')
endif

local_deps = [
ctre,
]
local_deps = [ ]

if(get_option('use_tl_libs'))
add_project_arguments('-DDIRE_USE_TL_LIBS', language: 'cpp')
Expand Down
2 changes: 0 additions & 2 deletions src/lib/src/dire/detail/system_dirs/xdg_user_dirs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <utility>
#include <string>

#include <ctre.hpp>

#include <dire/detail/system_dirs/xdg_user_dirs.hpp>
#include <dire/defines.hpp>

Expand Down
Loading