mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-21 17:35:55 +01:00
Initial commit
This commit is contained in:
commit
44a967e326
211
ChangeLog
Normal file
211
ChangeLog
Normal file
@ -0,0 +1,211 @@
|
||||
NEW IN WAF 1.6.8
|
||||
----------------
|
||||
* Found a typo that prevented Waf from running on Pypy-trunk
|
||||
* Fixed a typo in Utils.py affecting Win32 platforms (copystat) #1029
|
||||
* Fixed a minor bug in the Eclipse project generator
|
||||
* Make the xlc/xlc++ compiler detection more accurate by looking at the version number (#1022)
|
||||
* Minor perl and ruby tool improvements
|
||||
|
||||
NEW IN WAF 1.6.7
|
||||
----------------
|
||||
|
||||
* Provide more diagnostic for invalid build groups #914
|
||||
* Various enhancements to msvs.py
|
||||
* Read MSVC_VERSIONS and MSVC_TARGETS from the command-line
|
||||
* Minor cross-compiler detection fix on msvc.py
|
||||
* Fix the redirections with pipes (waf configure > log)
|
||||
* Do not display runnable_status exceptions when running with -k
|
||||
* Let -k stop at the first runnable_status error and -kk run even further
|
||||
* Merge the add_object extension in the main line (source='file.o')
|
||||
* Make update_outputs more robust with changes in the task definition #1017
|
||||
* Qt4 detection on Win32
|
||||
|
||||
NEW IN WAF 1.6.6
|
||||
----------------
|
||||
|
||||
* Fix the performance regression related to #974
|
||||
|
||||
NEW IN WAF 1.6.5
|
||||
----------------
|
||||
|
||||
* More documentation
|
||||
* Re-enable the colors for msys
|
||||
* Add the .ui files for the qt4 translations
|
||||
* Fix the conf.check_large_file() test
|
||||
* Fix the conf.check_library() in C++ mode #955
|
||||
* Improve the latex scanner to avoid depending on generated files #943
|
||||
* Remove the @file processing from the winrc tasks
|
||||
* Fix the python detection using python-config
|
||||
* Add the missing default includes and defines to the moc command
|
||||
* Improve support for hierarchical go-lang packages #953
|
||||
* Fix the gfortran verbose flag detection on Windows
|
||||
* Fix the support of fortran import libraries #950
|
||||
* Added a fix for running with Python 2.4 on Windows #949
|
||||
* Limited support for IronPython
|
||||
* Support for older Visual Studio versions (VC6) #952
|
||||
* New waf.bat file #964
|
||||
* New method ConfigSet.keys
|
||||
* New Visual Studio and Eclipse CTD project generators (waflib/extras)
|
||||
* New lru_cache tool for use with WAFCACHE (waflib/extras)
|
||||
|
||||
NEW IN WAF 1.6.4
|
||||
----------------
|
||||
|
||||
* Fix the Python detection on win32 #883
|
||||
* Optimize the Python file installation #892
|
||||
* Force +x permissions on installed fortran programs #893
|
||||
* Qt library detection fixes #895
|
||||
* Ensure that unit tests are executed only after the symlinks are created
|
||||
* Fix the precedence constraints for classes ending in _task #896
|
||||
* Support the install_path attribute with add_pcfile #913
|
||||
* Make the goprograms executable when installed #928
|
||||
* Allow non-python data files in the waf executable #927
|
||||
* Enforce a build order based on the scanner results #777, #922
|
||||
* Multiple msvc detection fixes #907 #910 #923 #924 #926
|
||||
* Fix the -of flag append with dmd #917
|
||||
* Boost detection fixes #920
|
||||
* Support newer javac compilers #921
|
||||
* Fix the execution on python 2.3 for: "waf update", msvc.py, fc.py
|
||||
* Improve the support for mac applications (demos/mac_app)
|
||||
* Better default regexps in "waf step"
|
||||
* New error check for tasks creating the same nodes or having the same identifiers (waf -v)
|
||||
* New variables conf.env.NO_LOCK_IN_TOP/OUT/RUN for special projects (top='..')
|
||||
* New example on avoiding rebuilds when moving a project (playground/relocate)
|
||||
* Improve go-lang support for cgo-packages (fixes #932)
|
||||
* Fix the progress bar on cmd and msys
|
||||
|
||||
NEW IN WAF 1.6.3
|
||||
----------------
|
||||
|
||||
* Fixed the interaction of Fortran configuration tests and WAFCACHE #842
|
||||
* Various documentation fixes
|
||||
* Set the PYTHONARCHDIR variable for installing python extensions
|
||||
* Fixed the Waf file creation with --zip-type=gz (bunzip2 was not replaced by gzip -d)
|
||||
* Fixed multiple problems in the call to TaskGen.declare_chain(...) #850
|
||||
* Fixed the task attribute 'vars' which might cause unnecessary rebuilds #852
|
||||
* Return the value of post_check(...) in conf.check(...) #857
|
||||
* Rewrite the boost tool (waflib/extras/boost.py) #814, #454, #424
|
||||
* More fortran file extensions: .for, .FOR #867
|
||||
* Searching above the root nodes no longer raise exceptions #868
|
||||
* Msvc detection fixes for non-utf8 encodings #873
|
||||
* Fixed the destdir processing on Windows #874
|
||||
* Stop changing the flags on waf -v (make the errors more visible) #875
|
||||
* Fixed the resource file compilation on Windows #876
|
||||
* Fixed the vala file installation #881
|
||||
* New system of plugins for C/C++/Fortran compilers (files named c_* in waflib/extras/)
|
||||
* New examples of interaction between Waf and existing makefiles (playground/)
|
||||
* New names for @before/@after: @before_method/@after_method
|
||||
|
||||
NEW IN WAF 1.6.2
|
||||
----------------
|
||||
|
||||
* Support for C# debugging files #797
|
||||
* Add -relocation-model=pic for shared libraries on ldc
|
||||
* Fixed 'waf dist' for tar files on python 3 #799
|
||||
* Make the latex scanner recursive #798
|
||||
* Enable the packing of non-python files in the waf file #802
|
||||
* Improve the feature sniffing for hybrid programs/libraries #800
|
||||
* New apidocs + tutorial in Sphinx format
|
||||
* Add the CPPFLAGS from os.environ #803
|
||||
* Create the java output directory anywhere #806
|
||||
* Enable the .luac file installation
|
||||
* Process Qt translation files
|
||||
* Detect when the folders were copied and prompt for "waf configure"
|
||||
* Parse_flags for the *-config outputs on windows (backslashes) #811
|
||||
* Fix the doxygen task build order + improve the dependency scanner #821
|
||||
* Various msvc fixes #819, #826, #825
|
||||
* Ported the batch executor to waf 1.6 (batched_cc)
|
||||
* New tools: erlang, scala
|
||||
* Moved conf.multicheck(..) from playground to the library
|
||||
* New parameter to avoid reading the same scripts: bld.recurse(dir, once=True)
|
||||
* Detect invalid method calls in 'waf -v' such as env.append/env.add/env.prepend
|
||||
* New manifest option for jar targets #832
|
||||
|
||||
NEW IN WAF 1.6.1
|
||||
----------------
|
||||
|
||||
* Fixed the method check_waf_version #764
|
||||
* Fixed the name in ctx.recurse(name) #769
|
||||
* Stop caching the install tasks and tasks that have no outputs #770
|
||||
* Fix the log in Context.cmd_and_log() when calling with "quiet" #778
|
||||
* c_preproc exception when a file has the same name as a directory #777
|
||||
* 'intltool_po' does not install the .mo files #782
|
||||
* 'intltool_in' was broken #792
|
||||
* Bind stderr and stdout to the exception in Context.cmd_and_log #779
|
||||
* Tasks not rebuilding properly when the 'run' method changes #786
|
||||
* Print the progress bar information as late as possible #787
|
||||
* Fix for the FRAMEWORK value processing
|
||||
* Verbose mode should not require the compat15 tools #790
|
||||
* Let static libraries use other static libraries as in 1.5 #768
|
||||
* Fix for the boost tool #776
|
||||
* boost tool update (in playground) #780
|
||||
* Updated the java tool and examples
|
||||
* New gcj tool in playground
|
||||
* Update the c# tool and examples (playground) #796
|
||||
* Read external c# libraries #774
|
||||
* Xelatex support #785
|
||||
* Rebuild fortran files when .mod files change #766
|
||||
* docs #781
|
||||
* Improve the ant_glob behaviour on ctx.root + absolute paths
|
||||
* Fix for glib_mkenums and dbus-binding-tool #795
|
||||
* New feature 'subst' (see demos/subst)
|
||||
|
||||
NEW IN WAF 1.6.0
|
||||
----------------
|
||||
|
||||
General:
|
||||
* Python 3 syntax by default (runs unmodified for 2.6, 2.7, 3.0 and 3.1)
|
||||
* Environment -> ConfigSet
|
||||
* only lists are allowed in ConfigSet
|
||||
* Better Node apis
|
||||
* Utils.load_tool -> Context.load_tool
|
||||
* set_options becomes options
|
||||
* only the build-related commands require a configured project
|
||||
* new variant system + build context commands
|
||||
* removed the pseudo glob in installation methods
|
||||
* eliminate find_sources_in_dirs
|
||||
* node.__class__.bld → node.ctx
|
||||
* bld.new_task_gen(...) disappears, use bld(...)
|
||||
* network updates for waf tools
|
||||
* accept node objects in the source and includes attributes
|
||||
* remove task_gen.allnodes: modify self.source directly
|
||||
* merge the include system for c, c++, d, gas and nasm
|
||||
* allow top == out (no build directory)
|
||||
* merge the Tool/wscript system (detect->configure, set_options->options)
|
||||
* new command "waf list" to list the x for "waf build --targets=x"
|
||||
* rename apply_core -> process_source
|
||||
* rename apply_rule -> process_rule
|
||||
* rename Task.TaskBase.classes -> Task.classes
|
||||
* the modules Utils.py and Logs.py are now independent from the rest of waf (imports)
|
||||
* remove Task.TaskManager and Build.BuildContext.all_task_gen to improve the build group handling
|
||||
* remove program_USELIB, shlib_USELIB staticlib_USELIB support
|
||||
* use tasks for target installation
|
||||
* improve the exception handling (WscriptError was removed, use WafError)
|
||||
* let the commands access node objects
|
||||
* infer the build directory from the lock filename
|
||||
* waf step --file=main.c
|
||||
* post task generators in a lazy manner
|
||||
|
||||
preview 3:
|
||||
* remove the /W3 flag from msvc default flags
|
||||
* opt.tool_options -> opt.load (now all commands inherit the 'tool' method)
|
||||
* conf.check_tool -> conf.load
|
||||
* do not copy files when creating tar files in 'waf dist'
|
||||
* add zip files in 'waf dist'
|
||||
* fix the behaviour of 'waf distcheck'
|
||||
* preprocessor optimizations
|
||||
* python 2 fixes
|
||||
|
||||
release candidate:
|
||||
* cache fixes
|
||||
* fortran fixes
|
||||
* python 2 and 3 fixes
|
||||
* docs and docstrings
|
||||
* support for custom waf files and preludes
|
||||
* fix in waflib.Context for overriding command classes
|
||||
* port the doxygen tool
|
||||
* Utils.to_hashtable -> Utils.str2dict
|
||||
* change the thread pool to enable thread pool sharing
|
||||
* fixed a regression on win32 + ansiterm.py + python 3 -> thanks to kesselhaus :-)
|
||||
* various msvc fixes (thanks to Nicolas Mercier)
|
||||
|
41
DEVEL
Normal file
41
DEVEL
Normal file
@ -0,0 +1,41 @@
|
||||
branches
|
||||
--------
|
||||
|
||||
trunk the current branch (waf 1.6)
|
||||
branches/waf-1.5 waf 1.5 (currently waf 1.5.19)
|
||||
branches/waf-1.6 waf 1.6.0 (before waf 1.6)
|
||||
tags a tag is created each time a release is made
|
||||
|
||||
docs/apidocs located at the repository root - contains the apidocs
|
||||
the files have svn properties so they are browsable online from
|
||||
http://waf.googlecode.com/svn/docs/apidocs/index.html
|
||||
docs/wafbook the waf book of waf 1.6, browsable online from
|
||||
http://waf.googlecode.com/svn/docs/wafbook/single.html
|
||||
docs/ the waf book of waf 1.5, browsable online from
|
||||
http://waf.googlecode.com/svn/docs/single.html
|
||||
|
||||
other branches contain experimental things, most are unused now
|
||||
|
||||
folders in trunk/
|
||||
-----------------
|
||||
|
||||
trunk contains the source code which is being worked on (currently waf 1.6.3)
|
||||
|
||||
waflib the core library
|
||||
waflib/Tools essential waf tools
|
||||
waflib/extras tools which are not included in the waf file
|
||||
by default, except for the tool "compat15"
|
||||
build_system_kit examples of build systems that can be created
|
||||
from waf
|
||||
tests unit tests, most are unused
|
||||
playground experiments and integration tests for the tools in
|
||||
the folder waflib/extras
|
||||
demos integration tests - the folder can be configured
|
||||
as a standalone project
|
||||
demos/* integration tests and examples used as documentation
|
||||
docs documentation
|
||||
docs/sphinx extract docstrings from the source code to extract
|
||||
the apidocs, they are put in the folder "docs/apidocs"
|
||||
at the root of the repository
|
||||
|
||||
|
36
README
Normal file
36
README
Normal file
@ -0,0 +1,36 @@
|
||||
WHAT YOU WILL FIND HERE
|
||||
-----------------------
|
||||
|
||||
Waf (1.6)
|
||||
|
||||
For the manual: http://waf.googlecode.com/svn/docs/wafbook/single.html
|
||||
For the api docs: http://waf.googlecode.com/svn/docs/apidocs/index.html
|
||||
For the examples: see the folder demos/
|
||||
|
||||
HOW TO CREATE THE WAF SCRIPT
|
||||
----------------------------
|
||||
|
||||
Python 2.6, 2.7, 3.0 or 3.1 is required to generate the waf script. Execute:
|
||||
$ ./waf-light configure build
|
||||
Or, if you have several python versions installed:
|
||||
$ python3 ./waf-light configure build
|
||||
|
||||
The Waf tools in waflib/extras are not added to the waf script. To add
|
||||
some of them, use the --tools switch:
|
||||
$ ./waf-light --tools=compat15,swig
|
||||
|
||||
To add a tool that does not exist in the folder compat15, pass an absolute path
|
||||
To customize the initialization, pass the parameter 'prelude'
|
||||
$ ./waf-light --make-waf --tools=compat15,/comp/waf/aba.py --prelude=$'\tfrom waflib.extras import aba\n\taba.foo()'
|
||||
|
||||
HOW TO TRY THE EXAMPLES
|
||||
-----------------------
|
||||
|
||||
Try this:
|
||||
$ cp waf demos/c/
|
||||
$ cd demos/c/
|
||||
$ ./waf configure build
|
||||
|
||||
---------------------------
|
||||
Thomas Nagy, 2010 (ita)
|
||||
|
6
TODO
Normal file
6
TODO
Normal file
@ -0,0 +1,6 @@
|
||||
Waf 1.6.x
|
||||
---------
|
||||
|
||||
* fix the remaining bugs
|
||||
* provide more extensions
|
||||
|
33
build_system_kit/README.txt
Normal file
33
build_system_kit/README.txt
Normal file
@ -0,0 +1,33 @@
|
||||
The new "concurrent.futures" module from Python 3.2 will make it
|
||||
even easier to execute tasks concurrently:
|
||||
http://www.python.org/dev/peps/pep-3148/
|
||||
|
||||
It may be tempting to try to create a new build system from it,
|
||||
but that's only a small part of a build system:
|
||||
|
||||
* reinventing a system for handling commands and command-line options
|
||||
* adding a system of (task) order and dependencies
|
||||
* creating an extension system for new programming languages
|
||||
* handling exceptions and errors
|
||||
* adding support for python versions < 3.2
|
||||
|
||||
All this represents a lot of work, and there are of course lots of design
|
||||
mistakes to avoid. It is so easy to create a system with poor usability,
|
||||
poor extensibility, and poor performance.
|
||||
|
||||
These pitfalls and many others are already solved in the Waf build system, which
|
||||
also enables the re-use of its components into new build tools. By using these
|
||||
tested and maintained components, much more time will be left to work
|
||||
on the interesting problems such as creating an intuitive XML/YAML/JSON schema
|
||||
or creating a domain-specific programming language (make-like, cmake-like, ...),
|
||||
or extracting commands and dependencies to create derivated files (Makefiles, Visual studio, ..)
|
||||
|
||||
A few examples are provided to illustrate the range of possibilities:
|
||||
* overview: how to create a custom file using the waf framework to perform a simple build
|
||||
* parser: how to add a parser for a domain-specific language
|
||||
* noscript: infer what to build from given files, use no script file
|
||||
* makefile_dumper: create a makefile corresponding to the current build, extracting as many dependencies as possible
|
||||
* nostate: use timestamps only, and no build directory (very make-like)
|
||||
* extpy: a custom waf file able to read wscript files having the extension ".py"
|
||||
|
||||
Thomas Nagy, 2010-2011
|
54
build_system_kit/extpy/extpy.py
Normal file
54
build_system_kit/extpy/extpy.py
Normal file
@ -0,0 +1,54 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import os
|
||||
from waflib import Errors, Utils
|
||||
from waflib import Context as mod
|
||||
|
||||
class Context(mod.Context):
|
||||
cmd = 'all'
|
||||
def recurse(self, dirs, name=None, mandatory=True, once=True):
|
||||
try:
|
||||
cache = self.recurse_cache
|
||||
except:
|
||||
cache = self.recurse_cache = {}
|
||||
|
||||
for d in Utils.to_list(dirs):
|
||||
|
||||
if not os.path.isabs(d):
|
||||
# absolute paths only
|
||||
d = os.path.join(self.path.abspath(), d)
|
||||
|
||||
WSCRIPT = os.path.join(d, 'wscript.py')
|
||||
WSCRIPT_FUN = 'wscript_' + (name or self.fun) + '.py'
|
||||
|
||||
node = self.root.find_node(WSCRIPT_FUN)
|
||||
if node and (not once or node not in cache):
|
||||
cache[node] = True
|
||||
self.pre_recurse(node)
|
||||
try:
|
||||
function_code = node.read('rU')
|
||||
exec(compile(function_code, node.abspath(), 'exec'), self.exec_dict)
|
||||
finally:
|
||||
self.post_recurse(node)
|
||||
elif not node:
|
||||
node = self.root.find_node(WSCRIPT)
|
||||
if node and (not once or node not in cache):
|
||||
cache[node] = True
|
||||
self.pre_recurse(node)
|
||||
try:
|
||||
wscript_module = mod.load_module(node.abspath())
|
||||
user_function = getattr(wscript_module, (name or self.fun), None)
|
||||
if not user_function:
|
||||
if not mandatory:
|
||||
continue
|
||||
raise Errors.WafError('No function %s defined in %s' % (name or self.fun, node.abspath()))
|
||||
user_function(self)
|
||||
finally:
|
||||
self.post_recurse(node)
|
||||
elif not node:
|
||||
if not mandatory:
|
||||
continue
|
||||
raise Errors.WafError('No wscript file in directory %s' % d)
|
||||
mod.Context = Context
|
||||
mod.WSCRIPT_FILE = 'wscript.py'
|
29
build_system_kit/extpy/runme.py
Executable file
29
build_system_kit/extpy/runme.py
Executable file
@ -0,0 +1,29 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
Create a waf file able to read wscript files ending in ".py"
|
||||
execute a small test to show that it works
|
||||
|
||||
The waf file includes "extpy.py" which performs the required modifications
|
||||
"""
|
||||
|
||||
import os, subprocess
|
||||
|
||||
up = os.path.dirname
|
||||
join = os.path.join
|
||||
|
||||
cwd = os.getcwd()
|
||||
extpy = join(cwd, 'extpy.py')
|
||||
args = 'python waf-light --tools=compat15,%s --prelude=$"\tfrom waflib.extras import extpy\n" ' % extpy
|
||||
root = up(up(cwd))
|
||||
|
||||
subprocess.Popen(args, cwd=root, shell=True).wait()
|
||||
os.rename(join(root, 'waf'), join(cwd, 'waf.py'))
|
||||
|
||||
env = dict(os.environ)
|
||||
if 'WAFDIR' in env:
|
||||
del env['WAFDIR']
|
||||
|
||||
subprocess.Popen('python waf.py configure', cwd=cwd, shell=True, env=env).wait()
|
||||
|
5
build_system_kit/extpy/wscript.py
Normal file
5
build_system_kit/extpy/wscript.py
Normal file
@ -0,0 +1,5 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
def configure(conf):
|
||||
print("test succeeded")
|
5
build_system_kit/makefile_dumper/a.c
Normal file
5
build_system_kit/makefile_dumper/a.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include "a.h"
|
||||
|
||||
void test() {
|
||||
|
||||
}
|
1
build_system_kit/makefile_dumper/a.h
Normal file
1
build_system_kit/makefile_dumper/a.h
Normal file
@ -0,0 +1 @@
|
||||
void test();
|
6
build_system_kit/makefile_dumper/main.c
Normal file
6
build_system_kit/makefile_dumper/main.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "a.h"
|
||||
|
||||
int main() {
|
||||
test();
|
||||
return 0;
|
||||
}
|
79
build_system_kit/makefile_dumper/wscript
Normal file
79
build_system_kit/makefile_dumper/wscript
Normal file
@ -0,0 +1,79 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2010 (ita)
|
||||
|
||||
"""
|
||||
Calling 'waf build' executes a normal build with Waf
|
||||
Calling 'waf clean dump' will create a makefile corresponding to the build
|
||||
The dependencies will be extracted too
|
||||
"""
|
||||
|
||||
VERSION='0.0.1'
|
||||
APPNAME='cc_test'
|
||||
|
||||
top = '.'
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_c')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_c')
|
||||
|
||||
def build(bld):
|
||||
bld.program(source='main.c', target='app', use='mylib', cflags=['-O2'])
|
||||
bld.stlib(source='a.c', target='mylib')
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
from waflib import Build, Logs
|
||||
class Dumper(Build.BuildContext):
|
||||
fun = 'dump'
|
||||
cmd = 'dump'
|
||||
|
||||
def dump(bld):
|
||||
# call the build function as if a real build were performed
|
||||
build(bld)
|
||||
|
||||
from waflib import Task
|
||||
bld.commands = []
|
||||
bld.targets = []
|
||||
|
||||
# store the command executed
|
||||
old_exec = Task.TaskBase.exec_command
|
||||
def exec_command(self, *k, **kw):
|
||||
ret = old_exec(self, *k, **kw)
|
||||
self.command_executed = k[0]
|
||||
self.path = kw['cwd'] or self.generator.bld.cwd
|
||||
return ret
|
||||
Task.TaskBase.exec_command = exec_command
|
||||
|
||||
# perform a fake build, and accumulate the makefile bits
|
||||
old_process = Task.TaskBase.process
|
||||
def process(self):
|
||||
old_process(self)
|
||||
|
||||
lst = []
|
||||
for x in self.outputs:
|
||||
lst.append(x.path_from(self.generator.bld.bldnode))
|
||||
bld.targets.extend(lst)
|
||||
lst.append(':')
|
||||
for x in self.inputs + self.dep_nodes + self.generator.bld.node_deps.get(self.uid(), []):
|
||||
lst.append(x.path_from(self.generator.bld.bldnode))
|
||||
try:
|
||||
if isinstance(self.command_executed, list):
|
||||
self.command_executed = ' '.join(self.command_executed)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
else:
|
||||
bld.commands.append(' '.join(lst))
|
||||
bld.commands.append('\tcd %s && %s' % (self.path, self.command_executed))
|
||||
Task.TaskBase.process = process
|
||||
|
||||
# write the makefile after the build is complete
|
||||
def output_makefile(self):
|
||||
self.commands.insert(0, "all: %s" % " ".join(self.targets))
|
||||
node = self.bldnode.make_node('Makefile')
|
||||
node.write("\n".join(self.commands))
|
||||
Logs.warn('Wrote %s' % node.abspath())
|
||||
bld.add_post_fun(output_makefile)
|
||||
|
17
build_system_kit/noscript/README.txt
Normal file
17
build_system_kit/noscript/README.txt
Normal file
@ -0,0 +1,17 @@
|
||||
This example demonstrates the creation of a particular build tool which compiles
|
||||
specific files directly, for example:
|
||||
|
||||
main.c includes foo.h
|
||||
foo.h has a corresponding foo.c file
|
||||
foo.c includes bar.h
|
||||
bar.h has a corresponding bar.c file
|
||||
|
||||
Calling './dbd build' will then compile and link 'main.c', 'foo.c' and 'bar.c' into the program 'app'.
|
||||
No script file is required, although the build will create a .lock file and a c4che directory.
|
||||
|
||||
To create the build tool:
|
||||
./create_it.sh
|
||||
|
||||
To use on the file bbit which creates a program out of main.c:
|
||||
./cbd clean build
|
||||
|
1
build_system_kit/noscript/bar.c
Normal file
1
build_system_kit/noscript/bar.c
Normal file
@ -0,0 +1 @@
|
||||
int bar = 4434;
|
1
build_system_kit/noscript/bar.h
Normal file
1
build_system_kit/noscript/bar.h
Normal file
@ -0,0 +1 @@
|
||||
|
8
build_system_kit/noscript/create_it.sh
Executable file
8
build_system_kit/noscript/create_it.sh
Executable file
@ -0,0 +1,8 @@
|
||||
# /bin/bash
|
||||
|
||||
D=$PWD
|
||||
pushd ../..
|
||||
./waf-light configure build --tools=$D/dbdlib.py --prelude=$'\tfrom waflib.extras import dbdlib\n\tdbdlib.start(cwd, VERSION, wafdir)\n\tsys.exit(0)'
|
||||
popd
|
||||
cp ../../waf dbd
|
||||
|
134
build_system_kit/noscript/dbdlib.py
Normal file
134
build_system_kit/noscript/dbdlib.py
Normal file
@ -0,0 +1,134 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import os, sys, imp
|
||||
from waflib import Context, Options, Configure, Utils, Logs, TaskGen, Task
|
||||
import waflib.Tools.c
|
||||
|
||||
"""
|
||||
Compile main.c and dependent object files into a single target (program/shlib/stlib or just object files)
|
||||
|
||||
- no build directory and no script files
|
||||
- just a c4che directory for the configuration files
|
||||
- configure, clean or build
|
||||
|
||||
Uses the task signatures and the dependency calculation results to avoid
|
||||
rescanning/rebuilding the files all the time
|
||||
"""
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('--type', action='store', default='program', help='type: program, shlib, stlib, objects', dest='progtype')
|
||||
opt.add_option('--source', action='store', default='main.c', help='space-separated list of source files', dest='source')
|
||||
opt.add_option('--app', action='store', default='app', help='name of the binary file to create', dest='app')
|
||||
opt.load('compiler_c')
|
||||
|
||||
def configure(conf):
|
||||
conf.options = Options.options
|
||||
conf.load('compiler_c')
|
||||
|
||||
def build(bld):
|
||||
tp = Options.options.progtype
|
||||
features = 'c cprogram'
|
||||
if tp == 'shlib':
|
||||
features = 'c cshlib'
|
||||
elif tp == 'stlib':
|
||||
features = 'c cstlib'
|
||||
elif tp == 'objects':
|
||||
features = 'c'
|
||||
|
||||
source = Options.options.source
|
||||
app = Options.options.app
|
||||
bld(features=features, source=source, target=app)
|
||||
|
||||
def recurse_rep(x, y):
|
||||
f = getattr(Context.g_module, x.cmd or x.fun, Utils.nada)
|
||||
return f(x)
|
||||
|
||||
def start(cwd, version, wafdir):
|
||||
# this is the entry point of our small build system
|
||||
# no script file here
|
||||
Logs.init_log()
|
||||
Context.waf_dir = wafdir
|
||||
Context.out_dir = Context.top_dir = Context.run_dir = cwd
|
||||
Context.g_module = imp.new_module('wscript')
|
||||
Context.g_module.root_path = cwd
|
||||
Context.Context.recurse = recurse_rep
|
||||
|
||||
Context.g_module.configure = configure
|
||||
Context.g_module.build = build
|
||||
Context.g_module.options = options
|
||||
Context.g_module.top = Context.g_module.out = '.'
|
||||
|
||||
Options.OptionsContext().execute()
|
||||
|
||||
do_config = 'configure' in sys.argv
|
||||
try:
|
||||
os.stat(cwd + os.sep + 'c4che')
|
||||
except:
|
||||
do_config = True
|
||||
if do_config:
|
||||
Context.create_context('configure').execute()
|
||||
|
||||
if 'clean' in sys.argv:
|
||||
Context.create_context('clean').execute()
|
||||
|
||||
if 'build' in sys.argv:
|
||||
Context.create_context('build').execute()
|
||||
|
||||
|
||||
class c2(waflib.Tools.c.c):
|
||||
# Make a subclass of the default c task, and bind the .c extension to it
|
||||
|
||||
def runnable_status(self):
|
||||
ret = super(waflib.Tools.c.c, self).runnable_status()
|
||||
self.more_tasks = []
|
||||
|
||||
# use a cache to avoid creating the same tasks
|
||||
# for example, truc.cpp might be compiled twice
|
||||
try:
|
||||
shared = self.generator.bld.shared_tasks
|
||||
except AttributeError:
|
||||
shared = self.generator.bld.shared_tasks = {}
|
||||
|
||||
if ret != Task.ASK_LATER:
|
||||
for x in self.generator.bld.node_deps[self.uid()]:
|
||||
node = x.parent.get_src().find_resource(x.name.replace('.h', '.c'))
|
||||
if node:
|
||||
try:
|
||||
tsk = shared[node]
|
||||
except:
|
||||
tsk = shared[node] = self.generator.c_hook(node)
|
||||
|
||||
self.more_tasks.append(tsk)
|
||||
|
||||
# add the node created to the link task outputs
|
||||
try:
|
||||
link = self.generator.link_task
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
if not tsk.outputs[0] in link.inputs:
|
||||
link.inputs.append(tsk.outputs[0])
|
||||
link.set_run_after(tsk)
|
||||
|
||||
# any change in the order of the input nodes may cause a recompilation
|
||||
link.inputs.sort(key=lambda x: x.abspath())
|
||||
|
||||
# if you want to modify some flags
|
||||
# you *must* have the task recompute the signature
|
||||
self.env.append_value('CXXFLAGS', '-O2')
|
||||
delattr(self, 'cache_sig')
|
||||
return super(waflib.Tools.c.c, self).runnable_status()
|
||||
|
||||
return ret
|
||||
|
||||
@TaskGen.extension('.c')
|
||||
def c_hook(self, node):
|
||||
# re-bind the extension to this new class
|
||||
return self.create_compiled_task('c2', node)
|
||||
|
||||
# modify the existing class to output the targets in the same directory as the original files
|
||||
Task.update_outputs(c2)
|
||||
Task.update_outputs(waflib.Tools.c.cprogram)
|
||||
Task.update_outputs(waflib.Tools.c.cshlib)
|
||||
Task.update_outputs(waflib.Tools.c.cstlib)
|
||||
|
4
build_system_kit/noscript/foo.c
Normal file
4
build_system_kit/noscript/foo.c
Normal file
@ -0,0 +1,4 @@
|
||||
#include "foo.h"
|
||||
#include "bar.h"
|
||||
|
||||
int k = 334;
|
1
build_system_kit/noscript/foo.h
Normal file
1
build_system_kit/noscript/foo.h
Normal file
@ -0,0 +1 @@
|
||||
|
6
build_system_kit/noscript/main.c
Normal file
6
build_system_kit/noscript/main.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "foo.h"
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
printf("hello from app\n");
|
||||
return 0;
|
||||
}
|
21
build_system_kit/nostate/README.txt
Normal file
21
build_system_kit/nostate/README.txt
Normal file
@ -0,0 +1,21 @@
|
||||
Note from the author: using signatures is of course much better
|
||||
this example is for research purposes only
|
||||
|
||||
|
||||
In this example, no configuration will be written or read,
|
||||
and the build will only use timestamps (no cache files
|
||||
and no signatures). There is no build directory either.
|
||||
|
||||
To build, use "./ebd"
|
||||
|
||||
|
||||
Although the wscript file only declares a build function,
|
||||
the system performs a configuration internally to check for
|
||||
a C compiler. The configuration and build context classes are
|
||||
overridden to hide output messages and to avoid creating cache
|
||||
files.
|
||||
|
||||
The task class is monkey-patched so that all existing build tasks
|
||||
will execute without using signatures (only file timestamps are considered).
|
||||
Implicit dependencies such as headers are still computed automatically.
|
||||
|
5
build_system_kit/nostate/a.c
Normal file
5
build_system_kit/nostate/a.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include "a.h"
|
||||
|
||||
void test() {
|
||||
|
||||
}
|
1
build_system_kit/nostate/a.h
Normal file
1
build_system_kit/nostate/a.h
Normal file
@ -0,0 +1 @@
|
||||
void test();
|
8
build_system_kit/nostate/create_it.sh
Executable file
8
build_system_kit/nostate/create_it.sh
Executable file
@ -0,0 +1,8 @@
|
||||
# /bin/bash
|
||||
|
||||
D=$PWD
|
||||
pushd ../..
|
||||
./waf-light configure build --tools=$D/ebdlib.py --prelude=$'\tfrom waflib.extras import ebdlib\n\tebdlib.start(cwd, VERSION, wafdir)\n\tsys.exit(0)'
|
||||
popd
|
||||
cp ../../waf ebd
|
||||
|
131
build_system_kit/nostate/ebdlib.py
Normal file
131
build_system_kit/nostate/ebdlib.py
Normal file
@ -0,0 +1,131 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import os, sys, imp, time
|
||||
from waflib import Context, Options, Configure, Utils, Logs, TaskGen, Task, Build, ConfigSet
|
||||
import waflib.Tools.c
|
||||
|
||||
"""
|
||||
Create a modified waf file in which tasks use timestamps only
|
||||
see README.txt
|
||||
"""
|
||||
|
||||
# we hard-code a configuration for c but it could be left in the script file too
|
||||
def configure(conf):
|
||||
conf.load('gcc')
|
||||
|
||||
def recurse_rep(x, y):
|
||||
f = getattr(Context.g_module, x.cmd or x.fun, Utils.nada)
|
||||
return f(x)
|
||||
|
||||
def start(cwd, version, wafdir):
|
||||
# this is the entry point of our small build system
|
||||
|
||||
Logs.init_log()
|
||||
Context.waf_dir = wafdir
|
||||
Context.out_dir = Context.top_dir = Context.run_dir = cwd
|
||||
Context.g_module = Context.load_module(cwd + os.sep + 'wscript')
|
||||
Context.g_module.configure = configure
|
||||
Context.g_module.root_path = cwd
|
||||
Context.Context.recurse = recurse_rep
|
||||
|
||||
Context.g_module.top = Context.g_module.out = '.' # no build directory
|
||||
|
||||
# just parse the options and execute a build
|
||||
Options.OptionsContext().execute()
|
||||
|
||||
conf = Context.create_context('configure')
|
||||
conf.options = Options.options
|
||||
conf.execute()
|
||||
|
||||
bld = Context.create_context('build')
|
||||
bld.env = conf.env
|
||||
bld.options = Options.options
|
||||
bld.environ = os.environ
|
||||
bld.execute()
|
||||
|
||||
# change the build context so it does not need to write any file
|
||||
class StatelessBuild(Build.BuildContext):
|
||||
def load_envs(self):
|
||||
self.env = ConfigSet.ConfigSet()
|
||||
def store(self):
|
||||
pass
|
||||
def restore(self):
|
||||
self.init_dirs()
|
||||
def execute_build(self):
|
||||
# we override this method to hide the messages "leaving directory" (just because)
|
||||
self.recurse([self.run_dir])
|
||||
self.pre_build()
|
||||
|
||||
self.timer = Utils.Timer()
|
||||
|
||||
if Options.options.progress_bar:
|
||||
sys.stderr.write(Logs.colors.cursor_off)
|
||||
try:
|
||||
self.compile()
|
||||
finally:
|
||||
if Options.options.progress_bar:
|
||||
sys.stderr.write(Logs.colors.cursor_on)
|
||||
print('')
|
||||
self.post_build()
|
||||
|
||||
class SilentConf(Configure.ConfigurationContext):
|
||||
# silent configuration
|
||||
def __init__(self, **kw):
|
||||
# disable the configuration messages from Context.start_msg/end_msg
|
||||
self.in_msg = 1
|
||||
super(SilentConf, self).__init__(**kw)
|
||||
|
||||
def execute(self):
|
||||
|
||||
# copy-paste from the original method, but without the cache file creation
|
||||
self.init_dirs()
|
||||
|
||||
path = os.path.join(self.bldnode.abspath(), 'config.log')
|
||||
self.logger = Logs.make_logger(path, 'cfg')
|
||||
|
||||
app = getattr(Context.g_module, 'APPNAME', '')
|
||||
if app:
|
||||
ver = getattr(Context.g_module, 'VERSION', '')
|
||||
if ver:
|
||||
app = "%s (%s)" % (app, ver)
|
||||
|
||||
now = time.ctime()
|
||||
pyver = sys.hexversion
|
||||
systype = sys.platform
|
||||
args = " ".join(sys.argv)
|
||||
wafver = Context.WAFVERSION
|
||||
abi = Context.ABI
|
||||
self.to_log(Configure.conf_template % vars())
|
||||
|
||||
super(Configure.ConfigurationContext, self).execute()
|
||||
|
||||
|
||||
# change the superclass of existing tasks to force timestamps (the build has no state)
|
||||
def status(self):
|
||||
for t in self.run_after:
|
||||
if not t.hasrun:
|
||||
return Task.ASK_LATER
|
||||
|
||||
implicit_deps = []
|
||||
try:
|
||||
implicit_deps, _ = self.scan()
|
||||
except:
|
||||
pass
|
||||
|
||||
# we can add one more node, for example:
|
||||
implicit_deps.append(self.generator.path.make_node('wscript'))
|
||||
|
||||
for x in self.inputs + self.dep_nodes + implicit_deps:
|
||||
for y in self.outputs:
|
||||
try:
|
||||
if os.stat(x.abspath()).st_mtime > os.stat(y.abspath()).st_mtime:
|
||||
return Task.RUN_ME
|
||||
except:
|
||||
return Task.RUN_ME
|
||||
|
||||
return Task.SKIP_ME
|
||||
Task.Task.runnable_status = status
|
||||
|
||||
# the post build execution does not need to deal with signatures or anything else
|
||||
Task.Task.post_run = Utils.nada
|
||||
|
6
build_system_kit/nostate/main.c
Normal file
6
build_system_kit/nostate/main.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "a.h"
|
||||
|
||||
int main() {
|
||||
test();
|
||||
return 0;
|
||||
}
|
12
build_system_kit/nostate/wscript
Normal file
12
build_system_kit/nostate/wscript
Normal file
@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2010 (ita)
|
||||
|
||||
"""
|
||||
See README.txt
|
||||
"""
|
||||
|
||||
def build(bld):
|
||||
bld.program(source='main.c', target='app', use='mylib', cflags=['-O2'])
|
||||
bld.stlib(source='a.c', target='mylib')
|
||||
|
11
build_system_kit/overview/README.txt
Normal file
11
build_system_kit/overview/README.txt
Normal file
@ -0,0 +1,11 @@
|
||||
See the corresponding entry on the waf blog:
|
||||
http://waf-devel.blogspot.com/2010/12/make-your-own-build-system-with-waf.html
|
||||
|
||||
To create the build tool:
|
||||
./create_it.sh
|
||||
|
||||
To use on the file bbit which creates a program out of main.c:
|
||||
./bbd clean build
|
||||
|
||||
Enjoy your new build system! :-)
|
||||
|
39
build_system_kit/overview/bbdlib.py
Normal file
39
build_system_kit/overview/bbdlib.py
Normal file
@ -0,0 +1,39 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import os, sys, imp
|
||||
from waflib import Context, Options, Configure, Utils, Logs
|
||||
|
||||
def start(cwd, version, wafdir):
|
||||
# simple example, the file main.c is hard-coded
|
||||
try:
|
||||
os.stat(cwd + os.sep + 'bbit')
|
||||
except:
|
||||
print('call from a folder containing a file named "bbit"')
|
||||
sys.exit(1)
|
||||
|
||||
Logs.init_log()
|
||||
Context.waf_dir = wafdir
|
||||
Context.top_dir = Context.run_dir = cwd
|
||||
Context.out_dir = os.path.join(cwd, 'build')
|
||||
Context.g_module = imp.new_module('wscript')
|
||||
Context.g_module.root_path = os.path.join(cwd, 'bbit')
|
||||
Context.Context.recurse = \
|
||||
lambda x, y: getattr(Context.g_module, x.cmd or x.fun, Utils.nada)(x)
|
||||
|
||||
Context.g_module.configure = lambda ctx: ctx.load('g++')
|
||||
Context.g_module.build = lambda bld: bld.objects(source='main.c')
|
||||
|
||||
Options.OptionsContext().execute()
|
||||
|
||||
do_config = 'configure' in sys.argv
|
||||
try:
|
||||
os.stat(cwd + os.sep + 'build')
|
||||
except:
|
||||
do_config = True
|
||||
if do_config:
|
||||
Context.create_context('configure').execute()
|
||||
|
||||
if 'clean' in sys.argv:
|
||||
Context.create_context('clean').execute()
|
||||
if 'build' in sys.argv:
|
||||
Context.create_context('build').execute()
|
1
build_system_kit/overview/bbit
Normal file
1
build_system_kit/overview/bbit
Normal file
@ -0,0 +1 @@
|
||||
# empty file (for now)
|
8
build_system_kit/overview/create_it.sh
Executable file
8
build_system_kit/overview/create_it.sh
Executable file
@ -0,0 +1,8 @@
|
||||
# /bin/bash
|
||||
|
||||
D=$PWD
|
||||
pushd ../..
|
||||
./waf-light configure build --tools=$D/bbdlib.py --prelude=$'\tfrom waflib.extras import bbdlib\n\tbbdlib.start(cwd, VERSION, wafdir)\n\tsys.exit(0)'
|
||||
popd
|
||||
cp ../../waf bbd
|
||||
|
3
build_system_kit/overview/main.c
Normal file
3
build_system_kit/overview/main.c
Normal file
@ -0,0 +1,3 @@
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
11
build_system_kit/parser/README.txt
Normal file
11
build_system_kit/parser/README.txt
Normal file
@ -0,0 +1,11 @@
|
||||
This example derives from the 'overview' and demonstrates how to provide
|
||||
a parser for a make-like language.
|
||||
|
||||
The script files read are named 'cbit'
|
||||
|
||||
To create the build tool:
|
||||
./create_it.sh
|
||||
|
||||
To use on the file cbit which creates a program out of main.c:
|
||||
./cbd clean build
|
||||
|
73
build_system_kit/parser/cbdlib.py
Normal file
73
build_system_kit/parser/cbdlib.py
Normal file
@ -0,0 +1,73 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import os, sys, imp, re
|
||||
from waflib import Context, Options, Configure, Utils, Logs
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_c')
|
||||
|
||||
def configure(conf):
|
||||
conf.options = Options.options
|
||||
conf.load('compiler_c')
|
||||
|
||||
|
||||
re_com = re.compile("#.*$", re.M)
|
||||
def build(bld):
|
||||
txt = bld.path.find_node('cbit').read()
|
||||
txt = re_com.sub('', txt)
|
||||
|
||||
tg = None
|
||||
for x in txt.splitlines():
|
||||
if not x:
|
||||
continue
|
||||
elif x.startswith('\t') or x.startswith(' '):
|
||||
tg.rule = x.lstrip()
|
||||
else:
|
||||
line = x.split(':')
|
||||
tgt = line[0].lstrip()
|
||||
src = line[1].lstrip()
|
||||
tg = bld()
|
||||
if src:
|
||||
tg.source = src
|
||||
if tgt:
|
||||
tg.target = tgt
|
||||
|
||||
def recurse_rep(x, y):
|
||||
f = getattr(Context.g_module, x.cmd or x.fun, Utils.nada)
|
||||
return f(x)
|
||||
|
||||
def start(cwd, version, wafdir):
|
||||
# simple example, the file main.c is hard-coded
|
||||
try:
|
||||
os.stat(cwd + os.sep + 'cbit')
|
||||
except:
|
||||
print('call from a folder containing a file named "cbit"')
|
||||
sys.exit(1)
|
||||
|
||||
Logs.init_log()
|
||||
Context.waf_dir = wafdir
|
||||
Context.top_dir = Context.run_dir = cwd
|
||||
Context.out_dir = os.path.join(cwd, 'build')
|
||||
Context.g_module = imp.new_module('wscript')
|
||||
Context.g_module.root_path = os.path.join(cwd, 'cbit')
|
||||
Context.Context.recurse = recurse_rep
|
||||
|
||||
# this is a fake module, which looks like a standard wscript file
|
||||
Context.g_module.options = options
|
||||
Context.g_module.configure = configure
|
||||
Context.g_module.build = build
|
||||
|
||||
Options.OptionsContext().execute()
|
||||
|
||||
do_config = 'configure' in sys.argv
|
||||
try:
|
||||
os.stat(cwd + os.sep + 'build')
|
||||
except:
|
||||
do_config = True
|
||||
if do_config:
|
||||
Context.create_context('configure').execute()
|
||||
|
||||
if 'clean' in sys.argv:
|
||||
Context.create_context('clean').execute()
|
||||
if 'build' in sys.argv:
|
||||
Context.create_context('build').execute()
|
5
build_system_kit/parser/cbit
Normal file
5
build_system_kit/parser/cbit
Normal file
@ -0,0 +1,5 @@
|
||||
# a non-python file format (why not?)
|
||||
# just call "./cbd build"
|
||||
foo.txt: cbit
|
||||
cp ../cbit foo.txt
|
||||
|
8
build_system_kit/parser/create_it.sh
Executable file
8
build_system_kit/parser/create_it.sh
Executable file
@ -0,0 +1,8 @@
|
||||
# /bin/bash
|
||||
|
||||
D=$PWD
|
||||
pushd ../..
|
||||
./waf-light configure build --tools=$D/cbdlib.py --prelude=$'\tfrom waflib.extras import cbdlib\n\tcbdlib.start(cwd, VERSION, wafdir)\n\tsys.exit(0)'
|
||||
popd
|
||||
cp ../../waf cbd
|
||||
|
3
build_system_kit/parser/main.c
Normal file
3
build_system_kit/parser/main.c
Normal file
@ -0,0 +1,3 @@
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
119
configure
vendored
Executable file
119
configure
vendored
Executable file
@ -0,0 +1,119 @@
|
||||
#! /bin/sh
|
||||
|
||||
# waf configure wrapper
|
||||
|
||||
# Fancy colors used to beautify the output a bit.
|
||||
#
|
||||
if [ "$NOCOLOR" ] ; then
|
||||
NORMAL=""
|
||||
BOLD=""
|
||||
RED=""
|
||||
YELLOW=""
|
||||
GREEN=""
|
||||
else
|
||||
NORMAL='\033[0m'
|
||||
BOLD='\033[01;1m'
|
||||
RED='\033[01;91m'
|
||||
YELLOW='\033[00;33m'
|
||||
GREEN='\033[01;92m'
|
||||
fi
|
||||
|
||||
EXIT_SUCCESS=0
|
||||
EXIT_FAILURE=1
|
||||
EXIT_ERROR=2
|
||||
EXIT_BUG=10
|
||||
|
||||
CUR_DIR=$PWD
|
||||
|
||||
#possible relative path
|
||||
WORKINGDIR=`dirname $0`
|
||||
cd $WORKINGDIR
|
||||
#abs path
|
||||
WORKINGDIR=`pwd`
|
||||
cd $CUR_DIR
|
||||
|
||||
|
||||
# Checks for WAF. Honours $WAF if set. Stores path to 'waf' in $WAF.
|
||||
# Requires that $PYTHON is set.
|
||||
#
|
||||
checkWAF()
|
||||
{
|
||||
printf "Checking for WAF\t\t\t: "
|
||||
#installed miniwaf in sourcedir
|
||||
if [ -z "$WAF" ] ; then
|
||||
if [ -f "${WORKINGDIR}/waf" ] ; then
|
||||
WAF="${WORKINGDIR}/waf"
|
||||
if [ ! -x "$WAF" ] ; then
|
||||
chmod +x $WAF
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -z "$WAF" ] ; then
|
||||
if [ -f "${WORKINGDIR}/waf-light" ] ; then
|
||||
${WORKINGDIR}/waf-light --make-waf
|
||||
WAF="${WORKINGDIR}/waf"
|
||||
fi
|
||||
fi
|
||||
#global installed waf with waf->waf.py link
|
||||
if [ -z "$WAF" ] ; then
|
||||
WAF=`which waf 2>/dev/null`
|
||||
fi
|
||||
# neither waf nor miniwaf could be found
|
||||
if [ ! -x "$WAF" ] ; then
|
||||
printf "$RED""not found""$NORMAL""\n"
|
||||
echo "Go to http://code.google.com/p/waf/"
|
||||
echo "and download a waf version"
|
||||
exit $EXIT_FAILURE
|
||||
else
|
||||
printf "$GREEN""$WAF""$NORMAL""\n"
|
||||
fi
|
||||
}
|
||||
|
||||
# Generates a Makefile. Requires that $WAF is set.
|
||||
#
|
||||
generateMakefile()
|
||||
{
|
||||
cat > Makefile << EOF
|
||||
#!/usr/bin/make -f
|
||||
# Waf Makefile wrapper
|
||||
WAF_HOME=$CUR_DIR
|
||||
|
||||
all:
|
||||
#@$WAF build
|
||||
|
||||
all-debug:
|
||||
@$WAF -v build
|
||||
|
||||
all-progress:
|
||||
@$WAF -p build
|
||||
|
||||
install:
|
||||
$WAF install --yes;
|
||||
|
||||
uninstall:
|
||||
$WAF uninstall
|
||||
|
||||
clean:
|
||||
@$WAF clean
|
||||
|
||||
distclean:
|
||||
@$WAF distclean
|
||||
@-rm -rf build
|
||||
@-rm -f Makefile
|
||||
|
||||
check:
|
||||
@$WAF check
|
||||
|
||||
dist:
|
||||
@$WAF dist
|
||||
|
||||
.PHONY: clean dist distclean check uninstall install all
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
checkWAF
|
||||
generateMakefile
|
||||
|
||||
"${WAF}" configure $*
|
||||
exit $?
|
10
demos/asm/main.c
Normal file
10
demos/asm/main.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int mult10(int);
|
||||
|
||||
int main()
|
||||
{
|
||||
int asm_val = mult10(2);
|
||||
printf("From ASM: %d\n", asm_val);
|
||||
return 0;
|
||||
}
|
14
demos/asm/test.S
Normal file
14
demos/asm/test.S
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
.text
|
||||
.align 2
|
||||
|
||||
val:
|
||||
.long 10
|
||||
|
||||
# Multiply input value by 10...
|
||||
.global mult10
|
||||
.type mult10, function
|
||||
mult10:
|
||||
movl val,%eax
|
||||
imul 4(%esp),%eax
|
||||
ret
|
12
demos/asm/wscript
Normal file
12
demos/asm/wscript
Normal file
@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
def configure(conf):
|
||||
conf.load('gcc gas')
|
||||
|
||||
def build(bld):
|
||||
# http://waf.googlecode.com/svn/docs/apidocs/tools/asm.html
|
||||
bld.program(
|
||||
source = 'main.c test.S',
|
||||
target = 'asmtest')
|
||||
|
13
demos/bisonflex/calc.l
Normal file
13
demos/bisonflex/calc.l
Normal file
@ -0,0 +1,13 @@
|
||||
%{
|
||||
#define YYSTYPE double
|
||||
#include "calc.tab.h"
|
||||
extern YYSTYPE yylval;
|
||||
%}
|
||||
|
||||
%%
|
||||
[0-9]+\.?[0-9]* { yylval = atof( yytext ); return NUMBER; };
|
||||
[ \t] ; /* ignore whitespace */
|
||||
\n { return yytext[0]; };
|
||||
. { return yytext[0]; }
|
||||
<<EOF>> { printf("eof\n"); return 0; };
|
||||
%%
|
33
demos/bisonflex/calc.y
Normal file
33
demos/bisonflex/calc.y
Normal file
@ -0,0 +1,33 @@
|
||||
%{
|
||||
#define YYSTYPE double
|
||||
#include <stdio.h>
|
||||
// yylex() is generated by flex
|
||||
int yylex(void);
|
||||
// we have to define yyerror()
|
||||
int yyerror (char const *);
|
||||
|
||||
%}
|
||||
%token NUMBER
|
||||
|
||||
%left '+' '-'
|
||||
%left '*' '/'
|
||||
%right '('
|
||||
|
||||
%%
|
||||
stmtlist: statement '\n' stmtlist {
|
||||
printf("done with statement equal to [%g]\n", $1);
|
||||
} | // EMPTY RULE i.e. stmtlist -> nil
|
||||
{ printf("DONE\n") ;};
|
||||
|
||||
statement: expression { printf("VALUE=%g\n",$1); };
|
||||
|
||||
expression: expression '+' expression { $$ = $1 + $3; } |
|
||||
expression '-' expression { $$ = $1 - $3; } |
|
||||
expression '*' expression { $$ = $1 * $3; } |
|
||||
expression '/' expression {
|
||||
if($3 !=0) { $$ = $1 / $3; } else
|
||||
{ printf("div by zero\n"); $$=0;} } |
|
||||
'(' expression ')' { $$ = $2; } |
|
||||
NUMBER { $$ = $1; } ;
|
||||
|
||||
%%
|
24
demos/bisonflex/main.c
Normal file
24
demos/bisonflex/main.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
/* this file should work in both c and c++ */
|
||||
extern int yyparse();
|
||||
|
||||
int yyerror (char const *a)
|
||||
{
|
||||
printf("yyerror: (%s)\n", a);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int yy;
|
||||
yy = yyparse();
|
||||
if (yy != 0)
|
||||
{
|
||||
printf("Syntax or parse error %i. Aborting.\n", yy);
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
printf("Success.\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
26
demos/bisonflex/wscript
Normal file
26
demos/bisonflex/wscript
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_c')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_c flex bison')
|
||||
conf.env.LIB_CALC = ['fl']
|
||||
|
||||
def build(bld):
|
||||
tg = bld(
|
||||
features = 'c cprogram',
|
||||
source = 'calc.l calc.y main.c',
|
||||
target = 'calc',
|
||||
use = 'CALC')
|
||||
|
||||
# to compile in c++ mode change to:
|
||||
# features= 'cxx cxxprogram'
|
||||
# and add:
|
||||
# import waflib.Tools.cxx as cxx
|
||||
# tg.mappings['.c'] = cxx.cxx_hook
|
||||
|
||||
# re-use the files for other targets:
|
||||
# bld(features='c cshlib', source='calc.tab.c calc.lex.c', use='CALC', target='hmm')
|
||||
|
13
demos/c++/a.cpp
Normal file
13
demos/c++/a.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define testshlib_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
# define testshlib_EXPORT
|
||||
#endif
|
||||
|
||||
extern testshlib_EXPORT void foo();
|
||||
|
||||
static const int truc=5;
|
||||
|
||||
void foo() { }
|
||||
|
1
demos/c++/b.cpp
Normal file
1
demos/c++/b.cpp
Normal file
@ -0,0 +1 @@
|
||||
int u = 64;
|
3
demos/c++/main.c
Normal file
3
demos/c++/main.c
Normal file
@ -0,0 +1,3 @@
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
8
demos/c++/main.cpp
Normal file
8
demos/c++/main.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <iostream>
|
||||
|
||||
extern void foo();
|
||||
|
||||
int main() {
|
||||
foo();
|
||||
return 0;
|
||||
}
|
33
demos/c++/wscript
Normal file
33
demos/c++/wscript
Normal file
@ -0,0 +1,33 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2006-2010 (ita)
|
||||
|
||||
# the following two variables are used by the target "waf dist"
|
||||
VERSION='0.0.1'
|
||||
APPNAME='cxx_test'
|
||||
|
||||
# these variables are mandatory ('/' are converted automatically)
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx')
|
||||
conf.check(header_name='stdio.h', features='cxx cxxprogram', mandatory=False)
|
||||
|
||||
def build(bld):
|
||||
bld.shlib(source='a.cpp', target='mylib', vnum='9.8.7')
|
||||
bld.program(source='main.cpp', target='app', use='mylib')
|
||||
bld.stlib(target='foo', source='b.cpp')
|
||||
|
||||
# just a test to check if the .c is compiled as c++ when no c compiler is found
|
||||
bld.program(features='cxx cxxprogram', source='main.c', target='app2')
|
||||
|
||||
if bld.cmd != 'clean':
|
||||
from waflib import Logs
|
||||
bld.logger = Logs.make_logger('test.log', 'build') # just to get a clean output
|
||||
bld.check(header_name='sadlib.h', features='cxx cxxprogram', mandatory=False)
|
||||
bld.logger = None
|
||||
|
1
demos/c/program/a.h
Normal file
1
demos/c/program/a.h
Normal file
@ -0,0 +1 @@
|
||||
int k = 123;
|
9
demos/c/program/main.c
Normal file
9
demos/c/program/main.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include "a.h"
|
||||
#include "b.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "abc.h"
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
36
demos/c/program/wscript_build
Normal file
36
demos/c/program/wscript_build
Normal file
@ -0,0 +1,36 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
def write_header(tsk):
|
||||
tsk.outputs[0].write('int abc = 423;')
|
||||
bld(rule=write_header, target='b.h', ext_out=['.h'])
|
||||
|
||||
bld.program(
|
||||
features = 'aaa',
|
||||
source = 'main.c',
|
||||
includes = '. ..',
|
||||
cflags = ['-O3'],
|
||||
defines = ['foo=bar'],
|
||||
target = 'myprogram',
|
||||
use = 'M')
|
||||
|
||||
# make main.c depend on wscript_build, just for the fun of it
|
||||
bld.add_manual_dependency('main.c', bld.path.find_resource('wscript_build'))
|
||||
|
||||
# ----------------------------------------
|
||||
|
||||
from waflib import TaskGen
|
||||
@TaskGen.feature('aaa')
|
||||
@TaskGen.before('apply_link')
|
||||
def add_one_task(self):
|
||||
"""this is a task generator method, it is bound to the feature 'aaa' """
|
||||
tsk = self.create_task('foo')
|
||||
tsk.outputs = [self.bld.path.find_or_declare('abc.h')]
|
||||
|
||||
import waflib.Task
|
||||
class foo(waflib.Task.Task):
|
||||
"""this is a task class"""
|
||||
before = ['c']
|
||||
color = 'BLUE'
|
||||
def run(self):
|
||||
self.outputs[0].write('int kik = 343;\n')
|
||||
|
2
demos/c/shlib/foo.def
Normal file
2
demos/c/shlib/foo.def
Normal file
@ -0,0 +1,2 @@
|
||||
EXPORTS
|
||||
foo
|
8
demos/c/shlib/main.c
Normal file
8
demos/c/shlib/main.c
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
extern void foo();
|
||||
|
||||
int main()
|
||||
{
|
||||
foo();
|
||||
return 0;
|
||||
}
|
5
demos/c/shlib/test_shlib.c
Normal file
5
demos/c/shlib/test_shlib.c
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
static const int truc=5;
|
||||
|
||||
void foo() { }
|
||||
void _internal() {} /* this one is not gonna be exported by *.def */
|
44
demos/c/shlib/wscript_build
Normal file
44
demos/c/shlib/wscript_build
Normal file
@ -0,0 +1,44 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
bld.shlib(
|
||||
source = 'test_shlib.c',
|
||||
target = 'my_shared_lib',
|
||||
vnum = '1.2.3',
|
||||
defs = 'foo.def')
|
||||
|
||||
|
||||
t = bld.program(
|
||||
#features = 'my_precious',
|
||||
source = 'main.c',
|
||||
target = 'test_shared_link',
|
||||
use = 'my_shared_lib',
|
||||
# 1. settings flags directly
|
||||
#linkflags = ['-L/disk/comp/waf/demos/c/build/shlib', '-lmy_shared_lib']
|
||||
)
|
||||
# 2. another way of setting flags
|
||||
#t.env.linkflags = ['-L/disk/comp/waf/demos/c/build/shlib', '-lmy_shared_lib']
|
||||
|
||||
# 3. advanced flag control through 'feature' methods (standard practice when 1. or 2. is not enough)
|
||||
#import sys
|
||||
#from waflib import TaskGen
|
||||
#@TaskGen.feature('my_precious')
|
||||
#@TaskGen.after_method('apply_link', 'propagate_uselib_vars')
|
||||
#def set_flags(self):
|
||||
# if sys.platform == 'linux2':
|
||||
# self.link_task.env.LINKFLAGS = ['-Lshlib', '--whole-archive', '-lmy_shared_lib']
|
||||
# self.link_task.env.LIB = []
|
||||
# self.link_task.env.STLIB = []
|
||||
# self.link_task.env.STLIB_MARKER = []
|
||||
|
||||
# 4. changing the class - setting flags such as LINKFLAGS_cshlib is usually a much better idea
|
||||
#from waflib.Utils import run_once
|
||||
#from waflib.Tools.c import cprogram
|
||||
#class cprogram(cprogram):
|
||||
# def runnable_status(self):
|
||||
# self.set_flags()
|
||||
# self.set_flags() # just to see
|
||||
# return super(cprogram, self).runnable_status()
|
||||
# @run_once
|
||||
# def set_flags(self):
|
||||
# self.env.append_value('LINKFLAGS', ['-g'])
|
||||
|
7
demos/c/stlib/main.c
Normal file
7
demos/c/stlib/main.c
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
#include "foo.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
2
demos/c/stlib/test_staticlib.c
Normal file
2
demos/c/stlib/test_staticlib.c
Normal file
@ -0,0 +1,2 @@
|
||||
int k = 3;
|
||||
|
18
demos/c/stlib/wscript_build
Normal file
18
demos/c/stlib/wscript_build
Normal file
@ -0,0 +1,18 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
bld.stlib(
|
||||
source = 'test_staticlib.c',
|
||||
target = 'my_static_lib')
|
||||
|
||||
bld.program(
|
||||
source = 'main.c',
|
||||
target = 'test_static_link',
|
||||
includes = '.',
|
||||
use = 'my_static_lib')
|
||||
|
||||
def r1(self):
|
||||
import time
|
||||
time.sleep(1)
|
||||
self.outputs[0].write(' ')
|
||||
bld(rule=r1, target='foo.h') # when in doubt, add before=['c', 'cxx']
|
||||
|
98
demos/c/wscript
Normal file
98
demos/c/wscript
Normal file
@ -0,0 +1,98 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2006-2010 (ita)
|
||||
|
||||
# the following two variables are used by the target "waf dist"
|
||||
VERSION='0.0.1'
|
||||
APPNAME='cc_test'
|
||||
|
||||
top = '.'
|
||||
|
||||
import waflib.Configure
|
||||
#waflib.Configure.autoconfig = True
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_c')
|
||||
opt.load('gnu_dirs')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_c')
|
||||
conf.check_cc(fragment="int main() { return 0; }\n")
|
||||
conf.check_cc(fragment="int main() { return 0; }\n", execute=True)
|
||||
conf.check_cc(fragment="""#include<stdio.h>\nint main(){fprintf(stderr, "mu"); printf("%d", 22);return 0;}\n""", execute=True, define_name='HAVE_MU')
|
||||
conf.check_cc(lib='m', cflags='-Wall', defines=['var=foo', 'x=y'], uselib_store='M', mandatory=False)
|
||||
|
||||
conf.check_large_file(mandatory=False)
|
||||
conf.check_inline()
|
||||
conf.check_library()
|
||||
|
||||
conf.multicheck(
|
||||
{'header_name':'stdio.h'},
|
||||
{'header_name':'unistd.h'},
|
||||
{'header_name':'stdlib.h'},
|
||||
msg = 'Checking for standard headers',
|
||||
mandatory = False
|
||||
)
|
||||
conf.check_cc(header_name='stdio.h', auto_add_header_name=True)
|
||||
#conf.check_cc(header_name='unistd.h')
|
||||
conf.check_cc(fragment='int main() {return 0;}\n')
|
||||
conf.write_config_header('config.h')
|
||||
|
||||
# exclude system libraries, force a particular folder (see strictlib below)
|
||||
#conf.check(features='c cprogram strictlib', lib = 'gif', libpath = ['/opt/lib'])
|
||||
|
||||
def build(bld):
|
||||
bld.env.DEFINES=['WAF=1']
|
||||
|
||||
bld.recurse('program stlib shlib')
|
||||
#bld.install_files('/tmp/foo', 'wscript')
|
||||
#bld.env.PREFIX='/tmp/foo'
|
||||
bld.install_files('${PREFIX}/', 'program/a.h program/main.c', relative_trick=False)
|
||||
bld.install_as('${PREFIX}/gnigni.txt', 'wscript')
|
||||
bld.symlink_as('${PREFIX}/libfoo.so', 'wscript')
|
||||
|
||||
bld.env.FOO =['m', 'ncurses']
|
||||
bld.env.ST = '-L%s'
|
||||
bld(rule='echo ${ST:FOO}', always=True, shell=1)
|
||||
|
||||
# illustrate how to add a command 'foo' and to execute things in it
|
||||
if bld.cmd == 'foo':
|
||||
def bar(bld):
|
||||
print('myprogram exit status is',
|
||||
bld.exec_command(bld.get_tgen_by_name('myprogram').link_task.outputs[0].abspath()))
|
||||
bld.add_post_fun(bar)
|
||||
#bld(rule='echo ${SRC} ${tsk.generator.newsize}', newsize='256x256', source='wscript')
|
||||
|
||||
# command examples
|
||||
|
||||
from waflib.Build import BuildContext
|
||||
class foo_class(BuildContext):
|
||||
cmd = 'foo'
|
||||
|
||||
from waflib.Context import Context
|
||||
class package_class(Context):
|
||||
"""just a test, try calling 'waf package' """
|
||||
cmd = 'package'
|
||||
fun = 'package'
|
||||
|
||||
def package(ctx):
|
||||
print('just a test', ctx.path.ant_glob('wscript'))
|
||||
|
||||
# and a task generator method example
|
||||
|
||||
from waflib import TaskGen
|
||||
@TaskGen.feature('strictlib')
|
||||
def check_lib_in_libpath(self):
|
||||
#For use in a configuration check: raise an exception
|
||||
#if the library file does not exist in the folders pointed by 'libpath'
|
||||
pths = self.to_list(getattr(self, 'libpath', []))
|
||||
if pths:
|
||||
for l in self.to_list(Utils.to_list(getattr(self, 'lib', []))):
|
||||
for x in pths:
|
||||
names = Utils.listdir(x)
|
||||
lname = self.env.cshlib_PATTERN % l
|
||||
if lname in names:
|
||||
break
|
||||
else:
|
||||
self.bld.fatal('wrong path for the library %s' % l)
|
||||
|
11
demos/csharp/Dye.cs
Normal file
11
demos/csharp/Dye.cs
Normal file
@ -0,0 +1,11 @@
|
||||
public class Dye {
|
||||
private string msg = "";
|
||||
|
||||
public Dye(string _msg) {
|
||||
msg = _msg;
|
||||
}
|
||||
|
||||
public void display() {
|
||||
System.Console.WriteLine(msg);
|
||||
}
|
||||
}
|
15
demos/csharp/Hi.cs
Normal file
15
demos/csharp/Hi.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace MyApp
|
||||
{
|
||||
using System;
|
||||
|
||||
public class Hi
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
My fu = new My("Hello there");
|
||||
fu.display();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
demos/csharp/My.cs
Normal file
11
demos/csharp/My.cs
Normal file
@ -0,0 +1,11 @@
|
||||
public class My {
|
||||
private Dye foo;
|
||||
|
||||
public My(string msg) {
|
||||
foo = new Dye(msg);
|
||||
}
|
||||
|
||||
public void display() {
|
||||
foo.display();
|
||||
}
|
||||
}
|
37
demos/csharp/Simple.cs
Normal file
37
demos/csharp/Simple.cs
Normal file
@ -0,0 +1,37 @@
|
||||
// taken from the gtk# samples
|
||||
namespace MyApp
|
||||
{
|
||||
using Gtk;
|
||||
using System;
|
||||
|
||||
public class Simple
|
||||
{
|
||||
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
Application.Init();
|
||||
Window win = new Window("Simple gtk# app");
|
||||
win.DefaultWidth = 300;
|
||||
win.DefaultHeight = 300;
|
||||
win.DeleteEvent += new DeleteEventHandler(Window_Delete);
|
||||
Button btn = new Button("Simple button");
|
||||
btn.Clicked += new EventHandler(print_line);
|
||||
win.Add(btn);
|
||||
win.ShowAll();
|
||||
Application.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void print_line(object obj, EventArgs args)
|
||||
{
|
||||
Console.WriteLine("Simple button was clicked!");
|
||||
}
|
||||
|
||||
static void Window_Delete(object obj, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit();
|
||||
args.RetVal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
38
demos/csharp/wscript
Normal file
38
demos/csharp/wscript
Normal file
@ -0,0 +1,38 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2010 (ita)
|
||||
|
||||
FRAG = '''
|
||||
namespace Moo {
|
||||
public class Test {
|
||||
public static int Main(string[] args) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
def options(opt):
|
||||
opt.load('cs')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('cs')
|
||||
try:
|
||||
conf.check(features='cs', fragment=FRAG, compile_filename='test.cs', gen='test.exe',
|
||||
csflags=['-pkg:gtk-sharp-2.0'], msg='Checking for Gtksharp support')
|
||||
conf.env.HAS_GTKSHARP = True
|
||||
except:
|
||||
conf.env.HAS_GTKSHARP = False
|
||||
|
||||
def build(bld):
|
||||
|
||||
# for system libraries, use:
|
||||
#bld.read_csshlib('ManagedLibrary.dll', paths=[bld.env.mylibrarypath])
|
||||
|
||||
bld(features='cs', source='My.cs Dye.cs', gen='my.dll', name='mylib', csdebug='full')
|
||||
bld(features='cs', source='Hi.cs', includes='.', gen='hi.exe', use='mylib', name='hi')
|
||||
if bld.env.HAS_GTKSHARP:
|
||||
bld(features='cs', source='Simple.cs', includes='.', gen='mono-hello.exe', csflags=['-pkg:gtk-sharp-2.0'])
|
||||
|
||||
# note:
|
||||
# bld(features='cs', ..., type='module' # or exe, library, winexe, ...
|
35
demos/d/example.d
Normal file
35
demos/d/example.d
Normal file
@ -0,0 +1,35 @@
|
||||
module abc.
|
||||
def. gh;
|
||||
|
||||
import std.stdio; // for writefln()
|
||||
import std . // system2;
|
||||
system ;
|
||||
static import std.date, std.thread /+ /+ +/ , std.io +/ ;
|
||||
|
||||
import testlib.code;
|
||||
|
||||
int main(string[] args) // string is a type alias for const(char)[]
|
||||
{
|
||||
// Declare an associative array with string keys and
|
||||
// arrays of strings as data
|
||||
char[][] [char[]] container;
|
||||
|
||||
int result = test_lib();
|
||||
|
||||
|
||||
// Add some people to the container and let them carry some items
|
||||
container["Anya"] ~= cast(char[]) "scarf";
|
||||
container["Dimitri"] ~= cast(char[]) "tickets";
|
||||
container["Anya"] ~= cast(char[]) "puppy";
|
||||
|
||||
// Iterate over all the persons in the container
|
||||
foreach (const(char)[] person, char[][] items; container)
|
||||
display_item_count(cast(char[]) person, items);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void display_item_count(char[] person, char[][] items)
|
||||
{
|
||||
writefln(person, " is carrying ", items.length, " items");
|
||||
}
|
||||
|
7
demos/d/foo.d
Normal file
7
demos/d/foo.d
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
import hmm;
|
||||
int main() {
|
||||
gnaa();
|
||||
const char[] MakePrintOther = "\"\n" ~ " no ' ";
|
||||
return 0;
|
||||
}
|
3
demos/d/hmm.d
Normal file
3
demos/d/hmm.d
Normal file
@ -0,0 +1,3 @@
|
||||
int gnaa() {
|
||||
return 42;
|
||||
}
|
7
demos/d/src/extra.d
Normal file
7
demos/d/src/extra.d
Normal file
@ -0,0 +1,7 @@
|
||||
module extra;
|
||||
|
||||
char[] abc()
|
||||
{
|
||||
return cast(char[])"abc";
|
||||
}
|
||||
|
10
demos/d/src/main.d
Normal file
10
demos/d/src/main.d
Normal file
@ -0,0 +1,10 @@
|
||||
module main;
|
||||
import extra;
|
||||
import std.stdio;
|
||||
|
||||
int main()
|
||||
{
|
||||
writefln("%s", abc());
|
||||
return 0;
|
||||
}
|
||||
|
5
demos/d/src/wscript_build
Normal file
5
demos/d/src/wscript_build
Normal file
@ -0,0 +1,5 @@
|
||||
obj = bld(features='d dprogram')
|
||||
obj.source = 'main.d extra.d'
|
||||
obj.target = 'test2'
|
||||
obj.importpaths = '.'
|
||||
|
6
demos/d/testlib/code.d
Normal file
6
demos/d/testlib/code.d
Normal file
@ -0,0 +1,6 @@
|
||||
module testlib.code;
|
||||
|
||||
int test_lib()
|
||||
{
|
||||
return 125;
|
||||
}
|
55
demos/d/wscript
Normal file
55
demos/d/wscript
Normal file
@ -0,0 +1,55 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2006 (ita)
|
||||
|
||||
VERSION='0.0.1'
|
||||
APPNAME='d_test'
|
||||
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_d')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_d')
|
||||
conf.env.LIB_PTHREAD = ['pthread']
|
||||
conf.check_dlibrary()
|
||||
try:
|
||||
conf.check(features='d dprogram', fragment='int main() {return 0;}', compile_filename='test.d', dflags=['-version=Posix'])
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
conf.env.append_value('DFLAGS', ['-version=Posix'])
|
||||
|
||||
def build(bld):
|
||||
|
||||
if bld.env.DLIBRARY != 'tango':
|
||||
bld.recurse('src')
|
||||
|
||||
# here is how to use the object-oriented notation
|
||||
bld.stlib(
|
||||
source = 'testlib/code.d',
|
||||
includes = '.',
|
||||
name = 'testlib',
|
||||
target = 'testlib')
|
||||
|
||||
bld.program(
|
||||
source = 'example.d',
|
||||
target = 'd_test',
|
||||
use = 'testlib PTHREAD',
|
||||
includes = '.')
|
||||
|
||||
else:
|
||||
# bad pun hidden
|
||||
bld.program(source='foo.d', target='bar', use='hmm', includes=[bld.path])
|
||||
bld.stlib(source='hmm.d', target='hmm')
|
||||
|
||||
#bld(features='d dshlib', source='shared.d', target='sha')
|
||||
# shared libs do not work here:
|
||||
# ldc -relocation-model=pic -L-shared shared.d -offoo
|
||||
# /usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../x86_64-suse-linux/bin/ld:
|
||||
# /disk/comp/ldc/bin/../lib/libtango.a(tango-core-rt-compiler-ldc-object_-O2.o):
|
||||
# relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
|
||||
|
||||
|
3
demos/dbus/main.c
Normal file
3
demos/dbus/main.c
Normal file
@ -0,0 +1,3 @@
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
10
demos/dbus/test.xml
Normal file
10
demos/dbus/test.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<node name="/org/freedesktop/DBus/Properties">
|
||||
<interface name="org.freedesktop.DBus.Properties">
|
||||
<method name="Set">
|
||||
<arg type="s" name="interface_name"/>
|
||||
<arg type="s" name="property_name"/>
|
||||
<arg type="v" name="value"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
21
demos/dbus/wscript
Normal file
21
demos/dbus/wscript
Normal file
@ -0,0 +1,21 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2010 (ita)
|
||||
|
||||
VERSION = '1.0'
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_c')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_c dbus')
|
||||
conf.find_program('glib-genmarshal') # required on a few systems
|
||||
|
||||
def build(bld):
|
||||
tg = bld.program(
|
||||
includes = '.',
|
||||
source = bld.path.ant_glob('*.c'),
|
||||
target = 'gnome-hello')
|
||||
|
||||
tg.add_dbus_file('test.xml', 'test_prefix', 'glib-server')
|
||||
|
7
demos/doxy/a.cpp
Normal file
7
demos/doxy/a.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "a.h"
|
||||
|
||||
foo::foo()
|
||||
{
|
||||
|
||||
}
|
||||
|
24
demos/doxy/a.h
Normal file
24
demos/doxy/a.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*!
|
||||
* Unused class for demo a.h
|
||||
*/
|
||||
class foo
|
||||
{
|
||||
private:
|
||||
/*!
|
||||
* attribute x, hmmm :-)
|
||||
*/
|
||||
int x;
|
||||
|
||||
public:
|
||||
/*!
|
||||
* i love comments such as "this is a constructor"
|
||||
*/
|
||||
foo();
|
||||
|
||||
/*!
|
||||
* float y, tadam
|
||||
*/
|
||||
float y;
|
||||
};
|
||||
|
||||
|
12
demos/doxy/b.cpp
Normal file
12
demos/doxy/b.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "b.h"
|
||||
|
||||
bar::bar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
24
demos/doxy/b.h
Normal file
24
demos/doxy/b.h
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
/*!
|
||||
* pim pam
|
||||
*/
|
||||
class bar
|
||||
{
|
||||
private:
|
||||
/*!
|
||||
* zzzz
|
||||
*/
|
||||
int z;
|
||||
|
||||
public:
|
||||
/*!
|
||||
* guess what this is .. a constructor?
|
||||
*/
|
||||
bar();
|
||||
|
||||
/*!
|
||||
* out of ideas for comments
|
||||
*/
|
||||
float t;
|
||||
};
|
||||
|
7
demos/doxy/subdir/c.cpp
Normal file
7
demos/doxy/subdir/c.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "c.h"
|
||||
|
||||
meep::meep()
|
||||
{
|
||||
|
||||
}
|
||||
|
18
demos/doxy/subdir/c.h
Normal file
18
demos/doxy/subdir/c.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*!
|
||||
* Nothing to hide, so all is public
|
||||
*/
|
||||
class meep
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* attribute a, hmmm :-)
|
||||
*/
|
||||
int a;
|
||||
|
||||
/*!
|
||||
* no comments
|
||||
*/
|
||||
meep();
|
||||
};
|
||||
|
||||
|
183
demos/doxy/test.conf
Normal file
183
demos/doxy/test.conf
Normal file
@ -0,0 +1,183 @@
|
||||
# this template is provided as an example, it has been generated from 'doxygen -g' and modified afterwards
|
||||
|
||||
# the output directory is set by Waf to the build directory, leave it commented
|
||||
#OUTPUT_DIRECTORY =
|
||||
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = test
|
||||
PROJECT_NUMBER = 1.2.3
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
FILE_VERSION_FILTER =
|
||||
QUIET = YES
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
INPUT =
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS =
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS = */.*/*
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
GENERATE_LATEX = YES
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
CLASS_DIAGRAMS = YES
|
||||
MSCGEN_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
SEARCHENGINE = \
|
||||
NO
|
||||
|
24
demos/doxy/wscript
Normal file
24
demos/doxy/wscript
Normal file
@ -0,0 +1,24 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2008-2010 (ita)
|
||||
|
||||
VERSION='0.0.1'
|
||||
APPNAME='cc_test'
|
||||
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx doxygen')
|
||||
|
||||
def build(bld):
|
||||
# Note: Doxgen parameters may be passed using pars attribute
|
||||
# e.g. pars={'EXCLUDE_PATTERNS':'*.babu'}
|
||||
bld(
|
||||
features='doxygen',
|
||||
doxyfile='test.conf',
|
||||
doxy_tar='docs.tar.bz2')
|
||||
|
10
demos/fluid/PopupDialog.fl
Normal file
10
demos/fluid/PopupDialog.fl
Normal file
@ -0,0 +1,10 @@
|
||||
# data file for the Fltk User Interface Designer (fluid)
|
||||
version 1.0300
|
||||
header_name {.hpp}
|
||||
code_name {.cpp}
|
||||
widget_class PopupDialog {
|
||||
callback {o->hide();
|
||||
Fl::delete_widget(o);} open selected
|
||||
xywh {51 115 165 55} type Double align 5
|
||||
class Fl_Window modal visible
|
||||
} {}
|
31
demos/fluid/UserInterface.fl
Normal file
31
demos/fluid/UserInterface.fl
Normal file
@ -0,0 +1,31 @@
|
||||
# data file for the Fltk User Interface Designer (fluid)
|
||||
version 1.0300
|
||||
i18n_type 1
|
||||
i18n_include <libintl.h>
|
||||
i18n_function gettext
|
||||
header_name {.hpp}
|
||||
code_name {.cpp}
|
||||
decl {\#include "PopupDialog.hpp"} {public global
|
||||
}
|
||||
|
||||
class UserInterface {open
|
||||
} {
|
||||
Function {UserInterface()} {open
|
||||
} {
|
||||
Fl_Window main_win {
|
||||
callback {Fl::delete_widget(o);} open
|
||||
private xywh {12 31 125 80} type Double selection_color 48 align 80 when 1 visible
|
||||
} {
|
||||
Fl_Button {} {
|
||||
label {click me}
|
||||
callback {PopupDialog* p = new PopupDialog(165, 55, "PopupDialog");
|
||||
p->show();} selected
|
||||
xywh {25 25 70 20}
|
||||
}
|
||||
}
|
||||
}
|
||||
Function {show()} {open
|
||||
} {
|
||||
code {main_win->show();} {}
|
||||
}
|
||||
}
|
12
demos/fluid/main.cpp
Normal file
12
demos/fluid/main.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "FL/fl_ask.H"
|
||||
|
||||
#include "UserInterface.hpp"
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Fl::scheme("plastic");
|
||||
UserInterface ui;
|
||||
ui.show();
|
||||
return Fl::run();
|
||||
}
|
23
demos/fluid/wscript
Normal file
23
demos/fluid/wscript
Normal file
@ -0,0 +1,23 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Grygoriy Fuchedzhy 2009
|
||||
|
||||
top = '.'
|
||||
out = 'out'
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx')
|
||||
|
||||
def configure(conf):
|
||||
#conf.recurse('gni')
|
||||
conf.load('compiler_cxx')
|
||||
conf.load('fluid')
|
||||
|
||||
def build(bld):
|
||||
bld.program(
|
||||
target = 'sample',
|
||||
source = 'main.cpp PopupDialog.fl UserInterface.fl',
|
||||
includes = '.',
|
||||
install_path = '${PREFIX}/bin/',
|
||||
use = 'FLTK')
|
||||
|
2
demos/fortran/foo.f
Normal file
2
demos/fortran/foo.f
Normal file
@ -0,0 +1,2 @@
|
||||
subroutine foo
|
||||
end
|
8
demos/fortran/foo_pp.F
Normal file
8
demos/fortran/foo_pp.F
Normal file
@ -0,0 +1,8 @@
|
||||
program main
|
||||
#ifdef USEFOO
|
||||
print *,'FOO'
|
||||
#else
|
||||
print *,'HELLO'
|
||||
#endif
|
||||
end
|
||||
|
3
demos/fortran/hello.f
Normal file
3
demos/fortran/hello.f
Normal file
@ -0,0 +1,3 @@
|
||||
program main
|
||||
print *, 'hello'
|
||||
end
|
60
demos/fortran/mod/fakecc.py
Normal file
60
demos/fortran/mod/fakecc.py
Normal file
@ -0,0 +1,60 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# DC 2008
|
||||
# Thomas Nagy 2010 (ita)
|
||||
|
||||
import re
|
||||
|
||||
from waflib import Utils, Task, TaskGen, Logs
|
||||
from TaskGen import feature, before, after, extension
|
||||
from waflib.Tools import ccroot
|
||||
|
||||
IS_MODULE_R = re.compile('module ([a-z]*)')
|
||||
USE_MODULE_R = re.compile('use ([a-z]*)')
|
||||
|
||||
@extension('.a')
|
||||
def hook(self, node):
|
||||
self.create_compiled_task('fakecc', node)
|
||||
|
||||
def ismodule(node):
|
||||
deps = []
|
||||
for l in node.read().splitlines():
|
||||
m = IS_MODULE_R.match(l)
|
||||
if m:
|
||||
deps.append(m.group(1) + '.mod')
|
||||
return deps
|
||||
|
||||
def usemodule(node):
|
||||
deps = []
|
||||
for l in node.read().splitlines():
|
||||
m = USE_MODULE_R.match(l)
|
||||
if m:
|
||||
deps.append(m.group(1) + '.mod')
|
||||
return deps
|
||||
|
||||
def compile(tsk):
|
||||
tsk.outputs[0].write('compiled')
|
||||
m = ismodule(tsk.inputs[0])
|
||||
if m:
|
||||
print("%s declares module %s" % (tsk.inputs[0], m[0]))
|
||||
t2 = open(m[0], 'w')
|
||||
try:
|
||||
t2.write('module compiled')
|
||||
finally:
|
||||
t2.close()
|
||||
|
||||
class fakecc(Task.Task):
|
||||
color = 'YELLOW'
|
||||
def run(self):
|
||||
cmd = []
|
||||
if not len(self.outputs) == len(self.inputs) == 1:
|
||||
pass
|
||||
|
||||
bnodes = self.outputs
|
||||
m = usemodule(self.inputs[0])
|
||||
if m:
|
||||
print "%s requires module %s" % (self.inputs[0].abspath(), m[0])
|
||||
#bnodes.append(self.generator.bld.bldnode.exclusive_build_node(m[0]))
|
||||
|
||||
compile(self)
|
||||
|
34
demos/fortran/mod/two_mods.f90
Normal file
34
demos/fortran/mod/two_mods.f90
Normal file
@ -0,0 +1,34 @@
|
||||
module MOD1
|
||||
end module MOD1
|
||||
|
||||
module mod2
|
||||
use mod1
|
||||
integer :: mod2_int
|
||||
|
||||
! FIXME:
|
||||
! replace the following line with the commented version, and recompile.
|
||||
! mod/uses_two_mods.f90 should be recompiled, but currently isn't.
|
||||
|
||||
integer, parameter :: mod2_param = 5
|
||||
! integer, parameter :: mod2_param = 6
|
||||
|
||||
interface mod2_proc
|
||||
module procedure mod2_proc1, mod2_proc2
|
||||
end interface
|
||||
|
||||
contains
|
||||
|
||||
subroutine mod2_proc1(a)
|
||||
implicit none
|
||||
integer, intent(inout) :: a
|
||||
a = 10
|
||||
end subroutine
|
||||
|
||||
subroutine mod2_proc2(a)
|
||||
implicit none
|
||||
real, intent(inout) :: a
|
||||
a = 10.0
|
||||
end subroutine
|
||||
|
||||
end module mod2
|
||||
|
21
demos/fortran/mod/uses_two_mods.f90
Normal file
21
demos/fortran/mod/uses_two_mods.f90
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
! FIXME:
|
||||
! modifying two_mods.f90 should trigger this file's recompilation, too.
|
||||
|
||||
module uses_TWO_mods
|
||||
use mod2
|
||||
implicit none
|
||||
|
||||
integer, parameter :: uses_two_mods_param = mod2_param * 2
|
||||
|
||||
contains
|
||||
|
||||
subroutine printer
|
||||
implicit none
|
||||
|
||||
print *, uses_two_mods_param
|
||||
|
||||
end subroutine printer
|
||||
|
||||
end module uses_TWO_mods
|
17
demos/fortran/mod/wscript
Normal file
17
demos/fortran/mod/wscript
Normal file
@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# DC 2008
|
||||
# Thomas Nagy 2010 (ita)
|
||||
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(opt):
|
||||
opt.load('fakecc', tooldir='.')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('fakecc', tooldir='.')
|
||||
|
||||
def build(bld):
|
||||
bld(source='hello_main.a hello.a', target='hello')
|
||||
|
9
demos/fortran/src/calculator.f
Normal file
9
demos/fortran/src/calculator.f
Normal file
@ -0,0 +1,9 @@
|
||||
module calculator
|
||||
implicit none
|
||||
contains
|
||||
subroutine add (a, b, output)
|
||||
integer, intent (in) :: a, b
|
||||
integer, intent (out) :: output
|
||||
output = a + b
|
||||
end subroutine add
|
||||
end module calculator
|
6
demos/fortran/src/calculator_main.f
Normal file
6
demos/fortran/src/calculator_main.f
Normal file
@ -0,0 +1,6 @@
|
||||
PROGRAM Test
|
||||
use calculator, only: add
|
||||
integer:: result
|
||||
|
||||
call add (2,2,result)
|
||||
END PROGRAM
|
7
demos/fortran/src/hello_inc.f
Normal file
7
demos/fortran/src/hello_inc.f
Normal file
@ -0,0 +1,7 @@
|
||||
program main
|
||||
include "hello.h"
|
||||
real bar
|
||||
t0 = 1
|
||||
bar = t0
|
||||
print *,bar
|
||||
end
|
1
demos/fortran/src/include/hello.h
Normal file
1
demos/fortran/src/include/hello.h
Normal file
@ -0,0 +1 @@
|
||||
real t0
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user