EzDevInfo.com

jam

JavaScript package manager - using a browser-focused and RequireJS compatible repository Jam - The JavaScript package manager

What is Boost Jam and is Jam worth migrating to?

What is Boost Jam and is Jam worth migrating to?

I understand that jam is build system built by perforce however I am not sure how the boost jam & regular jam is different.

I'm also hoping there could be someone in the SO community who has worked with it and maybe can highlight some differences and/or benefits.


Source: (StackOverflow)

Build Visual Studio Projects from Jamfiles?

Anyone know of a way to create Visual Studio Projects from a build based on Jamfiles?

I'd settle for a jamfile -> XML-or-some-other-intermediate-format exporter tool, so I could write my own.


Source: (StackOverflow)

Advertisements

Is there a way to visualize dependencies in boost.build?

I have a large project that uses boost.build. I would like a way to view the dependency tree for specific build targets.

For example:

exe foo : foo.c /BAR//LIB : /MEOW//PUB ;

The dependencies of foo would include all requirements of /BAR//LIB and all usage requirements of /MEOW//PUB.

Is there such functionality built into boost.build, or is there a tool available to do this?


Source: (StackOverflow)

How to pass in cflags through jam

I'm attempting to compile and link a DLL through Jam. This is a resource-only DLL, so I need to figure out how to pass in the /noentry flag to the linker through Jam.

Here's what my Jamfile looks like right now:

// need to figure out how to specify the /noentry CFLAG somewhere here

PackageDll foo
    : NAME foo.dll
    : DESC  "Resource File"
    : USE_C
    ;

Build foo
    : system.pkg foo.rc
    : . 
    ;

Thanks in advance!


Source: (StackOverflow)

Migrate from Jam to CMake

I understand Jam builds existing projects and CMake generates projects to build. But, given I'd rather be generating projects I could use in various IDE's rather than trying to integrate Jam into those IDE's, has anybody had any experience/success turning a Jamfile into a CMakeLists.txt file?


Source: (StackOverflow)

Calling a python script from a Jamfile

I would like to call a python script from a Jamfile to generate a necessary source file.

In a Makefile, it would look somewhat like this:

sourcefile.c:
    python script.py

What is the most elegant way to archive something like this in a Jamfile?


Source: (StackOverflow)

How to build LuaPlus on Windows

I downloaded JamPlus (after expending quite some time discovering that this was the specific Jam derivate needed and didn't ship with the download), and set my PATH variable as dictated, and the thing doesn't work.

Specifically, Jam lists a trunk of errors, like not being able to find source folders and writing to nonexistent projects, and when attempting to build what actually did output with Visual Studio, it skips building 69 projects and fails to build one other.

How can I build LuaPlus? Or even just ... include the source directly or something ...?


Source: (StackOverflow)

Jam and static libraries

I need to build Platinum C++ Libraries for static linking. What command(s) can I supply to jam for this?


Source: (StackOverflow)

Require.js build not concatenation scripts loaded with Jam

Following one of the chapters of "Developing Backbone.js Apllication" by Addy Osmani (O'Reilly) about Grunt-BBB (Backbone Boilerplate Buddy), I just couldn't manage to create a build profile.

Here is the filesystem tree used for this :

/builds
    /closure
    /rhino
    /config
        /build.js
    build.sh
/development
    /* Grunt-BBB files after init */
    /app
        /styles
            index.css
        app.js
        config.js
        main.js
        router.js
    /test
        /* Not important files used for testing */
    /vendor
        /h5bp
            /css
                main.css
                normalize.css
        /jam
            /backbone
                backbone.js
                package.json
            /bakbone.layoutmanager
                bakbone.layoutmanager.js
                package.json
            /jquery
                jquery.js
                package.json
            /lodash
                lodash.js
                lodash.min.js
                lodash.underscore.min.js
                package.json
            require.config.js
            require.js
        /js
            /libs
                almond.js
                require.js
/distribution
    /* Empty dist directory where the optimized / minified / concatenated files should go */

Here are the steps I followed in the /development directory :

1) Install Grunt-BBB (npm install -g bbb)

2) Download r.js, a part of the Require.js project (git clone https://github.com/backbone-boilerplate/grunt-bbb)

3) Initialize the files of the boilerplate (bbb init)

Here is the build.js file I used to configure the r.js AMD loader for the Google Closure compiler :

({
    appDir: '../../development',
    baseUrl: 'app',
    dir: '../../distribution',
    optimize: 'closure', // 'uglify2'
    paths: {
        backbone: '../vendor/jam/backbone/backbone',
        'backbone.layoutmanager': '../vendor/jam/backbone.layoutmanager/backbone.layoutmanager',
        jquery: '../vendor/jam/jquery/jquery',
        lodash: '../vendor/jam/lodash/backbone.min'
    },
    modules: [
        {
            name: 'main'
        }
    ],
    onBuildRead: function(moduleNames, path, contents) {
        return contents;
        //return contents.replace(/console\.log\(([^\)]+)\);/g, '')
        //              .replace(/debugger;/, '');
    }
})

