Пример #1
0
    def Format(self, item, lang='en', output_dir='.'):
        grit_root = item.GetRoot()
        outputs = grit_root.GetOutputFiles()
        rc_header_file = None
        map_header_file = None
        for output in outputs:
            if 'rc_header' == output.GetType():
                rc_header_file = output.GetFilename()
            elif 'resource_map_header' == output.GetType():
                map_header_file = output.GetFilename()
        if not rc_header_file or not map_header_file:
            raise Exception('resource_map_source output type requires '
                            'resource_map_header and rc_header outputs')
        return '''\
// Copyright (c) %(year)d The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is automatically generated by GRIT.  Do not edit.

#include "%(map_header_file)s"

#include "base/basictypes.h"
#include "%(rc_header_file)s"

const GritResourceMap %(map_name)s[] = {
''' % {
            'year': util.GetCurrentYear(),
            'map_header_file': map_header_file,
            'rc_header_file': rc_header_file,
            'map_name': GetMapName(item.GetRoot()),
        }
Пример #2
0
    def Format(self, item, lang='en', begin_item=True, output_dir='.'):
        if not begin_item:
            return ''
        return '''\
// Copyright (c) %(year)d The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is automatically generated by GRIT.  Do not edit.

#include <stddef.h>

#ifndef GRIT_RESOURCE_MAP_STRUCT_
#define GRIT_RESOURCE_MAP_STRUCT_
struct GritResourceMap {
  const char* const name;
  int value;
};
#endif // GRIT_RESOURCE_MAP_STRUCT_

extern const GritResourceMap %(map_name)s[];
extern const size_t %(map_name)sSize;
''' % {
            'year': util.GetCurrentYear(),
            'map_name': GetMapName(item.GetRoot()),
        }
Пример #3
0
  def Format(self, item, lang='en', begin_item=True, output_dir='.'):
    """Format the JS file header."""
    assert isinstance(lang, types.StringTypes)
    if not begin_item:
      return ''
    else:
      return '''//  Copyright %d Google Inc. All Rights Reserved.
// This file is automatically generated by GRIT.  Do not edit.
''' % (util.GetCurrentYear())
Пример #4
0
    def Format(self, item, lang='en', begin_item=True, output_dir='.'):
        assert isinstance(lang, types.StringTypes)
        if not begin_item:
            return ''
        else:
            # Find the location of the resource header file, so that we can include
            # it.
            resource_header = 'resource.h'  # fall back to this
            language_directive = ''
            for output in item.GetRoot().GetOutputFiles():
                if output.attrs['type'] == 'rc_header':
                    resource_header = os.path.abspath(
                        output.GetOutputFilename())
                    resource_header = _MakeRelativePath(
                        output_dir, resource_header)
                if output.attrs['lang'] != lang:
                    continue
                if output.attrs['language_section'] == '':
                    # If no language_section is requested, no directive is added
                    # (Used when the generated rc will be included from another rc
                    # file that will have the appropriate language directive)
                    language_directive = ''
                elif output.attrs['language_section'] == 'neutral':
                    # If a neutral language section is requested (default), add a
                    # neutral language directive
                    language_directive = 'LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL'
                elif output.attrs['language_section'] == 'lang':
                    language_directive = 'LANGUAGE %s' % GetLangDirectivePair(
                        lang)
            resource_header = resource_header.replace('\\', '\\\\')
            return '''// Copyright (c) Google Inc. %d
// All rights reserved.
// This file is automatically generated by GRIT.  Do not edit.

#include "%s"
#include <winresrc.h>
#ifdef IDC_STATIC
#undef IDC_STATIC
#endif
#define IDC_STATIC (-1)

%s


''' % (util.GetCurrentYear(), resource_header, language_directive)
Пример #5
0
    def Format(self, item, lang='', output_dir='.'):
        header_string = '''// Copyright (c) Google Inc. %d
// All rights reserved.
// This file is automatically generated by GRIT. Do not edit.

#pragma once
''' % (util.GetCurrentYear())
        # Check for emit nodes under the rc_header. If any emit node
        # is present, we assume it means the GRD file wants to override
        # the default header, with no includes.
        for output_node in item.GetOutputFiles():
            if output_node.GetType() == 'rc_header':
                for child in output_node.children:
                    if child.name == 'emit':
                        if child.attrs['emit_type'] == 'prepend':
                            return header_string
        # else print out the default header with include
        return header_string + '''
Пример #6
0
    def Format(self, item, lang='en', output_dir='.'):
        """Format the C file header."""
        assert isinstance(lang, types.StringTypes)
        # Find the location of the resource header file, so that we can include
        # it.
        resource_header = 'resource.h'  # fall back to this
        for output in item.GetRoot().GetOutputFiles():
            if output.attrs['type'] == 'rc_header':
                resource_header = os.path.abspath(output.GetOutputFilename())
                resource_header = util.MakeRelativePath(
                    output_dir, resource_header)
        return """//  Copyright %d Google Inc. All Rights Reserved.
// This file is automatically generated by GRIT.  Do not edit.

#include "%s"

// All strings are UTF-8
""" % (util.GetCurrentYear(), resource_header)
Пример #7
0
import os
import sys
if __name__ == '__main__':
    sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..'))

import getopt

from grit import util

import grit.extern.FP

# Copyright notice
_COPYRIGHT = """\
GRIT - the Google Resource and Internationalization Tool
Copyright (c) Google Inc. %d
""" % util.GetCurrentYear()


# Tool info factories; these import only within each factory to avoid
# importing most of the GRIT code until required.
def ToolFactoryBuild():
    import grit.tool.build
    return grit.tool.build.RcBuilder()


def ToolFactoryBuildInfo():
    import grit.tool.buildinfo
    return grit.tool.buildinfo.DetermineBuildInfo()


def ToolFactoryCount():
Пример #8
0
import grit.tool.build
import grit.tool.count
import grit.tool.diff_structures
import grit.tool.menu_from_parts
import grit.tool.newgrd
import grit.tool.resize
import grit.tool.rc2grd
import grit.tool.test
import grit.tool.transl2tc
import grit.tool.unit

# Copyright notice
_COPYRIGHT = '''\
GRIT - the Google Resource and Internationalization Tool
Copyright (c) Google Inc. %d
''' % util.GetCurrentYear()

# Keys for the following map
_CLASS = 1
_REQUIRES_INPUT = 2
_HIDDEN = 3  # optional key - presence indicates tool is hidden

# Maps tool names to the tool's module.  Done as a list of (key, value) tuples
# instead of a map to preserve ordering.
_TOOLS = [
    ['build', {
        _CLASS: grit.tool.build.RcBuilder,
        _REQUIRES_INPUT: True
    }],
    ['newgrd', {
        _CLASS: grit.tool.newgrd.NewGrd,