OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
Loading...
Searching...
No Matches
layout_parity Namespace Reference

Functions

 load_types (path)
 program (prologue, types)
 keys (types)
 objcopy_for (compiler)
 measure (compiler, flags, source, tmp, tag, types)
 variant_flags (variant)
 main ()

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 SRC = os.path.join(ROOT, 'src')
dict PROTOCOL = {'linux': 118, 'linux-10': 115, 'mingw': 118, 'linux-client-x64': 118}
tuple X64_VARIANTS = ('linux-client-x64',)
tuple ENGINE_VM_TYPES = ('VariableUnion', 'VariableValue', 'VariableValueInternal')

Detailed Description

Compares struct layouts between this repo's headers and CoD2rev-Plus's.

    python3 scripts/layout_parity.py [--variant linux|linux-10|mingw|linux-client-x64]
    python3 scripts/layout_parity.py --headers-a A.h --headers-b B.h --types T.txt --flags "-m32"

Each line of the types file (default test/layout_parity_types.txt) is a type
name, optionally followed by ':field1,field2,...' (# comments); a name ending
in '~' compares only the fields, not sizeof. For each side a
C++ program prints sizeof and offsetof of every field; the two results are
compared. Side A is this repo (common_types.h and imports.h inside extern "C"),
side B is CoD2rev-Plus (qcommon.h, script_public.h, server.h and g_shared.h); both use the flags of the
variant's build in build/check-<variant>/. Nothing is run: each side's
values are an array in a section of its own (.lpar) of the compiled object,
which objcopy reads, so the mingw variant needs no wine. Prints 'ok <type>' or
'DIFF <type>: <field> <A> != <B>', and exits with 0 when nothing differs.

Function Documentation

◆ keys()

layout_parity.keys ( types)

◆ load_types()

layout_parity.load_types ( path)

◆ main()

layout_parity.main ( )

◆ measure()

layout_parity.measure ( compiler,
flags,
source,
tmp,
tag,
types )

◆ objcopy_for()

layout_parity.objcopy_for ( compiler)
The objcopy of the compiler's toolchain (i686-w64-mingw32-g++ -> i686-w64-mingw32-objcopy).

◆ program()

layout_parity.program ( prologue,
types )
A source whose layout_values array holds, in the order of keys(types),
each type's sizeof and its fields' offsetof.

◆ variant_flags()

layout_parity.variant_flags ( variant)
(compiler, flags) of an engine C++ source in build/check-<variant>, without -c/-o/source.

Variable Documentation

◆ ENGINE_VM_TYPES

tuple layout_parity.ENGINE_VM_TYPES = ('VariableUnion', 'VariableValue', 'VariableValueInternal')

◆ PROTOCOL

dict layout_parity.PROTOCOL = {'linux': 118, 'linux-10': 115, 'mingw': 118, 'linux-client-x64': 118}

◆ ROOT

layout_parity.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

◆ SRC

layout_parity.SRC = os.path.join(ROOT, 'src')

◆ X64_VARIANTS

tuple layout_parity.X64_VARIANTS = ('linux-client-x64',)