and this is the build.sh file I use :

#!/usr/bin/env bash

# r.js directory
RJSDIR="r.js"
RJS="$RJSDIR/dist/r.js"

# Rhino directory
RHINODIR="rhino"
RHINO="$RHINODIR/js.jar"

# Google Closure Compiler directory
CLOSUREDIR="closure"
CLOSURE="$CLOSUREDIR/compiler.jar"

# Build config directory
CONFIGDIR="config"
CONFIG="$CONFIGDIR/build.js"

# Launch compillation
java -Xms256m -Xmx256m -classpath "$RHINO":"$CLOSURE" org.mozilla.javascript.tools.shell.Main "$RJS" -o "$CONFIG" $@

My goal is to optimize, minify, concatenate all the JavaScrit file including the libraries and templates (which I don't have yet, I am only using the boilerplate files) but also CSS files.

The result I get by running ./build.sh is that every files are correctly minimised (besides CSS rule inlining, but that is besides the point) and concatenated but resources that are loaded and managed by the Jam (package manager that combines NPM and Require.js) aren't concatenated.

The reason for that since they are already loaded / managed by Jam, they are not redeclared in the JavaScript files AMD style.

In conclusion, my questions are the following :

  • How can I rewrite my build.js configuration file so that resources that are loaded by Jam also get included and concatenated in the release / dist file ?

  • How can I make it so that the concatenated resources aren't copied in the realse / dist directory ? Is it possible to configure this in the build.js file or should this go in my build.sh file ?

Edit : New build.js file :

({
    appDir: '../../development',
    baseUrl: 'app',
    dir: '../../distribution',
    optimize: 'closure', // 'uglify2'
    paths: {
        requirejs : '../vendor/jam/require',
        backbone: '../vendor/jam/backbone/backbone',
        'backbone.layoutmanager': '../vendor/jam/backbone.layoutmanager/backbone.layoutmanager',
        jquery: '../vendor/jam/jquery/jquery',
        lodash: '../vendor/jam/lodash/backbone.min'
    },
    name: 'main',
    include: ['requirejs'],
    onBuildRead: function(moduleNames, path, contents) {
        return contents;
        //return contents.replace(/console\.log\(([^\)]+)\);/g, '')
        //              .replace(/debugger;/, '');
    }
})

And here is the error :

file:///vendor/js/libs/require.jsFailed to load resource: The requested URL was not found on this server.
file:///app/styles/index.cssFailed to load resource: The requested URL was not found on this server.

Source: (StackOverflow)

Seperate build directory and include directory in Jam

I'd like to switch to using Jam as my build system. Currently, I have a src, include and build directories and I'm wondering how I can get Jam to put object files in the build directory and search for include files in the include directory.


Source: (StackOverflow)

Jam Package out of date, how to request upgrade?

The moment.js jam package is behind quite a bit. Currently at 2.9 the Jam package is only at 1.7. How can I get either Jam or upgrade it myself?


Source: (StackOverflow)

How can I build different versions of a project using the Jam make tool?

I have a C++ project that compiles to different versions, including release, debug, shared library, and executable, with different compiler flags for each. I am trying out Jam as an alternative to Make, because it looks like a simpler system.

Is Jam capable of this? The main problem is that it always places the .o files into the same folder as the source file, so it overwrites them when building multiple versions.

Update

I found a solution that seems to work. Using this file, I can build debug and release configurations of a library or executable.

Command to build release library:

jam -s config=lib -s release=1

If you only type jam, it builds the debug executable. Here is the Jamfile:

FILES = 
    main.cpp 
    ;

BASENAME = steve ;
OBJ = obj ;

if $(release) 
{
    OBJ = $(OBJ)r ;
} 
else 
{
    DEFINES += DEBUG ;
    OBJ = $(OBJ)d ;
}

if $(config) = lib 
{
    OBJ = $(OBJ)_lib ;
    OUTFILE = lib$(BASENAME).so ;
    DEFINES += SHARED_LIBRARY ;
    LINKFLAGS += 
        -shared -Wl,-soname,$(OUTFILE) -fvisibility=hidden -fPICS 
    ;
} 
else 
{
    OUTFILE = $(BASENAME) ;
}

LOCATE_TARGET = $(OBJ) ;
MkDir $(LOCATE_TARGET) ;
Main $(OUTFILE) : $(FILES) ;

Source: (StackOverflow)

Jam Object rule and directories

I suspect that the manual is actually saying what I'm doing wrong, but I can't really see a solution; the problem occurs when the .c file and the .o file to be build are not in the same directory, and the .c file has an automatic dependency on a .h file which has to be generated on the fly. The problem can be probably be solved by manually setting dependencies between the .c and .h file, but I would like to avoid that.

I have the following directory structure:

weird/
    Jamfile
    b.c
    src/
        a.c
        c.c

The src/a.c file is like this:

#include "src/a.h"

int main(int argc, char *argv[])
{
    return 0;
}

The b.c file is like this:

#include "src/b.h"

int main(int argc, char *argv[])
{
    return 0;
}

The src/c.c file is like this:

#include "c.h"

int main(int argc, char *argv[])
{
    return 0;
}

The Jamfile is:

rule CreateHeader
{
    Clean clean : $(1) ;
}

actions CreateHeader
{
    echo "int x = 10;" > $(1)
}

Object a.o : src/a.c ;
Object b.o : b.c ;
Object c.o : src/c.c ;

CreateHeader src/a.h ;
CreateHeader src/b.h ;
CreateHeader src/c.h ;

The following command correctly creates b.o and src/b.h:

jam b.o

The following command creates src/a.h, but then GCC fails to create a.o; the reason is quite obviously that the #include in a.c mentions src/a.h while in fact should simply refer to a.h:

jam a.o

The following command fails completely, and does not even create c.h; the reason is probably that when Jam analyzes c.c it generates a dependency on c.h instead of src/c.h, and in the Jamfile there are no rules for generating c.h:

jam c.o

This command compiles properly if I explicitly ask to generate src/c.h before asking for c.o:

jam src/c.h
jam c.o

In my opinion the jam src/c.h should not be necessary. What's wrong here? Check the Jam manual for more information, particularly under the section Header File Scanning.

Added after I accepted the answer

I kept experimenting a little bit with the constructs suggested by the author of the accepted answer, and I'll post here the results. In this setting you can type:

jam app

And the application will be linked under bin/app. Unfortunately I had to use a UNIX path when setting LOCATE_TARGET, and my understanding is that this is not exactly a good practice.

Directory Structure:

project/
    Jamfile
    src/
        main.c
    gen/
    bin/
        obj/

File Jamfile:

SubDir TOP ;

rule CreateHeader
{
    MakeLocate $(1) : $(LOCATE_SOURCE) ;
    Clean clean : $(1) ;
}

actions CreateHeader
{
    BUILD_DATE=`date`
    echo "char build_date[] = \"$BUILD_DATE\";" > $(1)
}

SEARCH_SOURCE = src ;
LOCATE_TARGET = bin/obj ;
SubDirHdrs gen ;
Object main.o : main.c ;

LOCATE_TARGET = bin ;
MainFromObjects app : main.o ;

LOCATE_SOURCE = gen ;
CreateHeader info.h ;

File src/main.c

src/main.c
#include <stdio.h>
#include "info.h"

int main(int argc, char *argv[])
{
    printf("Program built with Jam on %s.\n", build_date);

    return 0;
}

Source: (StackOverflow)

Building Boost date/time Jamfile with .v2 extension

I'm trying to build the Boost date_time library so I can link it in my Makefile. I'm in "libs/date_time/build" and see a lonely "Jamfile.v2", if I type jam I get:

Jamfile: No such file or directory
...found 7 target(s)...

I have no idea what to do now, I can't find anything about the date_time installation in the Boost documentation.

Here is the text in the document:

# Boost.date_time build and test Jamfile
#
#  Based on boost.python Jamfile
#
# To run all tests quietly: jam test
#
# Declares the following targets:
#   1. libboost_date_time, a static link library to be linked with all
#      Boost.date_time modules
#


project boost/date_time
    : requirements
        <define>DATE_TIME_INLINE
    <link>shared:<define>BOOST_ALL_DYN_LINK=1   
    <link>static:<define>BOOST_DATE_TIME_STATIC_LINK    
    : usage-requirements    
        <define>DATE_TIME_INLINE
        <link>shared:<define>BOOST_DATE_TIME_DYN_LINK=1
    : source-location ../src
    ;

# Base names of the source files for libboost_date_time
CPP_SOURCES = greg_month greg_weekday date_generators ;

lib boost_date_time : gregorian/$(CPP_SOURCES).cpp ;

boost-install boost_date_time ;

Thanks, Joe


Source: (StackOverflow)

How can I build a googletest unit test using the gtest_main library with Jam?

I am trying to build a googletest unit test for a proof of concept as a new unit testing framework that we could possibly use. In googletest, there are two ways to write a unit test: with a main, or without a main. If you do not define a main, you can link in the gtest_main library, which includes a main() function for you, saving you some time. In my environment, we use Jam to build binaries. I have gotten the binary to compile with main() in my code & by using the libgtest library, but I am looking for how to build it in Jam without the main.

Base case (with a main() function):

I am able to build a binary with this:

Main MyUnitTestBinary : MyClass.cpp ;
LinkLibraries MyUnitTestBinary : libgtest ;
Library libgtest : $(GTEST_DIR)/src/gtest-all.cc ;

Broken case (without a main() function):

I am not able to build a binary with this. I see many errors when I attempt to link the objects:

Main sample1_unittest : sample1.cc sample1_unittest.cc ;
LinkLibraries sample1_unittest : gtest_main ;
Library gtest_main : $(GTEST_DIR)/src/gtest_main.cc ;

I get many Linker Errors relating to undefined reference to blah. The undefined reference seems to be coming from the testing::internal namespace, which is not part of my code.

Any thoughts on how I can attack this, or look for more clues on the problem?


Source: (StackOverflow)