Fallback to default plugin install path

pull/5/head
A. R. Shajii 2021-10-17 16:26:26 -04:00
parent 497a111f43
commit 70a8864e9f
3 changed files with 11 additions and 3 deletions

View File

@ -34,7 +34,7 @@ build/codon run test/core/exit.codon || if [[ $? -ne 42 ]]; then false; fi
# package
export CODON_BUILD_ARCHIVE=codon-$(uname -s | awk '{print tolower($0)}')-$(uname -m).tar.gz
mkdir -p codon-deploy/bin codon-deploy/lib/codon
mkdir -p codon-deploy/bin codon-deploy/lib/codon codon-deploy/plugins
cp build/codon codon-deploy/bin/
cp build/libcodon*.so codon-deploy/lib/codon/
cp build/libomp.so codon-deploy/lib/codon/

View File

@ -184,7 +184,7 @@ jobs:
- name: Prepare Artifacts
run: |
mkdir -p codon-deploy/bin codon-deploy/lib/codon
mkdir -p codon-deploy/bin codon-deploy/lib/codon codon-deploy/plugins
cp build/codon codon-deploy/bin/
cp build/libcodon*.${LIBEXT} codon-deploy/lib/codon/
cp build/libomp.${LIBEXT} codon-deploy/lib/codon/

View File

@ -1,5 +1,6 @@
#include "plugins.h"
#include <cstdlib>
#include <filesystem>
#include "codon/parser/common.h"
@ -27,7 +28,14 @@ bool PluginManager::load(const std::string &path, std::string *errMsg) {
const std::string libExt = "so";
#endif
fs::path tomlPath = fs::path(path) / "plugin.toml";
const std::string config = "plugin.toml";
fs::path tomlPath = fs::path(path) / config;
if (!fs::exists(tomlPath)) {
// try default install path
if (auto *homeDir = std::getenv("HOME"))
tomlPath = fs::path(homeDir) / ".codon/plugins" / path / config;
}
toml::parse_result tml;
try {
tml = toml::parse_file(tomlPath.string());