Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap script #3

Merged
merged 8 commits into from
Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
*.qmake.stash
vendor
Makefile
apps/*/node_modules
example/*/node_modules
build
qpm
setupfile
coverage
src/node_path/node_modules
tmp
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,17 @@ Prebuilt binaries for OSX can be found on the releases page.
## Building
### Requirements
- Qt 5.7
- [qpm](https://github.com/Cutehacks/qpm)

### OSX
```bash
export PATH=$PATH:/path/to/Qt/5.7/clang_64/bin
qpm install
./tools/bootstrap.sh
mkdir build
cd build
qmake ..
make
#if you want to deploy:
./../tools/deploy_mac.sh quark.app /path/to/node
./../tools/deploy_mac.sh quark.app
```

### WIN (using mingw)
Expand All @@ -124,8 +123,7 @@ The created executable will only run on systems with Qt installed. The windeploy
```bash
export PATH=$PATH:/c/Qt/5.7/mingw53_32/bin
export PATH=$PATH:/c/Qt/Tools/mingw530_32/bin

qpm install
./tools/bootstrap.sh
mkdir build
cd build
qmake ..
Expand All @@ -135,15 +133,14 @@ make
```

### Linux (Ubuntu 16.04)
Currently there is no linuxdeployqt scripty, you need to use the following: [linuxdeployqt](https://github.com/probonopd/linuxdeployqt)
```bash
export PATH=/path/to/Qt/5.7/clang_64/bin:/path/to/linuxdeployqt:$PATH
sudo apt-get install mesa-common-dev libglu1-mesa-dev patchelf
qpm install
./tools/bootstrap.sh
mkdir build
cd build
qmake ..
make
#if you want to deploy:
./../tools/deploy_mac.sh quark.app /path/to/node
./../tools/deploy_linux.sh quark
```
11 changes: 7 additions & 4 deletions example/default/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name" : "quark-default",
"version" : "0.1.0",
"main" : "main.js",
"initialQml": "index.qml"
"name": "quark-default",
"version": "0.1.0",
"main": "main.js",
"initialQml": "index.qml",
"dependencies": {
"shelljs": "^0.7.5"
}
}
16 changes: 10 additions & 6 deletions qml-player.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,26 @@ HEADERS += \

RESOURCES += qml.qrc

#copy node binary
NODE_CMD = $$system(tools/downloadNode.sh)
macx: copy_node.commands = $(COPY_DIR) $$NODE_CMD $$OUT_PWD/$$TARGET".app"/Contents/MacOS/
linux: copy_node.commands = $(COPY_DIR) $$NODE_CMD $$OUT_PWD/

#copy node_path
macx: copy_node_path.commands = $(COPY_DIR) $$PWD/src/node_path $$OUT_PWD/$$TARGET".app"/Contents/Resources/
linux: copy_node_path.commands = $(COPY_DIR) $$PWD/src/node_path $$OUT_PWD/



#copy default app
macx: copy_app.commands = $(COPY_DIR) $$PWD/apps/default $$OUT_PWD/$$TARGET".app"/Contents/Resources/
linux: copy_app.commands = $(COPY_DIR) $$PWD/apps/default $$OUT_PWD/
macx: copy_app.commands = $(COPY_DIR) $$PWD/example/default $$OUT_PWD/$$TARGET".app"/Contents/Resources/
linux: copy_app.commands = $(COPY_DIR) $$PWD/example/default $$OUT_PWD/

first.depends = $(first) copy_node_path copy_app
first.depends = $(first) copy_node_path copy_app copy_node
export(first.depends)
export(copy_node_path.commands)
export(copy_app.commands)
export(copy_node.commands)

QMAKE_EXTRA_TARGETS += first copy_node_path copy_app
QMAKE_EXTRA_TARGETS += first copy_node_path copy_app copy_node

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
Expand Down
Empty file added quark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/node_path/Gluon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Stream = require("stream");
const StringDecoder = require("string_decoder").StringDecoder;
const Transform = Stream.Transform;
const Duplex = Stream.Duplex;
const JSONStream = require("JSONStream2");
const JSONStream = require("jsonstream2");
const Filter = require("through2-filter");
const Mapper = require("through2-map");

Expand Down
58 changes: 58 additions & 0 deletions tools/arch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
set -e
# A PosIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.

valid_formats=( "std" "node" "qpm" )
# Initialize our own variables:
format="std" # or qpm, node
show_arch=false
show_os=false

arch="$(uname -m)"
case "$OSTYPE" in
darwin*) os="darwin" ;;
linux*) os="linux" ;;
msys*) os="win" ;;
*) echo "unknown: $OSTYPE" ; exit 1;
esac

