Premake5 xcode4 Action: bad argument #1 to 'pairs' - premake

I'm newer to Premake, but I have used it successfully in Visual Studio projects on Windows. Now, I have a premake5 script that works fine for Visual Studio and Makefile projects, but xcode and codelite projects fail:
$ premake5 --verbose xcode4
Building configurations...
Running action 'xcode4'...
Error: [string "xcode/xcode_common.lua"]:201: bad argument #1 to 'pairs'
(table expected, got nil)
XCode and CodeLite support is listed as mostly working; can anyone tell me if there's some specific issue I'm bumping into in the premake listings below? The solution is really quite simple.
My main Premake solution file:
src/premake5.lua
solution "LogicCore"
-- set the major and minor build numbers
VERSION_MAJOR = 1
VERSION_MINOR = 0
major = "VERSION_MAJOR=" .. VERSION_MAJOR;
minor = "VERSION_MINOR=" .. VERSION_MINOR;
defines { major, minor }
configurations { "Debug", "Release" }
configuration { "Debug" }
targetdir "../bin/debug"
configuration { "Release" }
targetdir "../bin/release"
if _ACTION == "clean" then
os.rmdir("../bin")
end
-- PROJECT: Generic include and utility functions.
include "lc"
My Premake sub-project file:
src/lc/premake5.lua
project "lc"
kind "StaticLib"
language "C"
location "./"
files { "**.h", "**.c" }
configuration {"Debug"}
targetsuffix "_d";
defines { "DEBUG" };
flags { "Symbols" };
configuration {"Release"}
defines { "NDEBUG" };
flags { "Optimize" };
Thanks in advance for any help.

Related

Is it possible to disable publish without disabling publishLocal in sbt?

I have an sbt project where docker:publishLocal will create a docker image on my machine for testing, and docker:publish will publish the image to a repository and also publish jar files from the build to a repository.
If my project is a snapshot, I would like to disable publishing to the repositories, while still being able to build the local image.
ThisBuild / publishArtifact := ! isSnapshot.value
does the right thing for the publish command, but it also disables publishLocal.
I want to write something like
if (isSnapshot.value) {
publish := { }
}
but that gives me an error that I do not understand at all:
[info] Loading project definition from /Users/dev/project
/Users/dev/build.sbt:1: error: type mismatch;
found : Unit
required: sbt.internal.DslEntry
if (isSnapshot.value) {
^
Past experience dictates that redefining publish to conditionally call the original version won't work, as
publish := {
if (!isSnapshot.value) publish.value
}
gives warnings that the task is always evaluated.
Is there a way to do this?
The problem with this code is that it evaluates publish.value regardless of the if structure. I recommend reading the documentation on task dependencies. If you want to "delay" the evaluation of a task in one of the if branches, you need to use dynamic task definition:
publish := Def.taskDyn {
if (isSnapshot.value)
Def.task {} // doing nothing
else
Def.task { publish.value } // could be written as just publish
}.value
But apart from fixing your code, you should be aware that there is a special setting for the functionality you want, it's called skip:
publish/skip := isSnapshot.value
Another thing to notice, is the scoping. If you want to override docker:publish, which is the same as Docker/publish in the new syntax, you should add this Docker/ scope prefix to every mention of publish in the code above.

Problems with libraries in premake

I have experienced certain problems when using libraries in premake4 scripts.
1) When creating a shared library (.dll) on Windows 10 using a premake4 script, it creates the dll fine, but it also creates a static library of small size (2K).
In my case, I was creating a shared library named MathLib.dll using a premake4 script. It did that correctly, but it also created a file named libMathLib.a of size 2K. (It may be empty.)
I don't see why there was a need for the Makefile generated by premake4 to create libMathLib.a, when in fact the objective was to create a .dll file. I think this may be a premake4 bug and I have raised it on the premake4 Issue tracker on github.
The premake4 lua script is as follows:
-- Dir : Files > C > SW > Applications > Samples >
-- premakeSamples > premake-sharedlib-create
--#!lua
-- A solution contains projects,
-- and defines the available configurations
solution "MathLib"
configurations { "Debug", "Release" }
-- A project defines one build target
project "MathLib"
kind "SharedLib"
language "C++"
files { "**.h", "**.cpp" }
includedirs {"../../../ProgramLibraries/Headers/"}
-- Create target library in Files > C > SW >
-- Applications > ProgramLibraries
targetdir "../../../ProgramLibraries/"
configuration "Debug"
defines { "DEBUG" }
flags { "Symbols" }
configuration "Release"
defines { "NDEBUG" }
flags { "Optimize" }
-- Register the "runmakefile" action.
newaction
{
trigger = "runmakefile",
description = "run the generated makefile to create the executable using the default ('debug' config)",
execute = function()
os.execute("make")
end
}
-- Register the "runmakefilerelease" action.
newaction
{
trigger = "runmakefilerelease",
description = "run the generated makefile to create the executable using the 'release' config)",
execute = function()
os.execute("make config=release")
end
}
2) The above problem is more serious than it sounds. Supposing I had already created a genuine static library named libMathLib.a in the Libraries dir, using a separate premake4 script. Subsequently, if I also create a shared library named MathLib.dll in the same directory as the static library, a dummy static library (possibly empty) would be created and replace the earlier genuine static library.
3) -- EDIT -- : I had reported this point (use of a static library) as a problem, but it has started working now. I don't know the reason, but the only difference, as far as I am aware, is that I had shut down and restarted my PC (and therefore my MSYS session on Windows 10). Therefore I am deleting this point.
How can I solve the above 2 problems?
That's the import library. You can turn it off with Premake's NoImportLib flag.
flags { "NoImportLib" }

when running jasmine task in grunt, getting an error "glob pattern string required"

I am trying to run jasmine test using grunt-contrib-jasmine
Below is my Gruntfile.js code
module.exports = function(grunt) {
grunt.initConfig({
jasmine : {
// Your project's source files
src : 'src/**/*.js',
// Your Jasmine spec files
specs : 'specs/**/*spec.js',
// Your spec helper files
helpers : 'specs/helpers/*.js'
}
});
// Register tasks.
grunt.loadNpmTasks('grunt-contrib-jasmine');
// Default task.
grunt.registerTask('default', 'jasmine');
};
Then I tried running "grunt jasmine" command from command prompt. It gives me an error like below
The issue you're describing was reported in this grunt issue. It was then fixed in this commit to grunt-contrib-jasmine on February 13 2016.
As of this writing, the most recent release of grunt-contrib-jasmine is v1.0.0, released on January 26 2016. So, the fix didn't make it into the most recent release, which is what NPM pulls when you do an install.
You can get around this by bypassing the NPM repository and going straight to GitHub for a prerelease version of grunt-contrib-jasmine. You do this by changing your package.json to read:
"dependencies: {
"grunt-contrib-jasmine": "git://github.com/gruntjs/grunt-contrib-jasmine#1e78d891704fa13fe7c7abf4cabf43cefacafcaf"
}
(The commit SHA in the URL just happens to be the most recent one at the time of this writing; feel free to replace it with a later one if you like.)
Ideally, this solution will become obsolete, when grunt-contrib-jasmine releases v1.0.1 (or higher) with the fix commit. Today though, this is what fixed the problem for me.

ANDROID_HOME not specified

this is another error am getting
FAILURE: Build failed with an exception.
What went wrong:
ANDROID_HOME not specified. Either set it as a gradle property, a system environment variable or directly in your build.gradle by setting the extension jfxmobile.android.androidSdk.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
i think, you have to add your android path on your build.gradle . Here is my setting for the android part:
jfxmobile {
android {
// signingConfig {
// storeFile file("")
// storePassword ''
// keyAlias ''
// keyPassword ''
// }
applicationPackage = 'my.package.app.name'
manifest = 'src/android/AndroidManifest.xml'
resDirectory = 'src/android/res'
androidSdk ="$System.env.HOME/android-sdks" // this is bassicly path to your android sdk
}
}
Try it.
Regards,
Ivan
Since you haven't defined the OS you are using, I'll go ahead and include both.
Ubuntu (or any other Linux distro I think):
Add the following to your ~/.bashrc file.
First
nano ~/.bashrc
Then add the following in the last line
export ANDROID_HOME= "Enter you sdk path"
This path will end with a /Android/sdk/
For eg. mine is /home/Android/sdk/
Log out and log in again and presto, magic!
If bashrc does not seem to work. Use profile instead ie ~/.profile
Remember to log out to allow changes to occur on startup.
Windows:
We can't define names to exported paths in Windows(as far as I know) so we need to include it in the build.gradle
jfxmobile {
android {
compileSdkVersion = '15'
buildToolsVersion = '22.0.1'
androidSdk = 'C:/Users/your username/AppData/Local/Android/sdk'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
}
}
And hey, there's the magic again!
If you installed Android somewhere else, point it to the correct direction.
Use the gluon plugin for Netbeans. Its the best way I found for working with javafxports. It takes all headaches from customizing basic things out of the way.
Why set it globally in Ubuntu and not in the build.gradle file?
Declaring it globally is an approach which means you don't have to repeat the same process again in a new project.

How can I install Qt 5.2.1 from the command line in Cygwin?

