Changeset 97c5024a in rtems-libbsd for freebsd-to-rtems.py


Ignore:
Timestamp:
Apr 18, 2016, 12:53:20 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
c1e05b9ea378b2971e3d7704779112b4bc4296da, freebsd-9.3, 4a77611a223ea883fb548679b516d326a020d447
Children:
00a7956
Parents:
891a756
Message:

Add RTEMS version support, update all python to 2 and 3.

Add support to force the RTEMS version. This remove the need for using
the --rtems-version command line option if the automatic detection fails.

Update all python code to support python 2 and 3.

Update rtems_waf to the latest version to support the RTEMS version,
check environment variables and to display the CC version.

Sort all tests. I think the unsorted list is dependent on the version
of python and so would result in repo noise as if it regenerted.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freebsd-to-rtems.py

    r891a756 r97c5024a  
    11#! /usr/bin/env python
    22#
    3 #  Copyright (c) 2015 Chris Johns <chrisj@rtems.org>. All rights reserved.
     3#  Copyright (c) 2015-2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
    44#
    55#  Copyright (c) 2009-2015 embedded brains GmbH.  All rights reserved.
     
    3636# FreeBSD: http://svn.freebsd.org/base/releng/8.2/sys (revision 222485)
    3737
     38from __future__ import print_function
     39
    3840import os
    3941import sys
     
    4143
    4244import builder
    43 import makefile
    4445import waf_generator
    4546import libbsd
     
    4748isForward = True
    4849isEarlyExit = False
    49 isOnlyMakefile = False
     50isOnlyBuildScripts = False
    5051
    5152def usage():
    52     print "freebsd-to-rtems.py [args]"
    53     print "  -?|-h|--help     print this and exit"
    54     print "  -d|--dry-run     run program but no modifications"
    55     print "  -D|--diff        provide diff of files between trees"
    56     print "  -e|--early-exit  evaluate arguments, print results, and exit"
    57     print "  -m|--makefile    just generate Makefile"
    58     print "  -R|--reverse     default FreeBSD -> RTEMS, reverse that"
    59     print "  -r|--rtems       RTEMS Libbsd directory (default: '.')"
    60     print "  -f|--freebsd     FreeBSD SVN directory (default: 'freebsd-org')"
    61     print "  -v|--verbose     enable verbose output mode"
     53    print("freebsd-to-rtems.py [args]")
     54    print("  -?|-h|--help      print this and exit")
     55    print("  -d|--dry-run      run program but no modifications")
     56    print("  -D|--diff         provide diff of files between trees")
     57    print("  -e|--early-exit   evaluate arguments, print results, and exit")
     58    print("  -m|--makefile     Warning: depreciated and will be removed ")
     59    print("  -b|--buildscripts just generate the build scripts")
     60    print("  -R|--reverse      default FreeBSD -> RTEMS, reverse that")
     61    print("  -r|--rtems        RTEMS Libbsd directory (default: '.')")
     62    print("  -f|--freebsd      FreeBSD SVN directory (default: 'freebsd-org')")
     63    print("  -v|--verbose      enable verbose output mode")
    6264
    6365# Parse the arguments
    6466def parseArguments():
    6567    global isForward, isEarlyExit
    66     global isOnlyMakefile
     68    global isOnlyBuildScripts
    6769    try:
    6870        opts, args = getopt.getopt(sys.argv[1:],
    69                                    "?hdDemRr:f:v",
     71                                   "?hdDembRr:f:v",
    7072                                   [ "help",
    7173                                     "help",
     
    7476                                     "early-exit"
    7577                                     "makefile"
     78                                     "buildscripts"
    7679                                     "reverse"
    7780                                     "rtems="
    7881                                     "freebsd="
    7982                                     "verbose" ])
    80     except getopt.GetoptError, err:
     83    except getopt.GetoptError as err:
    8184        # print help information and exit:
    82         print str(err) # will print something like "option -a not recognized"
     85        print(str(err)) # will print something like "option -a not recognized"
    8386        usage()
    8487        sys.exit(2)
     
    9598        elif o in ("-e", "--early-exit"):
    9699            isEarlyExit = True
    97         elif o in ("-m", "--makefile"):
    98             isOnlyMakefile = True
     100        elif o in ("-b", "--buildscripts") or o in ("-m", "--makefile"):
     101            isOnlyBuildScripts = True
    99102        elif o in ("-R", "--reverse"):
    100103            isForward = False
     
    108111parseArguments()
    109112
    110 print "Verbose:                " + ("no", "yes")[builder.isVerbose]
    111 print "Dry Run:                " + ("no", "yes")[builder.isDryRun]
    112 print "Diff Mode Enabled:      " + ("no", "yes")[builder.isDiffMode]
    113 print "Only Generate Makefile: " + ("no", "yes")[isOnlyMakefile]
    114 print "RTEMS Libbsd Directory: " + builder.RTEMS_DIR
    115 print "FreeBSD SVN Directory:  " + builder.FreeBSD_DIR
    116 print "Direction:              " + ("reverse", "forward")[isForward]
     113print("Verbose:                     " + ("no", "yes")[builder.isVerbose])
     114print("Dry Run:                     " + ("no", "yes")[builder.isDryRun])
     115print("Diff Mode Enabled:           " + ("no", "yes")[builder.isDiffMode])
     116print("Only Generate Build Scripts: " + ("no", "yes")[isOnlyBuildScripts])
     117print("RTEMS Libbsd Directory:      " + builder.RTEMS_DIR)
     118print("FreeBSD SVN Directory:       " + builder.FreeBSD_DIR)
     119print("Direction:                   " + ("reverse", "forward")[isForward])
    117120
    118121# Check directory argument was set and exist
    119122def wasDirectorySet(desc, path):
    120123    if path == "not_set":
    121         print "error:" + desc + " Directory was not specified on command line"
     124        print("error:" + desc + " Directory was not specified on command line")
    122125        sys.exit(2)
    123126
    124127    if os.path.isdir( path ) != True:
    125         print "error:" + desc + " Directory (" + path + ") does not exist"
     128        print("error:" + desc + " Directory (" + path + ") does not exist")
    126129        sys.exit(2)
    127130
     
    132135# Are we generating or reverting?
    133136if isForward == True:
    134     print "Forward from FreeBSD GIT into ", builder.RTEMS_DIR
     137    print("Forward from FreeBSD GIT into ", builder.RTEMS_DIR)
    135138else:
    136     print "Reverting from ", builder.RTEMS_DIR
    137     if isOnlyMakefile == True:
    138         print "error: Makefile Mode and Reverse are contradictory"
     139    print("Reverting from ", builder.RTEMS_DIR)
     140    if isOnlyBuildScripts == True:
     141        print("error: Build Script generation and Reverse are contradictory")
    139142        sys.exit(2)
    140143
    141144if isEarlyExit == True:
    142     print "Early exit at user request"
     145    print("Early exit at user request")
    143146    sys.exit(0)
    144147
    145148try:
    146     makefile_gen = makefile.ModuleManager()
    147149    waf_gen = waf_generator.ModuleManager()
    148150
    149     libbsd.sources(makefile_gen)
    150151    libbsd.sources(waf_gen)
    151152
    152153    # Perform the actual file manipulation
    153154    if isForward:
    154         if not isOnlyMakefile:
    155             makefile_gen.copyFromFreeBSDToRTEMS()
    156         waf_gen.generate()
     155        if not isOnlyBuildScripts:
     156            waf_gen.copyFromFreeBSDToRTEMS()
     157        waf_gen.generate(libbsd.rtems_version())
    157158    else:
    158         makefile_gen.copyFromRTEMSToFreeBSD()
    159     # Print a summary if changing files
    160     if builder.isDiffMode == False:
    161         print '%d file(s) were changed.' % (builder.filesProcessed)
    162 except IOError, ioe:
    163     print 'error: %s' % (ioe)
     159        waf_gen.copyFromRTEMSToFreeBSD()
     160    builder.changedFileSummary()
     161except IOError as ioe:
     162    print('error: %s' % (ioe))
Note: See TracChangeset for help on using the changeset viewer.