Показаны сообщения с ярлыком Makefile. Показать все сообщения
Показаны сообщения с ярлыком Makefile. Показать все сообщения

пятница, 16 мая 2014 г.

Small and fast build tools: SVMK, NINJA

There are many build tools. One of them tracks dependencies and build result output via special file with dependencies-tree description, another generates such file from universal format (Premake, Bakefile, CMake, etc.). There are 2 big classes of such tools: with special syntax in its' Makefiles, and with supporting of some general-purpose language (Waf, Scoons, etc.). Difference is that in the 2nd kind you can solve absolutely any tasks without writing special plugins (sometimes is impossible to extend "Makefile" in natural way, only with command line utilities)...

If you want very small and fast build tools (and not Make:) you can see next: Ninja and Tcl-based Svmk. Another Tcl-based make tools are here.

Ninja

Ninja is very simple and fast. It have not functions, if-else-for-while operators, nothing, only variables, rules... But it can be used to process automatically generated "Makefile". Example:
DMD = c:/dmd2/windows/bin/dmd.exe
LINK = c:/dmd2/windows/bin/link.exe

INC = -Ic:/dmd2/src/phobos -Ic:/dmd2/src/druntime/import

rule mkprj
    command = $DMD -I$PKGDIR $INC -of$out $in
    description = Compile D program $out

PKGDIR = misc/scripts
build $PKGDIR/email.exe: mkprj $PKGDIR/characterencodings.d $PKGDIR/email.d
Save it in build.ninja, call ninja misc/scripts/email.exe and you will get result: email.exe in misc/scripts directory. rule creates rule which has attribute command to call when it's applied. build set dependency: email.exe will be built from 2 .d files with mkprj rule by calling it command. Nothing else. Simple, fast. ninja is only ONE FILE: ninja.exe and is about 800Kb! If no target (misc/scripts/email.exe), then ninja will build it.

Svmk

It's Tcl-based make alternatives. So you have all power of Tcl (use Tclkit Shell!) in one little Tcl-script: svmk.tcl. Example of the same:
# vi:set ft=tcl:

set DHOME c:/dmd2/windows/bin
set DMD $DHOME/dmd.exe

proc dcomp {out in {dflags ""}} {
    global DMD
    if [llength $dflags] {
        system $DMD $dflags -of$out {*}$in
    } else {
        system $DMD -of$out {*}$in
    }
}

target email.exe {
    cd misc/scripts
    set SRC "characterencodings.d email.d"
    depend $SRC {
        dcomp email.exe $SRC
    }
}
We create dcomp procedure for compiling of D applications. Then create rule "email.exe" which is PHONY :) Common usage is target TARGET { depend DEPENDENCIES { commands... } }. You can see: we can use any Tcl commands, even download something via Net :) All what you need is: tclkitsh.exe: 740Kb, svmk.tcl: 10Kb!
To run:
tclkitsh.exe svmk.tcl email.exe
And sure you can (and have) to use original D build tool (if we are talking about D;) - dub.

вторник, 10 сентября 2013 г.

Android build simplifier

Add this alias to ~/.bashrc:
alias amake='_(){ rm -f ./build.log; . ./build/envsetup.sh; lunch $1; make -j8 2>&1|tee ./build.log; }; _'
and now you can avoid envsetup.sh, lunch running and get build log file :) Better is to run:
$ amake something-userdebug
from Android source directory.
Or the same but as explicit function (put it, for example in ~/.zshrc):
function amake() {
/bin/bash -s stdin << EOF
rm -f ./build.log
. ./build/envsetup.sh
lunch $1
make -j8 2>&1|tee ./build.log
EOF
}

пятница, 22 марта 2013 г.

ASF/AVR32: how to read/write to FLASH

First, open example ASF project on FLASHC read/write. Get code from and paste into your project. Also add *.lds file from example (...asf/avr32/drivers/flashc/flash_example//.lds) into your project. Then add to Linker options next:
--rodata-writable -Wl,--direct-data -T../src/asf/avr32/drivers/flashc/flash_example/at32uc3a3256_evk1104/link_uc3a3256.lds
(first in options line on tab "Miscellaneous" and correct path).
Now build and no any linker errors about regions...

суббота, 28 мая 2011 г.

Bakefile: Makefile's generator

It's known problem - general way of making the project. There are many tools for this task: CMake, automake/autoconf, ant (usual for Java) and many-many other. But some of them use own build system and very few uses standard way of Makefile (i.e. generates Makefiles). This method is based on some input format which is translated to Makefile for target compiler. For example, automake/autoconf, Premake (with Lua scripting) and Bakefile (written in Python and is crossplatform, like Premake and many other). It's authors are Vaclav Slavik, Francesco Montorsi.

Bakefile uses XML as input format then generates standard Makefiles for the targets:

autoconf       Makefile.in for GNU Autoconf
borland        Makefile for Borland C++ and Borland make
dmars          Generic Makefile for Digital Mars C/C++
dmars_smake    Makefile for Digital Mars C/C++ with SMAKE
gnu            Makefile for GNU toolchain: GNU Make, GCC...
mingw          Makefile for MinGW: mingw32-make, MinGW...
msvc           Makefile for Visual C++ with Microsoft nmake
msvc6prj       Microsoft Visual C++ 6.0 project files
msevc4prj      Microsoft Embedded Visual C++ 4 project files
msvs2003prj    MS Visual Studio 2003 project files
msvs2005prj    MS Visual Studio 2005 project files
msvs2008prj    MS Visual Studio 2008 project files
suncc          GNU makefile for SunCC compiler
symbian        Symbian development files
watcom         Makefile for OpenWatcom C/C++
xcode2         Apple Xcode 2.4 project files

It's input file looks like:
<exe id="test_sockets">
        <cflags>-fpack-struct</cflags>
        <sources>test_sockets.c</sources>
        <sources>socks.c</sources>
        <sys-lib>pthread</sys-lib>
        <if cond="TOOLSET=='win32'">
            <sys-lib>wsock32</sys-lib>
        </if>
</exe>

This pie of code will build (via native Makefile sure) test_sockets binary from test_sockets.c and socks.c, with pthread library (available on Unix and MinGW too) and with wsock32 library only on Windows.

Another example of custom tag:
<include file="presets/simple.bkl">
    <define-tag name="lit" rules="action">
        <if cond="TOOLSET=='unix'">
            <command></command>pyweb.py -s $(attributes['web']).w
            <command></command>rst2html.py $(attributes['web']).rst $(attributes['web']).html
        </if>
        <if cond="TOOLSET=='win32'">
            <command></command>cmd /C pyweb.py -s $(attributes['web']).w
            <command></command>cmd /C rst2html.py $(attributes['web']).rst $(attributes['web']).html
        </if>
    </define-tag>

    <action id="lit">
        <lit web="maintest">
        <lit web="socks">
    </lit></lit></action>
</include>

This snippet will weave and tangle "literated" sources (with pyweb tool): maintest.w and socks.w but in different manners under Windows and Unix.
All of these snippets should be in <makefile> tag! When you use some tag, see documentation on tag (what outer tags it expect).