Cross platform build environment - cross-platform

As good developers we keep our code as standard compliant as possible to help in porting between platforms. But what tools are available that help us build the code in a uniform way across multiple platforms.
*nix family has make but Windows needs nmake.
I have read about SCons but never used it in anger. What is your favorite build tool, why do you find it effective and are there any limitations (i.e. platforms with bad support etc).
Cross platform IDEs as well.

cmake for c/c++ environments is good. http://www.cmake.org/

I personally use ant, rake, and maven2. I have used ant the most and find it great for several reasons:
Because it is java it works on lots of platforms (without changing any scripts)
The build files are written in XML and fairly easy to write
There are lots of 3rd party extensions available for it and it is easy to write plugins for

we do extreme cross development, and our code runs on linux, windows ce, windows 2K, nucleus and uCOS-II.
since each environment uses different 'make' methodology (out nucleus customer, for example, require us to compile via code-warrior GUI).
i used ANT combined with perl for about 2 years, but this lead the build script to total non-maintainability.
now we moved to use python, which increase the maintainability of the scripts.
bottom line, i did not find a ready-made tool, and had to build my own. maybe, when i have some time (2017 ?) i will pack my scripts and distribute them ....

If you're in the Java world, there are quite a few tools which are cross-platform. Apache Ant and Maven are both build tools which will run on any platform which has Java available for it.
Cruise Control (continuous integration tool) also works on Windows and Linux (it's written in Java as well).
I haven't had any real issues with the core tools, the only problems I've sometimes had have come from things external to the build process, i.e. publishing artifacts - this will vary between systems so I've found there's no single way of setting it up.

For C/C++ development, I've found that bakefile works well. The fairly large wxWidgets project, a cross-platform cross-platform utility and UI library, uses it for their build file generation.
Bakefile is cross-platform, cross-compiler native makefiles generator. It takes compiler-independent description of build tasks as input and generates native makefile (autoconf's Makefile.in, Visual C++ project, bcc makefile etc.).
Bakefile's task is to generate native makefiles, so that people can keep using their favorite tools. There are other cross-platform make solutions, but they either aren't native and require the user to use unfamiliar tools (Boost.Build) or they are too limited (qmake).

You can use gmake on Windows as well with cygwin/minGW or build your windows stuff on Linux.
http://cdtdoug.blogspot.com/2009/05/mingw-cross-for-linux.html

There are tools like Opus Make or MKS Toolkit that offers multiplatform and support. If you have an existing codebase of make script, could be easier migrate to one of there. I suspect you may hunt for similar tools in advertising of DDJ magazine.

We've been running a Java environment for Linux, Windows and the Mac for the last 18 months.
Maven 2 drives our builds, it's pretty easy to get things consistent here. Where M2 plugins don't dare to tread, we use small Ant scripts.
IDE-wise we're using Eclipse & IDEA - both, of course, multi-platform.
Testing - JUnit, Fitnesse, Fest - all nicely multi-platform.
Release scripts are written in Ruby. There's a bit more trouble with Windows here, but a function to convert paths as necessary generally does the trick.
TeamCity does CI. We've actually migrated this from Windows to Linux and encountered no errors at all, very nice package.
We did use GWT for a while and this did cause us large amounts of pain. Be careful if you swing that way.

Related

Language for cross-platform install script

In writing an install script, I quickly found that I'd have cross-platform issues, and bash scripts are hard to maintain. I decided to look for a cleaner solution that's more cross-platform.
The goal is to have an intelligent script sniff out components of the user's system and have as little user interaction as possible. That being stated, I thought about these languages:
Python- cross-platform, and many other programs rely on it, so it may already be present
Javascript- nodejs is required by part of my application, but it's a little clunky for exec calls
Are there any languages that would be a better fit for this application?
Requirements:
Available on all platforms
May be distributed as part of my application if small enough
Little to no version variation, so Ruby is out
*nix only for now, but eventually will be run on Windows
Maintainable
Clear syntax (Perl is out)
Modular (if I sniff the OS, I can include separate OS-specific code)
Capable of downloading files (unmet dependencies)
Capable of relatively complex scripting tasks
Testing for used HTTP ports
Reading and parsing files for configuration data
Checking for permissions and changing directories of insufficient privileges
Open source
Python can do all of those things:
Available on all platforms (Mac, Linux, Windows, and more)
May be distributed as part of my application if small enough (You can make binaries with cx_freeze, if needed)
Little to no version variation, so Ruby is out (Python is pretty static when it comes to version changes)
*nix only for now, but eventually will be run on Windows (It comes pre-installed on Mac, and ships with just about any Linux distro. Binaries don't need the interpreter to run)
Maintainable
Clear syntax (Perl is out) (Python is very easy to read, but that's up to you to decide)
Modular (if I sniff the OS, I can include separate OS-specific code) (Modules are just files in Python)
Capable of downloading files (unmet dependencies) (Urllib2 takes care of that, and it's pre-installed)
Open source (Yep)
Ant will do what you need. It is OS independent and will allow compiles and installs.

Code::Blocks for understanding C++ code it can't build

Have a C++ source I probably can't build in Code::Blocks. If I use it as an editor, would it be helpful in gaining understanding of the code? (Like Intellisense).
How does it compare to Visual Studio in this respect?
How should I go about doing it?
Can it somehow utilize gdb information (When I run it in gdb, there is a lot of information available)
It is Linux gcc/Makefile based.
The main executable is in one directory, but there are many includes, libraries etc.
If I just included all sources I would get sources for other executables (with similar code).
I expect to increase my understanding about where things are located over time.
Note 1: This is Linux, but I can easily edit on Windows. And I am trying to build under Cygwin.
Code::Blocks sounds too light weight for your tastes. Try NetBeans. It has very good hinting tools, doesn't have the infamous copy+paste bug, Its easier to navigate files, and can deal with makefiles better then C::B. Additionally it has a nice interface for debugging, and an exceptional one for performance monitoring.
I would reccomend you install a linux distro through WUBI and forgo using Windows.
I have used NetBeans, Eclipse, Visual Studio, Code::Blocks, and CodeLite. I don't normally write software under Windows anymore, but when I did CodeLite was the most elegant one I found. Debugging was a snap (mingw + GDB), all the meta information about your project is stored in an sqlite db (which I think is a great design), and it supports makefiles.
I think NetBeans would work great as well, but definitely give CodeLite a shot.
http://www.codelite.org/

Differences between CruiseControl (original) and CruiseControl.NET

Are there any differences between the original CruiseControl and the .NET port? I've compared the 2, but can't find any big differences except the language it has been developed in. I want to use either one of them for (automated) testing of web applications, using Selenium and Subversion, perhaps even Groovy but don't know which to choose.
[edit]
After looking at CC and Hudson, I've chosen Hudson for it's simplicity, it already has plugins to run Groovy scripts and Selenium as well
Choose me, choose me! (I work on the original CruiseControl.)
I've never used CC.NET but from what I know I agree that they are pretty comparable. Probably the most important difference is cross-platform vs. Windows only.
Now I wonder how long until someone comes by and says their both crap and you should try Hudson? ;)
(And of course there are lots of other choices...)
CruiseControl.NET (cc.net henceforth) has build queues (http://confluence.public.thoughtworks.org/display/CCNET/Project+Configuration+Block), which allows you to serialize builds that depends on a certain build order. I'm in the process of emulating this behavior in the java version of cruisecontrol but the functionality doesn't map one to one. The reason however, that I'm at all moving from the .net to the java version is that the .net version core dumps with mono (cc.net nightly build and mono nightly build as of two months ago). The fault lies with monos thread handling but voids attempts to get cc.net up and running.
The documentation on this can be tricky to find, if you don't notice the version numbers that the configuration examples/documentation adhere to (confluence.public.thoughtworks.org has the updated configuration documentation whereas ccnet.sourceforge.net has not. I know that the ccnet is most likely a dead site, but if your're not carefully reading the datestamps on every page you're visiting, this may bite you).
Furthermore, the sourcecontrol blocks for cvs and svn in cc.net are more granular and featurerich than their counterpart in the java version, but this has not been a problem in my work. The java version is also easy to extend/modify re: plugin behavior, but you would really just like to see this kind of work going upstream instead of forking.
I'm fairly impressed with both the java version and the fork in .net (modulo mono runtime behavior), but you really do not want to try any of the other forks of cruisecontrol. I've had peripheral experience with hudson, and the features were just not compelling enough to veer me from cruisecontrol. Hudson has a (somewhat coloured) comparison map of Hudson and CruiseControl (java) at http://hudson.gotdns.com/wiki/display/HUDSON/Home
A viable alternative is the python implemented buildbot (http://buildbot.net/trac). It does not have fancy gui dashboards and the setup is somewhat more commandline-bound, but if you're doing distributed builds, it's very easy to set up and get running.
I think for you it will come down to operating system, original can run on nix, and .net version runs on windows.
There are other automated build utilities that can do this as well, such as TeamCity in the windows space, and cruisecontrol.rb in the ruby world.
Also there is a PowerShell based build utility called pSake that can poll subversion and perform tasks.

What build tool do you use professionally?

At home, I use CTRL+SHIFT+B or F7 or whatever key sequence initiates the build for my build tool. At work, this doesn't quite cut it.
At my first job (an internship) we used a product called Visual Build, which I have come to like very much. It's the best build tool I've ever worked with. The down side here is that it's not free.
At my latest job, I came in knowing literally nothing about Ant. Now, unfortunately, I've become deeply involved in our build processes, and cannot extricate myself. It works, yes, but after coming from Visual build, it seems like it's fighting me every step of the way. Yes, it's free, but we're not trying to be a free-software-only development company or anything.
I've never looked in to make or any other build tools, so I don't really know what else is out there.
Has anybody ever seen or had experience with Visual Build? Mostly I'm fond of a few key things:
it has a GUI
it runs arbitrary VBScript without the need of a compiled class
you can step through the build process, or start from anywhere in the middle.
Are there any free build tools that have this? Is there any way to convince people that it's worth it to move on? It's 2008. We use IDEs to develop, why not (IBEs) to build?
Edit: I'm mostly looking for an answer to my last questions; Is there a solution with a built-in GUI that I can use for free?
Not very sophisticated, but we use a set of batch files. And that works great.
We use FinalBuilder - I think it's very similar to VisualBuild, though I've not used the latter.
It does run from the command line, and you can integrate it with CC.Net if you want.
For Java projects we use Teamcity, sort of cruise control like, but you can also do a remote run, i.e. you send your changes to the server, it builds and does unit tests, if everything works ok, THEN you checkin, very nice build tool and free for up to 20 build configurations.
For our Visual Studio 2005 projects including packaging the final exes and dlls with InstallShield and putting them up on a shared server we use Final Builder, it's not free, but it is very easy to use and get started with.
We also telnet out (from FinalBuilder) to a number of other platforms (Unix/Linux/OpenVMS) and start remote builds by running makefiles there.
We do not use continous build, but there is a FinalBuilder Server which handles that and comes free with the FinalBuilder Professional license.
We are very happy with FinalBuilder, it's quite easy to get up to speed with and powerful enough to solve most problems.
CMake. Generates build file for KDevelop, Eclipse, Makefiles and Visual Studio (and XCode), and it really works. You can easily extend it with macros, although the programming capabilities are rather limited. It's easy to learn, and porting an existing application from Visual Studio to it is pretty easy. However, you are limited to C++/C and IIRC Fortran code.
KDE is also using CMake now, so it seems to scale very well (i.e. generation time for the projects/dependency checking is not too bad).
I am not sure this is exactly what you are looking for, but I LOVE CruiseControl.NET. I have it build my projects using the MSBuild task. It doesn't have a GUI exactly, but there is a web interface to view the results of your builds and a System Tray resident program which will alert you of the build status.
UppercuT. It's free.
UppercuT uses NAnt to build and it is the insanely easy to use Build Framework.
Automated Builds as easy as (1) solution name, (2) source control path, (3) company name for most projects!!!
http://code.google.com/p/uppercut/
Some good explanations here: UppercuT
Going back to the keystrokes thing for a sec, I found Hoekey which the CTO loves. I don't use it myself, but as a way of assign keystrokes to things, it's pretty good.
I know nothing of Visual Build, but from your description it sounds like it is tied to Windows and doesn't run from the command line.
If you are building Java software (I assume you are since you are using Ant), it's preferable to have a cross-platform tool. If you can run the tool from the command-line, then it is scriptable which is extremely important for automation.
Ant is also extensible and a de facto standard. Many tools that you may use (Cobertura, TestNG, etc.) provide Ant tasks so that they can easily be intergrated with your build.
I use Ant for all Java projects. Some people prefer Maven, but I'm not one of them. Ant is far from perfect (the XML syntax is a bit clunky) but it is well documented, extremely stable and pretty straightforward.
If you use a standard tool, such as Ant or Maven, you will be able to take advantage of any number of Continuous Integration products. I doubt you will find many that work with Visual Build.
Most IDEs support Ant, so they give you a GUI of sorts and your CI server will give you a web interface for doing builds.
NAnt (.NET port of Ant). Works great and is easily extensible.
For small projects I do use post-build scripts and with the support of 7z, Nsis and similar CLI tools it's doing the job perfectly for me.
TeamCity and CuriseControl works well for any projects,but here is why you would like to choose TeamCity:-
Ease of setup: During setup we found TeamCity easier to setup and use especially compared to CruiseControl. We did not need to edit XML files or massively configure individual build machines like CruiseControl.
Ease of extensibility:TeamCity stands out in its ease of extensibility too. If we find that builds are waiting in the queue too long, we can add more computers as agents. The only additional work on our end is registering the new computers with the TeamCity server and installing msbuild and subversion.
Interaction with Subversion: One can check how many and what changes were committed to subversion since the last build, who started a build etc.
I've grown very fond of scons for building C++ files. It's very straightforward and the build scripts are written in Python (which is much better than some hacked together DSL IMO).
Ant or Maven are great little build tools.
And if you want to automate the build process there are some great tools like TeamCity and Bamboo.
Personally I use Makefiles for pretty much everything because they are simple as hell. But in my work, I'm forced to use ant.
The main problem I have against ant is that XML makes it hard to read and understand, even with the correct indentation. On the other hand, the verbosity of XML can help when reading someone else's ant file, but still makes it a PITA when the file is more than a few tens of lines.
As for having a GUI to build... I've always felt that's a minus rather than a plus.
Maven is the best for me because it handles the project dependencies

How to write a cross-platform program?

Greetings,
I want to write a small cross-platform utility program with GUI in it. What language/GUI-library should I stick to? Is it possible whatsoever?
This is gonna be a small program, so I don't want to make people download JVM or .NET Framework. Is it possible to develop it natively?
Update 1.
By "natively" I mean that the end result will be native code without intermediate layers like Java Virtual Machine or .NET Common Language Runtime
Update 2.
A FREE solution is preferable ;)
If you know C or C++ the first cross platform GUI framework I can think of are:
QT (C++, proprietary but free with the LGPL licensing)
wxWidgets (C++, the most complete and stable but also huge)
FLTK (C++)
FOX (C++)
IUP (C, simpler and cleaner than the ones above)
If you know Pascal, you can try freepascal+Lazarus. I've never used it, though.
The problem is: If you do not want to have a GUI but you do not want to ask the user to download an eternal API, Framework or virtual machine to run it in, be it TCL/TK, Java or QT etc. then you get lost pretty fast.
The reason is: You would have to rebuild all the (GUI) functionality those APIs, frameworks and virtual machines provide you with to be platform independent. And that's a whole lot of work to do... .
On the other side: The Java virtual machine is installed on nearly any operating system from scratch, why not give this one a shot?
You want to develop a cross-platform program natively? Uh...I don't think that'll work, mainly because that phrase is a paradox. If you write native code, it by its very nature will only run on the platform you programmed it for. ;-) That's what the Frameworks are all about.
So what you should do instead is use a very slim framework if your program is going to be so small. itsmatt's idea of Qt is a possibility.
WxWindows? Oh, it's called WxWidgets now: http://www.wxwidgets.org/
wxWidgets has bindings to all sorts of languages - python for instance, if your app is small enough.
Lazarus is great. GTK2 on Linux, win32/64 on Windows, WINCE on euh, Wince. It even uses Carbon on Mac (working on COCOA). Also easy to sell to your boss (the code is Delphi compatible)
How about Python using Qt or Wx and then using PythonToExe to make a 'distributable'
Thought will have to giving to the development to ensure that no native functionality is used (i.e. registry etc.) Also things like line breaks in text files will have different escape characters so will need to be handled
Which OS's do you have in mind when you say cross-platform?
As Epaga correctly points out, native and cross-platform are mutually exclusive. You can either write multiple versions that run natively on multiple platforms, or you need to use some cross-platform framework.
In the case of the cross-platform framework approach, there will always be extra installs required. For example, many here suggest using Python and one of its frameworks. This would necessitate instructing people to install python - and potentially the framework - first.
If you are aiming at Windows and OS X (and are prepared to experiment with alpha-release code for Linux if support for that OS is required), I'd highly recommend you take a look at using Adobe AIR for cross-platform GUI applications.
I agree with Georgi, Java is the way to go. With a bit of work, you can make your desktop application work as a Java applet too (so that users do not need to actively download anything at all). See http://www.geogebra.org as an example of an application with runs smoothly as a cross-platform Java application AND has a simple port to a web applet.
Two other advantages to using Java are:
They have extensive libraries for building the UI, including UI component builders.
The Java runtime framework is generally updated automatically for the user.
One disadvantage:
The version of Java installed on your end users computer may not be totally compatible with your application, requiring you to code to the lowest likely denominator.
Try RealBasic. Visual Basic-like syntax, targets Win32, OS X and Linux. I don't know any details about targetting Linux, but for any cross-platform development I've done between Win32 and OS X its been a dream.
http://www.realbasic.com
Edit: Generates native executables. There is a small cost - $100.
Have you looked at Qt?
Flash? It's installed pretty much everywhere.
If it "HAS" to be Desktop use Qt. Nothing beats it right now.
However personally I gave up on desktop and any UI based project I do is normally Browser/Server based. You can easily write a little custom server that listens to some port so the program can run locally with no need for your users to install Apache or have access to the net. I have a small Lua, Python and C++ framework I made for that purpose (Want to add Javascript for the backend with V8 :)
If you're going to look at Qt and WxWidgets, don't forget to also check out GTK+ !
I agree with David Wees and Georgi,
Java is cross-platformness par excellence. You literally write once and run everywhere. With no need of compiling your code for each target OS or bitness, no worries about linking against anything, etc.
Only thing is, as you pointed out, that a JRE must be installed, but it's quick and straightforward to do even for novice end-users (it's a matter of clicking "Next>" a few times in the installer).
And with Java Web Start deployment gets even easier: the user just clicks the launch button on a webpage and the application runs (if the proper JVM is installed according to what specified in the JNLP descriptor) or the user gets redirected to the Java download page (if no suitable JVM is found).