Skip to content

Commit

Permalink
Implemented 'Generate .exp + .lib via MS Library Manager' #9
Browse files Browse the repository at this point in the history
GUI Configurator
+
to configure this via MSBuild property: DllExportGenExpLib
  • Loading branch information
3F committed Oct 19, 2016
1 parent 54263f9 commit 22346e9
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 39 deletions.
21 changes: 17 additions & 4 deletions Configurator/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public void reset()
"DllExportNamespace",
"DllExportOrdinalsBase",
"DllExportSkipOnAnyCpu",
"DllExportDDNSCecil"
"DllExportDDNSCecil",
"DllExportGenExpLib"
);
}

Expand All @@ -92,7 +93,7 @@ protected void cfgNamespace()
config.MetaLibPublicKeyToken
);

setProperty("DllExportDDNSCecil", config.useCecil.ToString());
setProperty("DllExportDDNSCecil", config.useCecil);

// binary modifications of metalib assembly
ddns.setNamespace(config.script.MetaLib, config.unamespace, config.useCecil);
Expand Down Expand Up @@ -135,9 +136,11 @@ protected void cfgPlatform()

protected void cfgCompiler()
{
setProperty("DllExportOrdinalsBase", config.compiler.ordinalsBase.ToString());

setProperty("DllExportOrdinalsBase", config.compiler.ordinalsBase);
Log.send(this, $"The Base for ordinals: {config.compiler.ordinalsBase}");

setProperty("DllExportGenExpLib", config.compiler.genExpLib);
Log.send(this, $"Generate .exp + .lib via MS Library Manager: {config.compiler.genExpLib}");
}

protected void removeMsbuildProperties(params string[] names)
Expand All @@ -157,5 +160,15 @@ private void setProperty(string name, string val)
project.setProperty(name, val);
project.saveViaDTE();
}

private void setProperty(string name, bool val)
{
setProperty(name, val.ToString().ToLower());
}

private void setProperty(string name, int val)
{
setProperty(name, val.ToString());
}
}
}
93 changes: 67 additions & 26 deletions Configurator/GUI/InstallationForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion Configurator/GUI/InstallationForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private void saveConfig()
{
config.unamespace = getValidNS(comboNS.Text);
config.compiler.ordinalsBase = (int)numOrdinal.Value;
config.compiler.genExpLib = chkGenExpLib.Checked;
config.useCecil = rbCecil.Checked;

if(rbPlatformX86.Checked) {
Expand Down Expand Up @@ -97,6 +98,11 @@ private void prefilter()
comboNS.Text = comboNS.Text.Replace(" ", "");
}

private void openUrl(string url)
{
System.Diagnostics.Process.Start(url);
}

private void btnConfigure_Click(object sender, EventArgs e)
{
prefilter();
Expand Down Expand Up @@ -140,7 +146,7 @@ private void InstallationForm_FormClosed(object sender, FormClosedEventArgs e)

private void linkDDNS_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/3F/DllExport/issues/2");
openUrl("https://github.com/3F/DllExport/issues/2");
}

private void comboNS_TextUpdate(object sender, EventArgs e)
Expand All @@ -162,5 +168,15 @@ private void InstallationForm_Load(object sender, EventArgs e)
{
labelActiveCfg.Text += $"' {project.getPropertyValue("Configuration")} | {project.getPropertyValue("Platform")} '";
}

private void linkOrdinals_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
openUrl("https://github.com/3F/DllExport/issues/11#issuecomment-250907940");
}

private void linkExpLib_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
openUrl("https://github.com/3F/DllExport/issues/9#issuecomment-246189220");
}
}
}
5 changes: 5 additions & 0 deletions Configurator/UserConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public struct CompilerCfg
/// Base for ordinals.
/// </summary>
public int ordinalsBase;

/// <summary>
/// Generate .exp + .lib via MS Library Manager.
/// </summary>
public bool genExpLib;
}

