source: rtems-libbsd/freebsd-to-rtems.py @ 81fc57d

55-freebsd-126-freebsd-12
Last change on this file since 81fc57d was 445d59e, checked in by Sebastian Huber <sebastian.huber@…>, on 10/24/17 at 06:15:06

Remove ability to synchronize with Linux

  • Property mode set to 100755
File size: 6.3 KB
RevLine 
[314be23]1#! /usr/bin/env python
2#
[97c5024a]3#  Copyright (c) 2015-2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
[63e8969]4#
[012c263]5#  Copyright (c) 2009-2015 embedded brains GmbH.  All rights reserved.
[294ae20]6#
7#   embedded brains GmbH
[e599318]8#   Dornierstr. 4
[294ae20]9#   82178 Puchheim
10#   Germany
11#   <info@embedded-brains.de>
12#
[287453d]13#  Copyright (c) 2012 OAR Corporation. All rights reserved.
14#
[294ae20]15#  Redistribution and use in source and binary forms, with or without
16#  modification, are permitted provided that the following conditions
17#  are met:
18#  1. Redistributions of source code must retain the above copyright
19#     notice, this list of conditions and the following disclaimer.
20#  2. Redistributions in binary form must reproduce the above copyright
21#     notice, this list of conditions and the following disclaimer in the
22#     documentation and/or other materials provided with the distribution.
23#
24#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
36# FreeBSD: http://svn.freebsd.org/base/releng/8.2/sys (revision 222485)
37
[97c5024a]38from __future__ import print_function
39
[294ae20]40import os
[63e8969]41import sys
[b9c291c]42import getopt
43
[314be23]44import builder
[5ba6949]45import waf_generator
[314be23]46import libbsd
47
[b9c291c]48isForward = True
[a803d120]49isEarlyExit = False
[97c5024a]50isOnlyBuildScripts = False
[f9798ad]51statsReport = False
[b9c291c]52
53def usage():
[97c5024a]54    print("freebsd-to-rtems.py [args]")
55    print("  -?|-h|--help      print this and exit")
56    print("  -d|--dry-run      run program but no modifications")
57    print("  -D|--diff         provide diff of files between trees")
58    print("  -e|--early-exit   evaluate arguments, print results, and exit")
59    print("  -m|--makefile     Warning: depreciated and will be removed ")
60    print("  -b|--buildscripts just generate the build scripts")
[f9798ad]61    print("  -S|--stats        Print a statistics report")
[fa4ec51]62    print("  -R|--reverse      default origin -> LibBSD, reverse that")
63    print("  -r|--rtems        LibBSD directory (default: '.')")
64    print("  -f|--freebsd      FreeBSD origin directory (default: 'freebsd-org')")
[97c5024a]65    print("  -v|--verbose      enable verbose output mode")
[b9c291c]66
67# Parse the arguments
68def parseArguments():
[f9798ad]69    global isForward, isEarlyExit, statsReport
[97c5024a]70    global isOnlyBuildScripts
[314be23]71    try:
72        opts, args = getopt.getopt(sys.argv[1:],
[f9798ad]73                                   "?hdDembSRr:f:v",
[314be23]74                                   [ "help",
75                                     "help",
76                                     "dry-run"
77                                     "diff"
78                                     "early-exit"
79                                     "makefile"
[97c5024a]80                                     "buildscripts"
[314be23]81                                     "reverse"
[f9798ad]82                                     "stats"
[314be23]83                                     "rtems="
84                                     "freebsd="
85                                     "verbose" ])
[97c5024a]86    except getopt.GetoptError as err:
[314be23]87        # print help information and exit:
[97c5024a]88        print(str(err)) # will print something like "option -a not recognized"
[314be23]89        usage()
90        sys.exit(2)
91    for o, a in opts:
92        if o in ("-v", "--verbose"):
[f1fcdba]93            builder.verboseLevel += 1
[314be23]94        elif o in ("-h", "--help", "-?"):
95            usage()
96            sys.exit()
97        elif o in ("-d", "--dry-run"):
98            builder.isDryRun = True
99        elif o in ("-D", "--diff"):
100            builder.isDiffMode = True
101        elif o in ("-e", "--early-exit"):
102            isEarlyExit = True
[97c5024a]103        elif o in ("-b", "--buildscripts") or o in ("-m", "--makefile"):
104            isOnlyBuildScripts = True
[f9798ad]105        elif o in ("-S", "--stats"):
106            statsReport = True
[314be23]107        elif o in ("-R", "--reverse"):
108            isForward = False
109        elif o in ("-r", "--rtems"):
[fa4ec51]110            builder.LIBBSD_DIR = a
[314be23]111        elif o in ("-f", "--freebsd"):
112            builder.FreeBSD_DIR = a
113        else:
114            assert False, "unhandled option"
[b9c291c]115
116parseArguments()
[314be23]117
[f1fcdba]118print("Verbose:                     %s (%d)" % (("no", "yes")[builder.verbose()],
119                                                builder.verboseLevel))
120print("Dry Run:                     %s" % (("no", "yes")[builder.isDryRun]))
121print("Diff Mode Enabled:           %s" % (("no", "yes")[builder.isDiffMode]))
122print("Only Generate Build Scripts: %s" % (("no", "yes")[isOnlyBuildScripts]))
[fa4ec51]123print("LibBSD Directory:            %s" % (builder.LIBBSD_DIR))
124print("FreeBSD Directory:           %s" % (builder.FreeBSD_DIR))
[f1fcdba]125print("Direction:                   %s" % (("reverse", "forward")[isForward]))
[b9c291c]126
[a803d120]127# Check directory argument was set and exist
128def wasDirectorySet(desc, path):
129    if path == "not_set":
[97c5024a]130        print("error:" + desc + " Directory was not specified on command line")
[a803d120]131        sys.exit(2)
132
133    if os.path.isdir( path ) != True:
[97c5024a]134        print("error:" + desc + " Directory (" + path + ") does not exist")
[a803d120]135        sys.exit(2)
136
[fa4ec51]137# Were directories specified?
138wasDirectorySet( "LibBSD", builder.LIBBSD_DIR )
[314be23]139wasDirectorySet( "FreeBSD", builder.FreeBSD_DIR )
140
[1e8830f0]141# Are we generating or reverting?
142if isForward == True:
[445d59e]143    print("Forward from", builder.FreeBSD_DIR, "into", builder.LIBBSD_DIR)
[1e8830f0]144else:
[fa4ec51]145    print("Reverting from", builder.LIBBSD_DIR)
[97c5024a]146    if isOnlyBuildScripts == True:
147        print("error: Build Script generation and Reverse are contradictory")
[24600f2]148        sys.exit(2)
[1e8830f0]149
[a803d120]150if isEarlyExit == True:
[97c5024a]151    print("Early exit at user request")
[a803d120]152    sys.exit(0)
[294ae20]153
[8440506]154try:
[5338089]155    wafGen = waf_generator.ModuleManager()
156    libbsd.sources(wafGen)
[f1fcdba]157    if not isOnlyBuildScripts:
[5338089]158        wafGen.processSource(isForward)
159    wafGen.generate(libbsd.rtems_version())
[f9798ad]160    builder.changedFileSummary(statsReport)
[97c5024a]161except IOError as ioe:
[f1fcdba]162    print('error: %s' % (str(ioe)))
163except builder.error as be:
164    print('error: %s' % (be))
165except KeyboardInterrupt:
166    print('user abort')
Note: See TracBrowser for help on using the repository browser.