echo_qpm() {
arch="386"
}

echo_node() {
case "$arch" in
x86_64) arch="x64";;
i686) arch="x86";;
*) echo "could not parse uname -m output: $arcg" ; exit 1;
esac
}
while getopts "aof:" opt; do
case "$opt" in
a) show_arch=true
;;
o) show_os=true
;;
f) format=$OPTARG
;;
esac
done

shift $((OPTIND-1))

[ "$1" = "--" ] && shift

case "$format" in
std);;
qpm) echo_qpm;;
node) echo_node;;
*) echo "illegal format vale: $format. (valid: ${valid_formats[@]}))" ; exit 1;
esac

if [[ "$show_arch" = true ]]; then
echo "$arch"
fi
if [[ "$show_os" = true ]]; then
echo "$os"
fi
42 changes: 42 additions & 0 deletions tools/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
set -e
PROJECT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."

OS="$($PROJECT_PATH/tools/arch.sh -f node -o)"
echo "download node..."
NODE_CMD=$("$PROJECT_PATH/tools/downloadNode.sh")
NPM_CMD="$(dirname "$NODE_CMD")/npm"
echo "download qpm..."
QPM_CMD=$("$PROJECT_PATH/tools/downloadQpm.sh")

pushd . > /dev/null

"$QPM_CMD" install

