| 1 |
""" |
| 2 |
Check customization of profiles |
| 3 |
""" |
| 4 |
|
| 5 |
from drivers.alr import run_alr, init_local_crate, alr_with, alr_manifest |
| 6 |
from drivers.helpers import content_of |
| 7 |
from drivers.asserts import assert_match |
| 8 |
|
| 9 |
init_local_crate('lib_1', binary=False, enter=False) |
| 10 |
init_local_crate('lib_2', binary=False, enter=False) |
| 11 |
init_local_crate('bin_1', binary=True, enter=True) |
| 12 |
alr_with('lib_1', path='../lib_1') |
| 13 |
alr_with('lib_2', path='../lib_2') |
| 14 |
run_alr('update') |
| 15 |
|
| 16 |
|
| 17 |
def check_config(path, profile, expected_switches=[]): |
| 18 |
conf = content_of(path) |
| 19 |
assert_match('.*Build_Profile : Build_Profile_Kind := "%s"' % profile, |
| 20 |
conf) |
| 21 |
|
| 22 |
for sw in expected_switches: |
| 23 |
assert_match('.*"%s"' % sw,conf) |
| 24 |
|
| 25 |
|
| 26 |
lib1_config = '../lib_1/config/lib_1_config.gpr' |
| 27 |
lib2_config = '../lib_2/config/lib_2_config.gpr' |
| 28 |
bin_config = 'config/bin_1_config.gpr' |
| 29 |
|
| 30 |
# Check default profiles for root and dependency |
| 31 |
check_config(lib1_config, 'release', ['-O3', '-gnatn']) |
| 32 |
check_config(lib2_config, 'release', ['-O3', '-gnatn']) |
| 33 |
check_config(bin_config, 'development', ['-Og', '-g', '-gnatwa', '-gnaty3']) |
| 34 |
|
| 35 |
# Create custom Release profile for lib_1 |
| 36 |
with open('../lib_1/alire.toml', "a") as manifest: |
| 37 |
manifest.write('[build-switches]\n') |
| 38 |
manifest.write('release.optimization = "size"\n') |
| 39 |
manifest.write('release.contracts = "yes"\n') |
| 40 |
manifest.write('release.ada_version = "ada12"\n') |
| 41 |
|
| 42 |
|
| 43 |
# Create custom wildcard profile for lib_2 |
| 44 |
with open('../lib_2/alire.toml', "a") as manifest: |
| 45 |
manifest.write('[build-switches]\n') |
| 46 |
manifest.write('"*".optimization = "debug"\n') |
| 47 |
manifest.write('"*".contracts = "no"\n') |
| 48 |
manifest.write('"*".ada_version = "gnat_extensions"\n') |
| 49 |
|
| 50 |
|
| 51 |
# Check if we can change the profile of a dependency |
| 52 |
with open(alr_manifest(), "a") as manifest: |
| 53 |
manifest.write('[build-profiles]\n') |
| 54 |
manifest.write('lib_2 = "validation"\n') |
| 55 |
|
| 56 |
run_alr('update') |
| 57 |
check_config(lib1_config, 'release', ['-Os', '-gnata', '-gnat12']) |
| 58 |
check_config(lib2_config, 'validation', ['-Og', '-gnatX']) |
| 59 |
check_config(bin_config, 'development', ['-Og', '-g', '-gnatwa', '-gnaty3']) |
| 60 |
|
| 61 |
# Check that the project builds |
| 62 |
run_alr('build') |
| 63 |
|
| 64 |
print('SUCCESS') |