def _actual_build(self) -> None: # Convert SVG pictures to PDF files if exist. pics_dir = path_join(self.document_dir, 'pics') if exists(pics_dir): self._convert_svg_to_pdf(pics_dir) # Generate document itself. common_input_path = path_join(DocumentBuilder.script_dir, 'tools', 'common') cmd = [ 'xelatex', '-interaction=nonstopmode', '--output-driver=xdvipdfmx -V 5', '-synctex=1', f'-jobname=data', '-output-directory=data', fr'\def\pdf{{}}\input{{doc.tex}}' ] prev_digests = None, None while True: with open(devnull, 'w') as null: check_call(cmd, cwd=self.document_dir, env={'TEXINPUTS': f'.:{common_input_path}:'}, stdout=null) digests = self.__aux_digests() if digests == prev_digests: break prev_digests = digests # Burst generate document into separate pages. check_call(['pdftk', 'data.pdf', 'burst', 'output', 'Sheet_%02d.pdf'], cwd=self._tmp_data_dir())
def setUpRepos(cls): cls.repo = anyvcs.create(cls.main_path, 'svn') common.check_call(['svn', 'checkout', 'file://' + cls.main_path, cls.working_path]) cls.main_branch = 'HEAD' cls.working_head = 'HEAD' for action in cls.setUpWorkingCopy(cls.working_path): action.doSvn(cls)
def setUpRepos(cls): cls.repo = anyvcs.create(cls.main_path, 'svn') common.check_call( ['svn', 'checkout', 'file://' + cls.main_path, cls.working_path]) cls.main_branch = 'HEAD' cls.working_head = 'HEAD' for action in cls.setUpWorkingCopy(cls.working_path): action.doSvn(cls)
def _build_form(self) -> None: print('Generating form sheets ...') check_call([ self._tool_path('formgen'), '-i', path_join('..', 'form.kxg'), '-p', str(self.sheet_count) ], cwd=self._tmp_form_dir())
def setUpRepos(cls): cls.repo = anyvcs.create(cls.main_path, 'hg') common.check_call(['hg', 'clone', cls.main_path, cls.working_path]) with open(os.path.join(cls.working_path, '.hg', 'hgrc'), 'a') as hgrc: hgrc.write('[ui]\nusername = Test User <*****@*****.**>\n') cls.main_branch = 'default' cls.working_head = 'default' for action in cls.setUpWorkingCopy(cls.working_path): action.doHg(cls)
def setUpRepos(cls): cls.repo = anyvcs.create(cls.main_path, 'git') common.check_call(['git', 'clone', cls.main_path, cls.working_path]) cls.check_call(['git', 'config', 'user.email', '*****@*****.**']) cls.check_call(['git', 'config', 'user.name', 'Test User']) cls.main_branch = 'master' cls.working_head = 'master' for action in cls.setUpWorkingCopy(cls.working_path): action.doGit(cls)
def _combine_sheets(self) -> None: print('Combining individual sheets into a resulting document ...') sheets = [ path_join(basename(self._tmp_overlay_dir()), f'Sheet_{sheet_num:02}.pdf') for sheet_num in range(1, self.sheet_count + 1) ] check_call( ['pdftk'] + sheets + ['cat', 'output', basename(self.document_path)], cwd=self.document_dir)
def overlay(sheet_num: int) -> None: data_page_path = path_join(basename(self._tmp_data_dir()), f'Sheet_{sheet_num:02}.pdf') form_page_path = path_join(basename(self._tmp_form_dir()), f'Sheet_{sheet_num:02}.pdf') overlay_page_path = path_join(basename(self._tmp_overlay_dir()), f'Sheet_{sheet_num:02}.pdf') check_call([ 'pdftk', form_page_path, 'stamp', data_page_path, 'output', overlay_page_path ], cwd=self.document_dir)
def _actual_build(self) -> None: check_call([ self._tool_path(self._tool_name()), '-i', path_join('..', 'data.kxg') ], cwd=self._tmp_data_dir()) # TODO: Make possible generation of documents without list_of_changes.svg sheet. self._calculate_sheet_count() copyfile( path_join(DocumentBuilder.script_dir, 'tools', 'common', 'list_of_changes.svg'), path_join(self._tmp_data_dir(), f'Sheet_{self.sheet_count + 1:02}.svg'))
def main(): parser = argparse.ArgumentParser() parser.add_argument('--skija-version') (args, _) = parser.parse_known_args() modulepath = [] if args.skija_version: modulepath += [ common.fetch_maven('org.jetbrains.skija', 'skija-shared', args.skija_version, repo=common.space_skija), common.fetch_maven('org.jetbrains.skija', 'skija-' + common.classifier, args.skija_version, repo=common.space_skija) ] else: build.main() modulepath += [ '../shared/target/classes', '../platform/target/classes' ] os.chdir(common.root + '/tests') sources = common.glob('java', '*.java') common.javac(sources, 'target/classes', modulepath=modulepath, add_modules=[common.module]) common.check_call([ 'java', # '--class-path', common.classpath_separator.join(modulepath + ['target/classes']), '--class-path', 'target/classes', '--module-path', common.classpath_separator.join(modulepath), '--add-modules', common.module ] + (['-XstartOnFirstThread'] if 'macos' == common.system else []) + [ '-Djava.awt.headless=true', '-enableassertions', '-enablesystemassertions', '-Xcheck:jni', '-Dskija.logLevel=DEBUG', 'org.jetbrains.skija.test.TestSuite' ]) return 0
def main(): os.chdir(common.root + '/shared') print('Generating', 'target/generated-sources/delombok/**.java') subprocess.check_call([ "java", "-jar", common.deps()[0], "delombok", "java", "--module-path", common.classpath_separator.join(common.deps()), "-d", "target/generated-sources/delombok/org/jetbrains/skija" ]) if os.path.exists('target/generated-sources/delombok/module-info.java'): os.remove('target/generated-sources/delombok/module-info.java') print('Generating', '../docs/apidocs/**') sources = common.glob('target/generated-sources/delombok', '*.java') common.check_call([ 'javadoc', '--module-path', common.classpath_separator.join(common.deps()), '-d', '../docs/apidocs', '-quiet', '-Xdoclint:all,-missing' ] + sources) return 0
def build_tools(script_path: str, force: bool): if not force: tools = ['2.106-form1', '2.106-form5', 'formgen', 'listofelgen'] if all( exists(path_join(script_path, 'tools', 'apps', tool, tool)) for tool in tools): # All tools are already built. return print('Building tools ...') tmp_path = path_join(script_path, 'tmp') if exists(tmp_path): rmtree(tmp_path) makedirs(tmp_path) check_call(['cmake', '..'], cwd=tmp_path) check_call([ 'cmake', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_VERBOSE_MAKEFILE=1', '-G', 'Unix Makefiles', '..' ], cwd=tmp_path) check_call(['cmake', '--build', '.', '--config', 'Release'], cwd=tmp_path) rmtree(tmp_path) print('Tools have been built.')
def clean(self, project: str): print(f'Cleaning working copy of project "{project}" ...') check_call(['git', 'clean', '-ffdxq'], cwd=path_join(self.root, project))
def export(cls, rev, path): common.check_call(['hg', 'archive', '-r', str(rev), path], cwd=cls.main_path) trash = os.path.join(path, '.hg_archival.txt') if os.path.exists(trash): os.unlink(trash)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--debug', action='store_true') parser.add_argument('--arch', default=common.arch) parser.add_argument('--skia-dir') parser.add_argument('--skia-release', default='m93-87e8842e8c') parser.add_argument('--skija-version') (args, _) = parser.parse_known_args() # Fetch Skia build_type = 'Debug' if args.debug else 'Release' if args.skia_dir: skia_dir = os.path.abspath(args.skia_dir) os.chdir(common.root + '/platform') else: os.chdir(common.root + '/platform') skia_dir = "Skia-" + args.skia_release + "-" + common.system + "-" + build_type + '-' + common.arch if not os.path.exists(skia_dir): zip = skia_dir + '.zip' common.fetch('https://github.com/JetBrains/skia-build/releases/download/' + args.skia_release + '/' + zip, zip) with zipfile.ZipFile(zip, 'r') as f: print("Extracting", zip) f.extractall(skia_dir) os.remove(zip) skia_dir = os.path.abspath(skia_dir) print("Using Skia from", skia_dir) # CMake os.makedirs("build", exist_ok = True) common.check_call([ "cmake", "-G", "Ninja", "-DCMAKE_BUILD_TYPE=" + build_type, "-DSKIA_DIR=" + skia_dir, "-DSKIA_ARCH=" + common.arch] + (["-DCMAKE_OSX_ARCHITECTURES=" + {"x64": "x86_64", "arm64": "arm64"}[common.arch]] if common.system == "macos" else []) + [".."], cwd=os.path.abspath('build')) # Ninja common.check_call(["ninja"], cwd=os.path.abspath('build')) # Codesign if common.system == "macos" and os.getenv("APPLE_CODESIGN_IDENTITY"): subprocess.call(["codesign", # "--force", # "-vvvvvv", "--deep", "--sign", os.getenv("APPLE_CODESIGN_IDENTITY"), "build/libskija_" + common.arch + ".dylib"]) # javac modulepath = [] if args.skija_version: modulepath += [ common.fetch_maven('org.jetbrains.skija', 'skija-shared', args.skija_version, repo='https://packages.jetbrains.team/maven/p/skija/maven') ] else: build_shared.main() modulepath += ['../shared/target/classes'] os.chdir(common.root + '/platform') sources = common.glob('java-' + common.classifier, '*.java') common.javac(sources, 'target/classes', modulepath = modulepath, release = '9') # Copy files target = 'target/classes/org/jetbrains/skija' if common.classifier == 'macos-x64': common.copy_newer('build/libskija_x64.dylib', target + '/macos/x64/libskija_x64.dylib') elif common.classifier == 'macos-arm64': common.copy_newer('build/libskija_arm64.dylib', target + '/macos/arm64/libskija_arm64.dylib') elif common.classifier == 'linux': common.copy_newer('build/libskija.so', target + '/linux/libskija.so') elif common.classifier == 'windows': common.copy_newer('build/skija.dll', target + '/windows/skija.dll') common.copy_newer(skia_dir + '/out/' + build_type + '-' + common.arch + '/icudtl.dat', target + '/windows/icudtl.dat') return 0
def export(cls, rev, path): rev, prefix = cls.repo._maprev(rev) url = 'file://%s/%s@%d' % (cls.main_path, prefix, rev) common.check_call(['svn', 'export', url, path])