Write the index entirely in RAM. Its only a few hundred KiB, which trivially fits in memory. Compress it twice in memory, once to build the ZIP that is unpacked at runtime, and again to package it into a JAR for linking with the runtime. This saves a build step in the BUCK rules. Move the ZIP under the server package name, to reduce any risk of collision with another concept of "index.zip". Change-Id: I74e59712e9855ac79c5220ff0a6b30ecbc3d152f
		
			
				
	
	
		
			84 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
include_defs('//Documentation/asciidoc.defs')
 | 
						|
include_defs('//Documentation/config.defs')
 | 
						|
include_defs('//tools/git.defs')
 | 
						|
 | 
						|
DOC_DIR = 'Documentation'
 | 
						|
MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module']
 | 
						|
SRCS = glob(['*.txt'], excludes = ['licenses.txt'])
 | 
						|
 | 
						|
genrule(
 | 
						|
  name = 'html',
 | 
						|
  cmd = 'cd $TMP;' +
 | 
						|
    'mkdir -p %s/images;' % DOC_DIR +
 | 
						|
    'unzip -q $SRCDIR/only_html.zip -d %s/;' % DOC_DIR +
 | 
						|
    'for s in $SRCS;do ln -s $s %s;done;' % DOC_DIR +
 | 
						|
    'mv %s/*.{jpg,png} %s/images;' % (DOC_DIR, DOC_DIR) +
 | 
						|
    'rm %s/only_html.zip;' % DOC_DIR +
 | 
						|
    'rm %s/licenses.txt;' % DOC_DIR +
 | 
						|
    'cp $SRCDIR/licenses.txt LICENSES.txt;' +
 | 
						|
    'zip -qr $OUT *',
 | 
						|
  srcs = glob([
 | 
						|
      'images/*.jpg',
 | 
						|
      'images/*.png',
 | 
						|
    ]) + [
 | 
						|
      'doc.css',
 | 
						|
      genfile('licenses.txt'),
 | 
						|
      genfile('only_html.zip'),
 | 
						|
    ],
 | 
						|
  deps = [
 | 
						|
    ':generate_html',
 | 
						|
    ':licenses.txt',
 | 
						|
  ],
 | 
						|
  out = 'html.zip',
 | 
						|
  visibility = ['PUBLIC'],
 | 
						|
)
 | 
						|
 | 
						|
genasciidoc(
 | 
						|
  name = 'generate_html',
 | 
						|
  srcs = SRCS + [genfile('licenses.txt')],
 | 
						|
  deps = [':licenses.txt'],
 | 
						|
  attributes = documentation_attributes(git_describe()),
 | 
						|
  backend = 'html5',
 | 
						|
  out = 'only_html.zip',
 | 
						|
)
 | 
						|
 | 
						|
genrule(
 | 
						|
  name = 'licenses.txt',
 | 
						|
  cmd = '$(exe :gen_licenses) >$OUT',
 | 
						|
  deps = [':gen_licenses'] + MAIN,
 | 
						|
  out = 'licenses.txt',
 | 
						|
)
 | 
						|
 | 
						|
python_binary(
 | 
						|
  name = 'gen_licenses',
 | 
						|
  main = 'gen_licenses.py',
 | 
						|
)
 | 
						|
 | 
						|
python_binary(
 | 
						|
  name = 'replace_macros',
 | 
						|
  main = 'replace_macros.py',
 | 
						|
)
 | 
						|
 | 
						|
genrule(
 | 
						|
  name = 'index',
 | 
						|
  cmd = '$(exe //lib/asciidoctor:doc_indexer) ' +
 | 
						|
      '-o $OUT ' +
 | 
						|
      '--prefix "%s/" ' % DOC_DIR +
 | 
						|
      '--in-ext ".txt" ' +
 | 
						|
      '--out-ext ".html" ' +
 | 
						|
      '$SRCS',
 | 
						|
  srcs = SRCS + [genfile('licenses.txt')],
 | 
						|
  deps = [
 | 
						|
    ':licenses.txt',
 | 
						|
    '//lib/asciidoctor:doc_indexer',
 | 
						|
  ],
 | 
						|
  out = 'index.jar',
 | 
						|
)
 | 
						|
 | 
						|
prebuilt_jar(
 | 
						|
  name = 'index_lib',
 | 
						|
  binary_jar = genfile('index.jar'),
 | 
						|
  deps = [':index'],
 | 
						|
  visibility = ['PUBLIC'],
 | 
						|
)
 |