From 5a197cfbebaf814bce162493d596c767d078a67b Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Mon, 25 May 2020 13:30:50 +0200 Subject: [PATCH] Migration to GNAT Community 2020 --- .appveyor.yml | 10 ++++----- .travis.yml | 16 +++++++-------- scripts/build_all_examples.py | 24 +++++++--------------- scripts/install_dependencies.py | 36 ++++++++++++++++++--------------- testsuite/run.py | 22 ++++---------------- 5 files changed, 44 insertions(+), 64 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 4a04f584..1aa68aa3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,10 +5,10 @@ version: 0.0.{build} # Setup python for build and test-suite scripts environment: - PYTHON: C:\\Python27 + PYTHON: C:\\Python37 TOOLS_DIR: C:\ADL_tools\ - GNAT_NATIVE_INSTALLER: C:\ADL_tools\gnat-community-2019-x86_64-windows-bin.exe - GNAT_ARM_ELF_INSTALLER: C:\ADL_tools\gnat-community-2019-arm-elf-windows-bin.exe + GNAT_NATIVE_INSTALLER: C:\ADL_tools\gnat-community-2020-x86_64-windows-bin.exe + GNAT_ARM_ELF_INSTALLER: C:\ADL_tools\gnat-community-2020-arm-elf-windows-bin.exe INSTALL_DIR: C:\Install\ # Cache directories will be preseved from one build to the other @@ -32,8 +32,8 @@ install: - cmd: dir %INSTALL_DIR% # Download compiler installer if not already in the tool dir -- ps: If (Test-Path $env:GNAT_NATIVE_INSTALLER){echo compiler already in cache}Else{(new-object net.webclient).DownloadFile('https://community.download.adacore.com/v1/c13b2d02d23057d9251bcdc9a073cb932177f016?filename=gnat-community-2019-20190517-x86_64-windows-bin.exe', $env:GNAT_NATIVE_INSTALLER)} -- ps: If (Test-Path $env:GNAT_ARM_ELF_INSTALLER){echo compiler already in cache}Else{(new-object net.webclient).DownloadFile('https://community.download.adacore.com/v1/06e1ece65684785160796678c1944460e34e2e97?filename=gnat-community-2019-20190517-arm-elf-windows64-bin.exe', $env:GNAT_ARM_ELF_INSTALLER)} +- ps: If (Test-Path $env:GNAT_NATIVE_INSTALLER){echo compiler already in cache}Else{(new-object net.webclient).DownloadFile('https://community.download.adacore.com/v1/966801764ae160828c97d2c33000e9feb08d4cce?filename=gnat-2020-20200429-x86_64-windows-bin.exe', $env:GNAT_NATIVE_INSTALLER)} +- ps: If (Test-Path $env:GNAT_ARM_ELF_INSTALLER){echo compiler already in cache}Else{(new-object net.webclient).DownloadFile('https://community.download.adacore.com/v1/955b7bccce241e9931124be4df11fa7bd5cb5aef?filename=gnat-2020-20200429-arm-elf-windows64-bin.exe', $env:GNAT_ARM_ELF_INSTALLER)} # Show content of tool dir again so we can see if the download was ok - cmd: dir %TOOLS_DIR% diff --git a/.travis.yml b/.travis.yml index 64dabd3c..90862fff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,15 @@ -# We are using Python 2.7 to run the testsuite +# We are using Python 3.7 to run the testsuite language: python python: - - "2.7" + - "3.7" # Global variables env: global: - TOOLS_DIR=$HOME/build_tools - - GNAT_BIN_PATH=$TOOLS_DIR/gnat-community-2019-x86_64-linux-bin - - GNAT_ARM_BIN_PATH=$TOOLS_DIR/gnat-community-2019-arm-elf-bin - - GNAT_RV32_BIN_PATH=$TOOLS_DIR/gnat-community-2019-riscv32-elf-bin + - GNAT_BIN_PATH=$TOOLS_DIR/gnat-community-2020-x86_64-linux-bin + - GNAT_ARM_BIN_PATH=$TOOLS_DIR/gnat-community-2020-arm-elf-bin + - GNAT_RV32_BIN_PATH=$TOOLS_DIR/gnat-community-2020-riscv32-elf-bin os: - linux @@ -23,9 +23,9 @@ cache: install: # Check if the GNAT package is already available in the cache directory. If # not, download it. - - test -f $GNAT_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget https://community.download.adacore.com/v1/0cd3e2a668332613b522d9612ffa27ef3eb0815b?filename=gnat-community-2019-20190517-x86_64-linux-bin -O $GNAT_BIN_PATH) - - test -f $GNAT_ARM_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget https://community.download.adacore.com/v1/6696259f92b40178ab1cc1d3e005acf705dc4162?filename=gnat-community-2019-20190517-arm-elf-linux64-bin -O $GNAT_ARM_BIN_PATH) - - test -f $GNAT_RV32_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget https://community.download.adacore.com/v1/179a91e48f749b2aa8233bc63b3be75168bbb785?filename=gnat-community-2019-20190517-riscv32-elf-linux64-bin -O $GNAT_RV32_BIN_PATH) + - test -f $GNAT_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget https://community.download.adacore.com/v1/4d99b7b2f212c8efdab2ba8ede474bb9fa15888d?filename=gnat-2020-20200429-x86_64-linux-bin -O $GNAT_BIN_PATH) + - test -f $GNAT_ARM_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget https://community.download.adacore.com/v1/2b8ddb644a06808e7d2c6b62edf16d31b02f514f?filename=gnat-2020-20200429-arm-elf-linux64-bin -O $GNAT_ARM_BIN_PATH) + - test -f $GNAT_RV32_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget https://community.download.adacore.com/v1/fe26719b2279dee730d3e5a239d95c9fe926c83d?filename=gnat-2020-20200429-riscv32-elf-linux64-bin -O $GNAT_RV32_BIN_PATH) - wget https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_package.sh - wget https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_script.qs diff --git a/scripts/build_all_examples.py b/scripts/build_all_examples.py index 58d7b3fe..72ee6e5d 100755 --- a/scripts/build_all_examples.py +++ b/scripts/build_all_examples.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python2 +#! /usr/bin/env python3 import argparse import os @@ -11,21 +11,11 @@ ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) def run_program(*argv): - print "$ %s" % " ".join(argv) + print("$ %s" % " ".join(argv)) p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() - try: - stdout = stdout.decode('ascii') - except UnicodeError: - return 'stdout is not ASCII' - - try: - stderr = stderr.decode('ascii') - except UnicodeError: - return 'stderr is not ASCII' - return (p.returncode, stdout, stderr) @@ -35,19 +25,19 @@ def gprbuild(project_file, debug=False): extra_args += ["-XADL_BUILD=" + ("Debug" if debug else "Production")] extra_args += ["-XADL_BUILD_CHECKS=Enabled"] - print "Building '%s'" % project_file + print("Building '%s'" % project_file) # Build the project returncode, stdout, stderr = run_program( 'gprbuild', '-j0', '-p', '-q', '-s', '-P', project_file, *extra_args ) - print stdout + print(stdout) if returncode: - print 'Build error (gprbuild returned {}):\n{}'.format( + print('Build error (gprbuild returned {}):\n{}'.format( returncode, stderr - ) + )) # Clean to avoid error in the next build with a different run-time or # compile switches. @@ -195,7 +185,7 @@ def main(args): # Check if we can actually detect a build failure ret = gprbuild("This_Project_Doesnt_Exist", debug=False) if not ret: - print "Build failure is not detected" + print("Build failure is not detected") sys.exit(1) ret = 0 diff --git a/scripts/install_dependencies.py b/scripts/install_dependencies.py index 9c566b06..045629e1 100755 --- a/scripts/install_dependencies.py +++ b/scripts/install_dependencies.py @@ -1,16 +1,16 @@ -#! /usr/bin/env python2 +#! /usr/bin/env python3 import argparse import os import os.path import subprocess import sys - +import shutil ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../')) def run_program(argv, cwd=os.path.dirname(os.path.realpath(__file__))): - print "$ %s" % " ".join(argv) + print("$ %s" % " ".join(argv)) p = subprocess.Popen( argv, cwd=cwd, @@ -41,24 +41,24 @@ def git_clone(repo_url, branch, dst, recursive=False): # Clone the repo returncode, stdout, stderr = run_program( ['git', 'clone', repo_url, dst] + extra_args) - print stdout + print(stdout) if returncode: - print 'git clone error (returned {}):\n{}'.format( + print('git clone error (returned {}):\n{}'.format( returncode, stderr - ) + )) return returncode if branch: # Clone the repo returncode, stdout, stderr = run_program([ 'git', '-C', dst, 'checkout', '-b', branch, "origin/" + branch]) - print stdout + print(stdout) if returncode: - print 'git branch checkout error (returned {}):\n{}'.format( + print('git branch checkout error (returned {}):\n{}'.format( returncode, stderr - ) + )) return returncode # Git repositories @@ -71,7 +71,11 @@ git_repos = [("https://github.com/AdaCore/bb-runtimes", False, "bb-runtimes", False, - [sys.executable, ROOT_DIR + "/bb-runtimes/install.py", "--arch=arm-eabi"]), + [sys.executable, ROOT_DIR + "/bb-runtimes/install.py", + "--arch=arm-eabi", + "--prefix=" + + os.path.join(os.path.dirname(shutil.which("arm-eabi-gnatls")), + '..', 'arm-eabi', 'lib', 'gnat')]), ] parser = argparse.ArgumentParser('Download and install dependencies') @@ -85,7 +89,7 @@ parser.add_argument( def main(args): at_least_one_error = False - print "ROOT_DIR :" + ROOT_DIR + print("ROOT_DIR :" + ROOT_DIR) ret = 0 for repo, branch, dest, recursive, build_cmd in git_repos: if args.pattern and not any(pat in repo for pat in args.pattern): @@ -96,21 +100,21 @@ def main(args): if not os.path.exists(dest): ret = git_clone(repo, branch, dest, recursive) else: - print "%s already cloned" % dest + print("%s already cloned" % dest) if ret: at_least_one_error = True if build_cmd: - print "Running build command:" + print("Running build command:") ret, stdout, stderr = run_program(build_cmd, dest) - print stdout + print(stdout) if ret: - print 'Dependency install command error' +\ - ' (returned {}):\n{}'.format(ret, stderr) + print('Dependency install command error' +\ + ' (returned {}):\n{}'.format(ret, stderr)) if at_least_one_error: sys.exit(1) diff --git a/testsuite/run.py b/testsuite/run.py index 34758c2d..897e2e75 100755 --- a/testsuite/run.py +++ b/testsuite/run.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python2 +#! /usr/bin/env python3 import argparse import difflib @@ -20,16 +20,6 @@ def run_program(*argv): ) stdout, stderr = p.communicate() - try: - stdout = stdout.decode('ascii') - except UnicodeError: - return 'stdout is not ASCII' - - try: - stderr = stderr.decode('ascii') - except UnicodeError: - return 'stderr is not ASCII' - return (p.returncode, stdout, stderr) @@ -95,12 +85,8 @@ class Testcase: Helper for run, execute a single test driver. """ # Get the expected output - with open(expected_output_fn, 'r') as f: + with open(expected_output_fn, 'rb') as f: expected_output = f.read() - try: - expected_output = expected_output.decode('ascii') - except UnicodeError: - return 'Expected output is not ASCII' expected_output = expected_output.splitlines() # Run the program, get its output @@ -116,7 +102,7 @@ class Testcase: if returncode or stderr: return program_returned_msg elif args.verbose: - print program_returned_msg + print(program_returned_msg) stdout = stdout.splitlines() @@ -131,7 +117,7 @@ class Testcase: ) )) elif args.verbose: - print "\n".join(stdout) + print("\n".join(stdout)) def find_testcases():