I want to play a little bit with the Scalatra framework but run into problem that my sbt console does not know the aux-compile task. As suggested here, auto code reloading can be enabled with
~ ;copy-resources;aux-compile
I setted up my project with the following build.sbt file
name := "scalatra-app"
version := "0.1.0-SNAPSHOT"
scalaVersion := "2.11.2"
lazy val root = (project in file(".")).enablePlugins(SbtTwirl)
jetty()
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % "2.3.0",
//"org.scalatra" %% "scalatra-scalate" % "2.3.0",
"org.scalatra" %% "scalatra-specs2" % "2.3.0" % "test",
"org.slf4j" % "log4j-over-slf4j" % "1.6.1",
"ch.qos.logback" % "logback-classic" % "1.1.2" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.2.1.v20140609" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"
)
and use these plugins
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.4")
My sbt version is 0.13.7.
What am I missing? What should I do to use the aux-compile task?
That looks like doc bit rot. aux-compile went away with xsbt-web-plugin 1.0. It has been simplified by the plugin:
~container:start
This starts the container, then monitors the sources, resources, and webapp directories for changes, which triggers a container restart.
Here is this issue on Github.
I had trouble with aux-compile as well. I then tried container:start and it was not able to load my main class. I then stumbled across jetty:start and it works beautifully.
Related
I am trying to write a Qt .pro file that will run a set of commands, without compiling anything else first. Setting TEMPLATE=aux allows me to run just the script, and with help from this answer I have the following .pro file
# Target and build folders
TARGET = MySuperLibrary.dll
DESTDIR = ../../BuildAll
# Creates a Makefile for not building anything.
TEMPLATE = aux
extralib.target = extra
extralib.commands = echo \"Build the library\";
extralib.depends =
QMAKE_EXTRA_TARGETS += extralib
PRE_TARGETDEPS = extra
The problem is that the script commands are run every time, but I don't want them to run if the target file already exists. How should I modify the file so that the extralib commands are not run if the target file already exists?
Edit 16.01.2021
Following from zgyarmati's answer, I have modified the pro file as follows. Note that the new mytarget.commands actually generates the target dll and gives it a new timestamp. Unfortunately, this modified pro file still generates the dll every time it is run. Naturally the real script I want to run to generate this dll takes about ten minutes, so I really do not want it to run every time I build the project.
TARGET = MySuperLibrary.dll
DESTDIR = ../../BuildAll
# Creates a Makefile for not building anything.
TEMPLATE = aux
DESTDIR_WIN = $${DESTDIR}
DESTDIR_WIN ~= s,/,\\,g
mytarget.target = $${DESTDIR_WIN}\\$${TARGET}
mytarget.commands = echo \"MyDll\" > $${DESTDIR_WIN}\\$${TARGET}
mytarget.depends = mytarget2
mytarget2.commands = #echo Building $$mytarget.target
QMAKE_EXTRA_TARGETS += mytarget mytarget2
PRE_TARGETDEPS += mytarget2
Your script should create the extra file, to flag that it has been run. See https://doc.qt.io/qt-5/qmake-advanced-usage.html#adding-custom-targets
Here's a simple example of adding a custom build step:
mytarget.commands = #echo Testing123
QMAKE_EXTRA_TARGETS += mytarget
PRE_TARGETDEPS += mytarget
This works, and prints the message as expected. However, it also re-makes all targets in my project every time I build, which takes minutes.
If I take out PRE_TARGETDEPS += mytarget, no message is printed and the build succeeds quickly with no changes. But I need the message to print.
I need a pre-build step to execute, but I don't want any other targets to be remade if their dependencies didn't change. How can I achieve this with qt?
You must have a file on disk to make it working:
PRETARGET = .pretarget
!exists($$OUT_PWD/$$PRETARGET):system(touch $$OUT_PWD/$$PRETARGET)
$${PRETARGET}.depends = FORCE # or $${PRETARGET}.CONFIG = phony
$${PRETARGET}.commands = #echo -e \"[\\e[1m\\e[32mTARGET\\e[0m] $$OUT_PWD/$(DESTDIR_TARGET)\"
QMAKE_EXTRA_TARGETS += $$PRETARGET
PRE_TARGETDEPS += $$PRETARGET
My questions breack down in subquestions, but since all of them concern the same toppic of subdir-projekt setup and some decissions might influence the other questions i ask them all in one post.
1) Can i avoid writing the same include ines in every part using the same libs.
INCLUDEPATH += $$PWD/../MyLib1 # add header for usage
# Adds the QtQuickSampleLib.lib to the linker
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../MyLib1/release/ -lMyLib1
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../MyLib1/debug/ -lMyLib1
2) How to set up the output paths, so the dynamic-libs and Plugins can be loaded easely.
3) Can the Interface-Definition be placed in e seperate projekt, generating a static output so i can import it easely?
As i understand the Sourceprojekt-Folders schould be setup like this:
MainProjekt
+Main-Runner <generates the ELF>
+CoreLib (Most logic in a Lib for easyer tests, might make it a Plugin)
| +SRC
| +Test
+PluginInterface (currently .pri file)
+Plugins
| +PluginA
| | +SRC (Most logic in a Lib for easyer tests)
| | +Test
| +PluginB
| | +SRC (Most logic in a Lib for easyer tests)
| | +Test
| +PluginC <Depends on PluginA & PluginB being loaded>
| | +SRC (Most logic in a Lib for easyer tests)
| | +Test
PS: The idear is something like:
PluginA being hardwareInteraction (if possible having a "Fake-Version" for the test in PluginC)
PluginB Handles a Visible Data-Modell
PluginC is a Control-System Talking to the hardware and writing out Data.
The trick is to create a top-level .qmake.conf file and use it to define global paths:
CONFIG += c++11 #example, now it is set in every pro file
PROJ_VERSION = 1.0.0
OUT_ROOT = $$shadowed($$PWD)
LIB_OUT = $$OUT_ROOT/lib
PLG_OUT = $$OUT_ROOT/plugins
# ...
create that file as .qmake.conf in the MainProject folder. As long as you compile the project by using the MainProject.pro file, it is used for all sub pro files as well (recursively)
Now for the actual questions:
1.) Create a small pri file in the project root folder as:
INCLUDEPATH += $$PWD/MyLib1
win32:CONFIG(release, debug|release): LIBS += -L$$LIB_OUT -lMyLib1
else:win32:CONFIG(debug, debug|release): LIBS += -L$$LIB_OUT -lMyLib1d
you can include it in all the sub projects that need it. $$PWD is always the pri files directory itself, not where it is included. $$LIB_OUT is taken from the .qmake.conf
2.) As you might have noticed I defined a few variables in the conf file. You can now use these as DESTDIR in the actual pro files. For example, in your lib pro file you can use:
VERSION = $$PROJ_VERSION #optionally use the globally defined version
DESTDIR = $$LIB_OUT
You can do the same for plugins, binaries, etc.
I would like to know is there an easy way of adding patches to the SRC_URI in Yocto. I am creating a BSP for a customized board using Yocto. I have some hundred plus patches for the Linux kernel and barebox.
To include the patches for the Linux kernel, I have created an .scc file. In the .scc file I have included all the patches required.The SRC_URI option in the kernel recipe looks like:
SRC_URI += "https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.0.9.tar.xz \
file://kernelpatch.scc \
file://kernel-4.0.9.cfg \
"
For the barebox, I tried to do the same, but it seems it doesn't support .scc files. So now I have included all the hundred plus patches using
file://patchname.patch
file://patches/0001-drivers.patch \
file://patches/0002-hw_random-C.patch \
.
.
.
.
file://patches/0304-usb-fastbootupport.patch \
Is there any option to include all the patches in a single line like in the kernel.
Go to your meta-layer/recipes-kernel/linux Create a dir like patches. Copy all your patches to this patches directory.
create linux-ti_%.bbappend file and add below lines
FILESEXTRAPATHS_prepend := "${THISDIR}:"
SRC_URI = "file://patches/* "
this will take all your patches at single instance and apply to the kernel.
You can use the wildcard to include your files : file://* I don't think it's the best choice, but when you have lot of files, it can be usefull.
As #Pouet_forever "said", this is not best way to wildcards patches files, instead of this You may use bitbake approach with metadata files such like - .inc files. I mean by that You can extract all of them to one variable then include this file in Your main .bb recipe. Please take look at this example of keeping different patches in one file that may be easily used in many recipes:
.inc file with patches - https://github.com/kraj/meta-clang/blob/master/recipes-devtools/clang/common.inc
and usage of that in recipe: https://github.com/kraj/meta-clang/blob/master/recipes-devtools/clang/libcxx_git.bb
Before compile my program ,I need to compile a 3rd party library,but it is not writen in QT ,it has a Makefile to build itself . so if I write a pro file like this:
TEMPLATE = subdirs
SUBDIRS += image myapp
(image directory is the 3rd party library)
then qmake,make
it always report "Cannot find file: image.pro"
if I write a pro file inside image, it will create a Makefile which will overwrite the original Makefile.
any suggestions?
Thanks in advance
You could try several things, depending on what you want:
Use QMAKE_MAKEFILE to rename the qmake-generated makefile so that is won't overwrite the other one.
do some fancy stuff to create something like a QMAKE_PRE_BUILD sort of thing (this variable does not exist in qmake):
makefile.target = Makefile
makefile.depends += prebuild
prebuild.target = prebuild
prebuild.depends = FORCE
prebuild.commands = #echo before build (to replace)
QMAKE_EXTRA_TARGETS += makefile
QMAKE_EXTRA_TARGETS += prebuild
Source: http://forum.qtfr.org/viewtopic.php?id=10686 (read post two and three (google translate) and keep in mind that "défaut" wich means defect gets translated as default :) )
These should be able to solve the problem you're having.