Skip to content

Commit

Permalink
Use $ORIGIN in rpath when linking
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddiM8 committed Nov 2, 2023
1 parent 8a04052 commit 6447be9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
10 changes: 5 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/bin/sh

ARCHITECTURE=x64
if [ "$(uname -m)" == "arm64" ]; then
if [ "$(uname -m)" = "arm64" ]; then
ARCHITECTURE=arm64
elif [ -z "$1" ]; then
elif [ -n "$1" ]; then
ARCHITECTURE=$1
fi

TARGET=linux-$ARCHITECTURE
if [ "$(uname)" == "Darwin" ]; then
if [ "$(uname)" = "Darwin" ]; then
TARGET=osx-$ARCHITECTURE
else
elif [ -n "$1" ]; then
TARGET=$2-$ARCHITECTURE
fi

dotnet publish cli/Elk.Cli.csproj -r $TARGET -c Release
rm -rf build

if [ "$(uname)" == "Darwin" ]; then
if [ "$(uname)" = "Darwin" ]; then
mkdir -p build/$TARGET
cp cli/bin/Release/*/$TARGET/publish/Elk.Cli build/$TARGET/elk
cp -r cli/bin/Release/*/$TARGET/publish/Resources/* build/$TARGET
Expand Down
2 changes: 1 addition & 1 deletion cli/Elk.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
It's set to ../lib/elk, since this would mean ./usr/lib/elk if the executable is
in ./usr/bin. This makes it work in local folder structures.
-->
<LinkerArg Include="-Wl,-rpath,'../lib/elk'" Condition="$([MSBuild]::IsOSPlatform('macOS')) == 'false'" />
<LinkerArg Include="-Wl,-rpath,'$ORIGIN/../lib/elk'" Condition="$([MSBuild]::IsOSPlatform('macOS')) == 'false'" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 8 additions & 5 deletions src/FileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ public static class FileUtils
{
public static bool FileIsExecutable(string filePath)
{
if (!File.Exists(filePath))
return false;

if (OperatingSystem.IsWindows())
return false;

var fileMode = File.GetUnixFileMode(filePath);
var fileInfo = new FileInfo(filePath);
if (!fileInfo.Exists)
return false;

return (
fileMode & (UnixFileMode.OtherExecute | UnixFileMode.GroupExecute | UnixFileMode.UserExecute)
fileInfo.UnixFileMode & (
UnixFileMode.OtherExecute |
UnixFileMode.GroupExecute |
UnixFileMode.UserExecute
)
) != 0;
}

Expand Down

0 comments on commit 6447be9

Please sign in to comment.