AaronRobinsonMSFT / DNNE

Prototype native exports for a .NET Assembly.
MIT License
397 stars 41 forks source link

Output into subfolder #66

Open climblinne opened 3 years ago

climblinne commented 3 years ago

Hello,

is there an easy way to put the assembly (and their dependencies & runtime config) into a separate subfolder, when calling it from the native binary library?

May be as a MSBuild property?

Thanks

AaronRobinsonMSFT commented 3 years ago

is there an easy way to put the assembly (and their dependencies & runtime config) into a separate subfolder, when calling it from the native binary library?

Not really at present. This involves understanding how a user wants to deploy the generated managed/native pair. It would introduce some serious complexity into the system to support such an option. I think it would better to file an issue and push the single file scenario for Class Libraries/Components. Right now it is only for Applications.

See https://github.com/AaronRobinsonMSFT/DNNE/issues/30

climblinne commented 3 years ago

Yes, I think you are right. I just patched my DNNE to link to a subfolder with the assembly name. The copy have to be done manual. Not ideal, but it works for myself at the moment.

index 1563879..ad2a26a 100644
--- "a/src/platform/platform.c"
+++ "b/src/platform/platform.c"
@@ -161,6 +161,7 @@ typedef int (CORECLR_DELEGATE_CALLTYPE* component_entry_point_fn)(void* arg, int

 #define DNNE_NORETURN __declspec(noreturn)
 #define DNNE_DIR_SEPARATOR L'\\'
+#define DNNE_DIR_SEPARATOR_STR L"\\"

 static void* load_library(const char_t* path)
 {
@@ -213,6 +214,7 @@ static int get_this_image_path(int32_t buffer_len, char_t* buffer, int32_t* writ

 #define DNNE_NORETURN __attribute__((__noreturn__))
 #define DNNE_DIR_SEPARATOR '/'
+#define DNNE_DIR_SEPARATOR_STR L"/"

 static void* load_library(const char_t* path)
 {
@@ -382,7 +384,7 @@ static void prepare_runtime(void)

     // Initialize and start the runtime.
     char_t buffer[DNNE_MAX_PATH];
-    const char_t config_filename[] = DNNE_STR(DNNE_TOSTRING(DNNE_ASSEMBLY_NAME)) DNNE_STR(".runtimeconfig.json");
+    const char_t config_filename[] = DNNE_STR(DNNE_TOSTRING(DNNE_ASSEMBLY_NAME)) DNNE_DIR_SEPARATOR_STR DNNE_STR(DNNE_TOSTRING(DNNE_ASSEMBLY_NAME))  DNNE_STR(".runtimeconfig.json");
     const char_t* config_path = NULL;
     int rc = get_current_dir_filepath(DNNE_ARRAY_SIZE(buffer), buffer, DNNE_ARRAY_SIZE(config_filename), config_filename, &config_path);
     if (is_failure(rc))
@@ -412,7 +414,7 @@ void* get_callable_managed_function(
     }

     char_t buffer[DNNE_MAX_PATH];
-    const char_t assembly_filename[] = DNNE_STR(DNNE_TOSTRING(DNNE_ASSEMBLY_NAME)) DNNE_STR(".dll");
+    const char_t assembly_filename[] = DNNE_STR(DNNE_TOSTRING(DNNE_ASSEMBLY_NAME)) DNNE_DIR_SEPARATOR_STR DNNE_STR(DNNE_TOSTRING(DNNE_ASSEMBLY_NAME))  DNNE_STR(".dll");
     const char_t* assembly_path = NULL;
     int rc = get_current_dir_filepath(DNNE_ARRAY_SIZE(buffer), buffer, DNNE_ARRAY_SIZE(assembly_filename), assembly_filename, &assembly_path);
     if (is_failure(rc))