Skip to content

Commit

Permalink
Initial setup for isolated build
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkvdb committed Oct 3, 2023
1 parent 91c8e96 commit fa1a6fd
Show file tree
Hide file tree
Showing 6 changed files with 283 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/vcpkg-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Vcpkg build

on: [push]

jobs:
build:
name: ${{ matrix.cfg.os }}
runs-on: ${{ matrix.cfg.os }}
strategy:
fail-fast: false
matrix:
cfg:
- { os: ubuntu-latest, triplet: x64-linux }
- { os: windows-2022, triplet: x64-windows-static-vs2022 }
- { os: macos-latest, triplet: x64-osx }

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install linux dependencies
if: ${{ matrix.cfg.os == 'ubuntu-latest' }}
run: sudo apt-get install nasm openssl ninja-build
- name: Install osx dependencies
if: ${{ matrix.cfg.os == 'macos-latest' }}
run: brew install nasm ninja
- name: Cache vcpkg binary
id: cache-vcpkg-bin
uses: actions/cache@v3
with:
path: |
deps/vcpkg/vcpkg
deps/vcpkg/vcpkg.exe
key: ${{ runner.os }}-${{ hashFiles('deps/vcpkg/bootstrap.cmake') }}
- name: Cache vcpkg packages
id: cache-vcpkg
uses: actions/cache@v3
with:
path: |
~/.cache/vcpkg
~/AppData/Local/vcpkg/archives
key: ${{ runner.os }}-${{ matrix.cfg.triplet }}-${{ hashFiles('vcpkg.json', '.git/modules/deps/vcpkg/shallow') }}
- name: Bootstrap the ports
run: python bootstrap.py --triplet ${{ matrix.cfg.triplet }} --clean-after-build
- name: Build the code
run: python build.py --triplet ${{ matrix.cfg.triplet }} --no-avx2 --python-path '${{ steps.setup-python.outputs.python-path }}' --run-tests
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deps/vcpkg"]
path = deps/vcpkg
url = https://github.com/VITObelgium/vcpkg-ports.git
45 changes: 45 additions & 0 deletions bootstrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
import os
import sys
import sysconfig
import argparse

from deps.vcpkg.scripts.buildtools import vcpkg

if __name__ == "__main__":
try:
parser = argparse.ArgumentParser(
description="Bootstrap infra.", parents=[vcpkg.bootstrap_argparser()]
)

args = parser.parse_args()

platform = sysconfig.get_platform()
triplet = args.triplet
if platform == "win-amd64":
triplet = "x64-windows-static-vs2022"
elif platform == "mingw":
triplet = "x64-mingw"
elif not triplet:
triplet = vcpkg.prompt_for_triplet()

extras = []
build_root = None
packages_root = None

if args.clean:
vcpkg.clean(triplet=triplet)
else:
vcpkg.bootstrap(
ports_dir=os.path.join(".", "deps"),
triplet=triplet,
additional_ports=extras,
build_root=build_root,
packages_root=packages_root,
)
except KeyboardInterrupt:
print("\nInterrupted")
sys.exit(-1)
except RuntimeError as e:
print(e)
sys.exit(-1)
97 changes: 97 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
import os
import sys
import sysconfig
import platform
import argparse

from deps.vcpkg.scripts.buildtools import vcpkg

if __name__ == "__main__":
try:
parser = argparse.ArgumentParser(
description="Build infra.", parents=[vcpkg.build_argparser()]
)
parser.add_argument(
"--ui", dest="ui_enabled", action="store_true", help="build the ui"
)

parser.add_argument(
"--ci",
dest="ci_build",
action="store_true",
help="continuous integration build",
)

parser.add_argument(
"--build-config",
dest="build_config",
help="Build configuration (Debug or Release)",
default="Release",
)

args = parser.parse_args()

build_ui = (
"ON"
if (platform.system() == "Windows" and not args.ci_build) or args.ui_enabled
else "OFF"
)
sys_platform = sysconfig.get_platform()

triplet = args.triplet
if sys_platform == "win-amd64":
triplet = "x64-windows-static-vs2022"
elif sys_platform == "mingw":
triplet = "x64-mingw"
elif not triplet:
triplet = vcpkg.prompt_for_triplet()

cmake_args = [
f"-DINFRA_UI_COMPONENTS={build_ui}",
"-DINFRA_LOGGING=ON",
"-DINFRA_GDAL=ON",
"-DINFRA_XML=ON",
"-DINFRA_TBB=ON",
"-DINFRA_NUMERIC=OFF",
"-DINFRA_CHARSET=ON",
"-DINFRA_PROCESS=ON",
"-DINFRA_DATABASE=ON",
"-DINFRA_DATABASE_SQLITE=ON",
"-DINFRA_DATABASE_POSTGRES=ON",
"-DINFRA_DATABASE_HASHING=ON",
"-DINFRA_COMPRESSION=ON",
"-DINFRA_COMPRESSION_ZSTD=ON",
"-DINFRA_ENABLE_TESTS=ON",
"-DINFRA_CLI_PROGRESS=ON",
]

if build_ui and triplet.startswith("x64-osx"):
cmake_args.extend(
[
"-DCMAKE_PREFIX_PATH=/usr/local/opt/qt6",
"-DVCPKG_ALLOW_SYSTEM_LIBS=ON",
]
)

targets = []
build_dir = "infra"
install_root = "vcpkgs"

vcpkg.build_project(
os.path.abspath(args.source_dir),
triplet=triplet,
cmake_args=cmake_args,
targets=targets,
build_name=build_dir,
run_tests_after_build=args.run_tests,
test_arguments=args.test_args,
build_config=args.build_config,
install_root=install_root,
)
except KeyboardInterrupt:
print("\nInterrupted")
sys.exit(-1)
except RuntimeError as e:
print(e)
sys.exit(-1)
1 change: 1 addition & 0 deletions deps/vcpkg
Submodule vcpkg added at b2fe75
90 changes: 90 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "infra",
"version": "0.11.2",
"dependencies": [
"fmt",
"doctest"
],
"features": {
"log": {
"description": "logging support",
"dependencies": [
"spdlog"
]
},
"process": {
"description": "process support",
"dependencies": [
"reproc"
]
},
"hashing": {
"description": "hashing support",
"dependencies": [
"cryptopp"
]
},
"xml": {
"description": "xml support",
"dependencies": [
"tinyxml"
]
},
"tbb": {
"description": "threading building blocks support",
"dependencies": [
"tbb"
]
},
"numeric": {
"description": "numeric support",
"dependencies": [
"eigen3"
]
},
"charset": {
"description": "charset conversion/detection support",
"dependencies": [
"icu"
]
},
"compression": {
"description": "compression support",
"dependencies": [
"zstd"
]
},
"gdal": {
"description": "gdal support",
"dependencies": [
"gdal"
]
},
"db": {
"description": "database support",
"dependencies": [
{
"name": "hdf5",
"features": [
"sqlite",
"postgresql"
]
}
]
},
"cpp17": {
"description": "C++17 build",
"dependencies": [
"date",
"gsl"
]
},
"ui": {
"description": "ui support",
"dependencies": [
"qt6"
]
}
}
}

0 comments on commit fa1a6fd

Please sign in to comment.