Repository: mun-lang/mun (language: rust)

Issue:
Make RuntimeBuilder agnostic to library extension
- [x] claim this issue (assign yourself or comment below)
- [x] [setup repository on your local machine](https://github.com/mun-lang/mun) and make sure all tests pass (`cargo test`)
- [x] read our [contributing guidelines](https://github.com/mun-lang/mun/blob/master/CONTRIBUTING.md)
- [x] the Mun `Runtime` receives `RuntimeOptions` from the `RuntimeBuilder` in order to load a shared library. At the moment this library path is not platform agnostic (i.e. internally determines whether it is dealing with a *.so OR *.dll OR *.dylib file). This results in code like this (a contrived example):
    ```rust
    fn runtime_unix() -> Runtime {
        RuntimeBuilder::new("voxygen/src/anim/character/test.so")
            .spawn()
            .expect("Failed to spawn Runtime");
    }

    fn runtime_windows() -> Runtime {
        RuntimeBuilder::new("voxygen/src/anim/character/test.dll")
            .spawn()
            .expect("Failed to spawn Runtime");
    }
    ```
    Per @sonovice's submission, we want to instead generate libraries with a custom extension: `*.munlib`:
    ```rust
    fn runtime() -> Runtime {
        RuntimeBuilder::new("voxygen/src/anim/character/test.munlib")
            .spawn()
            .expect("Failed to spawn Runtime");
    }
    ```
    To implement this, you need to:
    - [x] replace *.so / *.dll / *.dylib extensions with *.munlib in the Mun Compiler when writing to file
    - [x] check that `RuntimeBuilder::new` is allowed to receive any path (both with and without extension)
- [x] start a Pull Request. Set description to `closes #72`. If this is your first PR, welcome :tada: :smile:


Discussion / hints:
I would like to contribute to this issue :eyes: 

Fix patch:
diff --git a/crates/mun_compiler/src/driver.rs b/crates/mun_compiler/src/driver.rs
index d464a9fd8..d38f4f5fc 100644
--- a/crates/mun_compiler/src/driver.rs
+++ b/crates/mun_compiler/src/driver.rs
@@ -8,7 +8,6 @@ use crate::{
 };
 use mun_codegen::IrDatabase;
 use mun_hir::{FileId, RelativePathBuf, SourceDatabase, SourceRoot, SourceRootId};
-use mun_target::spec::Target;
 use std::{
     path::{Path, PathBuf},
     sync::Arc,
@@ -126,19 +125,11 @@ impl Driver {
 impl Driver {
     /// Computes the output path for the assembly of the specified file.
     fn assembly_output_path(&self, file_id: FileId) -> PathBuf {
-        let target: Target = self.db.target();
         let relative_path: RelativePathBuf = self.db.file_relative_path(file_id);
         let original_filename = Path::new(relative_path.file_name().unwrap());
 
-        // Get the dll suffix without the starting dot
-        let dll_extension = if target.options.dll_suffix.starts_with('.') {
-            &target.options.dll_suffix[1..]
-        } else {
-            &target.options.dll_suffix
-        };
-
-        // Add the dll suffix to the original filename
-        let output_file_name = original_filename.with_extension(dll_extension);
+        // Add the `munlib` suffix to the original filename
+        let output_file_name = original_filename.with_extension("munlib");
 
         // If there is an out dir specified, prepend the output directory
         if let Some(ref out_dir) = self.out_dir {
diff --git a/crates/mun_target/src/spec.rs b/crates/mun_target/src/spec.rs
index b38c20353..54081577a 100644
--- a/crates/mun_target/src/spec.rs
+++ b/crates/mun_target/src/spec.rs
@@ -52,9 +52,6 @@ pub struct TargetOptions {
     /// String to prepend to the name of every dynamic library. Defaults to "lib".
     pub dll_prefix: String,
 
-    /// String to append to the name of every dynamic library. Defaults to ".so".
-    pub dll_suffix: String,
-
     /// Whether the target toolchain is like Windows
     pub is_like_windows: bool,
 }
@@ -66,7 +63,6 @@ impl Default for TargetOptions {
             cpu: "generic".to_string(),
             features: "".to_string(),
             dll_prefix: "lib".to_string(),
-            dll_suffix: ".so".to_string(),
             is_like_windows: false,
         }
     }
diff --git a/crates/mun_target/src/spec/apple_base.rs b/crates/mun_target/src/spec/apple_base.rs
index 423a24be9..27b944ab3 100644
--- a/crates/mun_target/src/spec/apple_base.rs
+++ b/crates/mun_target/src/spec/apple_base.rs
@@ -4,7 +4,6 @@ use std::env;
 pub fn opts() -> TargetOptions {
     TargetOptions {
         dll_prefix: "lib".to_string(),
-        dll_suffix: ".dylib".to_string(),
         ..Default::default()
     }
 }
diff --git a/crates/mun_target/src/spec/windows_msvc_base.rs b/crates/mun_target/src/spec/windows_msvc_base.rs
index dd94e63a1..a20e2db21 100644
--- a/crates/mun_target/src/spec/windows_msvc_base.rs
+++ b/crates/mun_target/src/spec/windows_msvc_base.rs
@@ -3,7 +3,6 @@ use crate::spec::TargetOptions;
 pub fn opts() -> TargetOptions {
     TargetOptions {
         dll_prefix: "".to_string(),
-        dll_suffix: ".dll".to_string(),
         is_like_windows: true,
         ..Default::default()
     }


Test patch: