Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/snapcraft-step1 into lp:qtcreator-plugin-ubuntu

Proposed by Benjamin Zeller on 2016-09-22
Status: Merged
Approved by: Zoltan Balogh on 2016-09-22
Approved revision: 471
Merged at revision: 470
Proposed branch: lp:~zeller-benjamin/qtcreator-plugin-ubuntu/snapcraft-step1
Merge into: lp:qtcreator-plugin-ubuntu
Diff against target: 1485 lines (+1183/-19)
26 files modified
UbuntuPlugin.pro (+9/-2)
share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName.pro (+32/-0)
share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/Main.qml (+54/-0)
share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.desktop (+9/-0)
share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.pro (+48/-0)
share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.qrc (+5/-0)
share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.wrapper (+63/-0)
share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/main.cpp (+14/-0)
share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/snapcraft.yaml (+23/-0)
share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/wizard.json (+108/-0)
share/qtcreator/ubuntu/qml/publishpage.qml (+2/-2)
share/qtcreator/ubuntu/scripts/usdk-target-build (+1/-0)
src/plugin.pri (+1/-0)
src/ubuntu/clicktoolchain.cpp (+1/-1)
src/ubuntu/clicktoolchain.h (+1/-1)
src/ubuntu/snap/snapcraftpackagestep.cpp (+468/-0)
src/ubuntu/snap/snapcraftpackagestep.h (+105/-0)
src/ubuntu/snap/snaphelper.cpp (+30/-0)
src/ubuntu/snap/snaphelper.h (+22/-0)
src/ubuntu/ubuntuconstants.h (+1/-0)
src/ubuntu/ubuntujsextension.cpp (+46/-0)
src/ubuntu/ubuntujsextension.h (+37/-0)
src/ubuntu/ubuntupackagingmodel.cpp (+86/-5)
src/ubuntu/ubuntupackagingmodel.h (+1/-0)
src/ubuntu/ubuntuplugin.cpp (+9/-3)
src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp (+7/-5)
To merge this branch: bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/snapcraft-step1
Reviewer Review Type Date Requested Status
Zoltan Balogh (community) 2016-09-22 Approve on 2016-09-22
ubuntu-sdk-build-bot continuous-integration Needs Fixing on 2016-09-22
Review via email: mp+306498@code.launchpad.net

Commit message

Support packaging snapcraft projects from the IDE (Step 1)

Description of the change

Support packaging snapcraft projects from the IDE (Step 1)

To post a comment you must log in.
471. By Benjamin Zeller on 2016-09-22

merge trunk

review: Needs Fixing (continuous-integration)
review: Needs Fixing (continuous-integration)
Zoltan Balogh (bzoltan) wrote :

Nice

Zoltan Balogh (bzoltan) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UbuntuPlugin.pro'
2--- UbuntuPlugin.pro 2016-09-05 17:14:46 +0000
3+++ UbuntuPlugin.pro 2016-09-22 15:50:47 +0000
4@@ -106,7 +106,10 @@
5 src/ubuntu/device/container/ubuntulocaldeployconfiguration.cpp \
6 src/ubuntu/device/container/ubuntulocalrunconfigurationfactory.cpp \
7 src/ubuntu/device/container/ubuntulocalrunconfiguration.cpp \
8- src/ubuntu/processoutputdialog.cpp
9+ src/ubuntu/processoutputdialog.cpp \
10+ $$PWD/src/ubuntu/ubuntujsextension.cpp \
11+ src/ubuntu/snap/snapcraftpackagestep.cpp \
12+ src/ubuntu/snap/snaphelper.cpp
13
14 HEADERS += \
15 src/ubuntu/ubuntuplugin.h \
16@@ -175,7 +178,10 @@
17 src/ubuntu/device/container/ubuntulocaldeployconfiguration.h \
18 src/ubuntu/device/container/ubuntulocalrunconfigurationfactory.h \
19 src/ubuntu/device/container/ubuntulocalrunconfiguration.h \
20- src/ubuntu/processoutputdialog.h
21+ src/ubuntu/processoutputdialog.h \
22+ $$PWD/src/ubuntu/ubuntujsextension.h \
23+ src/ubuntu/snap/snapcraftpackagestep.h \
24+ src/ubuntu/snap/snaphelper.h
25
26 #remote device support
27 SOURCES += \
28@@ -214,6 +220,7 @@
29 src/ubuntu/device/remote/ubuntudirectuploadstep.h \
30 src/ubuntu/device/remote/ubuntudeploystepfactory.h
31
32+
33 FORMS += \
34 src/ubuntu/device/remote/ubunturemoterunconfigurationwidget.ui \
35
36
37=== added directory 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake'
38=== added directory 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName'
39=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName.pro'
40--- share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName.pro 1970-01-01 00:00:00 +0000
41+++ share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName.pro 2016-09-22 15:50:47 +0000
42@@ -0,0 +1,32 @@
43+# This is the basic qmake template for the Ubuntu-SDK
44+# it handles creation and installation of the manifest
45+# file and takes care of subprojects
46+TEMPLATE = subdirs
47+
48+SUBDIRS += %{ProjectNameL}
49+
50+# enables/disabled the extra targets to build a snapcraft package
51+# also tells the IDE this is a snapcraft project
52+CONFIG += snapcraft
53+
54+snapcraft {
55+
56+ SNAPCRAFT_FILE=snapcraft.yaml
57+
58+ #the Ubuntu SDK IDE uses the snap target to create the package
59+ snappy.target = snap
60+ snappy.commands = cd $$OUT_PWD
61+ snappy.commands += && rm -rf \'$$OUT_PWD/snap-deploy\'
62+ snappy.commands += && make INSTALL_ROOT=$$OUT_PWD/snap-deploy install
63+ snappy.commands += && cd $$OUT_PWD/snap-deploy
64+ snappy.commands += && snapcraft
65+
66+ OTHER_FILES+=$$SNAPCRAFT_FILE
67+ QMAKE_EXTRA_TARGETS += snappy
68+
69+ packaging.files = $$SNAPCRAFT_FILE
70+ packaging.path = /
71+
72+ INSTALLS+=packaging
73+}
74+
75
76=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/Main.qml'
77--- share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/Main.qml 1970-01-01 00:00:00 +0000
78+++ share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/Main.qml 2016-09-22 15:50:47 +0000
79@@ -0,0 +1,54 @@
80+import QtQuick 2.4
81+import Ubuntu.Components 1.3
82+
83+/*!
84+ \brief MainView with a Label and Button elements.
85+*/
86+
87+MainView {
88+ // objectName for functional testing purposes (autopilot-qt5)
89+ objectName: "mainView"
90+
91+ applicationName: "%{ProjectNameL}.%{DeveloperId}"
92+
93+ width: units.gu(100)
94+ height: units.gu(75)
95+
96+ Page {
97+ header: PageHeader {
98+ id: pageHeader
99+ title: i18n.tr("%{ProjectNameL}")
100+ StyleHints {
101+ foregroundColor: UbuntuColors.orange
102+ backgroundColor: UbuntuColors.porcelain
103+ dividerColor: UbuntuColors.slate
104+ }
105+ }
106+
107+ Label {
108+ id: label
109+ objectName: "label"
110+ anchors {
111+ horizontalCenter: parent.horizontalCenter
112+ top: pageHeader.bottom
113+ topMargin: units.gu(2)
114+ }
115+
116+ text: i18n.tr("Hello..")
117+ }
118+
119+ Button {
120+ objectName: "button"
121+ anchors {
122+ horizontalCenter: parent.horizontalCenter
123+ top: label.bottom
124+ topMargin: units.gu(2)
125+ }
126+ width: parent.width
127+ text: i18n.tr("Tap me!")
128+ onClicked: {
129+ label.text = i18n.tr("..world!")
130+ }
131+ }
132+ }
133+}
134
135=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.desktop'
136--- share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.desktop 1970-01-01 00:00:00 +0000
137+++ share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.desktop 2016-09-22 15:50:47 +0000
138@@ -0,0 +1,9 @@
139+[Desktop Entry]
140+Version=1.0
141+Name=%{ProjectNameL}
142+Exec=%{ProjectNameL}
143+TryExec=%{ProjectNameL}
144+Icon=${SNAP}/meta/gui/%{ProjectNameL}.png
145+Terminal=false
146+Type=Application
147+X-Ubuntu-Touch=true
148
149=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.png'
150Binary files share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.png 1970-01-01 00:00:00 +0000 and share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.png 2016-09-22 15:50:47 +0000 differ
151=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.pro'
152--- share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.pro 1970-01-01 00:00:00 +0000
153+++ share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.pro 2016-09-22 15:50:47 +0000
154@@ -0,0 +1,48 @@
155+TEMPLATE = app
156+TARGET = %{ProjectNameL}
157+
158+QT += qml quick
159+
160+# enables/disabled the extra targets to build a snapcraft package
161+# also tells the IDE this is a snapcraft project
162+CONFIG += snapcraft
163+
164+SOURCES += main.cpp
165+
166+RESOURCES += %{ProjectNameL}.qrc
167+
168+QML_FILES += $$files(*.qml,true) \
169+ $$files(*.js,true)
170+
171+CONF_FILES += %{ProjectNameL}.png
172+
173+AP_TEST_FILES += tests/autopilot/run \
174+ $$files(tests/*.py,true)
175+
176+#show all the files in QtCreator
177+OTHER_FILES += $${CONF_FILES} \
178+ $${QML_FILES} \
179+ $${AP_TEST_FILES} \
180+ %{ProjectNameL}.desktop \
181+ %{ProjectNameL}.wrapper
182+
183+snapcraft {
184+ #specify where the config files are installed to
185+ config_files.path = /setup/gui
186+ config_files.files += $${CONF_FILES}
187+ INSTALLS+=config_files
188+
189+ #install the desktop file
190+ desktop_file.path = /setup/gui
191+ desktop_file.files = $$PWD/%{ProjectNameL}.desktop
192+ desktop_file.CONFIG += no_check_exist
193+ INSTALLS+=desktop_file
194+
195+ # Default rules for deployment.
196+
197+ wrapper.files = %{ProjectNameL}.wrapper
198+ wrapper.path = /deploy/bin
199+
200+ target.path = /deploy/bin
201+ INSTALLS+=target wrapper
202+}
203
204=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.qrc'
205--- share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.qrc 1970-01-01 00:00:00 +0000
206+++ share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.qrc 2016-09-22 15:50:47 +0000
207@@ -0,0 +1,5 @@
208+<RCC>
209+ <qresource prefix="/">
210+ <file>Main.qml</file>
211+ </qresource>
212+</RCC>
213
214=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.wrapper'
215--- share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.wrapper 1970-01-01 00:00:00 +0000
216+++ share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/appName.wrapper 2016-09-22 15:50:47 +0000
217@@ -0,0 +1,63 @@
218+#!/bin/bash
219+
220+if [ "$SNAP_ARCH" == "amd64" ]; then
221+ ARCH="x86_64-linux-gnu"
222+elif [ "$SNAP_ARCH" == "armhf" ]; then
223+ ARCH="arm-linux-gnueabihf"
224+else
225+ ARCH="$SNAP_ARCH-linux-gnu"
226+fi
227+
228+export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$LD_LIBRARY_PATH
229+
230+# XKB config
231+export XKB_CONFIG_ROOT=$SNAP/usr/share/X11/xkb
232+
233+if [ "$DESKTOP_SESSION" == "unity8" ]; then
234+ # Qt Platform to Mir
235+ export QT_QPA_PLATFORM=ubuntumirclient
236+ # Mir runtime
237+ export MIR_SOCKET=$XDG_RUNTIME_DIR/mir_socket
238+ export MIR_CLIENT_PLATFORM_PATH=$SNAP/usr/lib/$ARCH/mir/client-platform
239+fi
240+
241+# Qt Libs
242+export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/qt5/libs:$LD_LIBRARY_PATH
243+export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/pulseaudio:$LD_LIBRARY_PATH
244+
245+# Qt Modules
246+export QT_PLUGIN_PATH=$SNAP/usr/lib/$ARCH/qt5/plugins
247+export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$SNAP/usr/lib/$ARCH/qt5/qml
248+export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$SNAP/lib/$ARCH
249+
250+# Mesa Libs
251+export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa:$LD_LIBRARY_PATH
252+export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH
253+
254+# XDG Config
255+export XDG_CONFIG_DIRS=$SNAP/etc/xdg:$XDG_CONFIG_DIRS
256+export XDG_CONFIG_DIRS=$SNAP/usr/xdg:$XDG_CONFIG_DIRS
257+# Note: this doesn't seem to work, QML's LocalStorage either ignores
258+# or fails to use $SNAP_USER_DATA if defined here
259+export XDG_DATA_DIRS=$SNAP_USER_DATA:$XDG_DATA_DIRS
260+export XDG_DATA_DIRS=$SNAP/usr/share:$XDG_DATA_DIRS
261+
262+# needed for fontconfig
263+export XDG_DATA_HOME=$SNAP/usr/share
264+
265+# Font Config
266+export FONTCONFIG_PATH=$SNAP/etc/fonts/config.d
267+export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf
268+
269+# Tell libGL where to find the drivers
270+export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/$ARCH/dri
271+
272+# Necessary for the SDK to find the translations directory
273+export APP_DIR=$SNAP
274+
275+# ensure the snappy gl libs win
276+export LD_LIBRARY_PATH="$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH"
277+
278+cd $SNAP
279+exec $SNAP/bin/%{ProjectNameL}
280+
281
282=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/main.cpp'
283--- share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/main.cpp 1970-01-01 00:00:00 +0000
284+++ share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/appName/main.cpp 2016-09-22 15:50:47 +0000
285@@ -0,0 +1,14 @@
286+#include <QGuiApplication>
287+#include <QQmlApplicationEngine>
288+#include <QQuickView>
289+
290+int main(int argc, char *argv[])
291+{
292+ QGuiApplication app(argc, argv);
293+
294+ QQuickView view;
295+ view.setSource(QUrl(QStringLiteral("qrc:///Main.qml")));
296+ view.setResizeMode(QQuickView::SizeRootObjectToView);
297+ view.show();
298+ return app.exec();
299+}
300
301=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/snapcraft.yaml'
302--- share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/snapcraft.yaml 1970-01-01 00:00:00 +0000
303+++ share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/snapcraft.yaml 2016-09-22 15:50:47 +0000
304@@ -0,0 +1,23 @@
305+name: %{ProjectNameL}
306+version: 0.01
307+summary: Example application
308+description: Shows a basic UITK based UI
309+confinement: strict
310+
311+apps:
312+ %{ProjectNameL}:
313+ command: %{ProjectNameL}.wrapper
314+ plugs: [unity7, opengl]
315+
316+parts:
317+ %{ProjectNameL}:
318+ plugin: dump
319+ source: deploy/
320+ stage-packages:
321+ - ubuntu-sdk-libs
322+ - qtubuntu-desktop
323+ - qtmir-desktop
324+ - mir-graphics-drivers-desktop
325+
326+
327+
328
329=== added file 'share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/wizard.json'
330--- share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/wizard.json 1970-01-01 00:00:00 +0000
331+++ share/qtcreator/templates/wizards/ubuntu/snap-qtquick-app-qmake/wizard.json 2016-09-22 15:50:47 +0000
332@@ -0,0 +1,108 @@
333+{
334+ "version": 1,
335+ "supportedProjectTypes": [ "Qt4ProjectManager.Qt4Project" ],
336+ "id": "A.QtQuick Snappy Application",
337+ "category": "B.Snapcraft",
338+ "trDescription": "Creates a experimental C++ Ubuntu snappy application project with a sample UI containing a Label and a Button.",
339+ "trDisplayName": "QtQuick App with QML Ubuntu UI",
340+ "trDisplayCategory": "Snapcraft",
341+ "icon": "../share/ubuntu.png",
342+ "enabled": "%{JS: [ %{Plugins} ].indexOf('QmakeProjectManager') >= 0}",
343+
344+ "options":
345+ [
346+ { "key": "ProjectFile", "value": "%{JS: Util.fileName('%{ProjectDirectory}/%{ProjectName}', 'pro')}" },
347+ { "key": "ProjectNameL", "value": "%{JS: \"%{ProjectName}\".toLowerCase()}" },
348+ { "key": "CppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" },
349+ { "key": "IsTopLevelProject", "value": "%{JS: !'%{Exists:ProjectExplorer.Profile.Ids}'}" }
350+ ],
351+
352+ "pages":
353+ [
354+ {
355+ "trDisplayName": "Project Location",
356+ "trShortTitle": "Location",
357+ "typeId": "Project"
358+ },
359+ {
360+ "trDisplayName": "Developer ID",
361+ "trShortTitle": "Developer ID",
362+ "typeId": "Fields",
363+ "data" :
364+ [
365+ {
366+ "name": "DeveloperId",
367+ "trDisplayName": "Developer ID:",
368+ "mandatory": true,
369+ "type": "LineEdit",
370+ "data": {
371+ "validator": "^[A-Za-z0-9-]+$",
372+ "trText": "%{JS: Ubuntu.developerId()}"
373+ }
374+ }
375+ ]
376+ },
377+ {
378+ "trDisplayName": "Kit Selection",
379+ "trShortTitle": "Kits",
380+ "typeId": "Kits",
381+ "enabled": "%{IsTopLevelProject}",
382+ "data": { "projectFilePath": "%{ProjectFile}" }
383+ },
384+ {
385+ "trDisplayName": "Project Management",
386+ "trShortTitle": "Summary",
387+ "typeId": "Summary"
388+ }
389+ ],
390+ "generators":
391+ [
392+ {
393+ "typeId": "File",
394+ "data":
395+ [
396+ {
397+ "source": "appName.pro",
398+ "target": "%{ProjectFile}",
399+ "openAsProject": true
400+ },
401+ {
402+ "source": "snapcraft.yaml",
403+ "openInEditor": true
404+ },
405+ {
406+ "source": "appName/main.cpp",
407+ "target": "%{ProjectDirectory}/%{ProjectNameL}/%{CppFileName}",
408+ "openInEditor": true
409+ },
410+ {
411+ "source": "appName/Main.qml",
412+ "target": "%{ProjectDirectory}/%{ProjectNameL}/Main.qml",
413+ "openInEditor": true
414+ },
415+ {
416+ "source": "appName/appName.desktop",
417+ "target": "%{ProjectDirectory}/%{ProjectNameL}/%{ProjectNameL}.desktop"
418+ },
419+ {
420+ "source": "appName/appName.png",
421+ "target": "%{ProjectDirectory}/%{ProjectNameL}/%{ProjectNameL}.png"
422+ },
423+ {
424+ "source": "appName/appName.pro",
425+ "target": "%{ProjectDirectory}/%{ProjectNameL}/%{ProjectNameL}.pro"
426+ },
427+ {
428+ "source": "appName/appName.qrc",
429+ "target": "%{ProjectDirectory}/%{ProjectNameL}/%{ProjectNameL}.qrc"
430+ },
431+ {
432+ "source": "appName/appName.wrapper",
433+ "target": "%{ProjectDirectory}/%{ProjectNameL}/%{ProjectNameL}.wrapper",
434+ "userExecutable": true
435+ }
436+
437+ ]
438+ }
439+ ]
440+}
441
442=== modified file 'share/qtcreator/ubuntu/qml/publishpage.qml'
443--- share/qtcreator/ubuntu/qml/publishpage.qml 2015-11-26 09:55:54 +0000
444+++ share/qtcreator/ubuntu/qml/publishpage.qml 2016-09-22 15:50:47 +0000
445@@ -80,7 +80,7 @@
446 spacing: units.gu(2)
447 Button {
448 visible: publishModel.showValidationUi
449- text: "Validate existing click package"
450+ text: "Validate existing package"
451 onClicked: {
452 publishModel.on_pushButtonReviewersTools_clicked();
453 }
454@@ -88,7 +88,7 @@
455 Button {
456 visible: publishModel.showValidationUi
457 enabled: publishModel.canBuild
458- text: "Build and validate click package"
459+ text: "Build and validate package"
460 onClicked: {
461 publishModel.on_pushButtonClickPackage_clicked();
462 }
463
464=== modified file 'share/qtcreator/ubuntu/scripts/usdk-target-build'
465--- share/qtcreator/ubuntu/scripts/usdk-target-build 2016-08-01 10:15:22 +0000
466+++ share/qtcreator/ubuntu/scripts/usdk-target-build 2016-09-22 15:50:47 +0000
467@@ -147,6 +147,7 @@
468 "qttools5-dev:{TARGET}",
469 "ubuntu-sdk-qmake-extras:{TARGET}",
470 "ubuntu-ui-toolkit-doc:{TARGET}",
471+ "snapcraft"
472 ],
473 "ubuntu-sdk-16.10": [
474 ]
475
476=== modified file 'src/plugin.pri'
477--- src/plugin.pri 2015-06-05 10:25:56 +0000
478+++ src/plugin.pri 2016-09-22 15:50:47 +0000
479@@ -71,3 +71,4 @@
480 LIBS += -L$$[QT_INSTALL_LIBS]/qtcreator
481 LIBS += -L$$[QT_INSTALL_LIBS]/qtcreator/plugins
482 }
483+
484
485=== modified file 'src/ubuntu/clicktoolchain.cpp'
486--- src/ubuntu/clicktoolchain.cpp 2016-08-18 06:42:19 +0000
487+++ src/ubuntu/clicktoolchain.cpp 2016-09-22 15:50:47 +0000
488@@ -1,5 +1,5 @@
489 /*
490- * Copyright 2014 Canonical Ltd.
491+ * Copyright 2016 Canonical Ltd.
492 *
493 * This program is free software; you can redistribute it and/or modify
494 * it under the terms of the GNU Lesser General Public License as published by
495
496=== modified file 'src/ubuntu/clicktoolchain.h'
497--- src/ubuntu/clicktoolchain.h 2016-08-18 06:42:19 +0000
498+++ src/ubuntu/clicktoolchain.h 2016-09-22 15:50:47 +0000
499@@ -1,5 +1,5 @@
500 /*
501- * Copyright 2014 Canonical Ltd.
502+ * Copyright 2016 Canonical Ltd.
503 *
504 * This program is free software; you can redistribute it and/or modify
505 * it under the terms of the GNU Lesser General Public License as published by
506
507=== added directory 'src/ubuntu/snap'
508=== added file 'src/ubuntu/snap/snapcraftpackagestep.cpp'
509--- src/ubuntu/snap/snapcraftpackagestep.cpp 1970-01-01 00:00:00 +0000
510+++ src/ubuntu/snap/snapcraftpackagestep.cpp 2016-09-22 15:50:47 +0000
511@@ -0,0 +1,468 @@
512+/*
513+ * Copyright 2016 Canonical Ltd.
514+ *
515+ * This program is free software; you can redistribute it and/or modify
516+ * it under the terms of the GNU Lesser General Public License as published by
517+ * the Free Software Foundation; version 2.1.
518+ *
519+ * This program is distributed in the hope that it will be useful,
520+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
521+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
522+ * GNU Lesser General Public License for more details.
523+ *
524+ * You should have received a copy of the GNU Lesser General Public License
525+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
526+ *
527+ * Author: Benjamin Zeller <benjamin.zeller@canonical.com>
528+ */
529+
530+#include "snapcraftpackagestep.h"
531+
532+#include <ubuntu/ubuntuconstants.h>
533+#include <ubuntu/ubuntupackageoutputparser.h>
534+
535+#include <projectexplorer/target.h>
536+#include <projectexplorer/task.h>
537+#include <projectexplorer/kitinformation.h>
538+#include <projectexplorer/project.h>
539+#include <projectexplorer/projectexplorerconstants.h>
540+#include <projectexplorer/buildconfiguration.h>
541+#include <projectexplorer/toolchain.h>
542+#include <utils/qtcassert.h>
543+#include <utils/fileutils.h>
544+
545+#include <QTimer>
546+#include <QRegularExpression>
547+
548+namespace Ubuntu {
549+namespace Internal {
550+
551+const char * PACKAGE_NAME_REGEX = "^Snapped ([\\S]+\\.snap)$";
552+
553+SnapcraftPackageStep::SnapcraftPackageStep(ProjectExplorer::BuildStepList *bsl)
554+ : ProjectExplorer::BuildStep (bsl, Constants::UBUNTU_SNAP_PACKAGESTEP_ID)
555+{
556+
557+}
558+
559+SnapcraftPackageStep::SnapcraftPackageStep(ProjectExplorer::BuildStepList *bsl, SnapcraftPackageStep *other)
560+ : ProjectExplorer::BuildStep (bsl, other)
561+{
562+
563+}
564+
565+SnapcraftPackageStep::~SnapcraftPackageStep()
566+{
567+ cleanup();
568+}
569+
570+QString SnapcraftPackageStep::packagePath() const
571+{
572+ if(m_snapPackageName.isEmpty())
573+ return QString();
574+ return snapWorkingDir()
575+ + QDir::separator()
576+ + m_snapPackageName;
577+}
578+
579+QString SnapcraftPackageStep::snapWorkingDir() const
580+{
581+ return m_buildDir+QStringLiteral("/snap-deploy");
582+}
583+
584+bool SnapcraftPackageStep::init(QList<const ProjectExplorer::BuildStep *> &earlierSteps)
585+{
586+ Q_UNUSED(earlierSteps)
587+ return true;
588+}
589+
590+void SnapcraftPackageStep::run(QFutureInterface<bool> &fi)
591+{
592+ internalInit();
593+
594+ if (m_tasks.size()) {
595+ foreach (const ProjectExplorer::Task& task, m_tasks) {
596+ addTask(task);
597+ }
598+ emit addOutput(tr("Configuration is invalid. Aborting build")
599+ ,ProjectExplorer::BuildStep::MessageOutput);
600+
601+ reportRunResult(fi, false);
602+ cleanup();
603+ return;
604+ }
605+
606+ m_state = Idle;
607+ m_futureInterface = &fi;
608+ m_futureInterface->setProgressRange(0,2);
609+ QTimer::singleShot(0,this,SLOT(doNextStep()));
610+}
611+
612+void SnapcraftPackageStep::cleanup()
613+{
614+ if (m_process) {
615+ m_process->disconnect(this);
616+ m_process->kill();
617+ m_process->deleteLater();
618+ m_process = 0;
619+ }
620+
621+ //not owned by us
622+ m_futureInterface = 0;
623+
624+ if (m_outputParserChain) {
625+ delete m_outputParserChain;
626+ m_outputParserChain = 0;
627+ }
628+
629+ //reset params
630+ m_SnapReviewParam = m_MakeParam = ProjectExplorer::ProcessParameters();
631+ m_currParam = nullptr;
632+}
633+
634+/*!
635+ * \brief UbuntuPackageStep::setupAndStartProcess
636+ * Setups the interal QProcess and connects the required SIGNALS
637+ * also makes sure the process has a clean output parser
638+ */
639+void SnapcraftPackageStep::setupAndStartProcess(ProjectExplorer::ProcessParameters &params)
640+{
641+ if (m_process) {
642+ m_process->disconnect(this);
643+ m_process->kill();
644+ m_process->deleteLater();
645+ }
646+
647+ m_currParam = &params;
648+
649+ QDir wd(params.effectiveWorkingDirectory());
650+ if (!wd.exists())
651+ wd.mkpath(wd.absolutePath());
652+
653+ QString effectiveCommand = params.effectiveCommand();
654+ if (!QFileInfo(effectiveCommand).exists()) {
655+ onProcessFailedToStart();
656+ return;
657+ }
658+
659+ m_process = new Utils::QtcProcess();
660+ connect(m_process,SIGNAL(finished(int)),this,SLOT(doNextStep()));
661+ connect(m_process,SIGNAL(readyReadStandardOutput()),this,SLOT(onProcessStdOut()));
662+ connect(m_process,SIGNAL(readyReadStandardError()),this,SLOT(onProcessStdErr()));
663+
664+ m_process->setCommand(params.effectiveCommand(),params.effectiveArguments());
665+ m_process->setEnvironment(params.environment());
666+ m_process->setWorkingDirectory(wd.absolutePath());
667+
668+ emit addOutput(tr("Starting: \"%1 %2\"").arg(params.effectiveCommand(),params.effectiveArguments()),
669+ BuildStep::MessageOutput);
670+
671+ ProjectExplorer::IOutputParser *parser = target()->kit()->createOutputParser();
672+
673+ //add special parser on click review step
674+ if(m_state == SnapReview) {
675+ UbuntuPackageOutputParser *packageStepParser = new UbuntuPackageOutputParser;
676+ //packageStepParser->setTreatAllErrorsAsWarnings(m_treatClickErrorsAsWarnings);
677+ connect(this,SIGNAL(currentSubStepFinished()),packageStepParser,SLOT(setEndOfData()));
678+ if (parser)
679+ parser->appendOutputParser(packageStepParser);
680+ else
681+ parser = packageStepParser;
682+
683+ }
684+
685+ if(m_outputParserChain) {
686+ delete m_outputParserChain;
687+ m_outputParserChain = 0;
688+ }
689+
690+ if(parser) {
691+ m_outputParserChain = parser;
692+ m_outputParserChain->setWorkingDirectory(params.effectiveWorkingDirectory());
693+
694+ connect(m_outputParserChain,SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat)),
695+ this,SLOT(outputAdded(QString,ProjectExplorer::BuildStep::OutputFormat)));
696+ connect(m_outputParserChain,SIGNAL(addTask(ProjectExplorer::Task)),
697+ this,SLOT(taskAdded(ProjectExplorer::Task)));
698+ }
699+
700+ m_process->start();
701+ if(!m_process->waitForStarted()) {
702+ onProcessFailedToStart();
703+ return;
704+ }
705+}
706+
707+/*!
708+ * \brief UbuntuPackageStep::checkLastProcessSuccess
709+ * Checks if the last process has run without any errors
710+ */
711+bool SnapcraftPackageStep::processFinished(FinishedCheckMode mode)
712+{
713+ //make sure all data has been read
714+ QString line = QString::fromLocal8Bit(m_process->readAllStandardError());
715+ if (!line.isEmpty())
716+ stdError(line);
717+
718+ line = QString::fromLocal8Bit(m_process->readAllStandardOutput());
719+ if (!line.isEmpty())
720+ stdOutput(line);
721+
722+ emit currentSubStepFinished();
723+
724+ bool success = true;
725+
726+ if (m_outputParserChain) {
727+ m_outputParserChain->flush();
728+
729+ if(m_outputParserChain->hasFatalErrors())
730+ success = false;
731+ }
732+
733+ if(success) {
734+ QString command;
735+ if(m_currParam)
736+ command = QDir::toNativeSeparators(m_currParam->effectiveCommand());
737+ else
738+ command = tr("Unknown command");
739+
740+ if (m_process->exitStatus() == QProcess::NormalExit && m_process->exitCode() == 0) {
741+ emit addOutput(tr("The process \"%1\" exited normally.").arg(command),
742+ BuildStep::MessageOutput);
743+ } else if (m_process->exitStatus() == QProcess::NormalExit) {
744+ emit addOutput(tr("The process \"%1\" exited with code %2.")
745+ .arg(command, QString::number(m_process->exitCode())),
746+ BuildStep::ErrorMessageOutput);
747+ if(mode == CheckReturnCode)
748+ //error
749+ success = false;
750+ else {
751+ emit addOutput(tr("Ignoring return code for this step"),BuildStep::ErrorMessageOutput);
752+ }
753+ } else {
754+ emit addOutput(tr("The process \"%1\" crashed.").arg(command), BuildStep::ErrorMessageOutput);
755+
756+ //error
757+ success = false;
758+ }
759+ }
760+
761+ //the process failed, lets clean up
762+ if (!success) {
763+ if(m_futureInterface)
764+ reportRunResult(*m_futureInterface, false);
765+ cleanup();
766+ }
767+ return success;
768+}
769+
770+void SnapcraftPackageStep::stdOutput(const QString &line)
771+{
772+ m_lastLine = line;
773+
774+ if (m_outputParserChain)
775+ m_outputParserChain->stdOutput(line);
776+ emit addOutput(line, BuildStep::NormalOutput, BuildStep::DontAppendNewline);
777+}
778+
779+void SnapcraftPackageStep::stdError(const QString &line)
780+{
781+ if (m_outputParserChain)
782+ m_outputParserChain->stdError(line);
783+ emit addOutput(line, BuildStep::ErrorOutput, BuildStep::DontAppendNewline);
784+}
785+
786+
787+void SnapcraftPackageStep::onProcessStdOut()
788+{
789+ m_process->setReadChannel(QProcess::StandardOutput);
790+ while (m_process->canReadLine()) {
791+ QString line = QString::fromLocal8Bit(m_process->readLine());
792+ stdOutput(line);
793+ }
794+}
795+
796+void SnapcraftPackageStep::onProcessStdErr()
797+{
798+ m_process->setReadChannel(QProcess::StandardError);
799+ while (m_process->canReadLine()) {
800+ QString line = QString::fromLocal8Bit(m_process->readLine());
801+ stdError(line);
802+ }
803+}
804+
805+void SnapcraftPackageStep::outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format)
806+{
807+ emit addOutput(string, format, BuildStep::DontAppendNewline);
808+}
809+
810+void SnapcraftPackageStep::taskAdded(const ProjectExplorer::Task &task)
811+{
812+ emit addTask(task);
813+}
814+
815+void SnapcraftPackageStep::onProcessFailedToStart()
816+{
817+ if(m_futureInterface)
818+ reportRunResult(*m_futureInterface, false);
819+
820+ QString command = tr("Unknown command");
821+ QString args;
822+
823+ if (m_currParam) {
824+ command = QDir::toNativeSeparators(m_currParam->effectiveCommand());
825+ args = m_currParam->prettyArguments();
826+ }
827+
828+ emit addOutput(tr("Could not start process \"%1\" %2")
829+ .arg(command, args),
830+ BuildStep::ErrorMessageOutput);
831+
832+ cleanup();
833+
834+}
835+
836+QString SnapcraftPackageStep::makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Environment &env) const
837+{
838+ if (tc)
839+ return tc->makeCommand(env);
840+ return QString();
841+}
842+
843+
844+ProjectExplorer::BuildStepConfigWidget *SnapcraftPackageStep::createConfigWidget()
845+{
846+ return nullptr;
847+}
848+
849+void SnapcraftPackageStep::cancel()
850+{
851+
852+}
853+
854+bool SnapcraftPackageStep::immutable() const
855+{
856+ return true;
857+}
858+
859+bool SnapcraftPackageStep::runInGuiThread() const
860+{
861+ return true;
862+}
863+
864+void SnapcraftPackageStep::doNextStep()
865+{
866+ switch (m_state) {
867+ case Idle: {
868+ m_state = MakeSnap;
869+ m_currParam = nullptr;
870+ setupAndStartProcess(m_MakeParam);
871+ break;
872+ }
873+ case MakeSnap: {
874+ if (!processFinished(CheckReturnCode))
875+ return;
876+
877+ m_currParam = nullptr;
878+
879+ QRegularExpression exp((QLatin1String(PACKAGE_NAME_REGEX)));
880+ QRegularExpressionMatch m = exp.match(m_lastLine);
881+ if(m.hasMatch()) {
882+ m_snapPackageName = m.captured(1);
883+ emit addOutput(tr("The click package has been created in %1").arg(snapWorkingDir()) ,
884+ ProjectExplorer::BuildStep::MessageOutput);
885+ }
886+
887+ m_futureInterface->setProgressValueAndText(1,tr("Reviewing snap package"));
888+ m_state = SnapReview;
889+
890+ m_SnapReviewParam.setArguments(QString::fromLatin1(Constants::CLICK_REVIEWERSTOOLS_ARGS).arg(packagePath()));
891+ m_SnapReviewParam.resolveAll();
892+ setupAndStartProcess(m_SnapReviewParam);
893+ break;
894+ }
895+ case SnapReview: {
896+ //we need to ignore the return code for now,
897+ //until we have proper support for ignoring specific errors
898+ if (!processFinished(IgnoreReturnCode))
899+ return;
900+
901+ if(m_futureInterface)
902+ reportRunResult(*m_futureInterface, true);
903+ cleanup();
904+ break;
905+ }
906+ }
907+}
908+
909+void SnapcraftPackageStep::internalInit()
910+{
911+ m_tasks.clear();
912+
913+ QString projectDir = target()->project()->projectDirectory().toString();
914+ m_buildDir.clear();
915+ Utils::Environment env = Utils::Environment::systemEnvironment();
916+ Utils::MacroExpander *mExp = 0;
917+
918+
919+ ProjectExplorer::BuildConfiguration *bc = target()->activeBuildConfiguration();
920+ if (!bc) {
921+ ProjectExplorer::Task t(ProjectExplorer::Task::Error
922+ ,tr("No valid BuildConfiguration set for step: %1").arg(displayName())
923+ ,Utils::FileName(),-1
924+ ,ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
925+ m_tasks.append(t);
926+
927+ //SnapcraftPackageStep::run will stop if tasks exist
928+ return;
929+
930+ }
931+
932+ m_buildDir = bc->buildDirectory().toString();
933+ env = bc->environment();
934+ mExp = bc->macroExpander();
935+
936+ {
937+ QStringList arguments {
938+ QStringLiteral("snap")
939+ };
940+
941+ ProjectExplorer::ProcessParameters* params = &m_MakeParam;
942+ params->setMacroExpander(mExp);
943+
944+ //setup process parameters
945+ params->setWorkingDirectory(m_buildDir);
946+ params->setCommand(
947+ makeCommand(ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit()),
948+ env));
949+ params->setArguments(Utils::QtcProcess::joinArgs(arguments));
950+
951+ Utils::Environment tmpenv = env;
952+ // Force output to english for the parsers. Do this here and not in the toolchain's
953+ // addToEnvironment() to not screw up the users run environment.
954+ tmpenv.set(QLatin1String("LC_ALL"), QLatin1String("C"));
955+ params->setEnvironment(tmpenv);
956+
957+ params->resolveAll();
958+ }
959+
960+ //builds the snap review arguments
961+ {
962+ ProjectExplorer::ProcessParameters* params = &m_SnapReviewParam;
963+ params->setMacroExpander(mExp);
964+
965+ //setup process parameters
966+ params->setWorkingDirectory(m_buildDir);
967+ params->setCommand(QLatin1String(Constants::CLICK_REVIEWERSTOOLS_BINARY));
968+
969+ Utils::Environment tmpEnv = env;
970+ // Force output to english for the parsers. Do this here and not in the toolchain's
971+ // addToEnvironment() to not screw up the users run environment.
972+ tmpEnv.set(QLatin1String("LC_ALL"), QLatin1String("C"));
973+ params->setEnvironment(tmpEnv);
974+ }
975+}
976+
977+
978+} // namespace Internal
979+} // namespace Ubuntu
980
981=== added file 'src/ubuntu/snap/snapcraftpackagestep.h'
982--- src/ubuntu/snap/snapcraftpackagestep.h 1970-01-01 00:00:00 +0000
983+++ src/ubuntu/snap/snapcraftpackagestep.h 2016-09-22 15:50:47 +0000
984@@ -0,0 +1,105 @@
985+/*
986+ * Copyright 2016 Canonical Ltd.
987+ *
988+ * This program is free software; you can redistribute it and/or modify
989+ * it under the terms of the GNU Lesser General Public License as published by
990+ * the Free Software Foundation; version 2.1.
991+ *
992+ * This program is distributed in the hope that it will be useful,
993+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
994+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
995+ * GNU Lesser General Public License for more details.
996+ *
997+ * You should have received a copy of the GNU Lesser General Public License
998+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
999+ *
1000+ * Author: Benjamin Zeller <benjamin.zeller@canonical.com>
1001+ */
1002+
1003+#ifndef UBUNTU_INTERNAL_SNAPCRAFTPACKAGESTEP_H
1004+#define UBUNTU_INTERNAL_SNAPCRAFTPACKAGESTEP_H
1005+
1006+
1007+#include <projectexplorer/buildstep.h>
1008+#include <projectexplorer/ioutputparser.h>
1009+#include <projectexplorer/processparameters.h>
1010+#include <utils/qtcprocess.h>
1011+
1012+namespace ProjectExplorer{
1013+class ToolChain;
1014+}
1015+
1016+namespace Ubuntu {
1017+namespace Internal {
1018+
1019+class SnapcraftPackageStep : public ProjectExplorer::BuildStep
1020+{
1021+ Q_OBJECT
1022+public:
1023+
1024+ enum State {
1025+ Idle,
1026+ MakeSnap,
1027+ SnapReview
1028+ };
1029+
1030+ enum FinishedCheckMode {
1031+ CheckReturnCode,
1032+ IgnoreReturnCode
1033+ };
1034+
1035+ SnapcraftPackageStep(ProjectExplorer::BuildStepList *bsl);
1036+ SnapcraftPackageStep(ProjectExplorer::BuildStepList *bsl, SnapcraftPackageStep *other);
1037+ virtual ~SnapcraftPackageStep();
1038+
1039+ QString packagePath () const;
1040+ QString snapWorkingDir () const;
1041+
1042+ // BuildStep interface
1043+ virtual bool init(QList<const ProjectExplorer::BuildStep *> &earlierSteps) override;
1044+ virtual void run(QFutureInterface<bool> &fi) override;
1045+ virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
1046+ virtual void cancel() override;
1047+ virtual bool immutable() const override;
1048+ virtual bool runInGuiThread() const override;
1049+
1050+signals:
1051+ void currentSubStepFinished();
1052+
1053+protected slots:
1054+ void doNextStep ();
1055+ void onProcessFailedToStart();
1056+ void onProcessStdOut();
1057+ void onProcessStdErr();
1058+ void outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
1059+ void taskAdded (const ProjectExplorer::Task & task);
1060+
1061+private:
1062+ void internalInit ();
1063+ void cleanup();
1064+ QString makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Environment &env) const;
1065+ void setupAndStartProcess(ProjectExplorer::ProcessParameters &params);
1066+ void stdOutput(const QString &line);
1067+ void stdError(const QString &line);
1068+ bool processFinished(FinishedCheckMode mode);
1069+
1070+private:
1071+ State m_state = SnapcraftPackageStep::Idle;
1072+ QList<ProjectExplorer::Task> m_tasks;
1073+ QFutureInterface<bool> *m_futureInterface;
1074+
1075+ Utils::QtcProcess *m_process = nullptr;
1076+ ProjectExplorer::IOutputParser *m_outputParserChain = nullptr;
1077+
1078+ QString m_buildDir;
1079+ QString m_lastLine;
1080+ QString m_snapPackageName;
1081+ ProjectExplorer::ProcessParameters m_MakeParam;
1082+ ProjectExplorer::ProcessParameters m_SnapReviewParam;
1083+ ProjectExplorer::ProcessParameters *m_currParam = nullptr;
1084+};
1085+
1086+} // namespace Internal
1087+} // namespace Ubuntu
1088+
1089+#endif // UBUNTU_INTERNAL_SNAPCRAFTPACKAGESTEP_H
1090
1091=== added file 'src/ubuntu/snap/snaphelper.cpp'
1092--- src/ubuntu/snap/snaphelper.cpp 1970-01-01 00:00:00 +0000
1093+++ src/ubuntu/snap/snaphelper.cpp 2016-09-22 15:50:47 +0000
1094@@ -0,0 +1,30 @@
1095+#include "snaphelper.h"
1096+
1097+#include <projectexplorer/project.h>
1098+#include <qmakeprojectmanager/qmakeproject.h>
1099+#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
1100+
1101+namespace Ubuntu {
1102+namespace Internal {
1103+
1104+SnapHelper::SnapHelper()
1105+{
1106+
1107+}
1108+
1109+bool SnapHelper::isSnappyProject(ProjectExplorer::Project *project)
1110+{
1111+ if (!project)
1112+ return false;
1113+
1114+ QString mimeType = project->projectManager()->mimeType();
1115+ if(mimeType != QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE))
1116+ return false;
1117+
1118+ QmakeProjectManager::QmakeProject *qPro = static_cast<QmakeProjectManager::QmakeProject *>(project);
1119+ QmakeProjectManager::QmakeProFileNode *node = qPro->rootProjectNode();
1120+ return node->variableValue(QmakeProjectManager::ConfigVar).contains(QStringLiteral("snapcraft"), Qt::CaseInsensitive);
1121+}
1122+
1123+} // namespace Internal
1124+} // namespace Ubuntu
1125
1126=== added file 'src/ubuntu/snap/snaphelper.h'
1127--- src/ubuntu/snap/snaphelper.h 1970-01-01 00:00:00 +0000
1128+++ src/ubuntu/snap/snaphelper.h 2016-09-22 15:50:47 +0000
1129@@ -0,0 +1,22 @@
1130+#ifndef UBUNTU_INTERNAL_SNAPHELPER_H
1131+#define UBUNTU_INTERNAL_SNAPHELPER_H
1132+
1133+namespace ProjectExplorer {
1134+class Project;
1135+}
1136+
1137+namespace Ubuntu {
1138+namespace Internal {
1139+
1140+class SnapHelper
1141+{
1142+public:
1143+ SnapHelper();
1144+
1145+ static bool isSnappyProject (ProjectExplorer::Project* project);
1146+};
1147+
1148+} // namespace Internal
1149+} // namespace Ubuntu
1150+
1151+#endif // UBUNTU_INTERNAL_SNAPHELPER_H
1152
1153=== modified file 'src/ubuntu/ubuntuconstants.h'
1154--- src/ubuntu/ubuntuconstants.h 2016-07-20 14:56:52 +0000
1155+++ src/ubuntu/ubuntuconstants.h 2016-09-22 15:50:47 +0000
1156@@ -344,6 +344,7 @@
1157 const char UBUNTU_DEPLOY_UPLOADSTEP_ID[] = "UbuntuProjectManager.UploadStep";
1158 const char UBUNTU_DEPLOY_MAKESTEP_ID[] = "UbuntuProjectManager.UbuntuCMake.DeployMakeStep";
1159 const char UBUNTU_CLICK_PACKAGESTEP_ID[] = "UbuntuProjectManager.ClickPackageStep";
1160+const char UBUNTU_SNAP_PACKAGESTEP_ID[] = "UbuntuProjectManager.SnapPackageStep";
1161 const char UBUNTU_DEPLOY_DESTDIR[] = ".ubuntu-sdk-deploy";
1162 const char UBUNTU_CLICK_SUCCESS_PACKAGE_REGEX[] = "^.*'(.*)'.$";
1163
1164
1165=== added file 'src/ubuntu/ubuntujsextension.cpp'
1166--- src/ubuntu/ubuntujsextension.cpp 1970-01-01 00:00:00 +0000
1167+++ src/ubuntu/ubuntujsextension.cpp 2016-09-22 15:50:47 +0000
1168@@ -0,0 +1,46 @@
1169+/*
1170+ * Copyright 2016 Canonical Ltd.
1171+ *
1172+ * This program is free software; you can redistribute it and/or modify
1173+ * it under the terms of the GNU Lesser General Public License as published by
1174+ * the Free Software Foundation; version 2.1.
1175+ *
1176+ * This program is distributed in the hope that it will be useful,
1177+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1178+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1179+ * GNU Lesser General Public License for more details.
1180+ *
1181+ * You should have received a copy of the GNU Lesser General Public License
1182+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1183+ *
1184+ * Author: Benjamin Zeller <benjamin.zeller@canonical.com>
1185+ */
1186+#include "ubuntujsextension.h"
1187+#include <ubuntu/ubuntubzr.h>
1188+
1189+namespace Ubuntu {
1190+namespace Internal {
1191+
1192+UbuntuJsExtension::UbuntuJsExtension(QObject *parent) : QObject(parent)
1193+{
1194+
1195+}
1196+
1197+QString UbuntuJsExtension::developerId() const
1198+{
1199+ QString maintainer = QStringLiteral("username");
1200+ UbuntuBzr *bzr = UbuntuBzr::instance();
1201+
1202+ if(!bzr->isInitialized()) {
1203+ bzr->initialize();
1204+ bzr->waitForFinished();
1205+ }
1206+
1207+ if(bzr->isInitialized()) {
1208+ maintainer = bzr->launchpadId();
1209+ }
1210+
1211+ return maintainer;
1212+}
1213+
1214+}}
1215
1216=== added file 'src/ubuntu/ubuntujsextension.h'
1217--- src/ubuntu/ubuntujsextension.h 1970-01-01 00:00:00 +0000
1218+++ src/ubuntu/ubuntujsextension.h 2016-09-22 15:50:47 +0000
1219@@ -0,0 +1,37 @@
1220+/*
1221+ * Copyright 2016 Canonical Ltd.
1222+ *
1223+ * This program is free software; you can redistribute it and/or modify
1224+ * it under the terms of the GNU Lesser General Public License as published by
1225+ * the Free Software Foundation; version 2.1.
1226+ *
1227+ * This program is distributed in the hope that it will be useful,
1228+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1229+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1230+ * GNU Lesser General Public License for more details.
1231+ *
1232+ * You should have received a copy of the GNU Lesser General Public License
1233+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1234+ *
1235+ * Author: Benjamin Zeller <benjamin.zeller@canonical.com>
1236+ */
1237+#ifndef UBUNTUJSEXTENSION_H
1238+#define UBUNTUJSEXTENSION_H
1239+
1240+#include <QObject>
1241+
1242+namespace Ubuntu {
1243+namespace Internal {
1244+
1245+class UbuntuJsExtension : public QObject
1246+{
1247+ Q_OBJECT
1248+public:
1249+ explicit UbuntuJsExtension(QObject *parent = 0);
1250+
1251+ Q_INVOKABLE QString developerId() const;
1252+};
1253+
1254+}}
1255+
1256+#endif // UBUNTUJSEXTENSION_H
1257
1258=== modified file 'src/ubuntu/ubuntupackagingmodel.cpp'
1259--- src/ubuntu/ubuntupackagingmodel.cpp 2016-09-05 17:14:46 +0000
1260+++ src/ubuntu/ubuntupackagingmodel.cpp 2016-09-22 15:50:47 +0000
1261@@ -30,6 +30,8 @@
1262 #include "ubuntuproject.h"
1263
1264 #include <ubuntu/device/remote/ubuntudevice.h>
1265+#include <ubuntu/snap/snaphelper.h>
1266+#include <ubuntu/snap/snapcraftpackagestep.h>
1267
1268 #include <projectexplorer/projectexplorer.h>
1269 #include <projectexplorer/project.h>
1270@@ -159,7 +161,6 @@
1271 m_ubuntuProcess.append(QStringList() << QString::fromLatin1(Constants::CLICK_REVIEWERSTOOLS_LOCATION).arg(sClickPackagePath));
1272 m_ubuntuProcess.start(QString(QLatin1String(Constants::UBUNTUPACKAGINGWIDGET_CLICK_REVIEWER_TOOLS_AGAINST_PACKAGE)).arg(sClickPackagePath));
1273 }
1274-
1275 }
1276
1277 void UbuntuPackagingModel::onMessage(QString msg)
1278@@ -294,6 +295,16 @@
1279 if(!project)
1280 return;
1281
1282+ if (SnapHelper::isSnappyProject(project)) {
1283+ if(m_reviewToolsInstalled)
1284+ m_postPackageTask = Verify;
1285+ else
1286+ m_postPackageTask = None;
1287+
1288+ buildSnapPackage();
1289+ return;
1290+ }
1291+
1292 QString mimeType = project->projectManager()->mimeType();
1293 if(mimeType == QLatin1String(CMakeProjectManager::Constants::CMAKEPROJECTMIMETYPE)
1294 || mimeType == QLatin1String(Ubuntu::Constants::UBUNTUPROJECT_MIMETYPE)
1295@@ -303,6 +314,7 @@
1296 m_postPackageTask = Verify;
1297 else
1298 m_postPackageTask = None;
1299+
1300 buildClickPackage();
1301 } else {
1302 m_UbuntuMenu_connection = QObject::connect(UbuntuMenu::instance(),SIGNAL(finished_action(const QProcess*,QString)),this,SLOT(onFinishedAction(const QProcess*,QString)));
1303@@ -330,10 +342,11 @@
1304 if (success) {
1305 //the step that created the click package is always in the last list and always the last step
1306 UbuntuPackageStep *pckStep = qobject_cast<UbuntuPackageStep*>(m_packageBuildSteps.last()->steps().last());
1307- if (pckStep && !pckStep->packagePath().isEmpty()) {
1308+ SnapcraftPackageStep *snapPckStep = qobject_cast<SnapcraftPackageStep*>(m_packageBuildSteps.last()->steps().last());
1309+ if ((pckStep && !pckStep->packagePath().isEmpty()) || (snapPckStep && !snapPckStep->packagePath().isEmpty())) {
1310 m_ubuntuProcess.stop();
1311
1312- QString sClickPackagePath = pckStep->packagePath();
1313+ QString sClickPackagePath = pckStep ? pckStep->packagePath() : snapPckStep->packagePath();
1314 if (sClickPackagePath.isEmpty()) {
1315 clearPackageBuildList();
1316 return;
1317@@ -381,19 +394,34 @@
1318 void UbuntuPackagingModel::buildAndInstallPackageRequested()
1319 {
1320 m_postPackageTask = Install;
1321+
1322+ if (SnapHelper::isSnappyProject(ProjectExplorer::SessionManager::startupProject())) {
1323+ QMessageBox::information(Core::ICore::mainWindow(), qApp->applicationName(),
1324+ tr("Installing is currently not supported for snappy projects."));
1325+ return;
1326+ }
1327+
1328 buildClickPackage();
1329 }
1330
1331 void UbuntuPackagingModel::buildAndVerifyPackageRequested()
1332 {
1333 m_postPackageTask = Verify;
1334- buildClickPackage();
1335+
1336+ if (SnapHelper::isSnappyProject(ProjectExplorer::SessionManager::startupProject()))
1337+ buildSnapPackage();
1338+ else
1339+ buildClickPackage();
1340 }
1341
1342 void UbuntuPackagingModel::buildPackageRequested()
1343 {
1344 m_postPackageTask = None;
1345- buildClickPackage();
1346+
1347+ if (SnapHelper::isSnappyProject(ProjectExplorer::SessionManager::startupProject()))
1348+ buildSnapPackage();
1349+ else
1350+ buildClickPackage();
1351 }
1352
1353 void UbuntuPackagingModel::targetChanged()
1354@@ -561,6 +589,59 @@
1355 }
1356 }
1357
1358+void UbuntuPackagingModel::buildSnapPackage()
1359+{
1360+ ProjectExplorer::Project* project = ProjectExplorer::SessionManager::startupProject();
1361+ if(!project) {
1362+ QMessageBox::warning(Core::ICore::mainWindow(),tr("No Project"),tr("No valid project loaded."));
1363+ return;
1364+ }
1365+
1366+ if(ProjectExplorer::BuildManager::isBuilding()) {
1367+ QMessageBox::information(Core::ICore::mainWindow(),tr("Build running"),tr("There is currently a build running, please wait for it to be finished"));
1368+ return;
1369+ }
1370+
1371+ if(!ProjectExplorer::ProjectExplorerPlugin::instance()->saveModifiedFiles())
1372+ return;
1373+
1374+ if(!SnapHelper::isSnappyProject(project))
1375+ return;
1376+
1377+ ProjectExplorer::Target* target = project->activeTarget();
1378+ if(!target)
1379+ return;
1380+
1381+ ProjectExplorer::BuildConfiguration* bc = target->activeBuildConfiguration();
1382+ if(!bc) {
1383+ QMessageBox::information(Core::ICore::mainWindow(),tr("Error"),tr("Please add a valid buildconfiguration to your project"));
1384+ return;
1385+ }
1386+
1387+ if(!bc->isEnabled()) {
1388+ QString disabledReason = bc->disabledReason();
1389+ QMessageBox::information(Core::ICore::mainWindow(),tr("Disabled"),tr("The currently selected Buildconfiguration is disabled. %1").arg(disabledReason));
1390+ return;
1391+ }
1392+
1393+ clearPackageBuildList();
1394+
1395+ m_packageBuildSteps.append(QSharedPointer<ProjectExplorer::BuildStepList> (new ProjectExplorer::BuildStepList(bc,ProjectExplorer::Constants::BUILDSTEPS_BUILD)));
1396+ ProjectExplorer::BuildStepList *buildSteps = bc->stepList(Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD));
1397+ if (buildSteps && buildSteps->count() > 0) {
1398+ //add the normal buildsteps
1399+ m_packageBuildSteps.last()->cloneSteps(buildSteps);
1400+ }
1401+
1402+ //append the snap packaging step
1403+ SnapcraftPackageStep *package = new SnapcraftPackageStep(m_packageBuildSteps.last().data());
1404+ m_packageBuildSteps.last()->appendStep(package);
1405+
1406+ m_buildManagerConnection = connect(ProjectExplorer::BuildManager::instance(),SIGNAL(buildQueueFinished(bool)),this,SLOT(buildFinished(bool)));
1407+
1408+ ProjectExplorer::BuildManager::buildList(m_packageBuildSteps.last().data(),tr("Build Project"));
1409+}
1410+
1411 /*!
1412 * \brief UbuntuPackagingWidget::clearAdditionalBuildSteps
1413 * Clears the last used additional buildsteps
1414
1415=== modified file 'src/ubuntu/ubuntupackagingmodel.h'
1416--- src/ubuntu/ubuntupackagingmodel.h 2015-02-13 12:04:38 +0000
1417+++ src/ubuntu/ubuntupackagingmodel.h 2016-09-22 15:50:47 +0000
1418@@ -95,6 +95,7 @@
1419
1420 private:
1421 void buildClickPackage ();
1422+ void buildSnapPackage ();
1423 void clearPackageBuildList ();
1424 void updateFrameworkList ();
1425 void resetValidationResult ();
1426
1427=== modified file 'src/ubuntu/ubuntuplugin.cpp'
1428--- src/ubuntu/ubuntuplugin.cpp 2016-09-05 17:14:46 +0000
1429+++ src/ubuntu/ubuntuplugin.cpp 2016-09-22 15:50:47 +0000
1430@@ -49,9 +49,11 @@
1431 #include <ubuntu/device/remote/ubunturemotedeployconfiguration.h>
1432 #include <ubuntu/device/remote/ubuntudeploystepfactory.h>
1433
1434-#include "wizards/ubuntuprojectapplicationwizard.h"
1435-#include "wizards/ubuntufirstrunwizard.h"
1436-#include "wizards/ubuntuprojectmigrationwizard.h"
1437+#include <ubuntu/wizards/ubuntuprojectapplicationwizard.h>
1438+#include <ubuntu/wizards/ubuntufirstrunwizard.h>
1439+#include <ubuntu/wizards/ubuntuprojectmigrationwizard.h>
1440+
1441+#include "ubuntujsextension.h"
1442
1443 #include <coreplugin/modemanager.h>
1444 #include <projectexplorer/kitmanager.h>
1445@@ -60,6 +62,7 @@
1446 #include <projectexplorer/processparameters.h>
1447 #include <coreplugin/featureprovider.h>
1448 #include <coreplugin/coreplugin.h>
1449+#include <coreplugin/jsexpander.h>
1450 #include <utils/mimetypes/mimedatabase.h>
1451 #include <utils/mimetypes/mimeglobpattern_p.h>
1452 #include <cmakeprojectmanager/cmaketoolmanager.h>
1453@@ -233,6 +236,9 @@
1454 addAutoReleasedObject(new Internal::UbuntuManifestEditorFactory);
1455 addAutoReleasedObject(new Internal::UbuntuApparmorEditorFactory);
1456
1457+ //Ubuntu expander
1458+ Core::JsExpander::registerQObjectForJs(QStringLiteral("Ubuntu"), new UbuntuJsExtension);
1459+
1460 //trigger kit autodetection and update after projectexplorer loaded the kits
1461 connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitsLoaded())
1462 ,this,SLOT(onKitsLoaded()));
1463
1464=== modified file 'src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp'
1465--- src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp 2016-09-05 17:14:46 +0000
1466+++ src/ubuntu/wizards/ubuntuprojectapplicationwizard.cpp 2016-09-22 15:50:47 +0000
1467@@ -18,11 +18,13 @@
1468
1469 #include "ubuntuprojectapplicationwizard.h"
1470 #include "ubuntufirstrunwizard.h"
1471-#include "../ubuntushared.h"
1472-#include "../ubuntuconstants.h"
1473-#include "../ubuntuproject.h"
1474-#include "../ubuntubzr.h"
1475-#include "../ubuntuclicktool.h"
1476+
1477+#include <ubuntu/ubuntushared.h>
1478+#include <ubuntu/ubuntushared.h>
1479+#include <ubuntu/ubuntuconstants.h>
1480+#include <ubuntu/ubuntuproject.h>
1481+#include <ubuntu/ubuntubzr.h>
1482+#include <ubuntu/ubuntuclicktool.h>
1483
1484 #include <utils/qtcassert.h>
1485 #include <utils/pathchooser.h>

Subscribers

People subscribed via source and target branches