Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions 10-unusual-build-from-source/README-ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Case №10 - Необычная сборка из исходников компонента xsd

- [Case №10 - Необычная сборка из исходников компонента xsd]
(#case-10---необычная-сборка-из-исходников-компонента-xsd)
- [Цель](#цель)
- [Стэк](#стэк)
- [Контрольные точки](#контрольные-точки)
- [Результат](#результат)
- [Контакты](#контакты)

## Цель

Обычно приложения или библиотеки в UNIX-like системах конфигурируются и собираются при помощи autotools. Это набор утилит, позволяющий описать необходимые этапы при помощи предопределенных функций и макросов. Другой кросс-платформенный и более современный вариант - CMake либо аналоги. Вас попросили автоматизировать сборку кодогенератора xsd, транслирующего XML в C++, но в репозитории видно: используется некоторая "build". Попробуйте реорганизовать сборочный процесс так, чтобы его можно было запустить на CI без интерактивных диалогов в терминале.

## Стэк

![bash](https://img.shields.io/badge/Bash-000000?logo=gnubash&logoColor=white)
![Debian](https://img.shields.io/badge/Debian-A81D33?logo=debian&logoColor=white)
![CMake](https://img.shields.io/badge/CMake-%23008FBA.svg?style=for-the-badge&logo=cmake&logoColor=white)

## Контрольные точки

### Базовый

1. **Склонируйте репозиторий утилиты:**
- Исходный код доступен по [ссылке](https://github.com/codesynthesis-com/xsd). Нас интересует тэг `4.0.0` - сделайте `git checkout`.
2. **Установите необходимые для стандартной сборки C++ приложений пакеты:**
- Базовый набор - мета-пакет `build-essential`. Для дистрибутивов без `apt` можно установить компоненты `make`, `autotools`, `gcc`, `g++` по отдельности либо использовать мета-пакеты при их наличии.
3. **Соберите xsd в варианте, предоставленном авторами:**
- Находясь в корне репозитория, отправьте в терминал команду `make`.
- При нехватке каких-либо зависимостей сборки можно получить архив с исходным кодом утилиты и всех зависимостей [здесь](https://codesynthesis.com/download/xsd/4.0/)
4. **Обеспечьте возможность автоматической сборки xsd на CI:**
- Попробуйте избавиться от необходимости ввода ответов на вопросы в терминал. Для этого можно использовать стандартные инструменты оболочки bash или модифицировать файлы, использующиеся при сборке (в `makefile` есть указания, куда внутри репозитория "обращается" та или иная инструкция при необходимости).

### Продвинутый

1. **Установите CMake:**
- Обычно `cmake` доступен пакетом в любом Linux-дистрибутиве и называется точно так же. Под другие ОС при необходимости используют `brew` (MacOS) или `winget` \ `choco` (Windows). На [сайте](https://cmake.org/) доступны исходный код и бинарные файлы. Лучше устанавливать 3.31 мажорную версию, т.к. 4 ломает совместимость со многими проектами из-за политик.
2. **Переведите сборку xsd на CMake:**
- Стандартной заменой поиска внешних зависимостей в `CMake` являются функции `FetchContent` и\или `ExternalProject`. По желанию можно использовать пакетные менеджеры, например `Conan`. У этой системы сборки есть хорошая [документация](https://cmake.org/cmake/help/v3.31/).

## Результат

Сборку `xsd` можно запустить либо через `.sh` скрипт, либо через `make` (в продвинутом варианте - `cmake`). Процесс не требует действий со стороны пользователя кроме вызова одной либо двух команд (конфигурация+сборка либо по отдельности в случае с `cmake`).

## Контакты

Нужна помощь? Пиши в [наш Telegram чат](https://t.me/+nSELCyIX8ltlNjU6)!
53 changes: 53 additions & 0 deletions 10-unusual-build-from-source/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Case №10 - Unusual Build from Source of the xsd Component

- [Case №10 - Unusual Build from Source of the xsd Component]
(#case-10---unusual-build-from-source-of-the-xsd-component)
- [Authors](#authors)
- [Goal](#goal)
- [Stack](#stack)
- [Checkpoints](#checkpoints)
- [Result](#result)
- [Contacts](#contacts)

## Authors

[![Author](https://img.shields.io/badge/cmdrcrm-000000.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/CommanderCRM)

## Goal

Usually, applications or libraries in UNIX-like systems are configured and built using autotools. This is a set of utilities that allows describing the necessary stages using predefined functions and macros. Another cross-platform and more modern option is CMake or similar. You have been asked to automate the build of the xsd code generator, which translates XML into C++, but in the repository you can see: a certain "build" is used. Try to reorganize the build process so that it can be run on CI without interactive dialogs in the terminal.

## Stack

![bash](https://img.shields.io/badge/Bash-000000?logo=gnubash&logoColor=white)
![Debian](https://img.shields.io/badge/Debian-A81D33?logo=debian&logoColor=white)
![CMake](https://img.shields.io/badge/CMake-%23008FBA.svg?style=for-the-badge&logo=cmake&logoColor=white)

## Checkpoints

### Basic

1. **Clone the utility repository:**
- The source code is available at this [link](https://github.com/codesynthesis-com/xsd). We are interested in the tag `4.0.0` - do a `git checkout`.
2. **Install the necessary packages for standard C++ application builds:**
- The basic set is the meta-package `build-essential`. For distributions without `apt`, you can install the components `make`, `autotools`, `gcc`, `g++` individually or use meta-packages if available.
3. **Build xsd in the variant provided by the authors:**
- While in the root of the repository, execute the command `make` in the terminal.
- If any build dependencies are missing, you can get an archive with the source code of the utility and all dependencies [here](https://codesynthesis.com/download/xsd/4.0/).
4. **Enable automatic building of xsd on CI:**
- Try to eliminate the need to input answers to questions in the terminal. You can use standard bash shell tools or modify the files used during the build (the `makefile` contains indications of where in the repository certain instructions "refer" to when needed).

### Advanced

1. **Install CMake:**
- Typically, `cmake` is available as a package in any Linux distribution and is named exactly that. For other OSes, `brew` (macOS) or `winget` \ `choco` (Windows) are used if necessary. The source code and binary files are available on the [website](https://cmake.org/). It's better to install the 3.31 major version, as version 4 breaks compatibility with many projects due to policy changes.
2. **Migrate the xsd build to CMake:**
- The standard replacement for finding external dependencies in `CMake` is the `FetchContent` and/or `ExternalProject` functions. Optionally, package managers like `Conan` can be used. This build system has good [documentation](https://cmake.org/cmake/help/v3.31/).

## Result

The `xsd` build can be started either via a `.sh` script or via `make` (in the advanced version - `cmake`). The process requires no action from the user other than calling one or two commands (configure+build separately or individually in the case of `cmake`).

## Contacts

Need help? Write to [our Telegram chat](https://t.me/+nSELCyIX8ltlNjU6)!
1 change: 1 addition & 0 deletions README-ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
7. [n8n & Ollama](07-n8n-ollama/README-ru.md)
8. [Kubernetes: идентификация пользователей (Keycloak + OIDC)](08-k8s-keycloak-oidc)
9. [Docker: создание базового образа](09-create-base-image)
10. [xsd: необычная сборка из исходников](10-unusual-build-from-source)

## 🗝️ Как отправить решение на GitHub

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ You can solve our cases in the next order:
7. [n8n & Ollama](07-n8n-ollama/README.md)
8. [Kubernetes: user identification (Keycloak + OIDC)](08-k8s-keycloak-oidc)
9. [Docker: Create Base Image](09-create-base-image)
10. [xsd: Unusual Build From Source](09-create-base-image)

## 🗝️ How to submit a solution on GitHub

Expand Down