diff --git a/.gitignore b/.gitignore index ccc3012e..18e7ad4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ -makefile.setup +__pycache__ gnat/ -src/sqlite/amalgamation/sqlite3_for_gps docs/_build @@ -34,3 +33,7 @@ testsuite/gnatcov testsuite/out examples/library/obj + +gnatcoll_core.json +gnatcoll_minimal.json +gnatcoll_projects.json diff --git a/Makefile b/Makefile index 8b35a248..bd6148c8 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ # Makefile targets # ---------------- # -# Setup: make [VAR=VALUE] setup (see below) # Build: make # Install: make install @@ -40,45 +39,24 @@ # TARGET : target triplet for cross-compilation # INTEGRATED : installs the project as part of the compiler installation; # this adds NORMALIZED_TARGET subdir to prefix -# PROJECT : gnatcoll, gnatcoll_projects or gnatcoll_core # Project specific: # -# GNATCOLL_MMAP : whether MMAP is supported (yes/no) -# default is "yes"; has no effect on Windows -# GNATCOLL_MADVISE : whether MADVISE is supported (yes/no) -# default is "yes"; has no effect on Windows # GNATCOLL_PROJECTS : whether GNATCOLL projects package is included (yes/no) # default is "yes"; # helper programs -CAT := cat -ECHO := echo WHICH := which SED := sed -PROJECT=gnatcoll - # check for out-of-tree build SOURCE_DIR := $(dir $(MAKEFILE_LIST)) # make -f with absolute path to current directory Makefile is in-tree build ifeq ($(SOURCE_DIR), $(shell pwd)/) - SOURCE_DIR := ./ + SOURCE_DIR := . endif -ifeq ($(SOURCE_DIR),./) - RBD= - GNATCOLL_GPR=gnatcoll.gpr - GNATCOLL_CORE_GPR=gnatcoll_core.gpr - GNATCOLL_PROJECTS_GPR=gnatcoll_projects.gpr - MAKEPREFIX= -else - RBD=--relocate-build-tree - GNATCOLL_GPR=$(SOURCE_DIR)/gnatcoll.gpr - GNATCOLL_CORE_GPR=$(SOURCE_DIR)/gnatcoll_core.gpr - GNATCOLL_PROJECTS_GPR=$(SOURCE_DIR)/gnatcoll_projects.gpr - MAKEPREFIX=$(SOURCE_DIR)/ -endif +GNATCOLL_GPR=$(SOURCE_DIR)/gnatcoll.gpr TARGET := $(shell gcc -dumpmachine) NORMALIZED_TARGET := $(subst normalized_target:,,$(wordlist 6,6,$(shell gprconfig --config=ada --target=$(TARGET) --mi-show-compilers))) @@ -86,202 +64,65 @@ ifeq ($(NORMALIZED_TARGET),) $(error No toolchain found for target "$(TARGET)") endif -GNATCOLL_OS := $(if $(findstring darwin,$(NORMALIZED_TARGET)),osx,$(if $(findstring windows,$(NORMALIZED_TARGET)),windows,unix)) - prefix := $(dir $(shell $(WHICH) gnatls)).. -GNATCOLL_VERSION := $(shell $(CAT) $(SOURCE_DIR)/version_information) -GNATCOLL_MMAP := yes -GNATCOLL_MADVISE := yes -GNATCOLL_PROJECTS := yes +GNATCOLL_PROJECTS := yes BUILD = PROD PROCESSORS = 0 -BUILD_DIR = ENABLE_SHARED = yes INTEGRATED = no GNATCOV = -# Select the right implementation for blake3 -ifeq ($(NORMALIZED_TARGET), x86_64-linux) - GNATCOLL_BLAKE3_ARCH := x86_64-linux -else - ifeq ($(NORMALIZED_TARGET), x86_64-windows) - GNATCOLL_BLAKE3_ARCH := x86_64-windows - else - ifeq ($(NORMALIZED_TARGET), aarch64-linux) - GNATCOLL_BLAKE3_ARCH := aarch64-linux - else - GNATCOLL_BLAKE3_ARCH := generic - endif - endif -endif - -# Select the right implementation for xxhash -ifeq ($(NORMALIZED_TARGET), x86_64-linux) - GNATCOLL_XXHASH_ARCH := x86_64 -else - ifeq ($(NORMALIZED_TARGET), x86_64-windows) - GNATCOLL_XXHASH_ARCH := x86_64 - else - GNATCOLL_XXHASH_ARCH := generic - endif -endif - all: build -# Load current setup if any --include makefile.setup - GTARGET=--target=$(NORMALIZED_TARGET) -ifeq ($(ENABLE_SHARED), yes) - LIBRARY_TYPES=static relocatable static-pic -else - LIBRARY_TYPES=static -endif - ifeq ($(GNATCOV), yes) - LIBRARY_TYPES=static - GNATCOV_RTS=gnatcovrts - GNATCOV_BUILD_OPTS=--src-subdirs=gnatcov-instr --implicit-with=gnatcov_rts - GNATCOV_PROJECT_PATH=GPR_PROJECT_PATH=$(CURDIR)/gnatcov_rts/share/gpr:$(GPR_PROJECT_PATH) + GNATCOV_BUILD_OPTS=--gnatcov else - GNATCOV_RTS= GNATCOV_BUILD_OPTS= - GNATCOV_PROJECT_PATH= endif ifeq ($(INTEGRATED), yes) integrated_install=/$(NORMALIZED_TARGET) endif +BUILD_ARGS=--jobs=$(PROCESSORS) \ + --build=$(BUILD) \ + --target=$(NORMALIZED_TARGET) \ + --prefix=local-install \ + --install \ + --enable-shared=$(ENABLE_SHARED) - -GPR_VARS=-XGNATCOLL_MMAP=$(GNATCOLL_MMAP) \ - -XGNATCOLL_MADVISE=$(GNATCOLL_MADVISE) \ - -XGNATCOLL_BLAKE3_ARCH=$(GNATCOLL_BLAKE3_ARCH) \ - -XGNATCOLL_XXHASH_ARCH=$(GNATCOLL_XXHASH_ARCH) \ - -XGNATCOLL_PROJECTS=$(GNATCOLL_PROJECTS) \ - -XGNATCOLL_VERSION=$(GNATCOLL_VERSION) \ - -XGNATCOLL_OS=$(GNATCOLL_OS) \ - -XBUILD=$(BUILD) - -# Used to pass extra options to GPRBUILD, like -d for instance -GPRBUILD_OPTIONS= - -BUILDER=$(GNATCOV_PROJECT_PATH) gprbuild -p -m $(GTARGET) $(RBD) \ - -j$(PROCESSORS) $(GPR_VARS) \ - $(GPRBUILD_OPTIONS) $(GNATCOV_BUILD_OPTS) -INSTALLER=gprinstall -p -f $(GTARGET) $(GPR_VARS) \ - $(RBD) --prefix=$(prefix)$(integrated_install) -CLEANER=gprclean -q $(RBD) $(GTARGET) -UNINSTALLER=$(INSTALLER) -p -f --uninstall - -######### -# build # -######### - -build: $(LIBRARY_TYPES:%=build-%) - -build-%: $(GNATCOV_RTS) - -# Gnatcoll projects related packages need libgpr. As conditional -# with does not exist in GPR, `with "gpr"` at the beginning of -# gnatcoll.gpr needs to be commented or uncommented depending on -# the user choice. - +build: + rm -rf local-install + mkdir -p local-install/share/gpr + ifeq ($(GNATCOLL_PROJECTS), yes) - $(SED) -e 's/^-- with "gnatcoll_projects"/with "gnatcoll_projects"/g' $(GNATCOLL_GPR) > tmp ; mv tmp $(GNATCOLL_GPR) + $(SED) -e 's/^-- with "gnatcoll_projects"/with "gnatcoll_projects"/g' $(GNATCOLL_GPR) > local-install/share/gpr/gnatcoll.gpr else - $(SED) -e 's/^with "gnatcoll_projects"/-- with "gnatcoll_projects"/g' $(GNATCOLL_GPR) > tmp ; mv tmp $(GNATCOLL_GPR) + $(SED) -e 's/^with "gnatcoll_projects"/-- with "gnatcoll_projects"/g' $(GNATCOLL_GPR) > local-install/share/gpr/gnatcoll.gpr endif -ifeq ($(GNATCOV), yes) - $(GNATCOV_PROJECT_PATH) gnatcov instrument -P $(GNATCOLL_CORE_GPR) $(GPR_VARS) $(RBD) \ - --no-subprojects --level=stmt+decision -endif - $(BUILDER) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$* -XGPR_BUILD=$* \ - $(GPR_VARS) $(GNATCOLL_CORE_GPR) -v -ifeq ($(GNATCOLL_PROJECTS), yes) - $(BUILDER) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$* -XGPR_BUILD=$* \ - $(GPR_VARS) $(GNATCOLL_PROJECTS_GPR) -v -endif - -################### -# Instrumentation # -################### - -gnatcovrts: - gnatcov setup --prefix=gnatcov_rts + $(SOURCE_DIR)/minimal/gnatcoll_minimal.gpr.py build $(GNATCOV_BUILD_OPTS) $(BUILD_ARGS) + $(SOURCE_DIR)/core/gnatcoll_core.gpr.py build $(GNATCOV_BUILD_OPTS) $(BUILD_ARGS) -########### -# Install # -########### - -uninstall: -ifneq (,$(wildcard $(prefix)$(integrated_install)/share/gpr/manifests/gnatcoll_core)) - $(UNINSTALLER) $(GNATCOLL_CORE_GPR) --install-name=gnatcoll_core --sources-subdir=include/gnatcoll_core -endif ifeq ($(GNATCOLL_PROJECTS), yes) -ifneq (,$(wildcard $(prefix)$(integrated_install)/share/gpr/manifests/gnatcoll_projects)) - $(UNINSTALLER) $(GNATCOLL_PROJECTS_GPR) --install-name=gnatcoll_projects --sources-subdir=include/gnatcoll_projects -endif + $(SOURCE_DIR)/projects/gnatcoll_projects.gpr.py build $(GNATCOV_BUILD_OPTS) $(BUILD_ARGS) endif - - - -install: uninstall $(LIBRARY_TYPES:%=install-%) - -install-%: - $(INSTALLER) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$* -XGPR_BUILD=$* \ - --build-name=$* $(GPR_VARS) \ - --sources-subdir=include/gnatcoll_core \ - --build-var=LIBRARY_TYPE --build-var=GNATCOLL_BUILD \ - --build-var=GNATCOLL_CORE_BUILD $(GNATCOLL_CORE_GPR) -ifeq ($(GNATCOLL_PROJECTS), yes) - $(INSTALLER) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$* -XGPR_BUILD=$* \ - --build-name=$* $(GPR_VARS) \ - --sources-subdir=include/gnatcoll_projects \ - --build-var=LIBRARY_TYPE --build-var=GNATCOLL_BUILD \ - --build-var=GNATCOLL_CORE_BUILD $(GNATCOLL_PROJECTS_GPR) -endif - cp $(GNATCOLL_GPR) $(prefix)$(integrated_install)/share/gpr +install: + @echo "Installing gnatcoll into $(prefix)" + rsync -av ./local-install/ $(prefix)$(integrated_install) ########### # Cleanup # ########### -clean: $(LIBRARY_TYPES:%=clean-%) - -clean-%: -ifeq ($(GNATCOLL_PROJECTS), yes) - -$(CLEANER) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$* -XGPR_BUILD=$* \ - $(GPR_VARS) $(GNATCOLL_PROJECTS_GPR) -endif - -$(CLEANER) -XLIBRARY_TYPE=$* -XXMLADA_BUILD=$* -XGPR_BUILD=$* \ - $(GPR_VARS) $(GNATCOLL_CORE_GPR) - - -######### -# setup # -######### - -.SILENT: setup - -setup: - $(ECHO) "prefix=$(prefix)" > makefile.setup - $(ECHO) "ENABLE_SHARED=$(ENABLE_SHARED)" >> makefile.setup - $(ECHO) "INTEGRATED=$(INTEGRATED)" >> makefile.setup - $(ECHO) "BUILD=$(BUILD)" >> makefile.setup - $(ECHO) "PROCESSORS=$(PROCESSORS)" >> makefile.setup - $(ECHO) "TARGET=$(TARGET)" >> makefile.setup - $(ECHO) "SOURCE_DIR=$(SOURCE_DIR)" >> makefile.setup - $(ECHO) "GNATCOLL_OS=$(GNATCOLL_OS)" >> makefile.setup - $(ECHO) "GNATCOLL_VERSION=$(GNATCOLL_VERSION)" >> makefile.setup - $(ECHO) "GNATCOLL_MMAP=$(GNATCOLL_MMAP)" >> makefile.setup - $(ECHO) "GNATCOLL_MADVISE=$(GNATCOLL_MADVISE)" >> makefile.setup - $(ECHO) "GNATCOLL_PROJECTS=$(GNATCOLL_PROJECTS)" >> makefile.setup +clean: + $(SOURCE_DIR)/projects/gnatcoll_projects.gpr.py clean --add-gpr-path=local-install/share/gpr + $(SOURCE_DIR)/core/gnatcoll_core.gpr.py clean --add-gpr-path=local-install/share/gpr + $(SOURCE_DIR)/minimal/gnatcoll_minimal.gpr.py clean --add-gpr-path=local-install/share/gpr # Let gprbuild handle parallelisation. In general, we don't support parallel # runs in this Makefile, as concurrent gprinstall processes may crash. diff --git a/README.md b/README.md index 4befb12a..e96bd5f1 100644 --- a/README.md +++ b/README.md @@ -1,88 +1,156 @@ -The GNAT Components Collection (GNATcoll) - Core packages -========================================================= +# The GNAT Components Collection (GNATcoll) - Core packages This is the core module of the GNAT Components Collection. Please refer to the documentation in the `docs/` directory. -Code status -=========== +## Structure -TBD +The repository contains three projects: -Dependencies ------------- +* `minimal/gnatcoll_minimal.gpr`: packages that may work on more restrictive cross + environments. +* `core/gnatcoll_core.gpr`: packages that can be used in POSIX or Win32 + environments. +* `projects/gnatcoll_projects.gpr`: high level binding to libgpr project -GNATCOLL requires a recent GNAT compiler. Building it also requires -GPRbuild. GNATCOLL.Projects depends on LIBGPR library which is part of -GPRbuild project. +For backward compatibility a project called `gnatcoll.gpr` is also provided -Configuring the build process ------------------------------ +## Dependencies -The following variables can be used to configure the build process: +GNATCOLL requires: -General: +* A recent GNAT compiler +* Gprbuild tools +* (optional) LIBGPR library (only if using `gnatcoll_project.gpr`) +* (optional) Python (>3.8) to easily configure, build, install each projects. +* (optional) GNU Make to use the legacy makefile that builds the three projects. -* `prefix`: location of the installation, the default is the running GNAT - installation root. +## Building and Installing -* `ENABLE_SHARED`: Use relocatable and static-pic libraries in addition - to static ones (default is 'yes'). +Each project has a helper Python script to handle automatic configuration +and launch of gpr tools. The script is located next to each project and +called `PROJECT_NAME.gpr.py`. -* `BUILD`: control the build options: `PROD` (default) or `DEBUG` +## Building -* `PROCESSORS`: parallel compilation (default is 0, which uses all available - cores) +The simplest way to build a given project is to use the Python helper script. -* `TARGET`: for cross-compilation, auto-detected for native platforms +For example to build gnatcoll_core.gpr project: -* `SOURCE_DIR`: for out-of-tree build +```sh +$ ./gnatcoll_core.gpr.py build +``` -* `INTEGRATED`: if `yes` (default is `no`), consider that `prefix` is where the - toolchain is installed and install GNATcoll in a target-dependent - subdirectory. This makes it possible to install GNATcoll multiple times for - the various compilers in the same prefix. Enable this only for cross - compilers. +For each project the script provides the following commands: -Module-specific: +* `build`: to build and configure the project +* `install`': to install the built project (gprinstall step) +* `clean`': to clean all object files (gprclean step) +* `uninstall`': to uninstall the project (gprinstall --uninstall step) -* `GNATCOLL_MMAP`: whether MMAP is supported (yes/no) default is "yes"; has no - effect on Windows -* `GNATCOLL_MADVISE`: whether MADVISE is supported (yes/no) default is "yes"; - has no effect on Windows +### Build Command -To use the default options: +Use `--help` switch to get the full help on a command. For the build command +the results is: ```sh -$ make setup +$ ./gnatcoll_core.gpr.py build --help +usage: gnatcoll_core.gpr.py build [-h] [--gpr-opts ...] + [--add-gpr-path ADD_GPR_PATH] [--jobs JOBS] + [--target TARGET] [--prefix PREFIX] + [--integrated] [--install] [--gnatcov] + [--configure-only] [--disable-constant-updates] + [--build {DEBUG,PROD}] + [--enable-shared {yes,no}] + +options: + -h, --help show this help message and exit + --gpr-opts ... pass remaining arguments to gprbuild + --add-gpr-path ADD_GPR_PATH + prepend a path to look for GPR files + --jobs JOBS, -j JOBS gprbuild parallelism + --target TARGET target + --prefix PREFIX installation prefix + --integrated installation in platform specific subdir + --install proceed with install automatically after the build + --gnatcov build project with gnatcov instrumentation + --configure-only only perform configuration (i.e: update of project + constants and creation of json file). Can be used to + integrate with Alire + --disable-constant-updates + Do not update constants in GPR file and use only + -XVAR=VALUE to pass configuration to gpr tools + +project specific options: + --build {DEBUG,PROD} + --enable-shared {yes,no} ``` -For example, to setup GNATcoll to install a debug version in -`/opt/libgnatcoll`: +The first set of options is generic, and the second set under `project specific options` +is usually connected to some scenario variables in the project. + +On call to the build command a JSON file is generated containing all the complete +configuration of the project. For example for `gnatcoll_minimal.gpr`, if you call from a +directory called `OBJ_DIR` the following command: ```sh -$ make prefix=/opt/libgnatcoll BUILD=DEBUG install +$ SOURCE_DIR/minimal/gnatcoll_minimal.gpr.py build +... ``` +This will generate in `OBJ_DIR` the file called `gnatcoll_minimal.json`: + +```json +{ + "project_file": "SOURCE_DIR/minimal/gnatcoll_minimal.gpr", + "object_dir": "OBJ_DIR", + "target": null, + "integrated": false, + "variables": { + "GNATCOLL_BUILD_MODE": "PROD", + "GNATCOLL_VERSION": "25.0", + "GNATCOLL_OS": "unix" + }, + "jobs": "0", + "variants_var": "LIBRARY_TYPE", + "variants_values": [ + "static", + "relocatable", + "static-pic" + ], + "gnatcov": false, + "prefix": "COMPILER_PREFIX", + "gpr_paths": [] +} +``` -Building --------- - -Building all versions of the GNATCOLL Core Packages (static, relocatable and -static-pic) is as easy as running `make` in the top directory. Then, to install -it: +In addition, to the generated JSON file a project file might be updated to +update the default values for the managed scenario variables. In the +context of `gnatcoll_minimal.gpr` the project is located in +`config/gnatcoll_minimal_constants.gpr` and contains the following: -```sh -$ make install ``` +abstract project GNATCOLL_Minimal_Constants is + GNATCOLL_VERSION_DEFAULT := "25.0"; + GNATCOLL_BUILD_MODE_DEFAULT := "PROD"; + GNATCOLL_OS_DEFAULT := "unix"; +end GNATCOLL_Minimal_Constants; +``` + +This update can be skipped by passing `--disable-constant-updates`. +In that case the Python script will pass only -XVAR=VALUE options to +the GPR tools to pass the selected configuration. + +Having a project with the updated defaults ease work with: -Note that underneath, this Makefile uses a GPR project file: `gnatcoll.gpr`. -You can build GNATCOLL using it with GPRbuild, but make sure to use the same -command-line options. +* `Alire`: You can use `build --configure-only` command to as a pre-build + step in the `Alire` configuration to generate the right values for the + scenario variables +* `IDE`: When opening the project the right value is automatically selected + for all the scenario variables -Bug reports ------------ +## Bug reports -Please send questions and bug reports to report@adacore.com following +Please send questions and bug reports to support@adacore.com following the same procedures used to submit reports with the GNAT toolset itself. diff --git a/core/VERSION b/core/VERSION new file mode 100644 index 00000000..be8e64f5 --- /dev/null +++ b/core/VERSION @@ -0,0 +1 @@ +25.0 diff --git a/core/config/gnatcoll_core_constants.gpr b/core/config/gnatcoll_core_constants.gpr new file mode 100644 index 00000000..6d9d7de6 --- /dev/null +++ b/core/config/gnatcoll_core_constants.gpr @@ -0,0 +1,9 @@ +abstract project GNATCOLL_Core_Constants is + GNATCOLL_VERSION_DEFAULT := "0.0"; + GNATCOLL_MMAP_DEFAULT := "yes"; + GNATCOLL_MADVISE_DEFAULT := "yes"; + GNATCOLL_BLAKE3_ARCH_DEFAULT := "generic"; + GNATCOLL_XXHASH_ARCH_DEFAULT := "generic"; + GNATCOLL_BUILD_MODE_DEFAULT := "PROD"; + GNATCOLL_OS_DEFAULT := "unix"; +end GNATCOLL_Core_Constants; diff --git a/gnatcoll_core.gpr b/core/gnatcoll_core.gpr similarity index 94% rename from gnatcoll_core.gpr rename to core/gnatcoll_core.gpr index 36a69d09..4892175d 100644 --- a/gnatcoll_core.gpr +++ b/core/gnatcoll_core.gpr @@ -21,25 +21,40 @@ -- -- ------------------------------------------------------------------------------ +with "gnatcoll_minimal.gpr"; +with "config/gnatcoll_core_constants.gpr"; + library project GNATCOLL_Core is - Version := External ("GNATCOLL_VERSION", "0.0"); + type Yes_No is ("yes", "no"); + Name := "gnatcoll_core"; + Version := External + ("GNATCOLL_VERSION", GNATCOLL_Core_Constants.GNATCOLL_VERSION_DEFAULT); + Mmap : Yes_No := External + ("GNATCOLL_MMAP", GNATCOLL_Core_Constants.GNATCOLL_MMAP_DEFAULT); + + Madvise : Yes_No := External + ("GNATCOLL_MADVISE", GNATCOLL_Core_Constants.GNATCOLL_MADVISE_DEFAULT); + Blake3_Arch := External + ("GNATCOLL_BLAKE3_ARCH", + GNATCOLL_Core_Constants.GNATCOLL_BLAKE3_ARCH_DEFAULT); + XXHash_Arch := External + ("GNATCOLL_XXHASH_ARCH", + GNATCOLL_Core_Constants.GNATCOLL_XXHASH_ARCH_DEFAULT); - type Yes_No is ("yes", "no"); - Mmap : Yes_No := External ("GNATCOLL_MMAP", "yes"); - Madvise : Yes_No := External ("GNATCOLL_MADVISE", "yes"); - Blake3_Arch := External ("GNATCOLL_BLAKE3_ARCH", "generic"); - XXHash_Arch := External ("GNATCOLL_XXHASH_ARCH", "generic"); type Build_Type is ("DEBUG", "PROD"); - Build : Build_Type := - External ("GNATCOLL_BUILD_MODE", External ("BUILD", "DEBUG")); + Build : Build_Type := External + ("GNATCOLL_BUILD_MODE", + External + ("BUILD", GNATCOLL_Core_Constants.GNATCOLL_BUILD_MODE_DEFAULT)); type Library_Type_Type is ("relocatable", "static", "static-pic"); Library_Type : Library_Type_Type := External ("LIBRARY_TYPE", "static"); type OS_Kind is ("windows", "unix", "osx"); - OS : OS_Kind := External ("GNATCOLL_OS", "unix"); + OS : OS_Kind := External + ("GNATCOLL_OS", GNATCOLL_Core_Constants.GNATCOLL_OS_DEFAULT); Sources := ("src", "src/os", @@ -205,7 +220,7 @@ library project GNATCOLL_Core is package Builder is case Build is when "DEBUG" => - for Global_Configuration_Pragmas use "gnat_debug.adc"; + for Global_Configuration_Pragmas use "src/gnat_debug.adc"; when "PROD" => null; end case; diff --git a/core/gnatcoll_core.gpr.py b/core/gnatcoll_core.gpr.py new file mode 100755 index 00000000..03a3de53 --- /dev/null +++ b/core/gnatcoll_core.gpr.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +from __future__ import annotations +from typing import TYPE_CHECKING +import logging +import sys +import os + +# Support code is located in parent directory +SOURCE_DIR = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.dirname(SOURCE_DIR)) + +from gprproject import BuilderApp + +if TYPE_CHECKING: + import argparse + from gprproject.gprbuild import GPRTool + + +class GNATCollCore(BuilderApp): + project_file = os.path.join(SOURCE_DIR, "gnatcoll_core.gpr") + description = "GNATCOLL Core library." "" + constants_project_file = os.path.join( + SOURCE_DIR, "config", "gnatcoll_core_constants.gpr" + ) + constants = [ + "GNATCOLL_OS", + "GNATCOLL_BUILD_MODE", + "GNATCOLL_VERSION", + "GNATCOLL_MMAP", + "GNATCOLL_ADVISE", + "GNATCOLL_BLAKE3_ARCH", + "GNATCOLL_XXHASH_ARCH", + ] + + def add_arguments(self, parser: argparse.ArgumentParser) -> None: + parser.add_argument("--build", choices=["DEBUG", "PROD"], default="PROD") + parser.add_argument("--enable-shared", choices=["yes", "no"], default="yes") + + def adjust_config(self, gpr: GPRTool, args: argparse.Namespace) -> None: + # Compute which implementation should be used for blake3 + if gpr.target in ("x86_64-linux", "aarch64-linux", "x86_64-windows"): + blake3_arch = gpr.target + else: + blake3_arch = "generic" + + logging.debug(f"blake3 implementation: {blake3_arch}") + gpr.set_variable("GNATCOLL_BLAKE3_ARCH", blake3_arch) + + # Compute which implementation should be used for xxhash + if gpr.target in ("x86_64-linux", "x86_64-windows"): + xxhash_arch = "x86_64" + else: + xxhash_arch = "generic" + + logging.debug(f"xxhash implementation: {xxhash_arch}") + gpr.set_variable("GNATCOLL_XXHASH_ARCH", xxhash_arch) + + gpr.set_variable("GNATCOLL_MMAP", "yes") + gpr.set_variable("GNATCOLL_MADVISE", "yes") + + with open(os.path.join(SOURCE_DIR, "VERSION")) as fd: + version = fd.read().strip() + gpr.set_variable("GNATCOLL_VERSION", version) + + if "windows" in gpr.target: + gnatcoll_os = "windows" + elif "darwin" in gpr.target: + gnatcoll_os = "osx" + else: + gnatcoll_os = "unix" + gpr.set_variable("GNATCOLL_OS", gnatcoll_os) + gpr.set_variable("GNATCOLL_BUILD_MODE", args.build) + + if args.gnatcov: + gpr.set_variable("LIBRARY_TYPE", "static") + else: + gpr.variants_var = "LIBRARY_TYPE" + if args.enable_shared == "yes": + gpr.variants_values = ["static", "relocatable", "static-pic"] + else: + gpr.variants_values = ["static"] + + +if __name__ == "__main__": + app = GNATCollCore() + sys.exit(app.run()) diff --git a/src/executable_path.c b/core/src/executable_path.c similarity index 100% rename from src/executable_path.c rename to core/src/executable_path.c diff --git a/gnat_debug.adc b/core/src/gnat_debug.adc similarity index 100% rename from gnat_debug.adc rename to core/src/gnat_debug.adc diff --git a/src/gnatcoll-arg_lists.adb b/core/src/gnatcoll-arg_lists.adb similarity index 100% rename from src/gnatcoll-arg_lists.adb rename to core/src/gnatcoll-arg_lists.adb diff --git a/src/gnatcoll-arg_lists.ads b/core/src/gnatcoll-arg_lists.ads similarity index 100% rename from src/gnatcoll-arg_lists.ads rename to core/src/gnatcoll-arg_lists.ads diff --git a/src/gnatcoll-buffer.adb b/core/src/gnatcoll-buffer.adb similarity index 100% rename from src/gnatcoll-buffer.adb rename to core/src/gnatcoll-buffer.adb diff --git a/src/gnatcoll-buffer.ads b/core/src/gnatcoll-buffer.ads similarity index 100% rename from src/gnatcoll-buffer.ads rename to core/src/gnatcoll-buffer.ads diff --git a/src/gnatcoll-config.adb b/core/src/gnatcoll-config.adb similarity index 100% rename from src/gnatcoll-config.adb rename to core/src/gnatcoll-config.adb diff --git a/src/gnatcoll-config.ads b/core/src/gnatcoll-config.ads similarity index 100% rename from src/gnatcoll-config.ads rename to core/src/gnatcoll-config.ads diff --git a/src/gnatcoll-directed_graph.adb b/core/src/gnatcoll-directed_graph.adb similarity index 100% rename from src/gnatcoll-directed_graph.adb rename to core/src/gnatcoll-directed_graph.adb diff --git a/src/gnatcoll-directed_graph.ads b/core/src/gnatcoll-directed_graph.ads similarity index 100% rename from src/gnatcoll-directed_graph.ads rename to core/src/gnatcoll-directed_graph.ads diff --git a/src/gnatcoll-email-mailboxes.adb b/core/src/gnatcoll-email-mailboxes.adb similarity index 100% rename from src/gnatcoll-email-mailboxes.adb rename to core/src/gnatcoll-email-mailboxes.adb diff --git a/src/gnatcoll-email-mailboxes.ads b/core/src/gnatcoll-email-mailboxes.ads similarity index 100% rename from src/gnatcoll-email-mailboxes.ads rename to core/src/gnatcoll-email-mailboxes.ads diff --git a/src/gnatcoll-email-parser.adb b/core/src/gnatcoll-email-parser.adb similarity index 100% rename from src/gnatcoll-email-parser.adb rename to core/src/gnatcoll-email-parser.adb diff --git a/src/gnatcoll-email-parser.ads b/core/src/gnatcoll-email-parser.ads similarity index 100% rename from src/gnatcoll-email-parser.ads rename to core/src/gnatcoll-email-parser.ads diff --git a/src/gnatcoll-email-utils.adb b/core/src/gnatcoll-email-utils.adb similarity index 100% rename from src/gnatcoll-email-utils.adb rename to core/src/gnatcoll-email-utils.adb diff --git a/src/gnatcoll-email-utils.ads b/core/src/gnatcoll-email-utils.ads similarity index 100% rename from src/gnatcoll-email-utils.ads rename to core/src/gnatcoll-email-utils.ads diff --git a/src/gnatcoll-email.adb b/core/src/gnatcoll-email.adb similarity index 100% rename from src/gnatcoll-email.adb rename to core/src/gnatcoll-email.adb diff --git a/src/gnatcoll-email.ads b/core/src/gnatcoll-email.ads similarity index 100% rename from src/gnatcoll-email.ads rename to core/src/gnatcoll-email.ads diff --git a/src/gnatcoll-file_indexes.adb b/core/src/gnatcoll-file_indexes.adb similarity index 100% rename from src/gnatcoll-file_indexes.adb rename to core/src/gnatcoll-file_indexes.adb diff --git a/src/gnatcoll-file_indexes.ads b/core/src/gnatcoll-file_indexes.ads similarity index 100% rename from src/gnatcoll-file_indexes.ads rename to core/src/gnatcoll-file_indexes.ads diff --git a/src/gnatcoll-file_paths.adb b/core/src/gnatcoll-file_paths.adb similarity index 100% rename from src/gnatcoll-file_paths.adb rename to core/src/gnatcoll-file_paths.adb diff --git a/src/gnatcoll-file_paths.ads b/core/src/gnatcoll-file_paths.ads similarity index 100% rename from src/gnatcoll-file_paths.ads rename to core/src/gnatcoll-file_paths.ads diff --git a/src/gnatcoll-format_columns_vertical.ads b/core/src/gnatcoll-format_columns_vertical.ads similarity index 100% rename from src/gnatcoll-format_columns_vertical.ads rename to core/src/gnatcoll-format_columns_vertical.ads diff --git a/src/gnatcoll-formatters.adb b/core/src/gnatcoll-formatters.adb similarity index 100% rename from src/gnatcoll-formatters.adb rename to core/src/gnatcoll-formatters.adb diff --git a/src/gnatcoll-formatters.ads b/core/src/gnatcoll-formatters.ads similarity index 100% rename from src/gnatcoll-formatters.ads rename to core/src/gnatcoll-formatters.ads diff --git a/src/gnatcoll-io-native-codec__unix.adb b/core/src/gnatcoll-io-native-codec__unix.adb similarity index 100% rename from src/gnatcoll-io-native-codec__unix.adb rename to core/src/gnatcoll-io-native-codec__unix.adb diff --git a/src/gnatcoll-io-native-codec__win32.adb b/core/src/gnatcoll-io-native-codec__win32.adb similarity index 100% rename from src/gnatcoll-io-native-codec__win32.adb rename to core/src/gnatcoll-io-native-codec__win32.adb diff --git a/src/gnatcoll-io-native.adb b/core/src/gnatcoll-io-native.adb similarity index 100% rename from src/gnatcoll-io-native.adb rename to core/src/gnatcoll-io-native.adb diff --git a/src/gnatcoll-io-native.ads b/core/src/gnatcoll-io-native.ads similarity index 100% rename from src/gnatcoll-io-native.ads rename to core/src/gnatcoll-io-native.ads diff --git a/src/gnatcoll-io-remote-unix.adb b/core/src/gnatcoll-io-remote-unix.adb similarity index 100% rename from src/gnatcoll-io-remote-unix.adb rename to core/src/gnatcoll-io-remote-unix.adb diff --git a/src/gnatcoll-io-remote-unix.ads b/core/src/gnatcoll-io-remote-unix.ads similarity index 100% rename from src/gnatcoll-io-remote-unix.ads rename to core/src/gnatcoll-io-remote-unix.ads diff --git a/src/gnatcoll-io-remote-windows.adb b/core/src/gnatcoll-io-remote-windows.adb similarity index 100% rename from src/gnatcoll-io-remote-windows.adb rename to core/src/gnatcoll-io-remote-windows.adb diff --git a/src/gnatcoll-io-remote-windows.ads b/core/src/gnatcoll-io-remote-windows.ads similarity index 100% rename from src/gnatcoll-io-remote-windows.ads rename to core/src/gnatcoll-io-remote-windows.ads diff --git a/src/gnatcoll-io-remote.adb b/core/src/gnatcoll-io-remote.adb similarity index 100% rename from src/gnatcoll-io-remote.adb rename to core/src/gnatcoll-io-remote.adb diff --git a/src/gnatcoll-io-remote.ads b/core/src/gnatcoll-io-remote.ads similarity index 100% rename from src/gnatcoll-io-remote.ads rename to core/src/gnatcoll-io-remote.ads diff --git a/src/gnatcoll-io.adb b/core/src/gnatcoll-io.adb similarity index 100% rename from src/gnatcoll-io.adb rename to core/src/gnatcoll-io.adb diff --git a/src/gnatcoll-io.ads b/core/src/gnatcoll-io.ads similarity index 100% rename from src/gnatcoll-io.ads rename to core/src/gnatcoll-io.ads diff --git a/src/gnatcoll-json-utility.adb b/core/src/gnatcoll-json-utility.adb similarity index 100% rename from src/gnatcoll-json-utility.adb rename to core/src/gnatcoll-json-utility.adb diff --git a/src/gnatcoll-json-utility.ads b/core/src/gnatcoll-json-utility.ads similarity index 100% rename from src/gnatcoll-json-utility.ads rename to core/src/gnatcoll-json-utility.ads diff --git a/src/gnatcoll-json.adb b/core/src/gnatcoll-json.adb similarity index 100% rename from src/gnatcoll-json.adb rename to core/src/gnatcoll-json.adb diff --git a/src/gnatcoll-json.ads b/core/src/gnatcoll-json.ads similarity index 100% rename from src/gnatcoll-json.ads rename to core/src/gnatcoll-json.ads diff --git a/src/gnatcoll-mmap-system__unix.adb b/core/src/gnatcoll-mmap-system__unix.adb similarity index 100% rename from src/gnatcoll-mmap-system__unix.adb rename to core/src/gnatcoll-mmap-system__unix.adb diff --git a/src/gnatcoll-mmap-system__unix.ads b/core/src/gnatcoll-mmap-system__unix.ads similarity index 100% rename from src/gnatcoll-mmap-system__unix.ads rename to core/src/gnatcoll-mmap-system__unix.ads diff --git a/src/gnatcoll-mmap-system__win32.adb b/core/src/gnatcoll-mmap-system__win32.adb similarity index 100% rename from src/gnatcoll-mmap-system__win32.adb rename to core/src/gnatcoll-mmap-system__win32.adb diff --git a/src/gnatcoll-mmap-system__win32.ads b/core/src/gnatcoll-mmap-system__win32.ads similarity index 100% rename from src/gnatcoll-mmap-system__win32.ads rename to core/src/gnatcoll-mmap-system__win32.ads diff --git a/src/gnatcoll-mmap.adb b/core/src/gnatcoll-mmap.adb similarity index 100% rename from src/gnatcoll-mmap.adb rename to core/src/gnatcoll-mmap.adb diff --git a/src/gnatcoll-mmap.ads b/core/src/gnatcoll-mmap.ads similarity index 100% rename from src/gnatcoll-mmap.ads rename to core/src/gnatcoll-mmap.ads diff --git a/src/gnatcoll-opt_parse.adb b/core/src/gnatcoll-opt_parse.adb similarity index 100% rename from src/gnatcoll-opt_parse.adb rename to core/src/gnatcoll-opt_parse.adb diff --git a/src/gnatcoll-opt_parse.ads b/core/src/gnatcoll-opt_parse.ads similarity index 100% rename from src/gnatcoll-opt_parse.ads rename to core/src/gnatcoll-opt_parse.ads diff --git a/src/gnatcoll-path.adb b/core/src/gnatcoll-path.adb similarity index 100% rename from src/gnatcoll-path.adb rename to core/src/gnatcoll-path.adb diff --git a/src/gnatcoll-path.ads b/core/src/gnatcoll-path.ads similarity index 100% rename from src/gnatcoll-path.ads rename to core/src/gnatcoll-path.ads diff --git a/src/gnatcoll-plugins.ads b/core/src/gnatcoll-plugins.ads similarity index 100% rename from src/gnatcoll-plugins.ads rename to core/src/gnatcoll-plugins.ads diff --git a/src/gnatcoll-plugins__unix.adb b/core/src/gnatcoll-plugins__unix.adb similarity index 100% rename from src/gnatcoll-plugins__unix.adb rename to core/src/gnatcoll-plugins__unix.adb diff --git a/src/gnatcoll-plugins__windows.adb b/core/src/gnatcoll-plugins__windows.adb similarity index 100% rename from src/gnatcoll-plugins__windows.adb rename to core/src/gnatcoll-plugins__windows.adb diff --git a/src/gnatcoll-pools.adb b/core/src/gnatcoll-pools.adb similarity index 100% rename from src/gnatcoll-pools.adb rename to core/src/gnatcoll-pools.adb diff --git a/src/gnatcoll-pools.ads b/core/src/gnatcoll-pools.ads similarity index 100% rename from src/gnatcoll-pools.ads rename to core/src/gnatcoll-pools.ads diff --git a/src/gnatcoll-remote-db.adb b/core/src/gnatcoll-remote-db.adb similarity index 100% rename from src/gnatcoll-remote-db.adb rename to core/src/gnatcoll-remote-db.adb diff --git a/src/gnatcoll-remote-db.ads b/core/src/gnatcoll-remote-db.ads similarity index 100% rename from src/gnatcoll-remote-db.ads rename to core/src/gnatcoll-remote-db.ads diff --git a/src/gnatcoll-remote.ads b/core/src/gnatcoll-remote.ads similarity index 100% rename from src/gnatcoll-remote.ads rename to core/src/gnatcoll-remote.ads diff --git a/src/gnatcoll-scripts-impl.adb b/core/src/gnatcoll-scripts-impl.adb similarity index 100% rename from src/gnatcoll-scripts-impl.adb rename to core/src/gnatcoll-scripts-impl.adb diff --git a/src/gnatcoll-scripts-impl.ads b/core/src/gnatcoll-scripts-impl.ads similarity index 100% rename from src/gnatcoll-scripts-impl.ads rename to core/src/gnatcoll-scripts-impl.ads diff --git a/src/gnatcoll-scripts-utils.adb b/core/src/gnatcoll-scripts-utils.adb similarity index 100% rename from src/gnatcoll-scripts-utils.adb rename to core/src/gnatcoll-scripts-utils.adb diff --git a/src/gnatcoll-scripts-utils.ads b/core/src/gnatcoll-scripts-utils.ads similarity index 100% rename from src/gnatcoll-scripts-utils.ads rename to core/src/gnatcoll-scripts-utils.ads diff --git a/src/gnatcoll-scripts.adb b/core/src/gnatcoll-scripts.adb similarity index 100% rename from src/gnatcoll-scripts.adb rename to core/src/gnatcoll-scripts.adb diff --git a/src/gnatcoll-scripts.ads b/core/src/gnatcoll-scripts.ads similarity index 100% rename from src/gnatcoll-scripts.ads rename to core/src/gnatcoll-scripts.ads diff --git a/src/gnatcoll-string_builders.adb b/core/src/gnatcoll-string_builders.adb similarity index 100% rename from src/gnatcoll-string_builders.adb rename to core/src/gnatcoll-string_builders.adb diff --git a/src/gnatcoll-string_builders.ads b/core/src/gnatcoll-string_builders.ads similarity index 100% rename from src/gnatcoll-string_builders.ads rename to core/src/gnatcoll-string_builders.ads diff --git a/src/gnatcoll-string_list_builders.adb b/core/src/gnatcoll-string_list_builders.adb similarity index 100% rename from src/gnatcoll-string_list_builders.adb rename to core/src/gnatcoll-string_list_builders.adb diff --git a/src/gnatcoll-string_list_builders.ads b/core/src/gnatcoll-string_list_builders.ads similarity index 100% rename from src/gnatcoll-string_list_builders.ads rename to core/src/gnatcoll-string_list_builders.ads diff --git a/src/gnatcoll-strings.ads b/core/src/gnatcoll-strings.ads similarity index 100% rename from src/gnatcoll-strings.ads rename to core/src/gnatcoll-strings.ads diff --git a/src/gnatcoll-strings_impl.adb b/core/src/gnatcoll-strings_impl.adb similarity index 100% rename from src/gnatcoll-strings_impl.adb rename to core/src/gnatcoll-strings_impl.adb diff --git a/src/gnatcoll-strings_impl.ads b/core/src/gnatcoll-strings_impl.ads similarity index 100% rename from src/gnatcoll-strings_impl.ads rename to core/src/gnatcoll-strings_impl.ads diff --git a/src/gnatcoll-symbols.adb b/core/src/gnatcoll-symbols.adb similarity index 100% rename from src/gnatcoll-symbols.adb rename to core/src/gnatcoll-symbols.adb diff --git a/src/gnatcoll-symbols.ads b/core/src/gnatcoll-symbols.ads similarity index 100% rename from src/gnatcoll-symbols.ads rename to core/src/gnatcoll-symbols.ads diff --git a/src/gnatcoll-templates.adb b/core/src/gnatcoll-templates.adb similarity index 100% rename from src/gnatcoll-templates.adb rename to core/src/gnatcoll-templates.adb diff --git a/src/gnatcoll-templates.ads b/core/src/gnatcoll-templates.ads similarity index 100% rename from src/gnatcoll-templates.ads rename to core/src/gnatcoll-templates.ads diff --git a/src/gnatcoll-terminal.adb b/core/src/gnatcoll-terminal.adb similarity index 100% rename from src/gnatcoll-terminal.adb rename to core/src/gnatcoll-terminal.adb diff --git a/src/gnatcoll-terminal.ads b/core/src/gnatcoll-terminal.ads similarity index 100% rename from src/gnatcoll-terminal.ads rename to core/src/gnatcoll-terminal.ads diff --git a/src/gnatcoll-traces.adb b/core/src/gnatcoll-traces.adb similarity index 100% rename from src/gnatcoll-traces.adb rename to core/src/gnatcoll-traces.adb diff --git a/src/gnatcoll-traces.ads b/core/src/gnatcoll-traces.ads similarity index 100% rename from src/gnatcoll-traces.ads rename to core/src/gnatcoll-traces.ads diff --git a/src/gnatcoll-utils.adb b/core/src/gnatcoll-utils.adb similarity index 100% rename from src/gnatcoll-utils.adb rename to core/src/gnatcoll-utils.adb diff --git a/src/gnatcoll-utils.ads b/core/src/gnatcoll-utils.ads similarity index 100% rename from src/gnatcoll-utils.ads rename to core/src/gnatcoll-utils.ads diff --git a/src/gnatcoll-vfs.adb b/core/src/gnatcoll-vfs.adb similarity index 100% rename from src/gnatcoll-vfs.adb rename to core/src/gnatcoll-vfs.adb diff --git a/src/gnatcoll-vfs.ads b/core/src/gnatcoll-vfs.ads similarity index 100% rename from src/gnatcoll-vfs.ads rename to core/src/gnatcoll-vfs.ads diff --git a/src/gnatcoll-vfs_types.ads b/core/src/gnatcoll-vfs_types.ads similarity index 100% rename from src/gnatcoll-vfs_types.ads rename to core/src/gnatcoll-vfs_types.ads diff --git a/src/gnatcoll-vfs_utils.adb b/core/src/gnatcoll-vfs_utils.adb similarity index 100% rename from src/gnatcoll-vfs_utils.adb rename to core/src/gnatcoll-vfs_utils.adb diff --git a/src/gnatcoll-vfs_utils.ads b/core/src/gnatcoll-vfs_utils.ads similarity index 100% rename from src/gnatcoll-vfs_utils.ads rename to core/src/gnatcoll-vfs_utils.ads diff --git a/src/gnatcoll-wstring_builders.adb b/core/src/gnatcoll-wstring_builders.adb similarity index 100% rename from src/gnatcoll-wstring_builders.adb rename to core/src/gnatcoll-wstring_builders.adb diff --git a/src/gnatcoll-wstring_builders.ads b/core/src/gnatcoll-wstring_builders.ads similarity index 100% rename from src/gnatcoll-wstring_builders.ads rename to core/src/gnatcoll-wstring_builders.ads diff --git a/src/gnatcoll-wstring_list_builders.adb b/core/src/gnatcoll-wstring_list_builders.adb similarity index 100% rename from src/gnatcoll-wstring_list_builders.adb rename to core/src/gnatcoll-wstring_list_builders.adb diff --git a/src/gnatcoll-wstring_list_builders.ads b/core/src/gnatcoll-wstring_list_builders.ads similarity index 100% rename from src/gnatcoll-wstring_list_builders.ads rename to core/src/gnatcoll-wstring_list_builders.ads diff --git a/src/gnatcoll_support.c b/core/src/gnatcoll_support.c similarity index 100% rename from src/gnatcoll_support.c rename to core/src/gnatcoll_support.c diff --git a/src/hash/blake3/aarch64-linux/blake3_neon.c b/core/src/hash/blake3/aarch64-linux/blake3_neon.c similarity index 100% rename from src/hash/blake3/aarch64-linux/blake3_neon.c rename to core/src/hash/blake3/aarch64-linux/blake3_neon.c diff --git a/src/hash/blake3/blake3.c b/core/src/hash/blake3/blake3.c similarity index 100% rename from src/hash/blake3/blake3.c rename to core/src/hash/blake3/blake3.c diff --git a/src/hash/blake3/blake3.h b/core/src/hash/blake3/blake3.h similarity index 100% rename from src/hash/blake3/blake3.h rename to core/src/hash/blake3/blake3.h diff --git a/src/hash/blake3/blake3_dispatch.c b/core/src/hash/blake3/blake3_dispatch.c similarity index 100% rename from src/hash/blake3/blake3_dispatch.c rename to core/src/hash/blake3/blake3_dispatch.c diff --git a/src/hash/blake3/blake3_impl.h b/core/src/hash/blake3/blake3_impl.h similarity index 100% rename from src/hash/blake3/blake3_impl.h rename to core/src/hash/blake3/blake3_impl.h diff --git a/src/hash/blake3/blake3_portable.c b/core/src/hash/blake3/blake3_portable.c similarity index 100% rename from src/hash/blake3/blake3_portable.c rename to core/src/hash/blake3/blake3_portable.c diff --git a/src/hash/blake3/gnatcoll-hash-blake3.adb b/core/src/hash/blake3/gnatcoll-hash-blake3.adb similarity index 100% rename from src/hash/blake3/gnatcoll-hash-blake3.adb rename to core/src/hash/blake3/gnatcoll-hash-blake3.adb diff --git a/src/hash/blake3/gnatcoll-hash-blake3.ads b/core/src/hash/blake3/gnatcoll-hash-blake3.ads similarity index 100% rename from src/hash/blake3/gnatcoll-hash-blake3.ads rename to core/src/hash/blake3/gnatcoll-hash-blake3.ads diff --git a/src/hash/blake3/x86_64-linux/blake3_avx2_x86-64_unix.S b/core/src/hash/blake3/x86_64-linux/blake3_avx2_x86-64_unix.S similarity index 100% rename from src/hash/blake3/x86_64-linux/blake3_avx2_x86-64_unix.S rename to core/src/hash/blake3/x86_64-linux/blake3_avx2_x86-64_unix.S diff --git a/src/hash/blake3/x86_64-linux/blake3_avx512_x86-64_unix.S b/core/src/hash/blake3/x86_64-linux/blake3_avx512_x86-64_unix.S similarity index 100% rename from src/hash/blake3/x86_64-linux/blake3_avx512_x86-64_unix.S rename to core/src/hash/blake3/x86_64-linux/blake3_avx512_x86-64_unix.S diff --git a/src/hash/blake3/x86_64-linux/blake3_sse2_x86-64_unix.S b/core/src/hash/blake3/x86_64-linux/blake3_sse2_x86-64_unix.S similarity index 100% rename from src/hash/blake3/x86_64-linux/blake3_sse2_x86-64_unix.S rename to core/src/hash/blake3/x86_64-linux/blake3_sse2_x86-64_unix.S diff --git a/src/hash/blake3/x86_64-linux/blake3_sse41_x86-64_unix.S b/core/src/hash/blake3/x86_64-linux/blake3_sse41_x86-64_unix.S similarity index 100% rename from src/hash/blake3/x86_64-linux/blake3_sse41_x86-64_unix.S rename to core/src/hash/blake3/x86_64-linux/blake3_sse41_x86-64_unix.S diff --git a/src/hash/blake3/x86_64-windows/blake3_avx2_x86-64_windows_gnu.S b/core/src/hash/blake3/x86_64-windows/blake3_avx2_x86-64_windows_gnu.S similarity index 100% rename from src/hash/blake3/x86_64-windows/blake3_avx2_x86-64_windows_gnu.S rename to core/src/hash/blake3/x86_64-windows/blake3_avx2_x86-64_windows_gnu.S diff --git a/src/hash/blake3/x86_64-windows/blake3_avx512_x86-64_windows_gnu.S b/core/src/hash/blake3/x86_64-windows/blake3_avx512_x86-64_windows_gnu.S similarity index 100% rename from src/hash/blake3/x86_64-windows/blake3_avx512_x86-64_windows_gnu.S rename to core/src/hash/blake3/x86_64-windows/blake3_avx512_x86-64_windows_gnu.S diff --git a/src/hash/blake3/x86_64-windows/blake3_sse2_x86-64_windows_gnu.S b/core/src/hash/blake3/x86_64-windows/blake3_sse2_x86-64_windows_gnu.S similarity index 100% rename from src/hash/blake3/x86_64-windows/blake3_sse2_x86-64_windows_gnu.S rename to core/src/hash/blake3/x86_64-windows/blake3_sse2_x86-64_windows_gnu.S diff --git a/src/hash/blake3/x86_64-windows/blake3_sse41_x86-64_windows_gnu.S b/core/src/hash/blake3/x86_64-windows/blake3_sse41_x86-64_windows_gnu.S similarity index 100% rename from src/hash/blake3/x86_64-windows/blake3_sse41_x86-64_windows_gnu.S rename to core/src/hash/blake3/x86_64-windows/blake3_sse41_x86-64_windows_gnu.S diff --git a/src/hash/gnatcoll-hash.ads b/core/src/hash/gnatcoll-hash.ads similarity index 100% rename from src/hash/gnatcoll-hash.ads rename to core/src/hash/gnatcoll-hash.ads diff --git a/src/hash/xxhash/gnatcoll-hash-xxhash.ads b/core/src/hash/xxhash/gnatcoll-hash-xxhash.ads similarity index 100% rename from src/hash/xxhash/gnatcoll-hash-xxhash.ads rename to core/src/hash/xxhash/gnatcoll-hash-xxhash.ads diff --git a/src/hash/xxhash/gnatcoll-hash-xxhash__generic.adb b/core/src/hash/xxhash/gnatcoll-hash-xxhash__generic.adb similarity index 100% rename from src/hash/xxhash/gnatcoll-hash-xxhash__generic.adb rename to core/src/hash/xxhash/gnatcoll-hash-xxhash__generic.adb diff --git a/src/hash/xxhash/gnatcoll-hash-xxhash__x8664.adb b/core/src/hash/xxhash/gnatcoll-hash-xxhash__x8664.adb similarity index 100% rename from src/hash/xxhash/gnatcoll-hash-xxhash__x8664.adb rename to core/src/hash/xxhash/gnatcoll-hash-xxhash__x8664.adb diff --git a/src/hash/xxhash/x86_64/xxh_x86dispatch.c b/core/src/hash/xxhash/x86_64/xxh_x86dispatch.c similarity index 100% rename from src/hash/xxhash/x86_64/xxh_x86dispatch.c rename to core/src/hash/xxhash/x86_64/xxh_x86dispatch.c diff --git a/src/hash/xxhash/x86_64/xxh_x86dispatch.h b/core/src/hash/xxhash/x86_64/xxh_x86dispatch.h similarity index 100% rename from src/hash/xxhash/x86_64/xxh_x86dispatch.h rename to core/src/hash/xxhash/x86_64/xxh_x86dispatch.h diff --git a/src/hash/xxhash/xxhash.c b/core/src/hash/xxhash/xxhash.c similarity index 100% rename from src/hash/xxhash/xxhash.c rename to core/src/hash/xxhash/xxhash.c diff --git a/src/hash/xxhash/xxhash.h b/core/src/hash/xxhash/xxhash.h similarity index 100% rename from src/hash/xxhash/xxhash.h rename to core/src/hash/xxhash/xxhash.h diff --git a/src/link_max.c b/core/src/link_max.c similarity index 100% rename from src/link_max.c rename to core/src/link_max.c diff --git a/src/objlist_file.c b/core/src/objlist_file.c similarity index 100% rename from src/objlist_file.c rename to core/src/objlist_file.c diff --git a/src/os/gnatcoll-os-constants__osx.ads b/core/src/os/gnatcoll-os-constants__osx.ads similarity index 100% rename from src/os/gnatcoll-os-constants__osx.ads rename to core/src/os/gnatcoll-os-constants__osx.ads diff --git a/src/os/gnatcoll-os-constants__unix.ads b/core/src/os/gnatcoll-os-constants__unix.ads similarity index 100% rename from src/os/gnatcoll-os-constants__unix.ads rename to core/src/os/gnatcoll-os-constants__unix.ads diff --git a/src/os/gnatcoll-os-constants__windows.ads b/core/src/os/gnatcoll-os-constants__windows.ads similarity index 100% rename from src/os/gnatcoll-os-constants__windows.ads rename to core/src/os/gnatcoll-os-constants__windows.ads diff --git a/src/os/gnatcoll-os-dir-close__unix.adb b/core/src/os/gnatcoll-os-dir-close__unix.adb similarity index 100% rename from src/os/gnatcoll-os-dir-close__unix.adb rename to core/src/os/gnatcoll-os-dir-close__unix.adb diff --git a/src/os/gnatcoll-os-dir-close__win32.adb b/core/src/os/gnatcoll-os-dir-close__win32.adb similarity index 100% rename from src/os/gnatcoll-os-dir-close__win32.adb rename to core/src/os/gnatcoll-os-dir-close__win32.adb diff --git a/src/os/gnatcoll-os-dir-create__unix.adb b/core/src/os/gnatcoll-os-dir-create__unix.adb similarity index 100% rename from src/os/gnatcoll-os-dir-create__unix.adb rename to core/src/os/gnatcoll-os-dir-create__unix.adb diff --git a/src/os/gnatcoll-os-dir-open__unix.adb b/core/src/os/gnatcoll-os-dir-open__unix.adb similarity index 100% rename from src/os/gnatcoll-os-dir-open__unix.adb rename to core/src/os/gnatcoll-os-dir-open__unix.adb diff --git a/src/os/gnatcoll-os-dir-open__win32.adb b/core/src/os/gnatcoll-os-dir-open__win32.adb similarity index 100% rename from src/os/gnatcoll-os-dir-open__win32.adb rename to core/src/os/gnatcoll-os-dir-open__win32.adb diff --git a/src/os/gnatcoll-os-dir-read__unix.adb b/core/src/os/gnatcoll-os-dir-read__unix.adb similarity index 100% rename from src/os/gnatcoll-os-dir-read__unix.adb rename to core/src/os/gnatcoll-os-dir-read__unix.adb diff --git a/src/os/gnatcoll-os-dir-read__win32.adb b/core/src/os/gnatcoll-os-dir-read__win32.adb similarity index 100% rename from src/os/gnatcoll-os-dir-read__win32.adb rename to core/src/os/gnatcoll-os-dir-read__win32.adb diff --git a/src/os/gnatcoll-os-dir.adb b/core/src/os/gnatcoll-os-dir.adb similarity index 100% rename from src/os/gnatcoll-os-dir.adb rename to core/src/os/gnatcoll-os-dir.adb diff --git a/src/os/gnatcoll-os-dir.ads b/core/src/os/gnatcoll-os-dir.ads similarity index 100% rename from src/os/gnatcoll-os-dir.ads rename to core/src/os/gnatcoll-os-dir.ads diff --git a/src/os/gnatcoll-os-dir_types__unix.ads b/core/src/os/gnatcoll-os-dir_types__unix.ads similarity index 100% rename from src/os/gnatcoll-os-dir_types__unix.ads rename to core/src/os/gnatcoll-os-dir_types__unix.ads diff --git a/src/os/gnatcoll-os-dir_types__win32.ads b/core/src/os/gnatcoll-os-dir_types__win32.ads similarity index 100% rename from src/os/gnatcoll-os-dir_types__win32.ads rename to core/src/os/gnatcoll-os-dir_types__win32.ads diff --git a/src/os/gnatcoll-os-fs-is_console__unix.adb b/core/src/os/gnatcoll-os-fs-is_console__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fs-is_console__unix.adb rename to core/src/os/gnatcoll-os-fs-is_console__unix.adb diff --git a/src/os/gnatcoll-os-fs-is_console__win32.adb b/core/src/os/gnatcoll-os-fs-is_console__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fs-is_console__win32.adb rename to core/src/os/gnatcoll-os-fs-is_console__win32.adb diff --git a/src/os/gnatcoll-os-fs-null_file__unix.adb b/core/src/os/gnatcoll-os-fs-null_file__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fs-null_file__unix.adb rename to core/src/os/gnatcoll-os-fs-null_file__unix.adb diff --git a/src/os/gnatcoll-os-fs-null_file__win32.adb b/core/src/os/gnatcoll-os-fs-null_file__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fs-null_file__win32.adb rename to core/src/os/gnatcoll-os-fs-null_file__win32.adb diff --git a/src/os/gnatcoll-os-fs-open__unix.adb b/core/src/os/gnatcoll-os-fs-open__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fs-open__unix.adb rename to core/src/os/gnatcoll-os-fs-open__unix.adb diff --git a/src/os/gnatcoll-os-fs-open__win32.adb b/core/src/os/gnatcoll-os-fs-open__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fs-open__win32.adb rename to core/src/os/gnatcoll-os-fs-open__win32.adb diff --git a/src/os/gnatcoll-os-fs-open_pipe__linux.adb b/core/src/os/gnatcoll-os-fs-open_pipe__linux.adb similarity index 100% rename from src/os/gnatcoll-os-fs-open_pipe__linux.adb rename to core/src/os/gnatcoll-os-fs-open_pipe__linux.adb diff --git a/src/os/gnatcoll-os-fs-open_pipe__unix.adb b/core/src/os/gnatcoll-os-fs-open_pipe__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fs-open_pipe__unix.adb rename to core/src/os/gnatcoll-os-fs-open_pipe__unix.adb diff --git a/src/os/gnatcoll-os-fs-open_pipe__win32.adb b/core/src/os/gnatcoll-os-fs-open_pipe__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fs-open_pipe__win32.adb rename to core/src/os/gnatcoll-os-fs-open_pipe__win32.adb diff --git a/src/os/gnatcoll-os-fs-set_close_on_exec__unix.adb b/core/src/os/gnatcoll-os-fs-set_close_on_exec__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fs-set_close_on_exec__unix.adb rename to core/src/os/gnatcoll-os-fs-set_close_on_exec__unix.adb diff --git a/src/os/gnatcoll-os-fs-set_close_on_exec__win32.adb b/core/src/os/gnatcoll-os-fs-set_close_on_exec__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fs-set_close_on_exec__win32.adb rename to core/src/os/gnatcoll-os-fs-set_close_on_exec__win32.adb diff --git a/src/os/gnatcoll-os-fs.adb b/core/src/os/gnatcoll-os-fs.adb similarity index 100% rename from src/os/gnatcoll-os-fs.adb rename to core/src/os/gnatcoll-os-fs.adb diff --git a/src/os/gnatcoll-os-fs.ads b/core/src/os/gnatcoll-os-fs.ads similarity index 100% rename from src/os/gnatcoll-os-fs.ads rename to core/src/os/gnatcoll-os-fs.ads diff --git a/src/os/gnatcoll-os-fsutil-copy_file_content__unix.adb b/core/src/os/gnatcoll-os-fsutil-copy_file_content__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-copy_file_content__unix.adb rename to core/src/os/gnatcoll-os-fsutil-copy_file_content__unix.adb diff --git a/src/os/gnatcoll-os-fsutil-copy_file_content__win32.adb b/core/src/os/gnatcoll-os-fsutil-copy_file_content__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-copy_file_content__win32.adb rename to core/src/os/gnatcoll-os-fsutil-copy_file_content__win32.adb diff --git a/src/os/gnatcoll-os-fsutil-copy_permissions__unix.adb b/core/src/os/gnatcoll-os-fsutil-copy_permissions__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-copy_permissions__unix.adb rename to core/src/os/gnatcoll-os-fsutil-copy_permissions__unix.adb diff --git a/src/os/gnatcoll-os-fsutil-copy_permissions__win32.adb b/core/src/os/gnatcoll-os-fsutil-copy_permissions__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-copy_permissions__win32.adb rename to core/src/os/gnatcoll-os-fsutil-copy_permissions__win32.adb diff --git a/src/os/gnatcoll-os-fsutil-copy_timestamps__unix.adb b/core/src/os/gnatcoll-os-fsutil-copy_timestamps__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-copy_timestamps__unix.adb rename to core/src/os/gnatcoll-os-fsutil-copy_timestamps__unix.adb diff --git a/src/os/gnatcoll-os-fsutil-copy_timestamps__win32.adb b/core/src/os/gnatcoll-os-fsutil-copy_timestamps__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-copy_timestamps__win32.adb rename to core/src/os/gnatcoll-os-fsutil-copy_timestamps__win32.adb diff --git a/src/os/gnatcoll-os-fsutil-create_directory__unix.adb b/core/src/os/gnatcoll-os-fsutil-create_directory__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-create_directory__unix.adb rename to core/src/os/gnatcoll-os-fsutil-create_directory__unix.adb diff --git a/src/os/gnatcoll-os-fsutil-create_directory__win32.adb b/core/src/os/gnatcoll-os-fsutil-create_directory__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-create_directory__win32.adb rename to core/src/os/gnatcoll-os-fsutil-create_directory__win32.adb diff --git a/src/os/gnatcoll-os-fsutil-create_symbolic_link__unix.adb b/core/src/os/gnatcoll-os-fsutil-create_symbolic_link__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-create_symbolic_link__unix.adb rename to core/src/os/gnatcoll-os-fsutil-create_symbolic_link__unix.adb diff --git a/src/os/gnatcoll-os-fsutil-create_symbolic_link__win32.adb b/core/src/os/gnatcoll-os-fsutil-create_symbolic_link__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-create_symbolic_link__win32.adb rename to core/src/os/gnatcoll-os-fsutil-create_symbolic_link__win32.adb diff --git a/src/os/gnatcoll-os-fsutil-read_symbolic_link__unix.adb b/core/src/os/gnatcoll-os-fsutil-read_symbolic_link__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-read_symbolic_link__unix.adb rename to core/src/os/gnatcoll-os-fsutil-read_symbolic_link__unix.adb diff --git a/src/os/gnatcoll-os-fsutil-read_symbolic_link__win32.adb b/core/src/os/gnatcoll-os-fsutil-read_symbolic_link__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-read_symbolic_link__win32.adb rename to core/src/os/gnatcoll-os-fsutil-read_symbolic_link__win32.adb diff --git a/src/os/gnatcoll-os-fsutil-remove_directory__unix.adb b/core/src/os/gnatcoll-os-fsutil-remove_directory__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-remove_directory__unix.adb rename to core/src/os/gnatcoll-os-fsutil-remove_directory__unix.adb diff --git a/src/os/gnatcoll-os-fsutil-remove_directory__win32.adb b/core/src/os/gnatcoll-os-fsutil-remove_directory__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-remove_directory__win32.adb rename to core/src/os/gnatcoll-os-fsutil-remove_directory__win32.adb diff --git a/src/os/gnatcoll-os-fsutil-remove_file__unix.adb b/core/src/os/gnatcoll-os-fsutil-remove_file__unix.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-remove_file__unix.adb rename to core/src/os/gnatcoll-os-fsutil-remove_file__unix.adb diff --git a/src/os/gnatcoll-os-fsutil-remove_file__win32.adb b/core/src/os/gnatcoll-os-fsutil-remove_file__win32.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil-remove_file__win32.adb rename to core/src/os/gnatcoll-os-fsutil-remove_file__win32.adb diff --git a/src/os/gnatcoll-os-fsutil.adb b/core/src/os/gnatcoll-os-fsutil.adb similarity index 100% rename from src/os/gnatcoll-os-fsutil.adb rename to core/src/os/gnatcoll-os-fsutil.adb diff --git a/src/os/gnatcoll-os-fsutil.ads b/core/src/os/gnatcoll-os-fsutil.ads similarity index 100% rename from src/os/gnatcoll-os-fsutil.ads rename to core/src/os/gnatcoll-os-fsutil.ads diff --git a/src/os/gnatcoll-os-process-internal_spawn__unix.adb b/core/src/os/gnatcoll-os-process-internal_spawn__unix.adb similarity index 100% rename from src/os/gnatcoll-os-process-internal_spawn__unix.adb rename to core/src/os/gnatcoll-os-process-internal_spawn__unix.adb diff --git a/src/os/gnatcoll-os-process-internal_spawn__win32.adb b/core/src/os/gnatcoll-os-process-internal_spawn__win32.adb similarity index 100% rename from src/os/gnatcoll-os-process-internal_spawn__win32.adb rename to core/src/os/gnatcoll-os-process-internal_spawn__win32.adb diff --git a/src/os/gnatcoll-os-process-state__unix.adb b/core/src/os/gnatcoll-os-process-state__unix.adb similarity index 100% rename from src/os/gnatcoll-os-process-state__unix.adb rename to core/src/os/gnatcoll-os-process-state__unix.adb diff --git a/src/os/gnatcoll-os-process-state__win32.adb b/core/src/os/gnatcoll-os-process-state__win32.adb similarity index 100% rename from src/os/gnatcoll-os-process-state__win32.adb rename to core/src/os/gnatcoll-os-process-state__win32.adb diff --git a/src/os/gnatcoll-os-process-wait__unix.adb b/core/src/os/gnatcoll-os-process-wait__unix.adb similarity index 100% rename from src/os/gnatcoll-os-process-wait__unix.adb rename to core/src/os/gnatcoll-os-process-wait__unix.adb diff --git a/src/os/gnatcoll-os-process-wait__win32.adb b/core/src/os/gnatcoll-os-process-wait__win32.adb similarity index 100% rename from src/os/gnatcoll-os-process-wait__win32.adb rename to core/src/os/gnatcoll-os-process-wait__win32.adb diff --git a/src/os/gnatcoll-os-process-wait_for_processes__unix.adb b/core/src/os/gnatcoll-os-process-wait_for_processes__unix.adb similarity index 100% rename from src/os/gnatcoll-os-process-wait_for_processes__unix.adb rename to core/src/os/gnatcoll-os-process-wait_for_processes__unix.adb diff --git a/src/os/gnatcoll-os-process-wait_for_processes__win32.adb b/core/src/os/gnatcoll-os-process-wait_for_processes__win32.adb similarity index 100% rename from src/os/gnatcoll-os-process-wait_for_processes__win32.adb rename to core/src/os/gnatcoll-os-process-wait_for_processes__win32.adb diff --git a/src/os/gnatcoll-os-process.adb b/core/src/os/gnatcoll-os-process.adb similarity index 100% rename from src/os/gnatcoll-os-process.adb rename to core/src/os/gnatcoll-os-process.adb diff --git a/src/os/gnatcoll-os-process.ads b/core/src/os/gnatcoll-os-process.ads similarity index 100% rename from src/os/gnatcoll-os-process.ads rename to core/src/os/gnatcoll-os-process.ads diff --git a/src/os/gnatcoll-os-process_types__unix.adb b/core/src/os/gnatcoll-os-process_types__unix.adb similarity index 100% rename from src/os/gnatcoll-os-process_types__unix.adb rename to core/src/os/gnatcoll-os-process_types__unix.adb diff --git a/src/os/gnatcoll-os-process_types__unix.ads b/core/src/os/gnatcoll-os-process_types__unix.ads similarity index 100% rename from src/os/gnatcoll-os-process_types__unix.ads rename to core/src/os/gnatcoll-os-process_types__unix.ads diff --git a/src/os/gnatcoll-os-process_types__win32.adb b/core/src/os/gnatcoll-os-process_types__win32.adb similarity index 100% rename from src/os/gnatcoll-os-process_types__win32.adb rename to core/src/os/gnatcoll-os-process_types__win32.adb diff --git a/src/os/gnatcoll-os-process_types__win32.ads b/core/src/os/gnatcoll-os-process_types__win32.ads similarity index 100% rename from src/os/gnatcoll-os-process_types__win32.ads rename to core/src/os/gnatcoll-os-process_types__win32.ads diff --git a/src/os/gnatcoll-os-stat-fstat__unix.adb b/core/src/os/gnatcoll-os-stat-fstat__unix.adb similarity index 100% rename from src/os/gnatcoll-os-stat-fstat__unix.adb rename to core/src/os/gnatcoll-os-stat-fstat__unix.adb diff --git a/src/os/gnatcoll-os-stat-fstat__win32.adb b/core/src/os/gnatcoll-os-stat-fstat__win32.adb similarity index 100% rename from src/os/gnatcoll-os-stat-fstat__win32.adb rename to core/src/os/gnatcoll-os-stat-fstat__win32.adb diff --git a/src/os/gnatcoll-os-stat-stat__unix.adb b/core/src/os/gnatcoll-os-stat-stat__unix.adb similarity index 100% rename from src/os/gnatcoll-os-stat-stat__unix.adb rename to core/src/os/gnatcoll-os-stat-stat__unix.adb diff --git a/src/os/gnatcoll-os-stat-stat__win32.adb b/core/src/os/gnatcoll-os-stat-stat__win32.adb similarity index 100% rename from src/os/gnatcoll-os-stat-stat__win32.adb rename to core/src/os/gnatcoll-os-stat-stat__win32.adb diff --git a/src/os/gnatcoll-os-stat.adb b/core/src/os/gnatcoll-os-stat.adb similarity index 100% rename from src/os/gnatcoll-os-stat.adb rename to core/src/os/gnatcoll-os-stat.adb diff --git a/src/os/gnatcoll-os-stat.ads b/core/src/os/gnatcoll-os-stat.ads similarity index 100% rename from src/os/gnatcoll-os-stat.ads rename to core/src/os/gnatcoll-os-stat.ads diff --git a/src/os/gnatcoll-os.ads b/core/src/os/gnatcoll-os.ads similarity index 100% rename from src/os/gnatcoll-os.ads rename to core/src/os/gnatcoll-os.ads diff --git a/src/os/unix/gnatcoll-os-libc-dirent.ads b/core/src/os/unix/gnatcoll-os-libc-dirent.ads similarity index 100% rename from src/os/unix/gnatcoll-os-libc-dirent.ads rename to core/src/os/unix/gnatcoll-os-libc-dirent.ads diff --git a/src/os/unix/gnatcoll-os-libc-spawn.ads b/core/src/os/unix/gnatcoll-os-libc-spawn.ads similarity index 100% rename from src/os/unix/gnatcoll-os-libc-spawn.ads rename to core/src/os/unix/gnatcoll-os-libc-spawn.ads diff --git a/src/os/unix/gnatcoll-os-libc-stat.ads b/core/src/os/unix/gnatcoll-os-libc-stat.ads similarity index 100% rename from src/os/unix/gnatcoll-os-libc-stat.ads rename to core/src/os/unix/gnatcoll-os-libc-stat.ads diff --git a/src/os/unix/gnatcoll-os-libc-utime.ads b/core/src/os/unix/gnatcoll-os-libc-utime.ads similarity index 100% rename from src/os/unix/gnatcoll-os-libc-utime.ads rename to core/src/os/unix/gnatcoll-os-libc-utime.ads diff --git a/src/os/unix/gnatcoll-os-libc.ads b/core/src/os/unix/gnatcoll-os-libc.ads similarity index 100% rename from src/os/unix/gnatcoll-os-libc.ads rename to core/src/os/unix/gnatcoll-os-libc.ads diff --git a/src/os/unix/gnatcoll-os-libc_constants__linux.ads b/core/src/os/unix/gnatcoll-os-libc_constants__linux.ads similarity index 100% rename from src/os/unix/gnatcoll-os-libc_constants__linux.ads rename to core/src/os/unix/gnatcoll-os-libc_constants__linux.ads diff --git a/src/os/unix/gnatcoll-os-libc_constants__osx.ads b/core/src/os/unix/gnatcoll-os-libc_constants__osx.ads similarity index 100% rename from src/os/unix/gnatcoll-os-libc_constants__osx.ads rename to core/src/os/unix/gnatcoll-os-libc_constants__osx.ads diff --git a/src/os/unix/libc-wrappers.c b/core/src/os/unix/libc-wrappers.c similarity index 100% rename from src/os/unix/libc-wrappers.c rename to core/src/os/unix/libc-wrappers.c diff --git a/src/os/unix/process-wrappers.c b/core/src/os/unix/process-wrappers.c similarity index 100% rename from src/os/unix/process-wrappers.c rename to core/src/os/unix/process-wrappers.c diff --git a/src/os/win32/gnatcoll-os-win32-files.adb b/core/src/os/win32/gnatcoll-os-win32-files.adb similarity index 100% rename from src/os/win32/gnatcoll-os-win32-files.adb rename to core/src/os/win32/gnatcoll-os-win32-files.adb diff --git a/src/os/win32/gnatcoll-os-win32-files.ads b/core/src/os/win32/gnatcoll-os-win32-files.ads similarity index 100% rename from src/os/win32/gnatcoll-os-win32-files.ads rename to core/src/os/win32/gnatcoll-os-win32-files.ads diff --git a/src/os/win32/gnatcoll-os-win32-process.ads b/core/src/os/win32/gnatcoll-os-win32-process.ads similarity index 100% rename from src/os/win32/gnatcoll-os-win32-process.ads rename to core/src/os/win32/gnatcoll-os-win32-process.ads diff --git a/src/os/win32/gnatcoll-os-win32-strings.adb b/core/src/os/win32/gnatcoll-os-win32-strings.adb similarity index 100% rename from src/os/win32/gnatcoll-os-win32-strings.adb rename to core/src/os/win32/gnatcoll-os-win32-strings.adb diff --git a/src/os/win32/gnatcoll-os-win32-strings.ads b/core/src/os/win32/gnatcoll-os-win32-strings.ads similarity index 100% rename from src/os/win32/gnatcoll-os-win32-strings.ads rename to core/src/os/win32/gnatcoll-os-win32-strings.ads diff --git a/src/os/win32/gnatcoll-os-win32.adb b/core/src/os/win32/gnatcoll-os-win32.adb similarity index 100% rename from src/os/win32/gnatcoll-os-win32.adb rename to core/src/os/win32/gnatcoll-os-win32.adb diff --git a/src/os/win32/gnatcoll-os-win32.ads b/core/src/os/win32/gnatcoll-os-win32.ads similarity index 100% rename from src/os/win32/gnatcoll-os-win32.ads rename to core/src/os/win32/gnatcoll-os-win32.ads diff --git a/src/os/win32/win32-wrappers.c b/core/src/os/win32/win32-wrappers.c similarity index 100% rename from src/os/win32/win32-wrappers.c rename to core/src/os/win32/win32-wrappers.c diff --git a/src/paragraph_filling/gnatcoll-paragraph_filling-badnesses.adb b/core/src/paragraph_filling/gnatcoll-paragraph_filling-badnesses.adb similarity index 100% rename from src/paragraph_filling/gnatcoll-paragraph_filling-badnesses.adb rename to core/src/paragraph_filling/gnatcoll-paragraph_filling-badnesses.adb diff --git a/src/paragraph_filling/gnatcoll-paragraph_filling-badnesses.ads b/core/src/paragraph_filling/gnatcoll-paragraph_filling-badnesses.ads similarity index 100% rename from src/paragraph_filling/gnatcoll-paragraph_filling-badnesses.ads rename to core/src/paragraph_filling/gnatcoll-paragraph_filling-badnesses.ads diff --git a/src/paragraph_filling/gnatcoll-paragraph_filling-words.adb b/core/src/paragraph_filling/gnatcoll-paragraph_filling-words.adb similarity index 100% rename from src/paragraph_filling/gnatcoll-paragraph_filling-words.adb rename to core/src/paragraph_filling/gnatcoll-paragraph_filling-words.adb diff --git a/src/paragraph_filling/gnatcoll-paragraph_filling-words.ads b/core/src/paragraph_filling/gnatcoll-paragraph_filling-words.ads similarity index 100% rename from src/paragraph_filling/gnatcoll-paragraph_filling-words.ads rename to core/src/paragraph_filling/gnatcoll-paragraph_filling-words.ads diff --git a/src/paragraph_filling/gnatcoll-paragraph_filling.adb b/core/src/paragraph_filling/gnatcoll-paragraph_filling.adb similarity index 100% rename from src/paragraph_filling/gnatcoll-paragraph_filling.adb rename to core/src/paragraph_filling/gnatcoll-paragraph_filling.adb diff --git a/src/paragraph_filling/gnatcoll-paragraph_filling.ads b/core/src/paragraph_filling/gnatcoll-paragraph_filling.ads similarity index 100% rename from src/paragraph_filling/gnatcoll-paragraph_filling.ads rename to core/src/paragraph_filling/gnatcoll-paragraph_filling.ads diff --git a/src/run_path_option.c b/core/src/run_path_option.c similarity index 100% rename from src/run_path_option.c rename to core/src/run_path_option.c diff --git a/src/separate_run_path_option.c b/core/src/separate_run_path_option.c similarity index 100% rename from src/separate_run_path_option.c rename to core/src/separate_run_path_option.c diff --git a/src/set_std_prefix.c b/core/src/set_std_prefix.c similarity index 100% rename from src/set_std_prefix.c rename to core/src/set_std_prefix.c diff --git a/src/terminals.c b/core/src/terminals.c similarity index 100% rename from src/terminals.c rename to core/src/terminals.c diff --git a/src/update_path.c b/core/src/update_path.c similarity index 100% rename from src/update_path.c rename to core/src/update_path.c diff --git a/gprproject/__init__.py b/gprproject/__init__.py new file mode 100644 index 00000000..121d5eb4 --- /dev/null +++ b/gprproject/__init__.py @@ -0,0 +1,224 @@ +#!/usr/bin/env python +from .gprbuild import GPRTool +from subprocess import CalledProcessError +import argparse +import logging +import os +import re + + +class BuilderApp: + + constants_project_file = None + constants = None + + def __init__(self): + """Create the main CLI argument parser.""" + self.main = argparse.ArgumentParser(description=self.description) + self.parser = self.main.add_subparsers( + title="commands", + description="available commands (do ./setup.py CMD --help " + "for help on command CMD)", + ) + + self.subparsers = {} + + # Build command + self.build_cmd = self.parser.add_parser("build", help="build") + self.build_cmd.add_argument( + "--gpr-opts", + nargs=argparse.REMAINDER, + default=[], + help="pass remaining arguments to gprbuild", + ) + self.build_cmd.add_argument( + "--add-gpr-path", help="prepend a path to look for GPR files" + ) + self.build_cmd.add_argument( + "--jobs", "-j", help="gprbuild parallelism", default="0" + ) + self.build_cmd.add_argument("--target", help="target", default=None) + self.build_cmd.add_argument( + "--prefix", help="installation prefix", default=None + ) + self.build_cmd.add_argument( + "--integrated", + help="installation in platform specific subdir", + default=False, + action="store_true", + ) + self.build_cmd.add_argument( + "--install", + help="proceed with install automatically after the build", + default=False, + action="store_true", + ) + self.build_cmd.add_argument( + "--gnatcov", + default=False, + action="store_true", + help="build project with gnatcov instrumentation", + ) + self.build_cmd.add_argument( + "--configure-only", + default=False, + action="store_true", + help=( + "only perform configuration (i.e: update of project " + "constants and creation of json file). Can be used to integrate " + "with Alire" + ), + ) + self.build_cmd.add_argument( + "--disable-constant-updates", + default=False, + action="store_true", + help=( + "Do not update constants in GPR file and use only -XVAR=VALUE" + " to pass configuration to gpr tools" + ), + ) + self.build_cmd.set_defaults(command=self.build) + + # Clean command + self.clean_cmd = self.parser.add_parser("clean", help="clean") + self.clean_cmd.add_argument( + "--gpr-opts", + default=[], + nargs=argparse.REMAINDER, + help="pass remaining arguments to gprclean", + ) + self.clean_cmd.set_defaults(command=self.clean) + + # Install command + self.install_cmd = self.parser.add_parser("install", help="install") + + self.install_cmd.add_argument( + "--gpr-opts", + default=[], + nargs=argparse.REMAINDER, + help="pass remaining arguments to gprinstall", + ) + self.install_cmd.add_argument( + "--prefix", help="installation prefix", default=None + ) + self.install_cmd.set_defaults(command=self.install) + + # Uninstall command + self.uninstall_cmd = self.parser.add_parser("uninstall", help="uninstall") + self.uninstall_cmd.add_argument( + "--gpr-opts", + default=[], + nargs=argparse.REMAINDER, + help="pass remaining arguments to gpruninstall", + ) + self.uninstall_cmd.add_argument( + "--prefix", help="un-installation prefix", default=None + ) + self.uninstall_cmd.set_defaults(command=self.uninstall) + + # Set basic logging + logging.basicConfig(level=logging.DEBUG, format="%(message)s") + + def adjust_config(self, gpr, args: argparse.Namespace) -> None: + pass + + def adjust_project_constants(self, gpr) -> None: + if self.constants_project_file is not None and self.constants: + with open(self.constants_project_file, "r") as fd: + content = fd.read().splitlines() + + with open(self.constants_project_file, "w") as fd: + result = [] + for line in content: + m = re.match( + r"(\s*)(" + "|".join(self.constants) + r")_DEFAULT(\s*):=", line + ) + if m: + variable = m.group(2) + result.append( + f'{m.group(1)}{variable}_DEFAULT{m.group(3)}:= "{gpr.variables[variable]}";' + ) + else: + result.append(line) + fd.write("\n".join(result) + "\n") + + def build(self, args): + gpr = GPRTool( + project_file=self.project_file, + target=args.target, + integrated=args.integrated, + jobs=args.jobs, + gnatcov=args.gnatcov, + prefix=args.prefix, + gpr_paths=args.add_gpr_path, + add_prefix_to_gpr_paths=args.prefix is not None, + ) + self.adjust_config(gpr, args) + + if not args.disable_constant_updates: + self.adjust_project_constants(gpr) + gpr.save() + + for var, value in gpr.variables.items(): + print(f'{var:<32} := "{value}";') + + if not args.configure_only: + status = gpr.build([]) + if status == 0 and args.install: + status = gpr.install([]) + return status + else: + return 0 + + def clean(self, args): + gpr = GPRTool.load(self.project_file) + return gpr.clean([]) + + def install(self, args): + gpr = GPRTool.load(self.project_file) + if args.prefix: + gpr.prefix = os.path.abspath(args.prefix) + return gpr.install([]) + + def uninstall(self, args): + gpr = GPRTool.load(self.project_file) + if args.prefix: + gpr.prefix = os.path.abspath(args.prefix) + return gpr.uninstall([]) + + def add_arguments(self, parser: argparse.ArgumentParser) -> None: + """Function to be used by end user to add switch to the build command. + + :param parser: the argparse subparser of the build command + """ + pass + + def run(self) -> int: + """Execute a command (build, install, uninstall or clean). + + :return: the process return code + """ + # Allow user to amend switches for the build command + build_cmd_group = self.build_cmd.add_argument_group( + title="project specific options" + ) + self.add_arguments(build_cmd_group) + + # Parse arguments and dispatch to the right implementation + args = self.main.parse_args() + + # Check that a command has been passed + if "command" not in args: + logging.error("Missing command") + self.main.print_help() + return 1 + + try: + return args.command(args) + except CalledProcessError as e: + logging.error("process failed with status: %s", e.returncode) + return 1 + except AssertionError as e: + logging.error("requirement missing: %s", e) + return 1 diff --git a/gprproject/gprbuild.py b/gprproject/gprbuild.py new file mode 100644 index 00000000..1e57c12e --- /dev/null +++ b/gprproject/gprbuild.py @@ -0,0 +1,261 @@ +from __future__ import annotations +from subprocess import run +from .os import which, add_search_path +import json +import os +import re + + +class GPRError(Exception): + pass + + +class GPRTool: + """Manage gpr tools invocation and configuration.""" + + def __init__( + self, + project_file: str, + object_dir: str | None = None, + target: str | None = None, + integrated: bool = False, + variables: dict[str, str] | None = None, + jobs: int = 0, + variants_var: str | None = None, + variants_values: list[str] | None = None, + gnatcov: bool = False, + prefix: str | None = None, + gpr_paths: list[str] | None = None, + add_prefix_to_gpr_paths: bool = False, + ) -> None: + """Instantiate gpr tools instance. + + :param project_file: path to the project file + :param object_dir: root path in which project should be built + :param target: gpr target + :param integrated: whether installation prefix should be platform specific + :param variables: scenario variables for the project + :param jobs: level of parallelism for gpr tools that support it + """ + project_full_path = os.path.abspath(project_file) + self.project_file = os.path.basename(project_full_path) + self.project_name = self.project_file[:-4] + self.source_dir = os.path.dirname(project_full_path) + self.object_dir = ( + os.path.abspath(object_dir) if object_dir is not None else os.getcwd() + ) + if variables: + self.variables = {k: v for k, v in variables.items()} + else: + self.variables = {} + + # Compute the canonical target + self.original_target = target + + # Compute canonical target + gprconfig_cmd = [which("gprconfig"), "--config=ada", "--mi-show-compilers"] + if self.original_target: + gprconfig_cmd.append(f"--target={self.original_target}") + gprconfig_output = self.capture(gprconfig_cmd) + self.target = re.findall(r" 1 normalized_target:(\S*)", gprconfig_output)[0] + + # Compute default prefix + if prefix: + self.prefix = os.path.abspath(prefix) + else: + self.prefix = re.findall(r" 1 path:(.*)", gprconfig_output)[0] + if self.prefix.endswith(os.sep): + self.prefix = os.path.dirname(os.path.dirname(self.prefix)) + else: + self.prefix = os.path.dirname(self.prefix) + self.integrated = integrated + + self.jobs = jobs + + # variants + self.variants_var = variants_var + if self.variants_var: + self.variants_values: list[str] = list(variants_values) + else: + self.variants_values = ["_"] + + self.gnatcov = gnatcov + self.gpr_paths: list[str] = [] + if self.gpr_paths: + self.gpr_paths = list(gpr_paths) + else: + self.gpr_paths = [] + + if add_prefix_to_gpr_paths: + self.gpr_paths.append(os.path.join(self.prefix, "share", "gpr")) + self.gpr_paths.append( + os.path.join(self.prefix, self.target, "share", "gpr") + ) + + def run(self, args: list[str], **kwargs) -> int: + """Execute a GPR tool. + + :param args: arguments to the tool including the command name as first + element + :param kwargs: named parameters passed down to subprocess.run + """ + cmd_name = args[0] + cmd = [which(args[0])] + args[1:] + + for path in self.gpr_paths: + add_search_path("GPR_PROJECT_PATH", path) + + # Handle gnatcov + if self.gnatcov: + gnatcov_prefix = os.path.join(self.object_dir, "gnatcov_rts") + if cmd_name == "gprbuild": + if not os.path.isdir(gnatcov_prefix): + print("Compile GNATCOV runtime") + status = run( + [which("gnatcov"), "setup", f"--prefix={gnatcov_prefix}"] + ) + # assert status == 0, "gnatcov runtime compilation failure" + + if cmd_name in ("gprbuild", "gprinstall"): + cmd += ["--src-subdirs=gnatcov-instr", "--implicit-with=gnatcov_rts"] + + add_search_path( + "GPR_PROJECT_PATH", os.path.join(gnatcov_prefix, "share", "gpr") + ) + + if args[0] == "gprbuild": + status = self.run( + [ + "gnatcov", + "instrument", + "--full-slugs", + "--no-subprojects", + "--level=stmt+decision", + "--restricted-to-languages=Ada", + ] + ) + if status != 0: + return status + + # Handle basic parameters such out of tree build + if self.source_dir != self.object_dir: + cmd.append("--relocate-build-tree") + cmd.append(f"-P{os.path.join(self.source_dir, self.project_file)}") + else: + cmd.append(f"-P{self.project_file}") + + # Pass jobs + if cmd_name == "gprbuild": + cmd.append(f"-j{self.jobs}") + + # Pass canonical target + cmd.append(f"--target={self.target}") + + for key, value in self.variables.items(): + cmd.append(f"-X{key}={value}") + + if cmd_name == "gprinstall": + if self.integrated: + final_prefix = os.path.join(self.prefix, self.target) + else: + final_prefix = self.prefix + + cmd += [ + "-p", + "-f", + f"--prefix={final_prefix}", + f"--sources-subdir=include/{self.project_name}", + ] + + status = 0 + for variants_value in self.variants_values: + final_cmd = list(cmd) + if self.variants_var: + final_cmd.append(f"-X{self.variants_var}={variants_value}") + if cmd_name == "gprinstall": + final_cmd += [ + f"--build-name={variants_value}", + f"--build-var={self.variants_var}", + ] + print(final_cmd) + status = run(final_cmd, **kwargs).returncode + if status != 0: + return status + return status + + def build(self, args: list[str], **kwargs): + return self.run(["gprbuild"] + args, **kwargs) + + def install(self, args: list[str], **kwargs): + return self.run(["gprinstall"] + args, **kwargs) + + def clean(self, args: list[str], **kwargs): + return self.run(["gprclean"] + args, **kwargs) + + def uninstall(self, args: list[str], **kwargs): + return self.run(["gprinstall", "--uninstall"] + args, **kwargs) + + def capture(self, cmd: list[str]) -> str: + """Capture output of a given tool and decode it to utf-8. + + :param cmd: the command to run + """ + process = run([which(cmd[0])] + cmd[1:], capture_output=True) + if process.returncode != 0: + raise GPRError(f"error while trying to capture output of '{cmd}'") + try: + output = process.stdout.decode("utf-8").strip() + except Exception: + raise GPRError(f"utf-8 output expected") + + return output + + def set_variable(self, name: str, value: str) -> None: + self.variables[name] = value + + def save(self): + json_file = os.path.join(self.object_dir, self.project_name + ".json") + data = { + "project_file": os.path.join(self.source_dir, self.project_file), + "object_dir": self.object_dir, + "target": self.original_target, + "integrated": self.integrated, + "variables": self.variables, + "jobs": self.jobs, + "variants_var": self.variants_var, + "variants_values": self.variants_values if self.variants_var else None, + "gnatcov": self.gnatcov, + "prefix": self.prefix, + "gpr_paths": self.gpr_paths, + } + with open(json_file, "w") as fd: + json.dump(data, fd, indent=2) + + @classmethod + def load(cls, project_file: str, object_dir: str | None = None) -> GPRTool: + object_dir = ( + os.path.abspath(object_dir) if object_dir is not None else os.getcwd() + ) + project_name = os.path.basename(project_file)[:-4] + json_file = os.path.join(object_dir, project_name + ".json") + + with open(json_file) as fd: + data = json.load(fd) + + return GPRTool( + project_file=data["project_file"], + object_dir=object_dir, + target=data["target"], + integrated=data["integrated"], + variables=data["variables"], + jobs=data["jobs"], + variants_var=data["variants_var"], + variants_values=data["variants_values"], + gnatcov=data["gnatcov"], + prefix=data["prefix"], + gpr_paths=data["gpr_paths"], + ) + + +if __name__ == "__main__": + d = GPRTool(project_file="toto.gpr") diff --git a/gprproject/os.py b/gprproject/os.py new file mode 100644 index 00000000..2d73161d --- /dev/null +++ b/gprproject/os.py @@ -0,0 +1,68 @@ +from __future__ import annotations +from typing import TYPE_CHECKING +import os +import sys + +if TYPE_CHECKING: + from typing import Any + + +def add_search_path(name: str, path: str) -> None: + """Prepend a path to a variable holding a list of paths. + + :param name: variable name + :param path: path to add + """ + prev_value = os.environ.get(name) + if prev_value: + os.environ[name] = path + os.pathsep + prev_value + else: + os.environ[name] = path + + +def which(prog: str, paths: str | None = None, default: Any = "") -> Any: + """Locate executable. + + :param prog: program to find + :param paths: if not None then we use this value instead of PATH to look + for the executable. + :param default: default value to return if not found + + :return: absolute path to the program on success, found by searching for an + executable in the directories listed in the environment variable PATH + or default value if not found + """ + + def is_exe(file_path: str) -> bool: + return os.path.isfile(file_path) and os.access(file_path, os.X_OK) + + def possible_names(file_path: str) -> list[str]: + names = [file_path] + if sys.platform == "win32": # unix: no cover + names.extend( + [ + file_path + ext + for ext in os.environ.get("PATHEXT", ".EXE").split(";") + ] + ) + return names + + fpath, _ = os.path.split(prog) + if fpath: + # Full path given, check if executable + for progname in possible_names(prog): + if is_exe(progname): + return progname + else: + # Check for all directories listed in $PATH + if paths is None: + paths = os.environ["PATH"] + + for pathdir in paths.split(os.pathsep): + exe_file = os.path.join(pathdir, prog) + for progname in possible_names(exe_file): + if is_exe(progname): + return progname + + # Not found. + return default diff --git a/minimal/VERSION b/minimal/VERSION new file mode 100644 index 00000000..be8e64f5 --- /dev/null +++ b/minimal/VERSION @@ -0,0 +1 @@ +25.0 diff --git a/minimal/config/gnatcoll_minimal_constants.gpr b/minimal/config/gnatcoll_minimal_constants.gpr new file mode 100644 index 00000000..dc22fa79 --- /dev/null +++ b/minimal/config/gnatcoll_minimal_constants.gpr @@ -0,0 +1,5 @@ +abstract project GNATCOLL_Minimal_Constants is + GNATCOLL_VERSION_DEFAULT := "25.0"; + GNATCOLL_BUILD_MODE_DEFAULT := "PROD"; + GNATCOLL_OS_DEFAULT := "unix"; +end GNATCOLL_Minimal_Constants; diff --git a/minimal/gnatcoll_minimal.gpr b/minimal/gnatcoll_minimal.gpr new file mode 100644 index 00000000..5a20c419 --- /dev/null +++ b/minimal/gnatcoll_minimal.gpr @@ -0,0 +1,166 @@ +------------------------------------------------------------------------------ +-- G N A T C O L L -- +-- -- +-- Copyright (C) 2015-2024, AdaCore -- +-- -- +-- This library is free software; you can redistribute it and/or modify it -- +-- under terms of the GNU General Public License as published by the Free -- +-- Software Foundation; either version 3, or (at your option) any later -- +-- version. This library is distributed in the hope that it will be useful, -- +-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- +-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +------------------------------------------------------------------------------ +with "config/gnatcoll_minimal_constants.gpr"; + +library project GNATCOLL_Minimal is + + Version := External ("GNATCOLL_VERSION", + GNATCOLL_Minimal_Constants.GNATCOLL_VERSION_DEFAULT); + Name := "gnatcoll_minimal"; + + type Build_Type is ("DEBUG", "PROD"); + Build : Build_Type := + External ("GNATCOLL_BUILD_MODE", + External ("BUILD", + GNATCOLL_Minimal_Constants.GNATCOLL_BUILD_MODE_DEFAULT)); + + type Library_Type_Type is ("relocatable", "static", "static-pic"); + Library_Type : Library_Type_Type := External ("LIBRARY_TYPE", "static"); + + type OS_Kind is ("windows", "unix", "osx"); + OS : OS_Kind := External + ("GNATCOLL_OS", GNATCOLL_Minimal_Constants.GNATCOLL_OS_DEFAULT); + + for Languages use ("Ada", "C"); + for Source_Dirs use ("src"); + + for Library_Kind use Library_Type; + + Read_Only := external ("EXTERNALLY_BUILT", "false"); + for Externally_Built use Read_Only; + + -- If gnatcoll-core is built out of tree, and is used by an external + -- afterwards, then GNATCOLL_OBJECT_ROOT can be used so gnatcoll.gpr + -- Object_Dir and Library_Dir point to the correct directory. + Object_Root := external ("GNATCOLL_OBJECT_ROOT", ""); + + case OS is + when "windows" | "osx" => + -- On MacOS and Windows all object are relocatable by default + -- thus the same object directory can be used + for Object_Dir use Object_Root & "obj/gnatcoll_minimal/all"; + when "unix" => + -- On Unix static-pic and relocatable shared the same objects + case Library_Type is + when "relocatable" | "static-pic" => + for Object_Dir use Object_Root & "obj/gnatcoll_minimal/pic"; + when "static" => + for Object_Dir use Object_Root & "obj/gnatcoll_minimal/static"; + end case; + end case; + + for Library_Dir + use Object_Root & "lib/gnatcoll_core/" & Project'Library_Kind; + + for Library_Name use Name; + + + Extra_Switches := (); + Extra_Libs := (); + case OS is + when "windows" => + Extra_Libs := ("-lpsapi", "-lntdll"); -- For gnatcoll.memory + when others => + null; + end case; + + So_Ext := ""; + case OS is + when "windows" => + So_Ext := ".dll"; + when "osx" => + So_Ext := ".dylib"; + when others => + So_Ext := ".so"; + end case; + + for Library_Version use "lib" & Name & So_Ext & "." & Version; + + case Library_Type is + when "relocatable" => + for Library_Options use Extra_Libs; + + -- Put user options in front, for options like --as-needed. + for Leading_Library_Options use External_As_List ("LDFLAGS", " "); + + when others => + null; + end case; + + package Compiler is + case Build is + when "DEBUG" => + for Switches ("Ada") use + ("-g", "-O0", "-gnata", "-gnatVa", "-gnatQ", "-gnaty", "-gnateE", + "-gnatwaCJe", "-fstack-check"); + for Switches ("C") use ("-g", "-Wunreachable-code"); + + when "PROD" => + -- Do not use -gnatwe for production mode + for Switches ("Ada") use ("-O2", "-gnatn", "-gnatwaCJ"); + for Switches ("C") use ("-O2", "-Wunreachable-code"); + end case; + + -- Give user flags the last word. + for Switches ("Ada") use Compiler'Switches ("Ada") + & External_As_List ("ADAFLAGS", " "); + for Switches ("C") use Compiler'Switches ("C") + & External_As_List ("CFLAGS", " ") + & External_As_List ("CPPFLAGS", " "); + + for Switches ("gnatcoll_support.c") use + Extra_Switches & Compiler'Switches ("C"); + end Compiler; + + package Binder is + case Build is + when "DEBUG" => + for Switches ("Ada") use ("-E"); + when "PROD" => + null; + end case; + end Binder; + + package Builder is + case Build is + when "DEBUG" => + for Global_Configuration_Pragmas use "src/gnat_debug.adc"; + when "PROD" => + null; + end case; + end Builder; + + package Ide is + for VCS_Kind use "Git"; + end Ide; + + package Linker is + case Library_Type is + when "relocatable" => + null; + when "static" | "static-pic" => + for Linker_Options use Extra_Libs; + end case; + end Linker; + +end GNATCOLL_Minimal; diff --git a/minimal/gnatcoll_minimal.gpr.py b/minimal/gnatcoll_minimal.gpr.py new file mode 100755 index 00000000..ab00a3ef --- /dev/null +++ b/minimal/gnatcoll_minimal.gpr.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +from __future__ import annotations +from typing import TYPE_CHECKING +import sys +import os + +# Support code is located in parent directory +SOURCE_DIR = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.dirname(SOURCE_DIR)) + +from gprproject import BuilderApp + +if TYPE_CHECKING: + import argparse + + +class GNATCollMinimal(BuilderApp): + project_file = os.path.join(SOURCE_DIR, "gnatcoll_minimal.gpr") + description = "Minimal GNATCOLL library." "" + constants_project_file = os.path.join( + SOURCE_DIR, "config", "gnatcoll_minimal_constants.gpr" + ) + constants = ["GNATCOLL_OS", "GNATCOLL_BUILD_MODE", "GNATCOLL_VERSION"] + + def add_arguments(self, parser: argparse.ArgumentParser) -> None: + parser.add_argument("--build", choices=["DEBUG", "PROD"], default="PROD") + parser.add_argument("--enable-shared", choices=["yes", "no"], default="yes") + + def adjust_config(self, gpr, args): + gpr.set_variable("GNATCOLL_BUILD_MODE", args.build) + + with open(os.path.join(SOURCE_DIR, "VERSION")) as fd: + version = fd.read().strip() + gpr.set_variable("GNATCOLL_VERSION", version) + + if "windows" in gpr.target: + gnatcoll_os = "windows" + elif "darwin" in gpr.target: + gnatcoll_os = "osx" + else: + gnatcoll_os = "unix" + gpr.set_variable("GNATCOLL_OS", gnatcoll_os) + + if args.gnatcov: + gpr.set_variable("LIBRARY_TYPE", "static") + else: + gpr.variants_var = "LIBRARY_TYPE" + if args.enable_shared == "yes": + gpr.variants_values = ["static", "relocatable", "static-pic"] + else: + gpr.variants_values = ["static"] + + +if __name__ == "__main__": + app = GNATCollMinimal() + sys.exit(app.run()) diff --git a/src/getRSS.c b/minimal/src/getRSS.c similarity index 100% rename from src/getRSS.c rename to minimal/src/getRSS.c diff --git a/minimal/src/gnat_debug.adc b/minimal/src/gnat_debug.adc new file mode 100644 index 00000000..7fef8cb9 --- /dev/null +++ b/minimal/src/gnat_debug.adc @@ -0,0 +1 @@ +pragma Initialize_Scalars; diff --git a/src/gnatcoll-any_types.adb b/minimal/src/gnatcoll-any_types.adb similarity index 100% rename from src/gnatcoll-any_types.adb rename to minimal/src/gnatcoll-any_types.adb diff --git a/src/gnatcoll-any_types.ads b/minimal/src/gnatcoll-any_types.ads similarity index 100% rename from src/gnatcoll-any_types.ads rename to minimal/src/gnatcoll-any_types.ads diff --git a/src/gnatcoll-asserts.adb b/minimal/src/gnatcoll-asserts.adb similarity index 100% rename from src/gnatcoll-asserts.adb rename to minimal/src/gnatcoll-asserts.adb diff --git a/src/gnatcoll-asserts.ads b/minimal/src/gnatcoll-asserts.ads similarity index 100% rename from src/gnatcoll-asserts.ads rename to minimal/src/gnatcoll-asserts.ads diff --git a/src/gnatcoll-atomic.adb b/minimal/src/gnatcoll-atomic.adb similarity index 100% rename from src/gnatcoll-atomic.adb rename to minimal/src/gnatcoll-atomic.adb diff --git a/src/gnatcoll-atomic.ads b/minimal/src/gnatcoll-atomic.ads similarity index 100% rename from src/gnatcoll-atomic.ads rename to minimal/src/gnatcoll-atomic.ads diff --git a/src/gnatcoll-boyer_moore.adb b/minimal/src/gnatcoll-boyer_moore.adb similarity index 100% rename from src/gnatcoll-boyer_moore.adb rename to minimal/src/gnatcoll-boyer_moore.adb diff --git a/src/gnatcoll-boyer_moore.ads b/minimal/src/gnatcoll-boyer_moore.ads similarity index 100% rename from src/gnatcoll-boyer_moore.ads rename to minimal/src/gnatcoll-boyer_moore.ads diff --git a/src/gnatcoll-coders-base64.adb b/minimal/src/gnatcoll-coders-base64.adb similarity index 100% rename from src/gnatcoll-coders-base64.adb rename to minimal/src/gnatcoll-coders-base64.adb diff --git a/src/gnatcoll-coders-base64.ads b/minimal/src/gnatcoll-coders-base64.ads similarity index 100% rename from src/gnatcoll-coders-base64.ads rename to minimal/src/gnatcoll-coders-base64.ads diff --git a/src/gnatcoll-coders-streams.adb b/minimal/src/gnatcoll-coders-streams.adb similarity index 100% rename from src/gnatcoll-coders-streams.adb rename to minimal/src/gnatcoll-coders-streams.adb diff --git a/src/gnatcoll-coders-streams.ads b/minimal/src/gnatcoll-coders-streams.ads similarity index 100% rename from src/gnatcoll-coders-streams.ads rename to minimal/src/gnatcoll-coders-streams.ads diff --git a/src/gnatcoll-coders.adb b/minimal/src/gnatcoll-coders.adb similarity index 100% rename from src/gnatcoll-coders.adb rename to minimal/src/gnatcoll-coders.adb diff --git a/src/gnatcoll-coders.ads b/minimal/src/gnatcoll-coders.ads similarity index 100% rename from src/gnatcoll-coders.ads rename to minimal/src/gnatcoll-coders.ads diff --git a/src/gnatcoll-damerau_levenshtein_distance.ads b/minimal/src/gnatcoll-damerau_levenshtein_distance.ads similarity index 100% rename from src/gnatcoll-damerau_levenshtein_distance.ads rename to minimal/src/gnatcoll-damerau_levenshtein_distance.ads diff --git a/src/gnatcoll-damerau_levenshtein_generic.adb b/minimal/src/gnatcoll-damerau_levenshtein_generic.adb similarity index 100% rename from src/gnatcoll-damerau_levenshtein_generic.adb rename to minimal/src/gnatcoll-damerau_levenshtein_generic.adb diff --git a/src/gnatcoll-damerau_levenshtein_generic.ads b/minimal/src/gnatcoll-damerau_levenshtein_generic.ads similarity index 100% rename from src/gnatcoll-damerau_levenshtein_generic.ads rename to minimal/src/gnatcoll-damerau_levenshtein_generic.ads diff --git a/src/gnatcoll-locks.adb b/minimal/src/gnatcoll-locks.adb similarity index 100% rename from src/gnatcoll-locks.adb rename to minimal/src/gnatcoll-locks.adb diff --git a/src/gnatcoll-locks.ads b/minimal/src/gnatcoll-locks.ads similarity index 100% rename from src/gnatcoll-locks.ads rename to minimal/src/gnatcoll-locks.ads diff --git a/src/gnatcoll-memory.adb b/minimal/src/gnatcoll-memory.adb similarity index 100% rename from src/gnatcoll-memory.adb rename to minimal/src/gnatcoll-memory.adb diff --git a/src/gnatcoll-memory.ads b/minimal/src/gnatcoll-memory.ads similarity index 100% rename from src/gnatcoll-memory.ads rename to minimal/src/gnatcoll-memory.ads diff --git a/src/gnatcoll-promises.adb b/minimal/src/gnatcoll-promises.adb similarity index 100% rename from src/gnatcoll-promises.adb rename to minimal/src/gnatcoll-promises.adb diff --git a/src/gnatcoll-promises.ads b/minimal/src/gnatcoll-promises.ads similarity index 100% rename from src/gnatcoll-promises.ads rename to minimal/src/gnatcoll-promises.ads diff --git a/src/gnatcoll-refcount-weakref.adb b/minimal/src/gnatcoll-refcount-weakref.adb similarity index 100% rename from src/gnatcoll-refcount-weakref.adb rename to minimal/src/gnatcoll-refcount-weakref.adb diff --git a/src/gnatcoll-refcount-weakref.ads b/minimal/src/gnatcoll-refcount-weakref.ads similarity index 100% rename from src/gnatcoll-refcount-weakref.ads rename to minimal/src/gnatcoll-refcount-weakref.ads diff --git a/src/gnatcoll-refcount.adb b/minimal/src/gnatcoll-refcount.adb similarity index 100% rename from src/gnatcoll-refcount.adb rename to minimal/src/gnatcoll-refcount.adb diff --git a/src/gnatcoll-refcount.ads b/minimal/src/gnatcoll-refcount.ads similarity index 100% rename from src/gnatcoll-refcount.ads rename to minimal/src/gnatcoll-refcount.ads diff --git a/src/gnatcoll-storage_pools-alignment.adb b/minimal/src/gnatcoll-storage_pools-alignment.adb similarity index 100% rename from src/gnatcoll-storage_pools-alignment.adb rename to minimal/src/gnatcoll-storage_pools-alignment.adb diff --git a/src/gnatcoll-storage_pools-alignment.ads b/minimal/src/gnatcoll-storage_pools-alignment.ads similarity index 100% rename from src/gnatcoll-storage_pools-alignment.ads rename to minimal/src/gnatcoll-storage_pools-alignment.ads diff --git a/src/gnatcoll-storage_pools-headers.adb b/minimal/src/gnatcoll-storage_pools-headers.adb similarity index 100% rename from src/gnatcoll-storage_pools-headers.adb rename to minimal/src/gnatcoll-storage_pools-headers.adb diff --git a/src/gnatcoll-storage_pools-headers.ads b/minimal/src/gnatcoll-storage_pools-headers.ads similarity index 100% rename from src/gnatcoll-storage_pools-headers.ads rename to minimal/src/gnatcoll-storage_pools-headers.ads diff --git a/src/gnatcoll-storage_pools.ads b/minimal/src/gnatcoll-storage_pools.ads similarity index 100% rename from src/gnatcoll-storage_pools.ads rename to minimal/src/gnatcoll-storage_pools.ads diff --git a/src/gnatcoll-tribooleans.adb b/minimal/src/gnatcoll-tribooleans.adb similarity index 100% rename from src/gnatcoll-tribooleans.adb rename to minimal/src/gnatcoll-tribooleans.adb diff --git a/src/gnatcoll-tribooleans.ads b/minimal/src/gnatcoll-tribooleans.ads similarity index 100% rename from src/gnatcoll-tribooleans.ads rename to minimal/src/gnatcoll-tribooleans.ads diff --git a/src/gnatcoll.ads b/minimal/src/gnatcoll.ads similarity index 100% rename from src/gnatcoll.ads rename to minimal/src/gnatcoll.ads diff --git a/minimal/src/gnatcoll_support.c b/minimal/src/gnatcoll_support.c new file mode 100644 index 00000000..a259944a --- /dev/null +++ b/minimal/src/gnatcoll_support.c @@ -0,0 +1,203 @@ +/*---------------------------------------------------------------------------- +-- G N A T C O L L -- +-- -- +-- Copyright (C) 2008-2018, AdaCore -- +-- -- +-- This library is free software; you can redistribute it and/or modify it -- +-- under terms of the GNU General Public License as published by the Free -- +-- Software Foundation; either version 3, or (at your option) any later -- +-- version. This library is distributed in the hope that it will be useful, -- +-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- +-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-----------------------------------------------------------------------------*/ + +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#endif + +#ifdef HAVE_SYSLOG +#include +void +syslog_wrapper(int priority, const char* msg) { + syslog(priority, "%s", msg); +} +#endif + +// From adaint.h +extern int __gnat_is_directory (char *); + +#ifdef HAVE_MMAP +#include + +int +gnatcoll_has_mmap() { + return 1; +} + +void * +gnatcoll_mmap (void *start, long length, int prot, int flags, + int fd, long offset) +{ + return mmap (start, (size_t)length, prot, flags, fd, (off_t)offset); +} + +int gnatcoll_munmap (void *start, long length) +{ + return munmap (start, (size_t)length); +} + +#ifdef HAVE_MADVISE + +void gnatcoll_madvise(void* addr, size_t len, int advice) { + int adv = (advice == 1 ? MADV_NORMAL + : advice == 2 ? MADV_RANDOM + : advice == 4 ? MADV_SEQUENTIAL + : MADV_NORMAL); + madvise(addr, len, adv); +} + +#else /* not HAVE_MADVISE */ + +void gnatcoll_madvise(void* addr, size_t len, int advice) { +} + +#endif /* HAVE_MADVISE */ + +#else +/* No mmap support, so no madvise support either */ + +int +gnatcoll_has_mmap () +{ + return 0; +} + +void gnatcoll_madvise(void* addr, size_t len, int advice) { +} + +void +*gnatcoll_mmap (void *start, long length, int prot, int flags, + int fd, long offset) +{ + return (void*)0; +} + +int gnatcoll_munmap (void *start, long length) +{ + return 0; +} + +#endif + +int +__gnatcoll_get_logical_drive_strings (char *buffer, int len) +{ +#ifdef _WIN32 + return GetLogicalDriveStringsA ((DWORD)len, (LPSTR)buffer); +#else + return 0; +#endif +} + +void +__gnatcoll_set_readable (char *file, int set) +{ +#ifdef _WIN32 + /* ??? NOT CURRENTLY SUPPORTED. + There is no support for setting a file as unreadable using the + standard chmod routine on Windows. With this routine it is only + possible to set a file as read-only. To set a file as unreadable it is + required to use the more complex [Get|Set]FileSecurity Win32 API by + setting the proper ACL. */ +#elif defined (__VMS__) + /* ??? NOT CURRENTLY SUPPORTED. */ +#else + struct stat statbuf; + + if (!stat (file, &statbuf)) + { + if (set) + chmod (file, statbuf.st_mode | S_IREAD); + else + chmod (file, statbuf.st_mode & (~S_IREAD)); + } +#endif +} + +/********************************************************** + ** __gnatcoll_get_tmp_dir () + ** Return the tmp directory. + ** Return value must be freed by caller + **********************************************************/ + +char* +__gnatcoll_get_tmp_dir (void) +{ + static char *result = NULL; + + /* test static result to see if result has already been found */ + if (result != NULL) + return strdup (result); + +#ifdef _WIN32 + { + DWORD dwRet; + + result = malloc ((MAX_PATH + 1) * sizeof (char)); + dwRet = GetTempPath (MAX_PATH, result); + if (dwRet > 0) { + result[dwRet] = '\0'; + if (__gnat_is_directory (result)) + return strdup (result); + } + free (result); + } +#endif + + result = getenv ("TMPDIR"); + if (result) + if (__gnat_is_directory (result)) + return strdup (result); + + result = getenv ("TMP"); + if (result) + if (__gnat_is_directory (result)) + return strdup (result); + + /* On Windows systems, this is the documented way of retrieving the tmp dir. + * However, the TMP env variable should also be defined */ + result = getenv ("TEMP"); + if (result) + if (__gnat_is_directory (result)) + return strdup (result); + + /* need to duplicate twice: one is for caching, the second one will be freed + * by user */ + result = strdup ("/tmp"); + return strdup (result); +} + +/************************************************************************ + * Support for atomic operations + ************************************************************************/ + +bool gnatcoll_sync_bool_compare_and_swap_access + (void** ptr, void* oldval, void* newval) +{ + return __sync_bool_compare_and_swap(ptr, oldval, newval); +} diff --git a/projects/VERSION b/projects/VERSION new file mode 100644 index 00000000..be8e64f5 --- /dev/null +++ b/projects/VERSION @@ -0,0 +1 @@ +25.0 diff --git a/projects/config/gnatcoll_projects_constants.gpr b/projects/config/gnatcoll_projects_constants.gpr new file mode 100644 index 00000000..f61e0d47 --- /dev/null +++ b/projects/config/gnatcoll_projects_constants.gpr @@ -0,0 +1,5 @@ +abstract project GNATCOLL_Projects_Constants is + GNATCOLL_VERSION_DEFAULT := "0.0"; + GNATCOLL_BUILD_MODE_DEFAULT := "PROD"; + GNATCOLL_OS_DEFAULT := "unix"; +end GNATCOLL_Projects_Constants; diff --git a/gnatcoll_projects.gpr b/projects/gnatcoll_projects.gpr similarity index 90% rename from gnatcoll_projects.gpr rename to projects/gnatcoll_projects.gpr index 0341b141..e0db1a8c 100644 --- a/gnatcoll_projects.gpr +++ b/projects/gnatcoll_projects.gpr @@ -23,23 +23,29 @@ with "gpr"; with "gnatcoll_core"; +with "config/gnatcoll_projects_constants.gpr"; library project GNATCOLL_Projects is - Version := External ("GNATCOLL_VERSION", "0.0"); Name := "gnatcoll_projects"; + Version := External + ("GNATCOLL_VERSION", + GNATCOLL_Projects_Constants.GNATCOLL_VERSION_DEFAULT); type Build_Type is ("DEBUG", "PROD"); Build : Build_Type := - External ("GNATCOLL_BUILD_MODE", External ("BUILD", "DEBUG")); + External ("GNATCOLL_BUILD_MODE", + External ("BUILD", + GNATCOLL_Projects_Constants.GNATCOLL_BUILD_MODE_DEFAULT)); type Library_Type_Type is ("relocatable", "static", "static-pic"); Library_Type : Library_Type_Type := External ("LIBRARY_TYPE", "static"); type OS_Kind is ("windows", "unix", "osx"); - OS : OS_Kind := External ("GNATCOLL_OS", "unix"); + OS : OS_Kind := External + ("GNATCOLL_OS", GNATCOLL_Projects_Constants.GNATCOLL_OS_DEFAULT); - for Source_Dirs use ("src/projects"); + for Source_Dirs use ("src"); for Library_Kind use Library_Type; @@ -125,7 +131,7 @@ library project GNATCOLL_Projects is package Builder is case Build is when "DEBUG" => - for Global_Configuration_Pragmas use "gnat_debug.adc"; + for Global_Configuration_Pragmas use "src/gnat_debug.adc"; when "PROD" => null; end case; diff --git a/projects/gnatcoll_projects.gpr.py b/projects/gnatcoll_projects.gpr.py new file mode 100755 index 00000000..38631adb --- /dev/null +++ b/projects/gnatcoll_projects.gpr.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +from __future__ import annotations +import logging +import sys +import os + +# Support code is located in parent directory +SOURCE_DIR = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.dirname(SOURCE_DIR)) + +from gprproject import BuilderApp + + +class GNATCollProjects(BuilderApp): + project_file = os.path.join(SOURCE_DIR, "gnatcoll_projects.gpr") + description = "GNATCOLL Projects library." "" + constants_project_file = os.path.join( + SOURCE_DIR, "config", "gnatcoll_projects_constants.gpr" + ) + constants = ["GNATCOLL_OS", "GNATCOLL_BUILD_MODE", "GNATCOLL_VERSION"] + + def add_arguments(self, parser: argparse.ArgumentParser) -> None: + parser.add_argument("--build", choices=["DEBUG", "PROD"], default="PROD") + parser.add_argument("--enable-shared", choices=["yes", "no"], default="yes") + + def adjust_config(self, gpr, args: argparse.Namespace) -> None: + with open(os.path.join(SOURCE_DIR, "VERSION")) as fd: + version = fd.read().strip() + gpr.set_variable("GNATCOLL_VERSION", version) + + if "windows" in gpr.target: + gnatcoll_os = "windows" + elif "darwin" in gpr.target: + gnatcoll_os = "osx" + else: + gnatcoll_os = "unix" + gpr.set_variable("GNATCOLL_OS", gnatcoll_os) + gpr.set_variable("GNATCOLL_BUILD_MODE", args.build) + + if args.gnatcov: + gpr.set_variable("LIBRARY_TYPE", "static") + else: + gpr.variants_var = "LIBRARY_TYPE" + if args.enable_shared == "yes": + gpr.variants_values = ["static", "relocatable", "static-pic"] + else: + gpr.variants_values = ["static"] + + +if __name__ == "__main__": + app = GNATCollProjects() + sys.exit(app.run()) diff --git a/projects/src/gnat_debug.adc b/projects/src/gnat_debug.adc new file mode 100644 index 00000000..7fef8cb9 --- /dev/null +++ b/projects/src/gnat_debug.adc @@ -0,0 +1 @@ +pragma Initialize_Scalars; diff --git a/src/projects/gnatcoll-projects-aux.adb b/projects/src/gnatcoll-projects-aux.adb similarity index 100% rename from src/projects/gnatcoll-projects-aux.adb rename to projects/src/gnatcoll-projects-aux.adb diff --git a/src/projects/gnatcoll-projects-aux.ads b/projects/src/gnatcoll-projects-aux.ads similarity index 100% rename from src/projects/gnatcoll-projects-aux.ads rename to projects/src/gnatcoll-projects-aux.ads diff --git a/src/projects/gnatcoll-projects-krunch.adb b/projects/src/gnatcoll-projects-krunch.adb similarity index 100% rename from src/projects/gnatcoll-projects-krunch.adb rename to projects/src/gnatcoll-projects-krunch.adb diff --git a/src/projects/gnatcoll-projects-krunch.ads b/projects/src/gnatcoll-projects-krunch.ads similarity index 100% rename from src/projects/gnatcoll-projects-krunch.ads rename to projects/src/gnatcoll-projects-krunch.ads diff --git a/src/projects/gnatcoll-projects-normalize.adb b/projects/src/gnatcoll-projects-normalize.adb similarity index 100% rename from src/projects/gnatcoll-projects-normalize.adb rename to projects/src/gnatcoll-projects-normalize.adb diff --git a/src/projects/gnatcoll-projects-normalize.ads b/projects/src/gnatcoll-projects-normalize.ads similarity index 100% rename from src/projects/gnatcoll-projects-normalize.ads rename to projects/src/gnatcoll-projects-normalize.ads diff --git a/src/projects/gnatcoll-projects.adb b/projects/src/gnatcoll-projects.adb similarity index 100% rename from src/projects/gnatcoll-projects.adb rename to projects/src/gnatcoll-projects.adb diff --git a/src/projects/gnatcoll-projects.ads b/projects/src/gnatcoll-projects.ads similarity index 100% rename from src/projects/gnatcoll-projects.ads rename to projects/src/gnatcoll-projects.ads diff --git a/src/projects/gnatcoll-scripts-files.adb b/projects/src/gnatcoll-scripts-files.adb similarity index 100% rename from src/projects/gnatcoll-scripts-files.adb rename to projects/src/gnatcoll-scripts-files.adb diff --git a/src/projects/gnatcoll-scripts-files.ads b/projects/src/gnatcoll-scripts-files.ads similarity index 100% rename from src/projects/gnatcoll-scripts-files.ads rename to projects/src/gnatcoll-scripts-files.ads diff --git a/src/projects/gnatcoll-scripts-projects.adb b/projects/src/gnatcoll-scripts-projects.adb similarity index 100% rename from src/projects/gnatcoll-scripts-projects.adb rename to projects/src/gnatcoll-scripts-projects.adb diff --git a/src/projects/gnatcoll-scripts-projects.ads b/projects/src/gnatcoll-scripts-projects.ads similarity index 100% rename from src/projects/gnatcoll-scripts-projects.ads rename to projects/src/gnatcoll-scripts-projects.ads diff --git a/testsuite/drivers/__init__.py b/testsuite/drivers/__init__.py index f7b2e224..91ac7381 100644 --- a/testsuite/drivers/__init__.py +++ b/testsuite/drivers/__init__.py @@ -142,20 +142,6 @@ def gprbuild( if driver.env.gnatcov: from drivers.gnatcov import COVERAGE_LEVEL - # As gnatcoll project is taken from source dir, ensure important - # project variables are passed to select right implementations. This - # should stay in sync with the Makefile logic - gnatcoll_config_vars = [] - if driver.env.target.platform in ( - "x86_64-linux", - "x86_64-windows64", - "aarch64-linux", - ): - platform = driver.env.target.platform.replace("windows64", "windows") - gnatcoll_config_vars.append(f"-XGNATCOLL_BLAKE3_ARCH={platform}") - if driver.env.target.platform in ("x86_64-linux", "x86_64-windows64"): - gnatcoll_config_vars.append(f"-XGNATCOLL_XXHASH_ARCH=x86_64") - gnatcov_cmd = ( [ "gnatcov", @@ -164,15 +150,17 @@ def gprbuild( COVERAGE_LEVEL, "--relocate-build-tree", "--dump-trigger=atexit", - "--projects", - "gnatcoll_core", "--externally-built-projects", - "-XEXTERNALLY_BUILT=true", + "--restricted-to-languages=Ada", + "--full-slugs", "--no-subprojects", + "--projects", "gnatcoll_core", + "--projects", "gnatcoll_minimal", + "--projects", "gnatcoll_projects", + "-XEXTERNALLY_BUILT=true", "-P", project_file, ] - + gnatcoll_config_vars + scenario_cmd ) @@ -194,7 +182,7 @@ def gprbuild( "--implicit-with=gnatcov_rts", "-XLIBRARY_TYPE=static", "-XEXTERNALLY_BUILT=true", - ] + gnatcoll_config_vars + ] if driver.env.is_cross: gprbuild_cmd.append( diff --git a/testsuite/drivers/gnatcov.py b/testsuite/drivers/gnatcov.py index 9f84b816..f06d9d06 100644 --- a/testsuite/drivers/gnatcov.py +++ b/testsuite/drivers/gnatcov.py @@ -60,8 +60,8 @@ def produce_report(driver, output_dir, source_root=None, formats=['dhtml', 'xml' # Produce a checkpoint from them checkpoint_file = os.path.join(driver.env.gnatcov_traces, 'report.ckpt') args = ['gnatcov', 'coverage', '--level', COVERAGE_LEVEL, - '-P', 'gnatcoll_core.gpr', - '-XLIBRARY_TYPE=static', '-XGNATCOLL_BUILD_MODE=DEBUG', + '-P', 'gnatcoll_projects.gpr', + "--externally-built-projects", '--save-checkpoint', checkpoint_file, f'@{traces_list}'] if source_root: args.append("--source-root="+source_root) @@ -80,8 +80,8 @@ def produce_report(driver, output_dir, source_root=None, formats=['dhtml', 'xml' '--annotate', fmt, '--level={}'.format(COVERAGE_LEVEL), '--output-dir', report_dir, - '-P', 'gnatcoll_core.gpr', - '-XLIBRARY_TYPE=static', '-XGNATCOLL_BUILD_MODE=DEBUG', + '-P', 'gnatcoll_projects.gpr', + "--externally-built-projects", '--checkpoint', checkpoint_file] if source_root: args.append("--source-root="+source_root) diff --git a/version_information b/version_information deleted file mode 100644 index ba66466c..00000000 --- a/version_information +++ /dev/null @@ -1 +0,0 @@ -0.0