Skip to content

Commit 57a420f

Browse files
authored
Merge pull request #143 from delafthi/feature/search_installed_libraries
Search the installed libraries in a hardcoded set of locations
2 parents 73a17b5 + 5b4028b commit 57a420f

File tree

5 files changed

+27
-25
lines changed

5 files changed

+27
-25
lines changed

.github/workflows/build-test-all.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ jobs:
4949
uses: actions-rs/cargo@v1
5050
with:
5151
command: build
52-
args: --manifest-path ${{ matrix.crate }}/Cargo.toml --release --target ${{ matrix.target }} --features "packaged"
52+
args: --manifest-path ${{ matrix.crate }}/Cargo.toml --release --target ${{ matrix.target }}
5353

5454
- name: Test
5555
uses: actions-rs/cargo@v1
5656
with:
5757
command: test
58-
args: --manifest-path ${{ matrix.crate }}/Cargo.toml --release --target ${{ matrix.target }} --features "packaged"
58+
args: --manifest-path ${{ matrix.crate }}/Cargo.toml --release --target ${{ matrix.target }}
5959

6060
- name: rustfmt
6161
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable'

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM clux/muslrust:$RUST_VERSION as builder
33
WORKDIR /volume
44
COPY . /volume/
55
ARG CRATE
6-
RUN cargo build --manifest-path $CRATE/Cargo.toml --release --features "packaged"
6+
RUN cargo build --manifest-path $CRATE/Cargo.toml --release
77

88
FROM scratch
99
ARG CRATE

vhdl_lang/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ assert_matches = "1"
3232

3333
[features]
3434
default = []
35-
packaged = []

vhdl_lang/src/config.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -218,28 +218,32 @@ impl Config {
218218

219219
/// Load configuration file from installation folder
220220
fn load_installed_config(&mut self, messages: &mut dyn MessageHandler) {
221-
let config_relative_path = if cfg!(feature = "packaged") {
222-
// relative to packaged bin folder
223-
"../vhdl_libraries"
224-
} else {
225-
// relative to target/debug or target/release
226-
"../../vhdl_libraries"
227-
};
228-
229-
let exe_path = env::current_exe().expect("Executable path needed");
230-
let exe_folder = exe_path.parent().expect("Executable folder must exist");
231-
232-
let mut file_name = exe_folder.join(config_relative_path);
233-
file_name.push("vhdl_ls.toml");
234-
235-
if !file_name.exists() {
236-
panic!(
237-
"Couldn't find installed libraries at {}.",
238-
file_name.to_string_lossy()
239-
);
221+
let search_paths = [
222+
"../vhdl_libraries",
223+
"../../vhdl_libraries",
224+
"/usr/lib/rust_hdl/vhdl_libraries",
225+
];
226+
227+
for dir in search_paths.into_iter() {
228+
let mut file_name = PathBuf::from(dir);
229+
// Expand a relative path
230+
if !file_name.is_absolute() {
231+
let exe_path = env::current_exe().expect("Executable path needed");
232+
let exe_folder = exe_path.parent().expect("Executable folder must exist");
233+
file_name = exe_folder.join(file_name)
234+
}
235+
file_name.push("vhdl_ls.toml");
236+
if file_name.exists() {
237+
self.load_config(&file_name, "Installation", messages);
238+
return;
239+
}
240240
}
241241

242-
self.load_config(&file_name, "Installation", messages);
242+
// Panic if we did not yet find the installed libraries
243+
panic!(
244+
"Couldn't find installed libraries at {}.",
245+
search_paths.join(", ")
246+
);
243247
}
244248

245249
/// Load configuration file from home folder

vhdl_ls/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ pretty_assertions = "1"
3030

3131
[features]
3232
default = []
33-
packaged = ["vhdl_lang/packaged"]

0 commit comments

Comments
 (0)