Skip to content

Commit d60f37a

Browse files
authored
Merge pull request #76 from patchkit-net/feature/v3.10.0/1010-setting-ld-library-path
1010 setting the ld_library_path on linux systems
2 parents 2188406 + 6eb7302 commit d60f37a

File tree

6 files changed

+99
-7
lines changed

6 files changed

+99
-7
lines changed

Assets/PatchKit Patcher/Editor/PatcherManifestCreator.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,35 @@ private static void PostProcessBuild(BuildTarget buildTarget, string buildPath)
4040
File.WriteAllText(manifestPath, manifestContent);
4141
}
4242

43-
private static Manifest WindowsManifest(string buildPath)
44-
{
45-
return CommonManifest(buildPath);
46-
}
47-
4843
private static Manifest LinuxManifest(string buildPath)
4944
{
50-
return CommonManifest(buildPath);
45+
string patcherExe = Path.GetFileName(buildPath);
46+
string launchScript = UnixLaunchScriptCreator.LaunchScriptName;
47+
48+
return new Manifest {
49+
ExeFileName = string.Format("\"{{exedir}}/{0}\"", patcherExe),
50+
ExeArguments = "--installdir \"{installdir}\" --secret \"{secret}\"",
51+
52+
Version = ManifestVersion,
53+
Target = "sh",
54+
Arguments = new Manifest.Argument[] {
55+
new Manifest.Argument { Value = new string[] {
56+
"{exedir}/" + launchScript
57+
}},
58+
new Manifest.Argument { Value = new string[] {
59+
"{exedir}",
60+
patcherExe,
61+
"{secret}",
62+
"{installdir}"
63+
}},
64+
new Manifest.Argument { Value = new string[] {
65+
"{lockfile}"
66+
}}
67+
}
68+
};
5169
}
5270

53-
private static Manifest CommonManifest(string buildPath)
71+
private static Manifest WindowsManifest(string buildPath)
5472
{
5573
string targetFile = Path.GetFileName(buildPath);
5674
return new Manifest {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.IO;
2+
using JetBrains.Annotations;
3+
using Newtonsoft.Json;
4+
using UnityEditor;
5+
using UnityEditor.Callbacks;
6+
7+
namespace PatchKit.Unity.Editor
8+
{
9+
public static class UnixLaunchScriptCreator
10+
{
11+
private const string LaunchScriptContentFile = "Assets/PatchKit Patcher/Editor/patcher.template.sh";
12+
public const string LaunchScriptName = "run.sh";
13+
14+
public static string LaunchScriptPath(string buildPath)
15+
{
16+
return Path.Combine(Path.GetDirectoryName(buildPath), LaunchScriptName);
17+
}
18+
19+
[PostProcessBuild, UsedImplicitly]
20+
private static void PostProcessBuild(BuildTarget buildTarget, string buildPath)
21+
{
22+
if (buildTarget != BuildTarget.StandaloneLinux64 &&
23+
buildTarget != BuildTarget.StandaloneLinux &&
24+
buildTarget != BuildTarget.StandaloneLinuxUniversal)
25+
{
26+
return;
27+
}
28+
29+
string launchScriptPath = LaunchScriptPath(buildPath);
30+
31+
File.Copy(LaunchScriptContentFile, launchScriptPath);
32+
}
33+
}
34+
}

Assets/PatchKit Patcher/Editor/UnixLaunchScriptCreator.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env sh
2+
3+
EXEDIR=$1
4+
PATCHER_EXE=$2
5+
SECRET=$3
6+
INSTALLDIR=$4
7+
LOCKFILE=$5
8+
9+
LD_DIRS=`find $EXEDIR -name "x86_64" -printf "%p:"`
10+
LD_DIRS=$LD_DIRS`find $EXEDIR -name "x86" -printf "%p:"`
11+
12+
export LD_LIBRARY_PATH=$LD_DIRS
13+
14+
if [ -n $LOCKFILE ]
15+
then
16+
$EXEDIR/$PATCHER_EXE --installdir $INSTALLDIR --secret $SECRET --lockfile $LOCKFILE
17+
else
18+
$EXEDIR/$PATCHER_EXE --installdir $INSTALLDIR --secret $SECRET
19+
fi

Assets/PatchKit Patcher/Editor/patcher.template.sh.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2525
- Animated progress bar during initialization and connecting
2626
- New manifest format support
2727
- Sending 'patcher_started' event to Statistics Reporting Service
28+
- A launch script on Linux platforms
2829

2930
### Changed
3031
- Update API servers configuration

0 commit comments

Comments
 (0)