Build Infrastructure

Page created on 2011-05-23 at 17:56:11 UTC by Chris – 27 Comments

All the software on this site is built using a custom build infrastructure whose aim is to automate as much as possible the process of building a project, including:

  • Minimal property-driven Makefile for each project
  • Support for Linux/gcc, MacOSX/gcc and Windows/MSVC
  • Release and debug configurations
  • Automatically downloads and builds dependencies
  • Support for executables, dynamic-link libraries and static-link libraries
  • Builtin support for Noel Llopis and Charles Nicholson's UnitTest++

You can download the build infrastructure from here:

Linux & MacOSX bundle (2013-07-19)
Windows bundle (2013-07-19)
Browse source repository
RSS feed of recent commits
Open issues

Linux Installation

Just unpack the MakeStuff tar file in a convenient location (e.g $HOME) and you're ready to start.

MacOSX Installation

Download and install the Command Line Tools for Xcode. Now you can download wget and the build infrastructure; from a terminal, do:

cd /
curl -sL http://bit.ly/wget-macosx | sudo tar zxvpf -
cd $HOME
wget -qO- http://www.swaton.ukfsn.org/bin/makestuff-lindar-20130719.tar.gz | tar zxf -

...and you're ready to go. If you want to do USB-related stuff, you'll need libusbx; from a terminal, do:

cd /
wget -qO- http://www.swaton.ukfsn.org/bin/libusbx-macosx/libusbx-1.0.14.tar.gz | sudo tar zxvpf -

Here's a short video showing how to install the build infrastructure on MacOSX. You can view it embedded below or in high definition here.

Windows Installation

Download and install Visual Studio Express 2010, 2012 or 2013, then unpack the MakeStuff zip file to a convenient location (e.g C:\). You can now follow the instructions in the README.txt or follow the video below.

Although the Windows build system uses the MSVC compiler and tools, it relies on various unix tools (e.g make, cat, etc). You may already have a suitable installation of these tools, but problems arising from subtle differences between their various flavours on Windows led me to include a definitive subset of the MinGW/MSYS tools. Whilst it may be possible to build stuff from this site using an alternative set of unix tools, I cannot help you with problems if you're using anything other than the tools supplied.

Here's a short video showing how to install the build infrastructure on Windows 7. You can view it embedded below or in high definition here.

Repo Build Example

If you just want to build the software on this site, find the repo on http://github.com/makestuff that you're interested in, and from inside libs or apps do ../scripts/msget.sh makestuff/<repo>, then follow the instructions in the project's README.

For example, if you want to build FPGALink, check its README for prerequisites, then do:

chris@wotan$ cd $HOME/libs/
chris@wotan$ ../scripts/msget.sh makestuff/libfpgalink
chris@wotan$ cd libfpgalink/
chris@wotan$ make deps

The make deps fetches and builds this repo's dependencies, and then builds itself. Once you know all the deps are in place you can run make on its own to just make the local directory. You can also use make clean to clean the local directory and make depclean to clean the local directory and its dependencies.

Tutorial

This section will interest you only if you wish to use the infrastructure to build your stuff. It is not necessary for building my stuff.

First make a mul directory under makestuff/apps, and put a Makefile there:

# makestuff/apps/mul/Makefile
ROOT    := $(realpath ../..)
DEPS    := 
TYPE    := exe
SUBDIRS := 

-include $(ROOT)/common/top.mk

Now a main.c:

// makestuff/apps/mul/main.c
#include <stdio.h>
#include <stdlib.h>
#include "mul.h"
int main(int argc, const char *argv[]) {
    int x, y;
    if ( argc != 3 ) {
        fprintf(stderr, "Synopsis: %s <num1> <num2>\n", argv[0]);
        exit(1);
    }
    x = atoi(argv[1]);
    y = atoi(argv[2]);
    printf("mul(%d, %d) = %d\n", x, y, mul(x, y));
    return 0;
}

Now mul.h:

// makestuff/apps/mul/mul.h
#ifndef MUL_H
#define MUL_H
#ifdef __cplusplus
extern "C" {
#endif
    int mul(int x, int y);
#ifdef __cplusplus
}
#endif
#endif

...and finally mul.c:

// makestuff/apps/mul/mul.c
int mul(int x, int y) {
    return x * y;
}

Now you can type make and it will make a release exe and a debug exe in lin.x64/rel and lin.x64/dbg respectively.

Adding unit tests is pretty simple. First make a tests directory under makestuff/apps/mul, and put a Makefile there:

# makefile/apps/mul/tests/Makefile
ROOT    := $(realpath ../../..)
DEPS    :=
TYPE    := exe
SUBDIRS :=

-include $(ROOT)/common/top.mk

Now a main.cpp:

// makestuff/apps/mul/tests/main.cpp
#include <UnitTest++.h>
int main() {
    return UnitTest::RunAllTests();
}

...and now the tests for the mul.c module:

// makestuff/apps/mul/tests/testMul.cpp
#include <UnitTest++.h>
#include "../mul.h"
TEST(Mul_testMultiply) {
    CHECK_EQUAL(20, mul(10, 2));
}

...and finally, edit makestuff/apps/mul/Makefile to tell it to run the tests:

# makestuff/apps/mul/Makefile
:
SUBDIRS := tests
:

Now when you type make in makestuff/apps/mul, it builds the code as before but now it builds and runs the tests too. If necessary, it will first download, build and test the testing framework itself (Noel Llopis and Charles Nicholson's UnitTest++).

Debugging

On Windows, you can launch the Visual Studio debugger on an exe with WDExpress.exe win.x64/dbg/mul.exe. You will then need to right-click the mul project in Solution Explorer, select Properties and fill in the Arguments property with 10 2. Now you can right-click mul again and choose Debug->Step Into New Instance to start debugging at main().

On Linux, you can launch gdb or ddd on an exe with ddd lin.x64/dbg/mul. Right-click inside the main() function and select Set Breakpoint. Then type run 10 2 into the console at the bottom to start debugging from your breakpoint.

27 Comments

[...] Build Infrastructure [...]

Reply

[...] Build Infrastructure [...]

Reply

In Windows 7 you have to edit C:\makestuff\msys\etc\profile and change all the paths containing C:/Program Files/ to C:/Program Files (x86)/

Reply

Thanks, noted. I think you mean Windows 7 64-bit edition though.

Reply

Hello Chris,
I am finding some difficulty in getting started with build infrastructure.
1. I have installed make stuff at c:\
2. I have installed the console2 at c:\
3. Is added in shell path C:\makestuff\msys\bin\sh.exe
3. MSVC 2010 is installed on my machine.
4. In windows environment variable path is added to c:\makestuff\msys\bin;
5. But still when I try to execute command like ls, make those are not working.

I must be doing something wrong. Any other step I need to follow to get this working.
Thanks and Regards
Amol

Reply

I have added a video above showing how to install the build infrastructure on Windows.

Reply

Hello Chris,
Thanks for this its working. *--login* was missing in the steps I mention above. Thank you for your help. this is too good and very cool software to work with.
Thanks and Regards
Amol

Reply

Hello Chris,
I am facing problem while running make deps its gives error message as asx8051 command not found.
I have installed SDCC and MSVC 2010. I think I am missing something.
Thanks and Regards
Amol

Reply

Please ensure you have installed SDCC 2.9.0 as specified in the FPGALink README, and ensure that you have /c/Program Files/SDCC/bin on your PATH.

Reply

Hello Chris,
Thank you for your quick reply.
I have installed the new version of SDCC because of that It was not working. I have checked in bin folder asx8051.exe was not there. I downloaded from the link which you have provided in README and not it is working.
Thanks and Regards
Amol

Reply

Hello Chris,

I have a one question about the set the console2 shell location.
In Windows,shell location is "C:\makestuff\msys\bin\sh.exe --login",
but I set to C:\makestuff\,so result the trouble.
I can't open the Console2.exe(because set the error shell location).

So,How to fix this error set?

Reply

Navigate to %APPDATA%\Console. Delete the console.xml. Redo the configuration step.

Reply

got it!

Thanks your help!

Reply

I tried to follow the steps in your video but the build of "lsep" fails because libusbx-1.0.12-win is missing. Where do I download this missing package?

Reply

Russell,

Many apologies, I missed your comment. I have been in the process of upgrading all my stuff to use libusbx rather than the rather old and unmaintained libusb-win32 (actually many of the developers of the latter now work on the former). I had obviously overlooked lsep.

Please try again and let me know if it still fails for you.

Chris

Reply

Hello Chris,

I'm trying to get your infrastructure installed. When I follow your fpgalink example I get an error saying libusb1.0/libusb.h not found. I'm using Ubuntu 12.4 32bit system with sdcc, g++ and libusb.1.0.9 installed I also installed libusb-dev using 'apt-get install libusb-dev'. Even a find / ... did not get a file named libusb.h.
Have you any idea what is missing?

best regards Juergen

Reply

Juergen,

Many apologies, I missed your comment. On Debian-like system you will need sudo apt-get install libusb-1.0-0-dev. This will install /usr/include/libusb-1.0/libusb.h. On older systems (e.g Ubuntu 12.04) this will install the libusb-1.0 files, but on newer machines (e.g Debian Wheezy) it'll install libusbx, the more actively-maintained fork. All my stuff will work with both.

Chris

Reply

re Windows Installation (I use 64-bit Windows 8 Pro)

All under "Tutorial", "Debugging" above (i.e., in http://www.makestuff.eu/wordpress/software/build-infrastructure/) works fine.

BUT, in "Repo Build Example" (for libs/fpgalink)
> make deps

result in:
...
make[2]: Entering directory '/c/makestuff/libs/libusbwrap'
make[2]: * No rule to make target '/c/makestuff/3rd/libusbx-1.0.14-win', needed by 'all'. Stop.
...

also happens for "lsep" (in your video), i.e., for apps/lsep
> make deps

results in the same errors as above (for fpgalink)

When will you have fixed this issue? Thank you very much.
Regards
David

Reply

Hi David,

Apologies for the late reply; I'm away from home right now and my Internet access is patchy.

I forgot to update the build infrastructure download links at the top of this page. I updated all the USB-related stuff on my site to use libusb-1.0 (or libusbx-1.0), and that required some tweaks to the build infrastructure. Please download the latest package and try again.

I'm interested to hear why you're building FPGALink from source. Does the binary download not meet your needs for some reason?

Chris

Reply

I try to build it under windows 7 64bits, and the makestuff for windows need modify msys/etc/profile.

Reply

Hi Lasty,

Thanks for your message. I actually added win.x64 platform support to a later revision, which is kind of a beta release. Try it and see if it works for you: makestuff-win32-20130126.zip. If it doesn't work, please direct patches at the project page on GitHub. Thanks!

Chris

Reply

Hi Chris,

I was running the lsep example and at the "make deps" part I am getting the following error:

LINK : fatal error LNK1104: cannot open file 'c:/makestuff/libs/lubusebwrap/win.x64/dbg/libusbwrap.lib

comes after the line after main.c (a long line: link -OUT:win.x64/dbg/lsep.exe -INCREMENTAL .... )

Any suggestions?

Reply

It looks like libs/libusbwrap/win.x64/rel/libs.txt has become corrupted on your system, because the build is looking for a file in libs/lubusebwrap rather than libs/libusbwrap. Try clearing out 3rd, libs and apps and trying again. I just did, and this was the result. Also, please ensure you're using the latest package (dated 2013-01-26). I just noticed I forgot to update the above links.

Chris

Reply

Thanks for the quick response!

The "lubusebwrap" was a typo, however I got the latest package and everything went smoothly.

Until I tried:
./win.x64/rel/lsep.exe 1443:0007 (I have a Nexys3)
c:\makestuff\apps\lsep\win.x64\rel\lsep.exe: usbOpenDevice(): LIBUSB_ERROR_NOT_FOUND

Reply

I suspect you do not have the correct driver installed. Remove whatever driver is currently installed for your Nexys3, and then download Zadig and use it to install either a WinUSB or libusbK (not libusb-win32) driver.

Hi Chris,
Having some trouble with the Win32 bundle (2013-01-26). The page won't load!
Have you changed the repository location or something?
Other friends of mine interested in your work are having the same issues :(
Thanks so much!

Reply

Hi Jeremy,

No I didn't move it. My ISP is having trouble, evidently. Apologies. Anyway, you can get the latest build infrastructure from my DropBox. You can see how to install it in the tutorial video. Let me know if you have problems.

Chris

Reply

Leave a Reply

You may use TWiki syntax in your comment. Your email address will not be published.

| Home | About |

Powered by WordPress & MakeStuff theme, with Silk icons