Skip to content

Commit cbae82b

Browse files
donnmole99
authored andcommitted
chore: update yosys to 0.60
- updates yosys to 0.60, specifically to pull in the following: - YosysHQ/yosys#5492 - YosysHQ/yosys#5497 - also update the github snapshot fetcher to support adding `.gitcommit` files much like the Yosys tree downloads for releases
1 parent 2a8043b commit cbae82b

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

nix/fetch_github_snapshot.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
repo,
3131
rev,
3232
hash,
33+
add-gitcommit ? false,
3334
}:
3435
stdenvNoCC.mkDerivation {
3536
name = "github-${repo}-${rev}-snapshot";
@@ -45,7 +46,7 @@ stdenvNoCC.mkDerivation {
4546
phases = [ "installPhase" ];
4647
installPhase = ''
4748
python3 ${./supporting/download_github_snapshot.py} \
48-
--out-dir $out \
49+
${lib.optionalString add-gitcommit "--add-gitcommit"} --out-dir $out \
4950
https://github.com/${owner}/${repo} \
5051
${rev}
5152
'';

nix/supporting/download_github_snapshot.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ def extract_tarball(tarball_path: str, extract_to: str):
130130
tar.extract(member, path=extract_to, filter="tar")
131131

132132

133-
def fetch_tarball_and_submodules(repo_url, commit, base_path=None, filter="."):
133+
def fetch_tarball_and_submodules(
134+
repo_url,
135+
commit,
136+
base_path=None,
137+
filter=".",
138+
add_gitcommit=False,
139+
):
134140
if base_path is None:
135141
base_path = urllib.parse.urlsplit(repo_url).path.split("/")[-1]
136142
key = (repo_url, commit)
@@ -155,6 +161,10 @@ def fetch_tarball_and_submodules(repo_url, commit, base_path=None, filter="."):
155161
tree_resp.raise_for_status()
156162
tree_data = tree_resp.json()
157163

164+
if add_gitcommit:
165+
with open(os.path.join(base_path, ".gitcommit"), "w") as f:
166+
f.write(tree_data["sha"])
167+
158168
submodules = {
159169
item["path"]: item["sha"]
160170
for item in tree_data.get("tree", [])
@@ -215,6 +225,7 @@ def fetch_tarball_and_submodules(repo_url, commit, base_path=None, filter="."):
215225
commit=sha,
216226
base_path=sub_path,
217227
filter=filter,
228+
add_gitcommit=add_gitcommit,
218229
)
219230

220231
with open(
@@ -238,9 +249,15 @@ def fetch_tarball_and_submodules(repo_url, commit, base_path=None, filter="."):
238249
default=".",
239250
help="Regex to match submodule paths. Submodules that are not matched will be excluded.",
240251
)
252+
@click.option(
253+
"--add-gitcommit",
254+
default=False,
255+
is_flag=True,
256+
help="Adds a .gitcommit file containing the commit sha256 of each resolved tree",
257+
)
241258
@click.argument("repo_url")
242259
@click.argument("commit")
243-
def main(repo_url, commit, out_dir, filter):
260+
def main(repo_url, commit, out_dir, filter, add_gitcommit):
244261
"""
245262
Downloads a snapshot of a GitHub repo, i.e. with all GitHub-based submodules
246263
recursively downloaded.
@@ -254,6 +271,7 @@ def main(repo_url, commit, out_dir, filter):
254271
commit=commit,
255272
base_path=out_dir,
256273
filter=filter,
274+
add_gitcommit=add_gitcommit,
257275
)
258276

259277

nix/yosys.nix

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
fetchurl,
4040
fetchGitHubSnapshot,
4141
bash,
42-
version ? "0.59.1",
42+
version ? "0.60",
4343
rev ? null,
44-
sha256 ? "sha256-XUQu07i6kBR745OZU/UQTwGbRt/uZHKpBNRrcUP87Bo=",
44+
sha256 ? "sha256-JKxNdc3AXE1IaodM5eg0t3PkkGsnIwFpIbN9Gj56G/k=",
4545
darwin, # To fix codesigning issue for pyosys
4646
# For environments
4747
yosys,
@@ -78,6 +78,7 @@ let
7878
repo = "yosys";
7979
inherit rev;
8080
hash = sha256;
81+
add-gitcommit = true;
8182
}
8283
else
8384
fetchurl {
@@ -152,14 +153,14 @@ let
152153
unpackPhase = ''
153154
runHook preUnpack
154155
if [ -d ${finalAttrs.src} ]; then
155-
cp -r ${finalAttrs.src}/* .
156+
cp -r ${finalAttrs.src}/* ${finalAttrs.src}/.* .
156157
chmod u+w -R .
157158
else
158159
tar -xzC . -f ${finalAttrs.src}
159160
fi
160161
runHook postUnpack
161162
'';
162-
163+
163164
configurePhase = ''
164165
runHook preConfigure
165166
CC=clang CXX=clang++ make config-clang

0 commit comments

Comments
 (0)