[crater] Rework representation of targets#1564
Conversation
are there font source repositories without any configs in which we were previously discovering and building some sources whereas now we will no longer? Or is that covered by the 'virtual configs'? |
|
No, previously we would rely on configs to find sources, but we would then forget about them. |
| .expect("config path always in sources dir"); | ||
| // config is always in sources, sources is always in org/repo | ||
| let repo_dir = relative_config_path.parent().unwrap().parent().unwrap(); | ||
| // we map repos to URLS in a special sources.json file |
There was a problem hiding this comment.
I don't think I understand what "special" is trying to tell me? I wonder if we could describe what is in sources.json (or point to the description) more directly? - it's not entirely clear to me from this what I'm going to find there
| // config is always in sources, sources is always in org/repo | ||
| let repo_dir = relative_config_path.parent().unwrap().parent().unwrap(); | ||
| // we map repos to URLS in a special sources.json file | ||
| let repo_dir = repo.repo_path(Path::new("")); |
There was a problem hiding this comment.
nit: would read nicer without Path::new, could we modify repo_path to allow &str input?
There was a problem hiding this comment.
we could, but it isn't defined in this crate so would be a bit of a hassle.
| .insert(repo_dir.to_owned(), repo.repo_url.clone()); | ||
| .insert(repo_dir.clone(), repo.repo_url.clone()); | ||
|
|
||
| let sources_dir = if repo.config_is_virtual() { |
There was a problem hiding this comment.
"virtual" for a file that exists feels a touch off to me. Might "external" or even out_of_repo or some siuch, aiming to convey that the config doesn't live in this repo (but does live somewhere!) convey the concept more clearly?
There was a problem hiding this comment.
config_in_repo seems like it would work? If the config is not in the repo { do something else } type of deal.
There was a problem hiding this comment.
- This method is also not defined here, we're just calling it.
- I'm not sure I understand, are you proposing a new method called
config_in_repo?
There was a problem hiding this comment.
Finally, this commit adds preliminary support for 'virtual configs', which occur when we want to provide a config file for a repository that we do not otherwise want to (or are unable to) modify. These config files live in the google/fonts repository.
To me this sounds like a config_override.
| pub(crate) struct Target { | ||
| /// path to the source dir for this target (relative to the git cache root) | ||
| source_dir: PathBuf, | ||
| /// path to the source repo, from the cache dir root |
There was a problem hiding this comment.
Suggest "relative to cache root" instead of "from..."
| /// | ||
| /// - From the cache root if it is virtual; | ||
| /// - From the repo root otherwise | ||
| pub(crate) config: PathBuf, |
There was a problem hiding this comment.
Similarly suggest "relative to..." instead of "from", clearer to at least this reader and consistent with how source is described below.
| } | ||
| } | ||
| impl Target { | ||
| pub(crate) fn new2( |
There was a problem hiding this comment.
is new2 temporary? If not perhaps we could use names that convey something? The purpose or when it shoudl be used or some such?
There was a problem hiding this comment.
oops yes this was leftover from earlier in the refactor, when I hadn't removed the previous constructor.
| /// | ||
| /// $ORG/$REPO/$CONFIG_PATH?$SHA $SRC_PATH ($BUILD_TYPE) | ||
| /// | ||
| /// where a virtual config's $CONFIG_PATH starts with the literal path element |
There was a problem hiding this comment.
I would find EXTERNAL or OUT_OF_REPO or similar more informative than VIRTUAL, virtual makes me think you synthesized it, not that it exists somewhere else.
There was a problem hiding this comment.
So if this is a serious concern I'll need to go and make a separate PR + release in google_fonts_sources, which is where I first picked this terminology. Would you prefer that?
rsheeter
left a comment
There was a problem hiding this comment.
LGTM subject to "virtual" changing, that term leads me (and I suspect others) to assume things that are entirely wrong
This patch is kind of doing a bunch of stuff and I apologize for getting it all tied up together. I. Preamble Crater, like much software, was accreted more than it was designed. This has started to pose challanges. The main problem is that historically we were only concerned with font source files; repositories and config files were just a way for us to discover sources. Later on, we started to also care about config files, so that we could do gftools builds; but this work brought in a bunch of assumptions about where config files could be found, and how they related to sources. II. This Commit - The main purpose of this commit is to move us from being focused on sources to being focused on configs. We will only build something if we have a config, and for a given config we will only build a source that is named by that config. - In addition to that, this commit tries to generally be more consistent about how we construct paths, and how we report errors if we cannot compile a given target. - Finally, this commit adds preliminary support for 'virtual configs', which occur when we want to provide a config file for a repository that we do not otherwise want to (or are unable to) modify. These config files live in the google/fonts repository. More work will be required before we can actually build these virtual configs, but at least now we understand that they exist.
This patch is kind of doing a bunch of stuff and I apologize for getting it all tied up together.
I. Preamble
Crater, like much software, was accreted more than it was designed. This has started to pose challanges.
The main problem is that historically we were only concerned with font source files; repositories and config files were just a way for us to discover sources.
Later on, we started to also care about config files, so that we could do gftools builds; but this work brought in a bunch of assumptions about where config files could be found, and how they related to sources.
II. This Commit
The main purpose of this commit is to move us from being focused on sources to being focused on configs. We will only build something if we have a config, and for a given config we will only build a source that is named by that config.
In addition to that, this commit tries to generally be more consistent about how we construct paths, and how we report errors if we cannot compile a given target.
Finally, this commit adds preliminary support for 'virtual configs', which occur when we want to provide a config file for a repository that we do not otherwise want to (or are unable to) modify. These config files live in the google/fonts repository.
More work will be required before we can actually build these virtual configs, but at least now we understand that they exist.