Starter Template

38 views
Skip to first unread message

Rob

unread,
Oct 15, 2013, 7:34:37 PM10/15/13
to fabrica...@googlegroups.com
Hey all, thanks for the great library.  I wanted to share the template I have been using for a small project.  I assembled it by grabbing pieces of information from the mailing list, docs, etc...  I found the template on the project home page to be a bit anemic.

Typically, I've used SCons, but I wanted to try something else.  I'm glad I found fabricate as it's so much less of a beast.

The template demonstrates:
  • How to do command line options
  • A non-recursive, multi-project complication
    • Specify different project files
    • Specify different compiler / linker flags
    • Specify build dir
    • Only compiles applications (not libs - for now - plumbing is in place for this)
TODO:
  • Add partial builds via the command line.
  • Add support for static/dynamic libraries.

Anyway, I hope this helps some new person getting up to speed with this library.  It's a really great tool and has been working out great for me.  Thanks for the hard work of developing it!

Have fun - gist is below!

-Rob


Simon Alford

unread,
Oct 18, 2013, 10:58:20 AM10/18/13
to fabrica...@googlegroups.com

Thanks Rob.

Glad to have another fabricate fan. I will take a look at your template and try and update the Wiki with it some point.

Simon.

--
You received this message because you are subscribed to the Google Groups "fabricate users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabricate-use...@googlegroups.com.
To post to this group, send email to fabrica...@googlegroups.com.
Visit this group at http://groups.google.com/group/fabricate-users.
For more options, visit https://groups.google.com/groups/opt_out.

Yassen Damyanov

unread,
Oct 18, 2013, 12:42:45 PM10/18/13
to fabrica...@googlegroups.com
Guys, how about keeping the overly simple template and _adding_ this
one as a bit more complex one? When I saw that simple template for the
first time, it was very attractive, because of it simplicity! So I
guess "seducing" newcomers is still a good hting ;)

Cheers,
Y.

Rob

unread,
Oct 21, 2013, 5:42:18 PM10/21/13
to fabrica...@googlegroups.com
I'm happy to help and be part of the community.  The template has lots of shortcomings, but I think it's a decent starting point for growth.  For example, I also would like to add the SMP build too.

Anyway, feel free to hack the template to make it wiki page worthy :)

Rob

unread,
Dec 3, 2014, 7:22:23 PM12/3/14
to fabrica...@googlegroups.com
I've updated the gist to what I have been using for the past few months... it's much more complex now. I've moved source specification to one or more .build files (they are python and get exec'd by build.py). Here is an example to build 'dlib' and then an app that uses it.

It supports dependency tracking, lazy glob expansion (ie: globs get expanded when the item gets built), lazy parameter expansion (ie: if you wanted to set the cxxflags to the 'name' you specified, you could do something like "cxxflags" : "-Dfoo=%(name)s), pre build commands, post build commands, etc.

Hopefully, someone will find this useful. I still haven't found anything as nice as fabricate on Linux. Something that automatically tracks dependencies, allows me to easily setup cross compile builds, add custom tooling, etc... Maybe gyp?

Note: I did have to make a small patch to fabricate to get ctrl-C for a multiprocess build to exit and not hang... not a clean fix but seems to work. I will copy it below.

dlib.build
sources.append(
    {"name" : "libdlib.a",
     "group" : "dlib",
     "sources" : ["ThirdParty/dlib-18.10/dlib/all/source.cpp"],
     "build_dir" : "ThirdParty/dlib-18.10/dlib/all",
     "install_dir" : "libs",
    
     "cxxflags" : "-DDLIB_NO_GUI_SUPPORT",
    }
)

app.build
sources.append(
    {"name" : "app",
     "depends" : ["dlib"],
     "sources" : ["src/app/main.cpp"],
     "build_dir" : "src/app",
     "install_dir" : "bin",

     "cxxflags" : "-Wall",
     "ldflags" : "-lz",

     "post_cmds" : ["cp ./src/app/config.*.txt ./bin/"],
    }
)

Here is a more complicated file that I just created to support the use of protoc (protobuf).

idl.build
PROTOSRC = "%(PROJ_DIR)s/ThirdParty/protobuf-2.6.1/src"
PROTOINCLUDE = "%(PROTOSRC)s/google"
PROTOC = "%(PROTOSRC)s/protoc"
PROTOLIBS = "%(PROTOSRC)s/.libs/*.a"

# copy the proto libs to the lib dir and add a symbolic link
# to the header files (I could copy them, but I don't want fabricate
# to have to track them)
sources.append(
    {"name" : "protolibs",

     "post_cmds" : ["cp %(PROTOLIBS)s ./libs",
                    "ln -s %(PROTOINCLUDE)s ./include"],
    }
)

# generate the src/header files from the .proto file
sources.append(
    {"name" : "icd",
     "depends" : ["protolibs"],
     "icd.proto" : "./src/app/icd.proto",

     "post_cmds" : ["%(PROTOC)s %(icd.proto)s --cpp_out=."],
    }
)

fabricate.diff
16:19 $ diff -Naur /tmp/fabricate.py fabricate.py
--- /a/fabricate.py 2014-12-03 16:19:30.152417926 -0800
+++ /b/fabricate.py 2014-09-29 18:04:41.404331760 -0700
@@ -713,7 +713,13 @@
                 os.close(handle)
                 raise
             try:
-                status, deps, outputs = self._do_strace(args, kwargs, outfile, outname)
+                try:
+                    status, deps, outputs = self._do_strace(args, kwargs, outfile, outname)
+                except KeyboardInterrupt:
+                    # this exception is caught here because it seems to fix the issue with python hanging
+                    # when ctrl-c is pressed.
+                    pass
+
                 if status is None:
                     raise ExecutionError(
                         '%r was killed unexpectedly' % args[0], '', -1)
Reply all
Reply to author
Forward
0 new messages