Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

How can I rename the library name, specific for module? #715

Closed
archeg opened this issue Nov 21, 2016 · 5 comments
Closed

How can I rename the library name, specific for module? #715

archeg opened this issue Nov 21, 2016 · 5 comments

Comments

@archeg
Copy link

archeg commented Nov 21, 2016

I have following set up 4 dlls: dll_a, dll_b, dll_c, dll_d. Some of them use each other. Each has it's own separate header dll_a.h, dll_b.h, dll_c.h, dll_d.h (sorry if I write something that sounds weird to C guy, I don't know C much). Each of the header is located in the different folder, and has additional includes.

My current setup is next (simplified);

        var options = driver.Options;
        options.GeneratorKind = GeneratorKind.CSharp;
        options.LibraryName = "PLT";
        options.NoGenIncludeDirs = new List<string>();
        options.NoGenIncludeDirs.Add("dll_a/");
        options.NoGenIncludeDirs.Add("dll_b/");
        options.NoGenIncludeDirs.Add("dll_c/");
        options.NoGenIncludeDirs.Add("dll_d/");

        var aModule = new Module();
        options.Modules.Add(aModule );
        aModule .LibraryName = "dll_a";
        aModule .Headers.Add("dll_a/dll_a.h");

        var bModule = new Module();
        options.Modules.Add(bModule );
        bModule .LibraryName = "dll_b";
        bModule .Headers.Add("dll_b/dll_b.h");

        var cModule = new Module();
        options.Modules.Add(cModule);
        cModule .LibraryName = "dll_c";
        cModule .Headers.Add("dll_c/dll_c.h");

        var dModule = new Module();
        options.Modules.Add(dModule );
        dModule .LibraryName = "dll_d";
        dModule .Headers.Add("dll_d/dll_d.h");

This generates different classes for extern calls (named dll_a, dll_b...), but every of them has [DllImport("PLT", ...], when I want [DllImport("dll_a", .. for dll_a, [DllImport("dll_b", ..] for dll_b.

I've also tried having separate ILibrary for each of the header, but this generates copies of data structures (for example dll_c has datastructure used in API for dll_a and dll_b, thus it is generated 3 times). They become not interchangable, so I cannot call:

 var stuff = dll_a.GetStuff();
 dll_b.ConsumeStuff(stuff);  // Conversion error: cannot cast dll_a.Stuff to dll_b.Stuff

P.S. Is this correct way to ask questions? As I understood google group is not monitored too much.

@tritao
Copy link
Collaborator

tritao commented Nov 21, 2016

Try the SharedLibraryName option.

And yes, it's fine to ask questions here.

@archeg
Copy link
Author

archeg commented Nov 21, 2016

@tritao That still applies the shared name to all of the modules. What I need is specific name for each module (in particular the name of the header file)

@ddobrev
Copy link
Contributor

ddobrev commented Nov 21, 2016

You could use CheckSymbols = true but this will only work if you pass your libraries themselves to your set up, per module - module.LibraryPaths.Add("path_to_dll_a") and module.Libraries.Add("dll_a").

@ddobrev
Copy link
Contributor

ddobrev commented Nov 21, 2016

Alternatively, @tritao 's suggestion works too. SharedLibraryName is a per module setting as well so you can have different ones as necessary.

@archeg
Copy link
Author

archeg commented Nov 21, 2016

@ddobrev I've tried setting it up per module, but it still applied one of them (it applied dll_b - the second one, which is weird). But your suggestion with CheckSymbols = true worked nicely, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants