JamPlus manual
|
JamPlus works out of the box with C/C++ compilation for Visual C++ compilers, Clang, GCC, MinGW, and others. It can also generate workspaces for Visual Studio 20xx, Visual C++ 6, Xcode, and CodeBlocks.
When the Jam executable is run, it reads a file called Jamfile.jam
in the current working directory. The Jamfile contains a description of how to build the current project. In the tutorials below, we'll talk about how to properly set up a Jamfile build description.
For this tutorial, we are going to make a basic helloworld application.
First, we need to create a helloworld.c
file. It will do nothing more than print Hello, world! to the user.
Straight out of the box, you can run jam
within the directory of helloworld.c
, and Jam will build a helloworld
executable using all of the *.c
, *.cpp
, *.m
, and *.mm
files in the directory.
While this is a convenient Jam feature, generally a more complex build is needed. We'll make one of those in Tutorial 1: Hello World!.
For this tutorial, we are going to make a basic helloworld application.
First, we need to create a helloworld.c
file. It will do nothing more than print Hello, world! to the user.
In the same directory as helloworld.c
, we also need to create Jamfile.jam
with the description of how to build the basic helloworld application.
Compiling the helloworld application is simple. Assuming the Jam executable is in your PATH
, run the following from the directory containing your Jamfile.jam
and main.c
:
That's it. Jam will detect your OS and then the appropriate compilers for your platform. On Windows, Jam looks for the most recent Visual Studio it can find. If it can't find any of those, it looks for a MinGW installation in the c:/Program Files/mingw-x64/
and c:/mingw/
directories. On macOS, Jam looks for clang or gcc. When a compiler is found, the helloworld application's Release configuration is built. The resultant filename will be .build/win64-release/TOP/helloworld/helloworld.exe
on Windows and in a similar location but with an executable name of helloworld
on other platforms.
Building the helloworld application Debug configuration is performed with a command line flag. In this case, the built executable will be .build/win64-debug/TOP/helloworld/helloworld.exe
on Windows and in a similar location but with an executable name removing the .exe
on other platforms.
or, preferred:
If you would like to run with another compiler by default, such as MinGW, an additional command line flag must be provided.
Compiler intermediates and outputs are, by default, stored within a .build/
directory. These files can be cleaned up using the clean
target.
One of the exciting features of JamPlus is its ability to build IDE workspaces for Visual Studio or Xcode or others. It does so with a set of scripts that are present in the JamPlus bin/scripts/
directory. These scripts create an out-of-source build tree optimized for best performance within JamPlus. By being out-of-source, the source tree remains pristine, and all compiler intermediates are stored in a separate location.
For the helloworld application, let's build a Visual Studio solution on Windows or an Xcode workspace on macOS.
It may be preferable to output to a different directory than .build/
.
After running jam –workspace
, the new out-of-source work area will have been created. Inside the generated build/_workspaces_/IDE/
directory, you'll find a helloworld.sln
. Open this file in Visual Studio to proceed.
When Visual Studio has loaded the helloworld.sln
, you'll find it contains the helloworld project within the Solution Explorer. If the helloworld project is not already the active project, right click on it and choose Set as StartUp Project.
On Mac OS X, you'll find the appropriate .xcodeproj as build/_workspaces_/xcode/helloworld.xcworkspace
. Open this project file in Xcode, and choose the appropriate scheme (such as helloworld-release
).
At this point, build as you normally would. Change between the Debug and Release configurations if you'd like. In fact, you can even debug as if the project were manually created!