docs added Partial guessing of TINYORM_BUILD_TREE

This commit is contained in:
silverqx
2023-10-08 14:29:10 +02:00
parent df0ddfc408
commit c9cce2faea
3 changed files with 45 additions and 5 deletions

View File

@@ -513,9 +513,11 @@ Create the `.qmake.conf` file in the `HelloWorld` project root folder with the f
```qmake
# Path to the PARENT folder of the TinyORM source folder
TINY_MAIN_DIR = $$clean_path($$PWD/../../TinyORM/)
TINY_MAIN_DIR = $$clean_path($$PWD/../../TinyORM/)
# To find .env and .env.$$QMAKE_PLATFORM files
TINY_DOTENV_ROOT = $$PWD
# Path to the current build tree (used to guess the TinyORM build tree)
#TINY_BUILD_TREE = $$shadowed($$PWD)
# To find .prf files, needed by eg. CONFIG += tiny_system_headers inline/extern_constants
QMAKEFEATURES *= $$quote($$TINY_MAIN_DIR/TinyORM/qmake/features)
@@ -593,8 +595,10 @@ QMAKE_LFLAGS *= -fuse-ld=lld
Don't forget to update the `TINYORM_BUILD_TREE` and `TINY_VCPKG_ROOT` folder paths to your needs if you are not using the recommended [`Folders structure`](tinyorm.mdx#folders-structure).
You can use the [Partial guessing of the `TINYORM_BUILD_TREE`](tinyorm.mdx#partial-guessing-of-the-tinyorm_build_tree) if you don't like to specify it manually. Just comment out the `TINYORM_BUILD_TREE` and uncomment the `TINY_BUILD_TREE = $$shadowed($$PWD)` in the `.qmake.conf` file.
:::tip
You can entirely avoid the `.env` files, just move the `TINYORM_BUILD_TREE` to the `.qmake.conf` and set the `VCPKG_ROOT` at system level as is described in [`Set up vcpkg environment`](tinyorm.mdx#set-up-vcpkg-environment).
You can entirely avoid the `.env` files, just move the `TINYORM_BUILD_TREE` to the `.qmake.conf` or remove it by help of [Partial guessing of the `TINYORM_BUILD_TREE`](tinyorm.mdx#partial-guessing-of-the-tinyorm_build_tree) and set the `VCPKG_ROOT` environment variable at system level as is described in [`Set up vcpkg environment`](tinyorm.mdx#set-up-vcpkg-environment).
:::
:::info

View File

@@ -724,11 +724,13 @@ Read the [Consume TinyOrm library (qmake)](tinyorm.mdx#consume-tinyorm-library-q
Create the `.qmake.conf` file in the `tom` application root folder with the following content.
```qmake
```qmake title='.qmake.conf'
# Path to the PARENT folder of the TinyORM source folder
TINY_MAIN_DIR = $$clean_path($$PWD/../../TinyORM/)
TINY_MAIN_DIR = $$clean_path($$PWD/../../TinyORM/)
# To find .env and .env.$$QMAKE_PLATFORM files
TINY_DOTENV_ROOT = $$PWD
# Path to the current build tree (used to guess the TinyORM build tree)
#TINY_BUILD_TREE = $$shadowed($$PWD)
# To find .prf files, needed by eg. CONFIG += tiny_system_headers inline/extern_constants
QMAKEFEATURES *= $$quote($$TINY_MAIN_DIR/TinyORM/qmake/features)
@@ -806,8 +808,10 @@ QMAKE_LFLAGS *= -fuse-ld=lld
Don't forget to update the `TINYORM_BUILD_TREE` and `TINY_VCPKG_ROOT` folder paths to your needs if you are not using the recommended [`Folders structure`](tinyorm.mdx#folders-structure).
You can use the [Partial guessing of the `TINYORM_BUILD_TREE`](tinyorm.mdx#partial-guessing-of-the-tinyorm_build_tree) if you don't like to specify it manually. Just comment out the `TINYORM_BUILD_TREE` and uncomment the `TINY_BUILD_TREE = $$shadowed($$PWD)` in the `.qmake.conf` file.
:::tip
You can entirely avoid the `.env` files, just move the `TINYORM_BUILD_TREE` to the `.qmake.conf` and set the `VCPKG_ROOT` at system level as is described in [`Set up vcpkg environment`](tinyorm.mdx#set-up-vcpkg-environment).
You can entirely avoid the `.env` files, just move the `TINYORM_BUILD_TREE` to the `.qmake.conf` or remove it by help of [Partial guessing of the `TINYORM_BUILD_TREE`](tinyorm.mdx#partial-guessing-of-the-tinyorm_build_tree) and set the `VCPKG_ROOT` environment variable at system level as is described in [`Set up vcpkg environment`](tinyorm.mdx#set-up-vcpkg-environment).
:::
:::info

View File

@@ -804,6 +804,8 @@ It has a few requirements, you need to:
- specify path to the `TinyORM` qmake features (`.prf` files) using the `QMAKEFEATURES` variable that can only be set in the `.qmake.conf` file
- specify `qmake` or `environment` variables to find the `vcpkg` installation <small>(`TINY_VCPKG_ROOT` and `TINY_VCPKG_TRIPLET`)</small>
- specify path to the `TinyORM` build folder <small>(`TINYORM_BUILD_TREE`)</small>
- you can specify it __manually__
- or you can use [Partial guessing of the `TINYORM_BUILD_TREE`](#partial-guessing-of-the-tinyorm_build_tree)
- build your application with the same `CONFIG` `qmake` variables that were used when building the `TinyORM` library
Let's explain one by one.
@@ -832,6 +834,10 @@ You can move all `qmake` variables that are part of the `qmake` configuration pr
You can look at the [Auto-configure using .qmake.conf and .env](hello-world.mdx#auto-configure-using-qmake_conf-and-env) example for `Hello world` project of what must stay in the `qmake.conf` file and what can be moved to the `.env` files.
:::tip
You can use the [Partial guessing of the `TINYORM_BUILD_TREE`](#partial-guessing-of-the-tinyorm_build_tree) if you don't like to specify it manually.
:::
##### Variables affecting `TinyOrm.pri`
You must define the following variables before the `TinyOrm.pri` is included:
@@ -1009,6 +1015,32 @@ The `tiny_dotenv` feature can be turned off using the [`disable_dotenv`](#disabl
`Environment files` don't work in the `CMake` builds.
:::
#### Partial guessing of the `TINYORM_BUILD_TREE`
You don't have to manually define the `TINYORM_BUILD_TREE` in `.env` or `.qmake.conf` files. The `TINYORM_BUILD_TREE` absolute path can be put together for you (this is happening inside the `variables.pri` file) and `TinyORM` build folder name can be guessed for you too.
You must define the following variables before the `TinyOrm.pri` will be included to make this real (set them in the `.qmake.conf`):
| Variable Name | Description |
| ----------------- | ----------- |
| `TINY_MAIN_DIR` | Path to the __PARENT__ folder of the `TinyORM` source folder. |
| `TINY_BUILD_TREE` | Path to the __current__ build tree - `TINY_BUILD_TREE = $$shadowed($$PWD)`. |
The `TINY_MAIN_DIR` is required for another features anyway (so it should already be set) and all that's left is to set the `TINY_BUILD_TREE`.
```qmake title='.qmake.conf'
# Path to the current build tree (used to guess the TinyORM build tree)
TINY_BUILD_TREE = $$shadowed($$PWD)
```
If you will follow this pattern or logic then you can switch `QtCreator Kits` and the `TINYORM_BUILD_TREE` will be __auto-generated__ correctly and will always point to the correct `TinyORM` build tree.
It works this way, all is happening inside the `variables.pri`, it takes a build folder name for the __current__ project eg. `build-HelloWorld-Desktop_Qt_6_5_3_MSVC2022_64bit-Debug`, replaces the `HelloWorld` with the `TinyORM` and as we already know the `TinyORM` build folder location we can simply concatenate these paths like `$$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_5_3_MSVC2022_64bit-Debug`.
:::caution
This will only work if you follow the recommended [`Folders structure`](#folders-structure).
:::
### Manual configuration internals
There is not much to say about the `Manual configuration` feature. It uses `conf.pri` files (there are four, one for every project or sub-project), and every project has prepared its own `conf.pri.example` file for faster initial configuration.