Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ref: move anon namespaces into dire #39

Merged
merged 5 commits into from
Feb 22, 2025
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
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ jobs:
[
{ runner: macos-14 },
{ runner: macos-13 },
{ runner: macos-12 },
]
runs-on: ${{ matrix.build.runner }}
env:
Expand Down
8 changes: 6 additions & 2 deletions nix/shell/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{pkgs, config, ...}: let
shells = pkgs.callPackages ./shells.nix { inherit (config.legacyPackages) tl-optional tl-expected; };
{
pkgs,
config,
...
}: let
shells = pkgs.callPackages ./shells.nix {inherit (config.legacyPackages) tl-optional tl-expected;};
in {
devShells = {
inherit (shells) ciGcc ciClang devGcc devClang;
Expand Down
41 changes: 23 additions & 18 deletions nix/shell/shells.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
mkShell,
nil,
just,
gcc11Stdenv,
llvmPackages_16,
act,
Expand All @@ -18,37 +20,40 @@
#
# Packages
#
baseShellDeps = [
doxygen
cmake
graphviz
];

devPackages = [
act
];

baseShellAttrs = {
hardeningDisable = ["all"];

packages =
[
meson
ninja
pkg-config
nativeBuildInputs = [
just
nil

meson
ninja
pkg-config

catch2_3
fmt
tl-optional
tl-expected
]
++ baseShellDeps;
doxygen
cmake
graphviz
];

buildInputs = [
catch2_3
fmt
tl-optional
tl-expected
];
};

baseDevShellAttrs =
baseShellAttrs
// {
packages = baseShellAttrs.packages ++ devPackages;
inherit (baseShellAttrs) buildInputs;

nativeBuildInputs = baseShellAttrs.nativeBuildInputs ++ devPackages;
};

#
Expand Down
31 changes: 16 additions & 15 deletions src/lib/src/dire/linux/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,40 @@ namespace dire

namespace detail
{
auto cache_dir_from_home(dire::Path home) -> dire::Path

auto cache_dir_from_home(Path home) -> Path
{
return dire::detail::getenv("XDG_CACHE_HOME")
.and_then(dire::detail::system_dirs::non_absolute_path_to_none)
return getenv("XDG_CACHE_HOME")
.and_then(system_dirs::non_absolute_path_to_none)
.value_or(home.append(".cache"));
}

auto config_dir_from_home(dire::Path home) -> dire::Path
auto config_dir_from_home(Path home) -> Path
{
return dire::detail::getenv("XDG_CONFIG_HOME")
.and_then(dire::detail::system_dirs::non_absolute_path_to_none)
return getenv("XDG_CONFIG_HOME")
.and_then(system_dirs::non_absolute_path_to_none)
.value_or(home.append(".config"));
}

auto executable_dir_from_home(dire::Path home) -> dire::Path
auto executable_dir_from_home(Path home) -> Path
{
// WARNING: this is not officially supported by the xdg spec
return dire::detail::getenv("XDG_BIN_HOME")
.and_then(dire::detail::system_dirs::non_absolute_path_to_none)
return getenv("XDG_BIN_HOME")
.and_then(system_dirs::non_absolute_path_to_none)
.value_or(home.append(".local/bin"));
}

auto state_dir_from_home(dire::Path home) -> dire::Path
auto state_dir_from_home(Path home) -> Path
{
return dire::detail::getenv("XDG_STATE_HOME")
.and_then(dire::detail::system_dirs::non_absolute_path_to_none)
return getenv("XDG_STATE_HOME")
.and_then(system_dirs::non_absolute_path_to_none)
.value_or(home.append(".local/state"));
}

auto data_dir_from_home(dire::Path home) -> dire::Path
auto data_dir_from_home(Path home) -> Path
{
return dire::detail::getenv("XDG_DATA_HOME")
.and_then(dire::detail::system_dirs::non_absolute_path_to_none)
return getenv("XDG_DATA_HOME")
.and_then(system_dirs::non_absolute_path_to_none)
.value_or(home.append(".local/share"));
}

Expand Down
18 changes: 9 additions & 9 deletions src/lib/src/dire/mac/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,44 @@
#include <dire/detail/system_dirs/shared.hpp>
#include <dire/detail/getenv.hpp>

namespace dire
{

namespace
{

auto concat_cache_dir(dire::Path const& home) -> dire::Path
auto concat_cache_dir(Path const& home) -> Path
{
return home / "Library" / "Caches";
}

auto concat_config_dir(dire::Path const& home) -> dire::Path
auto concat_config_dir(Path const& home) -> Path
{
return home / "Library" / "Application Support";
}

auto concat_config_local_dir(dire::Path const& home) -> dire::Path
auto concat_config_local_dir(Path const& home) -> Path
{
return concat_config_dir(home);
}

auto concat_data_dir(dire::Path const& home) -> dire::Path
auto concat_data_dir(Path const& home) -> Path
{
return concat_config_dir(home);
}

auto concat_data_local_dir(dire::Path const& home) -> dire::Path
auto concat_data_local_dir(Path const& home) -> Path
{
return concat_config_dir(home);
}

auto concat_preference_dir(dire::Path const& home) -> dire::Path
auto concat_preference_dir(Path const& home) -> Path
{
return concat_config_dir(home);
}

} // namespace

namespace dire
{

auto BaseDirsBundle::make() -> Optional<BaseDirsBundle>
{
auto home = ::dire::home_dir();
Expand Down
21 changes: 11 additions & 10 deletions src/lib/src/dire/mac/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,54 @@
#include <dire/detail/system_dirs/shared.hpp>
#include <dire/detail/getenv.hpp>

namespace dire
{

namespace
{

auto concat_audio_dir(dire::Path const& home) -> dire::Path
auto concat_audio_dir(Path const& home) -> Path
{
return home / "Music";
}

auto concat_desktop_dir(dire::Path const& home) -> dire::Path
auto concat_desktop_dir(Path const& home) -> Path
{
return home / "Desktop";
}

auto concat_document_dir(dire::Path const& home) -> dire::Path
auto concat_document_dir(Path const& home) -> Path
{
return home / "Documents";
}

auto concat_download_dir(dire::Path const& home) -> dire::Path
auto concat_download_dir(Path const& home) -> Path
{
return home / "Downloads";
}

auto concat_font_dir(dire::Path const& home) -> dire::Path
auto concat_font_dir(Path const& home) -> Path
{
return home / "Library" / "Fonts";
}

auto concat_picture_dir(dire::Path const& home) -> dire::Path
auto concat_picture_dir(Path const& home) -> Path
{
return home / "Pictures";
}

auto concat_public_dir(dire::Path const& home) -> dire::Path
auto concat_public_dir(Path const& home) -> Path
{
return home / "Public";
}

auto concat_video_dir(dire::Path const& home) -> dire::Path
auto concat_video_dir(Path const& home) -> Path
{
return home / "Movies";
}

} // namespace

namespace dire
{

auto UserDirsBundle::make() -> Optional<UserDirsBundle>
{
Expand Down
19 changes: 10 additions & 9 deletions src/lib/src/dire/windows/user.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <dire/base.hpp>
#include <dire/user.hpp>

#include <dire/detail/system_dirs/system_dirs.hpp>
Expand All @@ -7,23 +8,23 @@ namespace dire

auto UserDirsBundle::make() -> Optional<UserDirsBundle>
{
auto home = home_dir();
auto home = ::dire::home_dir();

if(not home) {
return {};
}

return UserDirsBundle {
.audio_dir = *audio_dir(),
.desktop_dir = *desktop_dir(),
.document_dir = *document_dir(),
.download_dir = *download_dir(),
.picture_dir = *picture_dir(),
.video_dir = *video_dir(),
.public_dir = *public_dir(),
.audio_dir = *::dire::audio_dir(),
.desktop_dir = *::dire::desktop_dir(),
.document_dir = *::dire::document_dir(),
.download_dir = *::dire::download_dir(),
.picture_dir = *::dire::picture_dir(),
.video_dir = *::dire::video_dir(),
.public_dir = *::dire::public_dir(),

.font_dir = {},
.template_dir = *template_dir(),
.template_dir = *::dire::template_dir(),
};
}

Expand Down