source: rtems-libbsd/freebsd-to-rtems.py @ df811cf

55-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since df811cf was df811cf, checked in by Sebastian Huber <sebastian.huber@…>, on 09/25/15 at 12:07:00

Makefile: Delete

Use waf instead.

  • Property mode set to 100755
File size: 5.9 KB
RevLine 
[314be23]1#! /usr/bin/env python
2#
3#  Copyright (c) 2015 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
38import os
[63e8969]39import sys
[b9c291c]40import getopt
41
[314be23]42import builder
43import makefile
[5ba6949]44import waf_generator
[314be23]45import libbsd
46
[b9c291c]47isForward = True
[a803d120]48isEarlyExit = False
[24600f2]49isOnlyMakefile = False
[b9c291c]50
51def usage():
[314be23]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"
[b9c291c]62
63# Parse the arguments
64def parseArguments():
[314be23]65    global isForward, isEarlyExit
66    global isOnlyMakefile
67    try:
68        opts, args = getopt.getopt(sys.argv[1:],
69                                   "?hdDemRr:f:v",
70                                   [ "help",
71                                     "help",
72                                     "dry-run"
73                                     "diff"
74                                     "early-exit"
75                                     "makefile"
76                                     "reverse"
77                                     "rtems="
78                                     "freebsd="
79                                     "verbose" ])
80    except getopt.GetoptError, err:
81        # print help information and exit:
82        print str(err) # will print something like "option -a not recognized"
83        usage()
84        sys.exit(2)
85    for o, a in opts:
86        if o in ("-v", "--verbose"):
87            builder.isVerbose = True
88        elif o in ("-h", "--help", "-?"):
89            usage()
90            sys.exit()
91        elif o in ("-d", "--dry-run"):
92            builder.isDryRun = True
93        elif o in ("-D", "--diff"):
94            builder.isDiffMode = True
95        elif o in ("-e", "--early-exit"):
96            isEarlyExit = True
97        elif o in ("-m", "--makefile"):
98            isOnlyMakefile = True
99        elif o in ("-R", "--reverse"):
100            isForward = False
101        elif o in ("-r", "--rtems"):
102            builder.RTEMS_DIR = a
103        elif o in ("-f", "--freebsd"):
104            builder.FreeBSD_DIR = a
105        else:
106            assert False, "unhandled option"
[b9c291c]107
108parseArguments()
[314be23]109
110print "Verbose:                " + ("no", "yes")[builder.isVerbose]
111print "Dry Run:                " + ("no", "yes")[builder.isDryRun]
112print "Diff Mode Enabled:      " + ("no", "yes")[builder.isDiffMode]
[24600f2]113print "Only Generate Makefile: " + ("no", "yes")[isOnlyMakefile]
[314be23]114print "RTEMS Libbsd Directory: " + builder.RTEMS_DIR
115print "FreeBSD SVN Directory:  " + builder.FreeBSD_DIR
[24600f2]116print "Direction:              " + ("reverse", "forward")[isForward]
[b9c291c]117
[a803d120]118# Check directory argument was set and exist
119def wasDirectorySet(desc, path):
120    if path == "not_set":
[314be23]121        print "error:" + desc + " Directory was not specified on command line"
[a803d120]122        sys.exit(2)
123
124    if os.path.isdir( path ) != True:
[314be23]125        print "error:" + desc + " Directory (" + path + ") does not exist"
[a803d120]126        sys.exit(2)
127
128# Were RTEMS and FreeBSD directories specified
[314be23]129wasDirectorySet( "RTEMS", builder.RTEMS_DIR )
130wasDirectorySet( "FreeBSD", builder.FreeBSD_DIR )
131
[1e8830f0]132# Are we generating or reverting?
133if isForward == True:
[314be23]134    print "Forward from FreeBSD GIT into ", builder.RTEMS_DIR
[1e8830f0]135else:
[314be23]136    print "Reverting from ", builder.RTEMS_DIR
[24600f2]137    if isOnlyMakefile == True:
[314be23]138        print "error: Makefile Mode and Reverse are contradictory"
[24600f2]139        sys.exit(2)
[1e8830f0]140
[a803d120]141if isEarlyExit == True:
142    print "Early exit at user request"
143    sys.exit(0)
[294ae20]144
[8440506]145try:
146    makefile_gen = makefile.ModuleManager()
147    waf_gen = waf_generator.ModuleManager()
148
149    libbsd.sources(makefile_gen)
150    libbsd.sources(waf_gen)
151
152    # Perform the actual file manipulation
153    if isForward:
154        if not isOnlyMakefile:
155            makefile_gen.copyFromFreeBSDToRTEMS()
156        waf_gen.generate()
157    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)
162except IOError, ioe:
163    print 'error: %s' % (ioe)
Note: See TracBrowser for help on using the repository browser.