$ wget --quiet http://download.qt-project.org/official_releases/qt/5.2/5.2.1/qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe
$
As seen above, I first downloaded the Qt package for Visual Studio in a Cygwin Bash shell.
A sidenote: The Qt library packaged within Cygwin is not useful for me because I need to use the Visual Studio C++ compiler.
First I set the correct permissions on the file
$ chmod 755 qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe
If I start it like this
$ ./qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe
a graphical window (GUI) is shown but that is not what I want as I would later like to have the installation procedure written into a Bash script that I could run in Cygwin.
If I add the option --help, like this
$ ./qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe --help
a new terminal window is opened with the following text
Usage: SDKMaintenanceTool [OPTIONS]
User:
--help Show commandline usage
--version Show current version
--checkupdates Check for updates and return an XML file describing
the available updates
--updater Start in updater mode.
--manage-packages Start in packagemanager mode.
--proxy Set system proxy on Win and Mac.
This option has no effect on Linux.
--verbose Show debug output on the console
--create-offline-repository Offline installer only: Create a local repository inside the
installation directory based on the offline
installer's content.
Developer:
--runoperation [OPERATION] [arguments...] Perform an operation with a list of arguments
--undooperation [OPERATION] [arguments...] Undo an operation with a list of arguments
--script [scriptName] Execute a script
--no-force-installations Enable deselection of forced components
--addRepository [URI] Add a local or remote repo to the list of user defined repos.
--addTempRepository [URI] Add a local or remote repo to the list of temporary available
repos.
--setTempRepository [URI] Set a local or remote repo as tmp repo, it is the only one
used during fetch.
Note: URI must be prefixed with the protocol, i.e. file:///
http:// or ftp://. It can consist of multiple
addresses separated by comma only.
--show-virtual-components Show virtual components in package manager and updater
--binarydatafile [binary_data_file] Use the binary data of another installer or maintenance tool.
--update-installerbase [new_installerbase] Patch a full installer with a new installer base
--dump-binary-data -i [PATH] -o [PATH] Dumps the binary content into specified output path (offline
installer only).
Input path pointing to binary data file, if omitted
the current application is used as input.
I don't know how to continue from here. Do you know how I could install the Qt 5.2.1 library (for Visual Studio) from the Bash shell in Cygwin?
Update: The advantage of writing the build script for a Cygwin environment is that commands like git, wget, and scp are available. This Stackoverflow answer describes how to invoke the MSVC compiler from a Cygwin bash script. Note, that the Qt application I'm building is not going to have any dependency on Cygwin.
I didn't test with Cygwin but I successfully installed Qt5.5 using a script. To do so, you must use the --script line of the normal installer.
.\qt-opensource-windows-x86-msvc2013_64-5.5.1.exe --script .\qt-installer-noninteractive.qs
Here's an example of qt-installer-noninteractive.qs file I used in the command above
function Controller() {
installer.autoRejectMessageBoxes();
installer.installationFinished.connect(function() {
gui.clickButton(buttons.NextButton);
})
}
Controller.prototype.WelcomePageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.CredentialsPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.IntroductionPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.TargetDirectoryPageCallback = function() {
gui.currentPageWidget().TargetDirectoryLineEdit.setText("C:/Qt/Qt5.5.1");
gui.clickButton(buttons.NextButton);
}
Controller.prototype.ComponentSelectionPageCallback = function() {
var widget = gui.currentPageWidget();
widget.deselectAll();
widget.selectComponent("qt.55.win64_msvc2013_64");
// widget.selectComponent("qt.55.qt3d");
// widget.selectComponent("qt.55.qtcanvas3d");
// widget.selectComponent("qt.55.qtquick1");
// widget.selectComponent("qt.55.qtscript");
// widget.selectComponent("qt.55.qtwebengine");
// widget.selectComponent("qt.55.qtquickcontrols");
// widget.selectComponent("qt.55.qtlocation");
gui.clickButton(buttons.NextButton);
}
Controller.prototype.LicenseAgreementPageCallback = function() {
gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true);
gui.clickButton(buttons.NextButton);
}
Controller.prototype.StartMenuDirectoryPageCallback = function() {
gui.clickButton(buttons.NextButton);
}
Controller.prototype.ReadyForInstallationPageCallback = function()
{
gui.clickButton(buttons.NextButton);
}
Controller.prototype.FinishedPageCallback = function() {
var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm
if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) {
checkBoxForm.launchQtCreatorCheckBox.checked = false;
}
gui.clickButton(buttons.FinishButton);
}
The tricky part was to found the id of the components! I was able to found the right id qt.55.win64_msvc2013_64 by adding the flag --verbose and installing it normally with the UI and stopping at the last page; all the ids that you selected for installation are there.
There is slightly more information in this answer if you need more details.
EDIT (29-11-2017): For installer 3.0.2-online, the "Next" button in the "Welcome" page is disabled for 1 second so you must add a delay
gui.clickButton(buttons.NextButton, 3000);
EDIT (10-11-2019): See Joshua Wade's answer for more traps and pitfalls, like the "User Data Collection" form and "Archive" and "Latest releases" checkboxes.

Resources