Архитектура сборки

Раздел архитектурной документации TMC Suite. Как организована сборка пакета: принцип «общие исходники / раздельные сборки», property sheets, четыре фазы, две платформы (win32/win64).

Сборка — самостоятельная часть архитектуры пакета. Она построена вокруг одного правила: исходники общие, результаты раздельные.


1. Принцип «исходники общие, сборки раздельные»

Единственный комплект исходного кода — в src/. Две платформы отличаются только папкой результата:

Платформа Выбор в Visual Studio Результаты
win32 Win32 dist/win32/lib, dist/win32/bin
win64 x64 dist/win64/lib, dist/win64/bin

Библиотеки — отдельная папка на каждую платформу. Нельзя смешивать win32 и win64 .lib в одной папке: имена совпадают, файлы затрут друг друга и линковка сломается. Все win32 → dist/win32/lib, все win64 → dist/win64/lib.

Исходный код никогда не дублируется под платформы.


2. Property sheets — централизованная конфигурация

Общие настройки сборки вынесены в property sheets (build/), а не прописаны в каждом проекте по отдельности. Это держит пути и параметры в одном месте.

Файл Назначение
build/Common.props Общие настройки для всех проектов (пути включений, параметры компиляции)
build/LibOutput.props Куда складывать результаты библиотек (dist/<платформа>/lib)
build/ExeOutput.props Куда складывать результаты программ (dist/<платформа>/bin)

В коде и проектах нет жёстких путей вида D:\work\... — только относительные через property sheets. Это часть архитектурного правила переносимости.


3. Структура каталогов проекта

TMC_Suite/
├── src/
│   ├── Include/      — общие заголовки (.h)
│   ├── libs/         — исходники 6 библиотек
│   ├── viewers/      — исходники 3 вьюверов
│   ├── kernels/      — исходники 2 счётных ядер
│   └── fieldview/    — исходник FieldView
├── build/            — property sheets (Common/LibOutput/ExeOutput.props)
├── dist/
│   ├── win32/{lib,bin}
│   └── win64/{lib,bin}
├── samples/SAMPLE_R/ — тестовые данные
└── docs/             — документация (api, build-guide, user-manual, architecture)

4. Порядок сборки — четыре фазы

Сборка строго фазовая. Каждую фазу выполняют для обеих платформ.

ФАЗА 1 — ВСЕ 6 библиотек
   sfile95, complex, exprint, TMCLibError, prepr, TMCIndan
ФАЗА 2 — 3 вьювера
   TMCROS, TMCGROUT, TMC_DN
ФАЗА 3 — 2 счётных ядра
   tmc_rth (H), tmc_rtx (X — требует 6 макросов)
ФАЗА 4 — FieldView (требует OpenGL)

Программы не собираются, пока не готовы ВСЕ 6 библиотек. Порядок между самими библиотеками не важен — каждая .lib компилируется независимо (см. Зависимости).

Зависимости линковки, определяющие фазовость:

  • Вьюверы ← sfile95, complex, exprint
  • Счётные ядра ← sfile95, prepr, exprint, TMCIndan, TMCLibError
  • FieldView ← те же, что у ядер, + opengl32, glu32

5. X-мода: конфигурация через макросы проекта

PlanarRT_X собирается из тех же исходников, что и PlanarRT_H, но с 6 макросами препроцессора, заданными в свойствах проекта (C/C++ → Preprocessor → Preprocessor Definitions):

ELECTRON_Q___
ELECTRON_M___
CTMCRTH_INDANBLCK_FILEY
CTMCRTH_INDANBLCK_RECTSTATY
CTMCRTH_INDANBLCK_CIRCSTATY
CTMCRTH_INDANBLCK_POLYGSTTY

Макросы не добавляются в общие заголовки (Typerth.h, Tmcgrviw.h) — иначе сломались бы H-мода и вьюверы. Это пример общего принципа: вариативность сборки выражается настройками проекта, а не правкой общего кода.


6. Две платформы: win32 и win64

Исторически пакет собирался под win16 и win32. Сборка под win64 — новая задача, потребовавшая правок разрядности в коде:

  • указатели не помещаются в int → корректные целочисленные типы;
  • LONGLONG_PTR в сигнатурах MFC;
  • запрет ассемблерных вставок (несовместимы с x64);
  • удаление остатков win16-типов.

Стратегия портирования:

  1. Сначала полностью собрать win32 (ближе к исходному коду, проще).
  2. Затем переключиться на win64 и чинить 64-битные ошибки по одной.

Каждое 64-битное изменение фиксируется в журнале портирования (docs/build-guide/.../08-porting-changes) с обоснованием. Математику расчётов при этом не трогают.


