Skip to content

Commit

Permalink
Merge pull request #2 from outscale-mgo/master
Browse files Browse the repository at this point in the history
appimage
  • Loading branch information
cosmo-ray authored May 20, 2021
2 parents 2a437d7 + 28f6147 commit 023d0e7
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 2 deletions.
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@

include config.mk

CFLAGS+="-std=c99"
CFLAGS+=$(JSON_C_CFLAGS)
LDFLAGS+=$(JSON_C_LDFLAGS)

json-search: json-search.o
$(CC) -ljson-c -std=c99 -Wall -Wextra json-search.o -o json-search
$(CC) -ljson-c $(JSON_C_LDFLAGS) -std=c99 -Wall -Wextra json-search.o -o json-search

appimagetool-x86_64.AppImage:
wget https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage

json-search-x86_64.AppImage: json-search appimagetool-x86_64.AppImage
mkdir -p json-search.AppDir/usr/
mkdir -p json-search.AppDir/usr/bin/
mkdir -p json-search.AppDir/usr/lib/
cp json-search json-search.AppDir/usr/bin/
./cp_json-c.sh
./appimagetool-x86_64.AppImage json-search.AppDir

clean:
rm json-search.o
Expand Down
2 changes: 2 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

JSON_C_CFLAGS=-I/usr/include/json-c
32 changes: 32 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

DIR=$PWD
NO_RECOMPILE=1

echo "" > config.mk
echo '#!/bin/bash' > ./cp_json-c.sh
chmod +x ./cp_json-c.sh

for arg in $@; do
echo $( echo "$arg" | cut -d '=' -f 1)
if [ "--compile-json-c" = $arg ]; then
git clone https://github.com/json-c/json-c.git
mkdir json-c-build
cd json-c-build
cmake3 ../json-c/
make
cd -
NO_RECOMPILE=0
echo 'JSON_C_CFLAGS=-I./json-c -I./json-c-build' >> config.mk
echo 'JSON_C_LDFLAGS="-L./json-c-build"' >> config.mk
echo "cp json-c-build/libjson-c.so* json-search.AppDir/usr/lib/" >> ./cp_json-c.sh
fi
if [ "--help" = $arg ]; then
echo "--compile-json-c: clone and compile json-c"
fi
done

if [ $NO_RECOMPILE -eq 1 ]; then
echo JSON_C_CFLAGS=$(pkg-config --cflags json-c) >> config.mk
echo "cp \$(ldd json-search | grep json | cut -d ' ' -f 3) json-search.AppDir/usr/lib/" >> ./cp_json-c.sh
fi
3 changes: 3 additions & 0 deletions json-search.AppDir/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

LD_LIBRARY_PATH=${APPDIR}/usr/lib/ "${APPDIR}/usr/bin/json-search" "$@"
Binary file added json-search.AppDir/appimage-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions json-search.AppDir/json-search.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Name=json-search
Exec=json-search
Comment=grep into like, and format print
Categories=Development;
Terminal=true
Icon=appimage-logo
2 changes: 1 addition & 1 deletion json-search.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <json-c/json.h>
#include "json.h"

#define panic(...) \
do { \
Expand Down

0 comments on commit 023d0e7

Please sign in to comment.