Example #1
0
def gen_tpl(path) :
  if (helper.is_modified(path) and
      not helper.should_compile(config.DEFAULT_COMPILED)) :
    print 'skip %s' % path
    return

  print 'gen_tpl %s\n' % path
  gen_flags = GEN_FLAGS[0 :]

  if helper.should_compile(config.DEFAULT_COMPILED) :
    gen_flags.append('--cssHandlingScheme REFERENCE')

  flags_str = ' '.join([str(soy_flag) for soy_flag in gen_flags])
  output_flag = '--outputPathFormat %s.js' % path
  cmd = 'java -jar %s %s %s %s' % (
    config.TPL_COMPILER_PATH,
    flags_str,
    output_flag,
    path)
  print cmd
  os.system(cmd)

  if helper.should_compile(config.DEFAULT_COMPILED) :
    helper.write_text(helper.get_build_info_file(path), 'build..')
  else :
    helper.write_text(helper.get_build_info_file(path),
                      str(os.path.getmtime(path)))
def gen_webconfig() :
  demo_css_files = []
  css_files = []

  for css_file in config.CSS_FILES :
    css_file = '/%s/%s' % (
      'resource/css',
      helper.get_file_name(css_file),
      )
    css_files.append("'%s'" % css_file)

  for css_file in config.DEMO_CSS_FILES :
    css_file = '/%s/%s' % (
      'resource/css',
      helper.get_file_name(css_file),
      )
    demo_css_files.append("'%s'" % css_file)

  text = '\n'.join([
    '# Generated file. DO NOT EDIT',
    'COMPILED = %s' % helper.should_compile(config.DEFAULT_COMPILED),
    'CSS_FILES = [\n%s\n]' % ',\n'.join(css_files),
    'DEMO_CSS_FILES = [\n%s\n]' % ',\n'.join(demo_css_files)
  ])
  helper.write_text(config.WEB_CONFIG_FILE_PATH, text)
Example #3
0
def build_css() :
  all_css_text = []

  css_files = None

  if helper.should_compile() :
    css_files = config.CSS_FILES
  else :
    css_files = config.DEMO_CSS_FILES

  for css_file in config.CSS_FILES :
    all_css_text.append(helper.get_file_text(css_file))
  all_css_text = ''.join(all_css_text)

  output_raw_path = config.BUILD_INFO_DIR + '/.raw.all_css_text.css'
  output_min_path = config.BUILD_INFO_DIR + '/.min.all_css_text.css'
  helper.write_text(output_raw_path, all_css_text)

  cmd = 'java -jar %s %s > %s' % (
    config.CSS_COMPRESSOR_PATH,
    output_raw_path,
    output_min_path)

  os.system(cmd)
  min_css_text = helper.get_file_text(output_min_path)

  js_vars = []
  css_names = re.findall(CSS_NAME_PATTERN, min_css_text)
  old_new_css_names = [(cn, rename_css_name(cn, js_vars))for cn in css_names]

  if helper.should_compile(config.DEFAULT_COMPILED) :
    bin_css_text = min_css_text
    for pair in old_new_css_names :
      bin_css_text = bin_css_text.replace(pair[0], pair[1])
    helper.write_text(config.CSS_BIN_DIR + '/all.css', bin_css_text)
  else :
    print 'Skip generate compiled CSS.'

  js_code = JS_CODE_TEMPLATE % ''.join(js_vars)
  helper.write_text(config.JS_CSS_NAMES_PATH, js_code.strip())
Example #4
0
import config
import helper
import os

CMD = ('''
python scripts/gen_webconfig.py
python scripts/gen_css.py
python scripts/gen_tpls.py
python scripts/gen_js_deps.py
python scripts/build_js.py
''').strip()

if __name__ == '__main__' :
  if helper.should_compile(config.DEFAULT_COMPILED) :
    lines = ['%s -c;' % line.strip() for line in CMD.splitlines()]
  else :
    lines = ['%s ;' % line.strip() for line in CMD.splitlines()]
  cmd = '\n'.join(lines)
  os.system('clear')
  print cmd
  os.system(cmd)
  demo_css_files = []
  css_files = []

  for css_file in config.CSS_FILES :
    css_file = '/%s/%s' % (
      'resource/css',
      helper.get_file_name(css_file),
      )
    css_files.append("'%s'" % css_file)

  for css_file in config.DEMO_CSS_FILES :
    css_file = '/%s/%s' % (
      'resource/css',
      helper.get_file_name(css_file),
      )
    demo_css_files.append("'%s'" % css_file)

  text = '\n'.join([
    '# Generated file. DO NOT EDIT',
    'COMPILED = %s' % helper.should_compile(config.DEFAULT_COMPILED),
    'CSS_FILES = [\n%s\n]' % ',\n'.join(css_files),
    'DEMO_CSS_FILES = [\n%s\n]' % ',\n'.join(demo_css_files)
  ])
  helper.write_text(config.WEB_CONFIG_FILE_PATH, text)


if __name__ == '__main__' :
  print '-' * 80
  print 'gen_webconfig'
  print 'COMPILED %s' % helper.should_compile(config.DEFAULT_COMPILED)
  gen_webconfig()