public UserConfig(IScriptConfig cfg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ public int OrdinalsBase
}
}

public bool GenExpLib
{
get {
return _ExportTaskImplementation.GenExpLib;
}

set {
_ExportTaskImplementation.GenExpLib = value;
}
}

public string MetaLib
{
get {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,17 @@ public int OrdinalsBase
}
}

public bool GenExpLib
{
get {
return _ExportTaskImplementation.GenExpLib;
}

set {
_ExportTaskImplementation.GenExpLib = value;
}
}

public string MetaLib
{
get {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ public int OrdinalsBase
}
}

public bool GenExpLib
{
get {
return _Values.GenExpLib;
}

set {
_Values.GenExpLib = value;
}
}

public string MetaLib
{
get {
Expand Down
6 changes: 6 additions & 0 deletions RGiesecke.DllExport/IInputValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ int OrdinalsBase
set;
}

bool GenExpLib
{
get;
set;
}

string MetaLib
{
get;
Expand Down
6 changes: 6 additions & 0 deletions RGiesecke.DllExport/InputValuesCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public int OrdinalsBase
set;
}

public bool GenExpLib
{
get;
set;
}

public string MetaLib
{
get;
Expand Down
16 changes: 8 additions & 8 deletions RGiesecke.DllExport/Parsing/ILAsm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,25 @@ private int RunCore(CpuPlatform cpu, string fileName, string ressourceParam, str

private int RunLibTool(CpuPlatform cpu, string fileName, string directory)
{
if(string.IsNullOrEmpty(this.InputValues.LibToolPath))
{
if(!InputValues.GenExpLib || String.IsNullOrWhiteSpace(InputValues.LibToolPath)) {
return 0;
}
string libraryFileNameRoot = IlAsm.GetLibraryFileNameRoot(fileName);
string defFile = this.CreateDefFile(cpu, directory, libraryFileNameRoot);

string libraryFileNameRoot = IlAsm.GetLibraryFileNameRoot(fileName);
string defFile = CreateDefFile(cpu, directory, libraryFileNameRoot);

try
{
return this.RunLibToolCore(cpu, directory, defFile);
return RunLibToolCore(cpu, directory, defFile);
}
catch(Exception ex)
{
this.Notifier.Notify(1, DllExportLogginCodes.LibToolLooging, Resources.An_error_occurred_while_calling_0_1_, (object)"lib.exe", (object)ex.Message);
Notifier.Notify(1, DllExportLogginCodes.LibToolLooging, Resources.An_error_occurred_while_calling_0_1_, "lib.exe", ex.Message);
return -1;
}
finally
{
if(File.Exists(defFile))
{
if(File.Exists(defFile)) {
File.Delete(defFile);
}
}
Expand Down
2 changes: 2 additions & 0 deletions tools/net.r_eg.DllExport.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<DllExportSdkPath Condition="'$(DllExportSdkPath)' == ''">$(TargetFrameworkSDKToolsDirectory)</DllExportSdkPath>
<DllExportSkipOnAnyCpu Condition="'$(DllExportSkipOnAnyCpu)' == ''">$(NoDllExportsForAnyCpu)</DllExportSkipOnAnyCpu>
<DllExportOrdinalsBase Condition="'$(DllExportOrdinalsBase)' == ''">1</DllExportOrdinalsBase>
<DllExportGenExpLib Condition="'$(DllExportGenExpLib)' == ''">false</DllExportGenExpLib>
</PropertyGroup>

<DllExportAppDomainIsolatedTask
Expand All @@ -58,6 +59,7 @@
SdkPath="$(DllExportSdkPath)"
SkipOnAnyCpu="$(DllExportSkipOnAnyCpu)"
OrdinalsBase="$(DllExportOrdinalsBase)"
GenExpLib="$(DllExportGenExpLib)"
MetaLib="$(DllExportMetaLibFullPath)"
/>

Expand Down

0 comments on commit 22346e9

Please sign in to comment.