Package: src/packages/judy.fdoc
Judy Arrays¶
key | file |
---|---|
judy.py | $PWD/buildsystem/judy.py |
unix32_judy.fpc | $PWD/src/config/unix32/judy.fpc |
unix64_judy.fpc | $PWD/src/config/unix64/judy.fpc |
win64_judy.fpc | $PWD/src/config/win64/judy.fpc |
Judy Builder¶
#[judy.py]
import fbuild
import fbuild.db
from fbuild.builders.file import copy, copy_regex
from fbuild.path import Path
from fbuild.record import Record
import buildsystem
from buildsystem.config import config_call
# ------------------------------------------------------------------------------
- def build_judytables(ctx, tablegen:fbuild.db.SRC, dst) -> fbuild.db.DST:
“”“Create the judytable generator executable.”“”
# Make sure the directory exists. dst.parent.makedirs()
# We have to run the tablegen from the working directory to get the files # generated in the right place. ctx.execute(tablegen.abspath(),
msg1=tablegen.name, msg2=dst, cwd=dst.parent, color=’yellow’)return dst
- def prepend_macros(ctx, src, macros, dst) -> fbuild.db.DST:
“”“Generate a new version of the input file which has the given macros added to the top as #define’s”“” # Make sure the directory exists. dst.parent.makedirs() src = Path(src) dst = Path(dst) outfile = open(dst, ‘wb’) try:
- for macro in macros:
- outfile.write(bytes(‘#ifndef ‘+macro+’n’+
- ‘#define ‘+macro+’ 1n’+ ‘#endifn’, ‘ascii’))
outfile.write(bytes(‘#include “../JudyCommon/’+src.name+’”’, ‘ascii’)) ctx.logger.check(‘ * generate’, ‘%s as #define %s and #include %s’ % (dst, ‘,’.join(macros), src), color=’yellow’)
finally: outfile.close() return dst
# ——————————————————————————
- def build_runtime(phase):
“”” Builds the judy runtime library, and returns the static and shared library versions. “”“
path = Path(phase.ctx.buildroot/’share’/’src/judy/src’)
# Copy the header into the runtime library. buildsystem.copy_to(phase.ctx,
phase.ctx.buildroot / ‘share/lib/rtl’, [path / ‘Judy.h’])- types = config_call(‘fbuild.config.c.c99.types’,
- phase.platform, phase.c.static)
#if types.voidp.size == 8: macros = [‘JU_64BIT’] print (“64 bit JUDY”)
macros.append(‘BUILD_JUDY’) #Apply this to all source files.
#macros.append(‘DEBUG’) #Apply this to all source files. # above fails with link error because the debug routines # simply don’t exist
- srcs = [
- path / ‘JudyCommon/JudyMalloc.c’, path / ‘JudySL/JudySL.c’, path / ‘JudyHS/JudyHS.c’] + ( path / ‘Judy1’ / ‘.c’).glob() + ( path / ‘JudyL’ / ‘.c’).glob()
- includes = [path,
- path / ‘JudyCommon’, path / ‘JudyL’, path / ‘Judy1’]
- static = buildsystem.build_c_static_lib(phase, ‘host/lib/rtl/judy’,
- srcs=srcs, macros=macros, includes=includes)
- shared = buildsystem.build_c_shared_lib(phase, ‘host/lib/rtl/judy’,
- srcs=srcs, macros=macros, includes=includes)
return Record(static=static, shared=shared)
//[unix32_judy.fpc]
Name: Judy
Description: Judy arrays
provides_dlib: -ljudy_dynamic
provides_slib: -ljudy_static
includes: '"Judy.h"'
library: judy
macros: JU_32BIT BUILD_JUDY
srcdir: src/judy/src
headers: Judy\.h
src: (JudyCommon/JudyMalloc|JudySL/.*|JudyHS/.*|Judy1/.*|JudyL/.*)\.c
build_includes: src/judy/src src/judy/src/Judy1 src/judy/src/JudyL src/judy/src/JudyHS src/judy/src/JudyCommon
//[unix64_judy.fpc]
Name: Judy
Description: Judy arrays
provides_dlib: -ljudy_dynamic
provides_slib: -ljudy_static
includes: '"Judy.h"'
library: judy
macros: JU_64BIT BUILD_JUDY
srcdir: src/judy/src
headers: Judy\.h
src: (JudyCommon/JudyMalloc|JudySL/.*|JudyHS/.*|Judy1/.*|JudyL/.*)\.c
build_includes: src/judy/src src/judy/src/Judy1 src/judy/src/JudyL src/judy/src/JudyHS src/judy/src/JudyCommon
//[win64_judy.fpc]
Name: Judy WIN32 64 BIT
Description: Judy arrays
provides_dlib: /DEFAULTLIB:judy_dynamic
provides_slib: /DEFAULTLIB:judy_static
includes "Judy.h"
library: judy
macros: JU_64BIT BUILD_JUDY
srcdir: src\judy\src
headers: Judy\.h
src: (JudyCommon\\JudyMalloc|JudySL\\.*|JudyHS\\.*|Judy1\\.*|JudyL\\.*)\.c
build_includes: src\judy\src src\judy\src\Judy1 src\judy\src\JudyL src\judy\src\JudyHS src\judy\src\JudyCommon