Skip to content

Commit

Permalink
Merge pull request #1062 from googlefonts/ninja-name
Browse files Browse the repository at this point in the history
[fontc] Only crater needs unique build file names
  • Loading branch information
m4rc1e authored Nov 14, 2024
2 parents 0935402 + e131fb0 commit 48f7b83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Lib/gftools/builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from os import chdir
from pathlib import Path
from tempfile import NamedTemporaryFile, gettempdir
import time
from typing import Any, Dict, List, Union

from gftools.builder.fontc import FontcArgs
Expand Down Expand Up @@ -64,7 +63,7 @@ def __init__(
fontc_args.modify_config(self.config)

self.known_operations = OperationRegistry(use_fontc=fontc_args.use_fontc)
self.ninja_file_name = f"build-{time.time_ns()}.ninja"
self.ninja_file_name = fontc_args.build_file_name()
self.writer = Writer(open(self.ninja_file_name, "w"))
self.named_files = {}
self.used_operations = set([])
Expand Down
11 changes: 11 additions & 0 deletions Lib/gftools/builder/fontc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from argparse import Namespace
from pathlib import Path
from typing import Union
import time

from gftools.builder.file import File
from gftools.builder.operations.fontc import set_global_fontc_path
Expand All @@ -35,6 +36,15 @@ def __init__(self, args: Union[Namespace, None]) -> None:
def use_fontc(self) -> bool:
return self.fontc_bin_path is not None

def build_file_name(self) -> str:
if self.fontc_bin_path or self.simple_output_path:
# if we're running for fontc we want uniquely named build files,
# to ensure they don't collide
return f"build-{time.time_ns()}.ninja"
else:
# otherwise just ues the default name
return "build.ninja"

# update the config dictionary based on our special needs
def modify_config(self, config: dict):
if self.single_source:
Expand All @@ -52,6 +62,7 @@ def modify_config(self, config: dict):
config["buildWebfont"] = False
config["buildSmallCap"] = False
config["splitItalic"] = False
config["cleanUp"] = True
# disable running ttfautohint, because we had a segfault
config["autohintTTF"] = False
# set --no-production-names, because it's easier to debug
Expand Down

0 comments on commit 48f7b83

Please sign in to comment.