for i in $PROJECT_PATH/example/* ; do
cd "$i"
echo "npm install $i"
"$NPM_CMD" install
done

cd "$PROJECT_PATH/src/node_path"
"$NPM_CMD" install

if [ "$OS" = "linux" ]; then
if [ ! -d "$PROJECT_PATH/tmp/linuxdeployqt-src" ] ; then
git clone "https://github.com/probonopd/linuxdeployqt" "$PROJECT_PATH/tmp/linuxdeployqt-src"
fi
if [ ! -d "$PROJECT_PATH/tmp/linuxdeployqt-build" ] ; then
mkdir "$PROJECT_PATH/tmp/linuxdeployqt-build"
cd "$PROJECT_PATH/tmp/linuxdeployqt-build"
qmake "../linuxdeployqt-src"
make
fi

APPIMG_CMD="$PROJECT_PATH/tmp/appimagetool"
if [ ! -f "$APPIMG_CMD" ] ; then
curl -L -o "$APPIMG_CMD" "https://github.com/probonopd/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod +x "$APPIMG_CMD"
fi
fi
popd > /dev/null
35 changes: 15 additions & 20 deletions tools/deploy_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@

PROJECT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../"
TARGET_APP=$1
NODE_CMD=$2
TARGET_PATH=$(dirname "$TARGET_APP")
QT_PATH="/home/dodo/Qt5.7.0aa/5.7/gcc_64"
DEPLOY_CMD="$PROJECT_PATH/tmp/linuxdeployqt-build/linuxdeployqt/linuxdeployqt"
TMP_PATH="$PROJECT_PATH/tmp"

linuxdeployqt $TARGET_APP --compiler-runtime --qmldir=$PROJECT_PATH/src/qml -bundle-non-qt-libs
cat << EOF > "$TARGET_PATH/quark.desktop"
[Desktop Entry]
Type=Application
Name=Quark
Exec=AppRun %F
Icon=default
Comment=Edit this default file
Terminal=true
EOF

: <<'END'
mkdir -p "$TARGET_PATH/platforms"
cp "$QT_PATH/plugins/platforms/libqxcb.so" "$TARGET_PATH/platforms/libqxcb.so"
cp "$PROJECT_PATH/quark.svg" "$TARGET_PATH/default.svg"

PATH="$TMP_PATH:$PATH" "$DEPLOY_CMD" $TARGET_APP -qmldir=$PROJECT_PATH/src/qml -bundle-non-qt-libs -no-strip

libs=( "libQt5DBus.so.5" )
#libs=( "libQt5DBus.so.5" "libQt5XcbQpa.so.5" "libicudata.so.56" "libicuuc.so.56" "libicui18n.so.56" "libQt5Core.so.5" "libQt5Gui.so.5" "libQt5Qml.so.5" "libQt5Network.so.5" "libQt5Widgets.so.5" )
for lib in ${libs[*]}
do
cp "$QT_PATH/lib/$lib" "$TARGET_PATH/$lib"
done


qmlPlugins=( "QtQuick" "QtQuick.2" "QtQml" )
for qml in ${qmlPlugins[*]}
do
cp -r "$QT_PATH/qml/$qml" "$TARGET_PATH/$qml"
done
END
# we need to run this two times...
PATH="$TMP_PATH:$PATH" "$DEPLOY_CMD" $TARGET_APP -appimage -qmldir=$PROJECT_PATH/src/qml -bundle-non-qt-libs -no-strip
6 changes: 0 additions & 6 deletions tools/deploy_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@ NODE_CMD=$2


macdeployqt $TARGET_APP -qmldir=$PROJECT_PATH/src/qml

rm -f $TARGET_APP/Contents/MacOS/node
rm -rf $TARGET_APP/Contents/Resources/app

cp $NODE_CMD $TARGET_APP/Contents/MacOS/node
cp -r $PROJECT_PATH/apps/default $TARGET_APP/Contents/Resources/app
35 changes: 35 additions & 0 deletions tools/downloadNode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

PROJECT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."

NODE_VERSION="v7.1.0"
ARCH="$($PROJECT_PATH/tools/arch.sh -f node -a)"
OS="$($PROJECT_PATH/tools/arch.sh -f node -o)"
BASE_URL="https://nodejs.org/dist/$NODE_VERSION"
BASE_PATH="$PROJECT_PATH/tmp/node-$NODE_VERSION-$OS-$ARCH"

pushd . > /dev/null
mkdir -p "$BASE_PATH"

if [ "$OS" == "win" ]; then
URL="$BASE_URL/win-$ARCH/node.exe"
NODE_CMD="$BASE_PATH/node.exe"

curl -o "$NODE_CMD" "$URL"
echo $NODE_CMD
exit
fi

URL="$BASE_URL/node-$NODE_VERSION-$OS-$ARCH.tar.xz"
NODE_CMD="$BASE_PATH/bin/node"

if [ -f "$NODE_CMD" ]; then
echo "$NODE_CMD"
exit
fi

cd "$BASE_PATH/.."
curl -0 "$URL"|tar -xJ
popd > /dev/null

echo "$NODE_CMD"
28 changes: 28 additions & 0 deletions tools/downloadQpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

PROJECT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."

VERSION="v0.10.0"
ARCH="$($PROJECT_PATH/tools/arch.sh -f qpm -a)"
OS="$($PROJECT_PATH/tools/arch.sh -f qpm -o)"
BASE_URL="https://www.qpm.io/download/$VERSION"
BASE_PATH="$PROJECT_PATH/tmp/qpm-$VERSION-$OS-$ARCH"

pushd . > /dev/null
mkdir -p "$BASE_PATH"

URL="$BASE_URL/$OS""_$ARCH/qpm"
CMD="$BASE_PATH/qpm"

if [ -f "$CMD" ]; then
echo "$CMD"
exit
fi

cd "$BASE_PATH"
curl -O "$URL"
chmod +x "$CMD"

popd > /dev/null

echo "$CMD"