usr/src/tools/onbld/Checks/Cddl.py
author Ali Bahrami <Ali.Bahrami@Sun.COM>
Tue, 10 Feb 2009 09:38:02 -0700
changeset 8744 03d5725cda56
parent 7078 935563142864
permissions -rw-r--r--
6798660 Cadmium .NOT file processing problem with CWD relative file paths Contributed by Richard Lowe 6785284 Mapfile versioning rules need to be more visible to gatelings 6800164 Standard file exclusion mechanism needed for Cadmium tools
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7078
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
     1
#! /usr/bin/python
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
     2
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
     3
CDDL = '''
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
     4
CDDL HEADER START
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
     5
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
     6
The contents of this file are subject to the terms of the
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
     7
Common Development and Distribution License (the "License").
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
     8
You may not use this file except in compliance with the License.
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
     9
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    10
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    11
or http://www.opensolaris.org/os/licensing.
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    12
See the License for the specific language governing permissions
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    13
and limitations under the License.
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    14
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    15
When distributing Covered Code, include this CDDL HEADER in each
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    16
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    17
If applicable, add the following below this CDDL HEADER, with the
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    18
fields enclosed by brackets "[]" replaced with your own identifying
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    19
information: Portions Copyright [yyyy] [name of copyright owner]
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    20
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    21
CDDL HEADER END
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    22
'''
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    23
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    24
#
8744
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    25
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
7078
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    26
# Use is subject to license terms.
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    27
#
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    28
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    29
#
8744
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    30
# Check that source files contain a valid CDDL block
7078
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    31
#
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    32
8744
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    33
import sys, CmtBlk
7078
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    34
8744
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    35
# scmtest has a test for cddlchk that depends on the variable
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    36
# Cddl.CmntChrs. However, that variable has been refactored into
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    37
# CmtBlk. The following line preserves the original interface
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    38
# from the Cddl module, and allows existing programs that assume
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    39
# Cddl.CmntChrs exists to continue working.
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    40
#
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    41
CmntChrs = CmtBlk.CmntChrs
7078
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    42
8744
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    43
# The CDDL string above contains the block guards so that the text will
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    44
# be tested by cddlchk. However, we don't want to include the initial
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    45
# \n or the block guards in the text passed in.
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    46
# 
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    47
CDDL = CDDL.splitlines()[3:-2]
7078
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    48
935563142864 6538468 add Mercurial support to ON developer tools
mjnelson
parents:
diff changeset
    49
def cddlchk(fh, filename=None, lenient=False, verbose=False, output=sys.stderr):
8744
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    50
	return CmtBlk.cmtblkchk(fh, 'CDDL', CDDL, filename=filename,
03d5725cda56 6798660 Cadmium .NOT file processing problem with CWD relative file paths
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 7078
diff changeset
    51
				lenient=lenient, verbose=verbose, output=output)