7. Команды сборки

# win32
msbuild <Solution>.sln /p:Platform=Win32 /p:Configuration=Release

# win64
msbuild <Solution>.sln /p:Platform=x64 /p:Configuration=Release

Подробная пошаговая инструкция — в docs/build-guide/.

Build architecture

Architecture documentation section of TMC Suite. How the package build is organized: the "shared sources / separate builds" principle, property sheets, the four phases, the two platforms (win32/win64).

The build is a self-contained part of the package architecture. It is built around one rule: shared sources, separate outputs.


1. The "shared sources, separate builds" principle

A single set of source code lives in src/. The two platforms differ only in the output folder:

Platform Choice in Visual Studio Outputs
win32 Win32 dist/win32/lib, dist/win32/bin
win64 x64 dist/win64/lib, dist/win64/bin

Libraries — a separate folder for each platform. You must not mix win32 and win64 .lib in one folder: the names coincide, the files would overwrite each other, and linking would break. All win32 → dist/win32/lib, all win64 → dist/win64/lib.

Source code is never duplicated per platform.


2. Property sheets — centralized configuration

Common build settings are extracted into property sheets (build/) rather than written into each project separately. This keeps paths and parameters in one place.

File Purpose
build/Common.props Common settings for all projects (include paths, compilation parameters)
build/LibOutput.props Where to place library outputs (dist/<platform>/lib)
build/ExeOutput.props Where to place program outputs (dist/<platform>/bin)

There are no hard-coded paths like D:\work\... in the code or projects — only relative ones through the property sheets. This is part of the architectural portability rule.


3. Project directory structure

TMC_Suite/
├── src/
│   ├── Include/      — shared headers (.h)
│   ├── libs/         — sources of the 6 libraries
│   ├── viewers/      — sources of the 3 viewers
│   ├── kernels/      — sources of the 2 compute kernels
│   └── fieldview/    — FieldView source
├── build/            — property sheets (Common/LibOutput/ExeOutput.props)
├── dist/
│   ├── win32/{lib,bin}
│   └── win64/{lib,bin}
├── samples/SAMPLE_R/ — test data
└── docs/             — documentation (api, build-guide, user-manual, architecture)

4. Build order — four phases

The build is strictly phased. Each phase is performed for both platforms.

PHASE 1 — ALL 6 libraries
   sfile95, complex, exprint, TMCLibError, prepr, TMCIndan
PHASE 2 — 3 viewers
   TMCROS, TMCGROUT, TMC_DN
PHASE 3 — 2 compute kernels
   tmc_rth (H), tmc_rtx (X — requires 6 macros)
PHASE 4 — FieldView (requires OpenGL)

Programs are not built until ALL 6 libraries are ready. The order among the libraries themselves does not matter — each .lib compiles independently (see Dependencies).

The link dependencies that determine the phasing:

  • Viewers ← sfile95, complex, exprint
  • Compute kernels ← sfile95, prepr, exprint, TMCIndan, TMCLibError
  • FieldView ← the same as the kernels, + opengl32, glu32

5. X-mode: configuration through project macros

PlanarRT_X is built from the same sources as PlanarRT_H, but with 6 preprocessor macros set in the project properties (C/C++ → Preprocessor → Preprocessor Definitions):

ELECTRON_Q___
ELECTRON_M___
CTMCRTH_INDANBLCK_FILEY
CTMCRTH_INDANBLCK_RECTSTATY
CTMCRTH_INDANBLCK_CIRCSTATY
CTMCRTH_INDANBLCK_POLYGSTTY

The macros are not added to the shared headers (Typerth.h, Tmcgrviw.h) — otherwise the H-mode and the viewers would break. This is an example of the general principle: build variability is expressed through project settings, not by editing shared code.


6. Two platforms: win32 and win64

Historically the package was built for win16 and win32. The win64 build is a new task that required width fixes in the code:

  • pointers do not fit into int → correct integer types;
  • LONGLONG_PTR in MFC signatures;
  • no inline assembly (incompatible with x64);
  • removal of win16-type remnants.

Porting strategy:

  1. First fully build win32 (closer to the original code, simpler).
  2. Then switch to win64 and fix 64-bit errors one by one.

Each 64-bit change is recorded in the porting log (docs/build-guide/.../08-porting-changes) with a justification. The computation math is not touched in the process.


7. Build commands

# win32
msbuild <Solution>.sln /p:Platform=Win32 /p:Configuration=Release

# win64
msbuild <Solution>.sln /p:Platform=x64 /p:Configuration=Release

A detailed step-by-step guide is in docs/build-guide/.