Skip to content

Commit

Permalink
add minimal realpath tool
Browse files Browse the repository at this point in the history
  • Loading branch information
gisogrimm committed Jun 26, 2023
1 parent 91ae5d1 commit a7c92f4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
all: build lib binaries

BINARIES = ov-client ov-client_hostname ov-client_listsounddevs ovbox test_exec
BINARIES = ov-client ov-client_hostname ov-client_listsounddevs ovbox \
test_exec ovrealpath

EXTERNALS = jack liblo sndfile libcurl gsl samplerate fftw3f xerces-c

Expand All @@ -10,6 +11,8 @@ BUILD_BINARIES = $(patsubst %,build/%,$(BINARIES))
CXXFLAGS = -Wall -Wno-deprecated-declarations -std=c++17 -pthread \
-ggdb -fno-finite-math-only

CFLAGS = -Wall -Wno-deprecated-declarations

ifeq "$(ARCH)" "x86_64"
CXXFLAGS += -msse -msse2 -mfpmath=sse -ffast-math
endif
Expand Down Expand Up @@ -109,6 +112,8 @@ $(BUILD_BINARIES): libov/build/libov.a
build/%: src/%.cc
$(CXX) $(CXXFLAGS) $< $(LDFLAGS) $(LDLIBS) -o $@

build/ovrealpath: src/ovrealpath.c
$(CC) $(CFLAGS) $< -o $@

build/%.o: src/%.cc $(HEADER)
$(CXX) $(CXXFLAGS) -c $< -o $@
Expand Down Expand Up @@ -193,3 +198,4 @@ gitupdate:

install:
cat packaging/deb/*.csv |sed -e 's/,usr/,$${PREFIX}/1' | PREFIX=$(PREFIX) envsubst |sed -e 's/.*,//1' | sort -u | xargs -L 1 -- mkdir -p && cat packaging/deb/*.csv |sed -e 's/,usr/ $${PREFIX}/1' | PREFIX=$(PREFIX) envsubst | xargs -L 1 -I % sh -c "cp --preserve=links -r %"

2 changes: 1 addition & 1 deletion packaging/Darwin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PACKVER:=$(FULLVERSION)_$(shell uname -s)_$(shell uname -m)

.PHONY : pack

BINS = ov-client ovbox ovzita-j2n ovzita-n2j
BINS = ov-client ovbox ovzita-j2n ovzita-n2j ovrealpath
LIBS = libovclienttascar.0.dylib libovclienttascargui.0.dylib
PLUGS = $(shell (cd ../../libov/tascar/plugins/build;echo ovclient*.dylib))

Expand Down
7 changes: 4 additions & 3 deletions packaging/Darwin/ovboxwrapper
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export HOMEBREW_REPOSITORY=$HOMEBREW_REPOSITORY
export HOMEBREW_PREFIX=$HOMEBREW_REPOSITORY
export HOMEBREW_CELLAR=$HOMEBREW_REPOSITORY/Cellar
export PATH="${HOMEBREW_REPOSITORY}/bin:${HOMEBREW_REPOSITORY}/sbin:${PATH}"
export RDIR=$(realpath $(dirname $0)/../Resources)
export BDIR=$(realpath $(dirname $0))
DNAME=$(dirname $0)
export RDIR=$($(dirname $0)/ovrealpath $(dirname $0)/../Resources)
export BDIR=$($(dirname $0)/ovrealpath $(dirname $0))
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:${BDIR}/lib"
(
cd "${TMPDIR}"
$BDIR/ovbox.bin
$BDIR/ovbox.bin $*
)
18 changes: 18 additions & 0 deletions src/ovrealpath.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
if(argc > 1) {
for(int argIter = 1; argIter < argc; ++argIter) {
char* resolved_path_buffer = NULL;
char* result = realpath(argv[argIter], resolved_path_buffer);
if(result != NULL) {
puts(result);
free(result);
}
}
}
return 0;
}

0 comments on commit a7c92f4

Please sign in to comment.