ciel 3.1.0__tar.gz → 3.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ciel
3
- Version: 3.1.0
3
+ Version: 3.2.0
4
4
  Summary: An PDK builder/version manager for PDKs in the open_pdks format
5
5
  Home-page: https://github.com/fossi-foundation/ciel
6
6
  License: Apache-2.0
@@ -71,23 +71,138 @@ ciel --version
71
71
  ```
72
72
 
73
73
  # About the builds
74
- In its current inception, ciel supports builds of **sky130** and **gf180mcu** PDKs using [Open-PDKs](https://github.com/rtimothyedwards/open_pdks), including the following libraries:
75
-
76
- |sky130|gf180mcu|ihp-sg13|
77
- |-|-|-|
78
- |sky130_fd_io|gf180mcu_fd_io|sg13g2_io|
79
- |sky130_fd_pr|gf180mcu_fd_pr|sg13g2_pr|
80
- |sky130_fd_pr_reram|-|-|
81
- |sky130_fd_sc_hd|gf180mcu_fd_sc_mcu7t5v0|sg13g2_stdcell|
82
- |sky130_ml_xx_hd|gf180mcu_fd_sc_mcu9t5v0|-|
83
- |sky130_fd_sc_hvl|gf180mcu_osu_sc_gp9t3v3|-|
84
- |sky130_fd_sc_lp|gf180mcu_osu_sc_gp12t3v3|-|
85
- |sky130_fd_sc_ls|-|-|
86
- |sky130_fd_sc_ms|-|-|
87
- |sky130_fd_sc_hs|-|-|
88
- |sky130_sram_macros|gf180mcu_fd_ip_sram|sg13g2_sram|
89
-
90
- Builds for sky130 and gf180mcu are identified by their [**open_pdks**](https://github.com/rtimothyedwards/open_pdks) commit hashes. Builds for ihp-sg13g2 are identified by their [**IHP-Open-PDK**](https://github.com/ihp-gmbh/ihp-open-pdk) commit hashes.
74
+
75
+ Ciel aims to support all kinds of open-source process design kits, so long
76
+ as they are laid out in the
77
+ [Open PDKs](https://github.com/fossi-foundation/open_pdks) format. Some PDKs
78
+ do not come in this format by default, so build scripts are added to `open_pdks`
79
+ to bring them into conformity, in which case open_pdks is transitively
80
+ responsible for their provenance (i.e. the versions of the PDK are identified
81
+ by the Open PDKs hash.)
82
+
83
+ This section lists supported PDKs and their identifiers: (You can list
84
+ supported standard cell libraries by using `ciel ls-libs --pdk <identifier>`)
85
+
86
+ * Manufacturable (AMS)
87
+ * [Google/SkyWater (130nm) Open Source PDK](https://github.com/fossi-foundation/skywater-pdk) — `sky130`
88
+ * Identified by [Open PDKs](https://github.com/fossi-foundation/open_pdks) hash.
89
+ * [Google/GlobalFoundries GF180MCU Open Source PDK](https://github.com/fossi-foundation/gf180mcu-pdk) - `gf180mcu`
90
+ * Identified by [Open PDKs](https://github.com/fossi-foundation/open_pdks) hash.
91
+ * [IHP (130nm) Open Source PDK](https://github.com/IHP-GmbH/IHP-Open-PDK) - `ihp-sg13`
92
+ * Identified by upstream repo hash, which is already in the Open PDKs
93
+ format.
94
+ * Predictive/Academic
95
+ * [FreePDK45](https://github.com/rjordans/freepdk45-open-pdks) - `freepdk45`
96
+ * Identified by hash in [Roel Jordans](https://github.com/rjordans)'
97
+ repo which lays it out in the Open PDKs format and adds LibreLane
98
+ support.
99
+ * Originally developed by NCSU - ([src](https://eda.ncsu.edu/freepdk/freepdk45/))
100
+
101
+ ## Included libraries
102
+
103
+ <!-- Regenerate library list using `python3 -m ciel _update_readme_lib_table Readme.md` -->
104
+
105
+ <!-- START LIBRARIES -->
106
+ <table>
107
+ <tr>
108
+ <th>sky130</th>
109
+ <th>gf180mcu</th>
110
+ <th>ihp-sg13</th>
111
+ <th>freepdk45</th>
112
+ </tr>
113
+ <tr>
114
+ <td>sky130_fd_io</td>
115
+ <td>gf180mcu_as_sc_mcu7t3v3</td>
116
+ <td>sg13cmos5l_io</td>
117
+ <td>fakeram45</td>
118
+ </tr>
119
+ <tr>
120
+ <td>sky130_fd_pr</td>
121
+ <td>gf180mcu_fd_io</td>
122
+ <td>sg13cmos5l_sram</td>
123
+ <td>nangate45</td>
124
+ </tr>
125
+ <tr>
126
+ <td>sky130_fd_pr_reram</td>
127
+ <td>gf180mcu_fd_ip_sram</td>
128
+ <td>sg13cmos5l_stdcell</td>
129
+ <td>-</td>
130
+ </tr>
131
+ <tr>
132
+ <td>sky130_fd_sc_hd</td>
133
+ <td>gf180mcu_fd_pr</td>
134
+ <td>sg13g2_io</td>
135
+ <td>-</td>
136
+ </tr>
137
+ <tr>
138
+ <td>sky130_fd_sc_hdll</td>
139
+ <td>gf180mcu_fd_sc_mcu7t5v0</td>
140
+ <td>sg13g2_pr</td>
141
+ <td>-</td>
142
+ </tr>
143
+ <tr>
144
+ <td>sky130_fd_sc_hs</td>
145
+ <td>gf180mcu_fd_sc_mcu9t5v0</td>
146
+ <td>sg13g2_sram</td>
147
+ <td>-</td>
148
+ </tr>
149
+ <tr>
150
+ <td>sky130_fd_sc_hvl</td>
151
+ <td>gf180mcu_ocd_alpha_large</td>
152
+ <td>sg13g2_stdcell</td>
153
+ <td>-</td>
154
+ </tr>
155
+ <tr>
156
+ <td>sky130_fd_sc_lp</td>
157
+ <td>gf180mcu_ocd_alpha_misc</td>
158
+ <td>-</td>
159
+ <td>-</td>
160
+ </tr>
161
+ <tr>
162
+ <td>sky130_fd_sc_ls</td>
163
+ <td>gf180mcu_ocd_alpha_small</td>
164
+ <td>-</td>
165
+ <td>-</td>
166
+ </tr>
167
+ <tr>
168
+ <td>sky130_fd_sc_ms</td>
169
+ <td>gf180mcu_ocd_io</td>
170
+ <td>-</td>
171
+ <td>-</td>
172
+ </tr>
173
+ <tr>
174
+ <td>sky130_ml_xx_hd</td>
175
+ <td>gf180mcu_ocd_ip_sram</td>
176
+ <td>-</td>
177
+ <td>-</td>
178
+ </tr>
179
+ <tr>
180
+ <td>sky130_sram_macros</td>
181
+ <td>gf180mcu_ocd_sc_rt12t3v3</td>
182
+ <td>-</td>
183
+ <td>-</td>
184
+ </tr>
185
+ <tr>
186
+ <td>-</td>
187
+ <td>gf180mcu_osu_sc_gp12t3v3</td>
188
+ <td>-</td>
189
+ <td>-</td>
190
+ </tr>
191
+ <tr>
192
+ <td>-</td>
193
+ <td>gf180mcu_osu_sc_gp9t3v3</td>
194
+ <td>-</td>
195
+ <td>-</td>
196
+ </tr>
197
+ <tr>
198
+ <td>-</td>
199
+ <td>gf180mcu_re_efuse</td>
200
+ <td>-</td>
201
+ <td>-</td>
202
+ </tr>
203
+ </tr>
204
+ </table>
205
+ <!-- END LIBRARIES -->
91
206
 
92
207
  # Usage
93
208
  Ciel requires a so-called **PDK Root**. This PDK root can be anywhere on your computer, but by default it's the folder `~/.ciel` in your home directory. If you have the variable `PDK_ROOT` set, ciel will use that instead. You can also manually override both values by supplying the `--pdk-root` commandline argument.
@@ -42,23 +42,138 @@ ciel --version
42
42
  ```
43
43
 
44
44
  # About the builds
45
- In its current inception, ciel supports builds of **sky130** and **gf180mcu** PDKs using [Open-PDKs](https://github.com/rtimothyedwards/open_pdks), including the following libraries:
46
-
47
- |sky130|gf180mcu|ihp-sg13|
48
- |-|-|-|
49
- |sky130_fd_io|gf180mcu_fd_io|sg13g2_io|
50
- |sky130_fd_pr|gf180mcu_fd_pr|sg13g2_pr|
51
- |sky130_fd_pr_reram|-|-|
52
- |sky130_fd_sc_hd|gf180mcu_fd_sc_mcu7t5v0|sg13g2_stdcell|
53
- |sky130_ml_xx_hd|gf180mcu_fd_sc_mcu9t5v0|-|
54
- |sky130_fd_sc_hvl|gf180mcu_osu_sc_gp9t3v3|-|
55
- |sky130_fd_sc_lp|gf180mcu_osu_sc_gp12t3v3|-|
56
- |sky130_fd_sc_ls|-|-|
57
- |sky130_fd_sc_ms|-|-|
58
- |sky130_fd_sc_hs|-|-|
59
- |sky130_sram_macros|gf180mcu_fd_ip_sram|sg13g2_sram|
60
-
61
- Builds for sky130 and gf180mcu are identified by their [**open_pdks**](https://github.com/rtimothyedwards/open_pdks) commit hashes. Builds for ihp-sg13g2 are identified by their [**IHP-Open-PDK**](https://github.com/ihp-gmbh/ihp-open-pdk) commit hashes.
45
+
46
+ Ciel aims to support all kinds of open-source process design kits, so long
47
+ as they are laid out in the
48
+ [Open PDKs](https://github.com/fossi-foundation/open_pdks) format. Some PDKs
49
+ do not come in this format by default, so build scripts are added to `open_pdks`
50
+ to bring them into conformity, in which case open_pdks is transitively
51
+ responsible for their provenance (i.e. the versions of the PDK are identified
52
+ by the Open PDKs hash.)
53
+
54
+ This section lists supported PDKs and their identifiers: (You can list
55
+ supported standard cell libraries by using `ciel ls-libs --pdk <identifier>`)
56
+
57
+ * Manufacturable (AMS)
58
+ * [Google/SkyWater (130nm) Open Source PDK](https://github.com/fossi-foundation/skywater-pdk) — `sky130`
59
+ * Identified by [Open PDKs](https://github.com/fossi-foundation/open_pdks) hash.
60
+ * [Google/GlobalFoundries GF180MCU Open Source PDK](https://github.com/fossi-foundation/gf180mcu-pdk) - `gf180mcu`
61
+ * Identified by [Open PDKs](https://github.com/fossi-foundation/open_pdks) hash.
62
+ * [IHP (130nm) Open Source PDK](https://github.com/IHP-GmbH/IHP-Open-PDK) - `ihp-sg13`
63
+ * Identified by upstream repo hash, which is already in the Open PDKs
64
+ format.
65
+ * Predictive/Academic
66
+ * [FreePDK45](https://github.com/rjordans/freepdk45-open-pdks) - `freepdk45`
67
+ * Identified by hash in [Roel Jordans](https://github.com/rjordans)'
68
+ repo which lays it out in the Open PDKs format and adds LibreLane
69
+ support.
70
+ * Originally developed by NCSU - ([src](https://eda.ncsu.edu/freepdk/freepdk45/))
71
+
72
+ ## Included libraries
73
+
74
+ <!-- Regenerate library list using `python3 -m ciel _update_readme_lib_table Readme.md` -->
75
+
76
+ <!-- START LIBRARIES -->
77
+ <table>
78
+ <tr>
79
+ <th>sky130</th>
80
+ <th>gf180mcu</th>
81
+ <th>ihp-sg13</th>
82
+ <th>freepdk45</th>
83
+ </tr>
84
+ <tr>
85
+ <td>sky130_fd_io</td>
86
+ <td>gf180mcu_as_sc_mcu7t3v3</td>
87
+ <td>sg13cmos5l_io</td>
88
+ <td>fakeram45</td>
89
+ </tr>
90
+ <tr>
91
+ <td>sky130_fd_pr</td>
92
+ <td>gf180mcu_fd_io</td>
93
+ <td>sg13cmos5l_sram</td>
94
+ <td>nangate45</td>
95
+ </tr>
96
+ <tr>
97
+ <td>sky130_fd_pr_reram</td>
98
+ <td>gf180mcu_fd_ip_sram</td>
99
+ <td>sg13cmos5l_stdcell</td>
100
+ <td>-</td>
101
+ </tr>
102
+ <tr>
103
+ <td>sky130_fd_sc_hd</td>
104
+ <td>gf180mcu_fd_pr</td>
105
+ <td>sg13g2_io</td>
106
+ <td>-</td>
107
+ </tr>
108
+ <tr>
109
+ <td>sky130_fd_sc_hdll</td>
110
+ <td>gf180mcu_fd_sc_mcu7t5v0</td>
111
+ <td>sg13g2_pr</td>
112
+ <td>-</td>
113
+ </tr>
114
+ <tr>
115
+ <td>sky130_fd_sc_hs</td>
116
+ <td>gf180mcu_fd_sc_mcu9t5v0</td>
117
+ <td>sg13g2_sram</td>
118
+ <td>-</td>
119
+ </tr>
120
+ <tr>
121
+ <td>sky130_fd_sc_hvl</td>
122
+ <td>gf180mcu_ocd_alpha_large</td>
123
+ <td>sg13g2_stdcell</td>
124
+ <td>-</td>
125
+ </tr>
126
+ <tr>
127
+ <td>sky130_fd_sc_lp</td>
128
+ <td>gf180mcu_ocd_alpha_misc</td>
129
+ <td>-</td>
130
+ <td>-</td>
131
+ </tr>
132
+ <tr>
133
+ <td>sky130_fd_sc_ls</td>
134
+ <td>gf180mcu_ocd_alpha_small</td>
135
+ <td>-</td>
136
+ <td>-</td>
137
+ </tr>
138
+ <tr>
139
+ <td>sky130_fd_sc_ms</td>
140
+ <td>gf180mcu_ocd_io</td>
141
+ <td>-</td>
142
+ <td>-</td>
143
+ </tr>
144
+ <tr>
145
+ <td>sky130_ml_xx_hd</td>
146
+ <td>gf180mcu_ocd_ip_sram</td>
147
+ <td>-</td>
148
+ <td>-</td>
149
+ </tr>
150
+ <tr>
151
+ <td>sky130_sram_macros</td>
152
+ <td>gf180mcu_ocd_sc_rt12t3v3</td>
153
+ <td>-</td>
154
+ <td>-</td>
155
+ </tr>
156
+ <tr>
157
+ <td>-</td>
158
+ <td>gf180mcu_osu_sc_gp12t3v3</td>
159
+ <td>-</td>
160
+ <td>-</td>
161
+ </tr>
162
+ <tr>
163
+ <td>-</td>
164
+ <td>gf180mcu_osu_sc_gp9t3v3</td>
165
+ <td>-</td>
166
+ <td>-</td>
167
+ </tr>
168
+ <tr>
169
+ <td>-</td>
170
+ <td>gf180mcu_re_efuse</td>
171
+ <td>-</td>
172
+ <td>-</td>
173
+ </tr>
174
+ </tr>
175
+ </table>
176
+ <!-- END LIBRARIES -->
62
177
 
63
178
  # Usage
64
179
  Ciel requires a so-called **PDK Root**. This PDK root can be anywhere on your computer, but by default it's the folder `~/.ciel` in your home directory. If you have the variable `PDK_ROOT` set, ciel will use that instead. You can also manually override both values by supplying the `--pdk-root` commandline argument.
@@ -15,37 +15,37 @@
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
- import sys
19
18
  import json
20
19
  import shutil
20
+ import sys
21
21
 
22
- import httpx
23
22
  import click
23
+ import httpx
24
24
  from rich.console import Console
25
25
 
26
26
  from .__version__ import __version__
27
- from .common import (
28
- Version,
29
- get_ciel_home,
27
+ from .build import (
28
+ build_cmd,
29
+ push_cmd,
30
30
  )
31
31
  from .click_common import (
32
- opt_pdk,
33
32
  arg_version,
33
+ opt_pdk,
34
34
  )
35
+ from .common import (
36
+ Version,
37
+ get_ciel_home,
38
+ )
39
+ from .families import Family, resolve_pdk_family, resolve_pdk_selector
40
+ from .github import opt_github_token
35
41
  from .manage import (
36
- print_installed_list,
37
- print_remote_list,
38
42
  enable,
39
43
  fetch,
40
44
  optimize,
45
+ print_installed_list,
46
+ print_remote_list,
41
47
  )
42
- from .build import (
43
- build_cmd,
44
- push_cmd,
45
- )
46
- from .github import opt_github_token
47
48
  from .source import opt_data_source
48
- from .families import Family, resolve_pdk_family
49
49
 
50
50
 
51
51
  @click.command("output")
@@ -348,6 +348,58 @@ def list_pdks_cmd():
348
348
  print(json.dumps(result), end="")
349
349
 
350
350
 
351
+ @click.command("ls-libs")
352
+ @opt_pdk
353
+ def list_libs_cmd(pdk_root, pdk_selector):
354
+ """Lists all libraries for a given PDK family or variant."""
355
+ family_name, variants = resolve_pdk_selector(pdk_selector)
356
+ family = Family.by_name[family_name]
357
+ for lib in sorted(family.resolve_libraries(("all",), variants)):
358
+ print(f"{lib}")
359
+
360
+
361
+ @click.command("_update_readme_lib_table", hidden=True)
362
+ @click.argument("readme", type=click.Path(exists=True, file_okay=True, writable=True))
363
+ def update_readme_lib_table_cmd(readme):
364
+ # internal command - behavior may change or command may be removed in any
365
+ # version
366
+ import fileinput
367
+ import html
368
+
369
+ table = [
370
+ (name, sorted(f.get_all_libraries("*"))) for name, f in Family.by_name.items()
371
+ ]
372
+ row_count = max(len(scls) for _, scls in table)
373
+
374
+ with fileinput.input(readme, inplace=True) as f:
375
+ skip = False
376
+ for line in f:
377
+ if "<!-- END LIBRARIES -->" in line:
378
+ skip = False
379
+ if not skip:
380
+ print(line, end="")
381
+ if "<!-- START LIBRARIES -->" in line:
382
+ skip = True
383
+ print("<table>")
384
+ print("<tr>")
385
+ for name, _ in table:
386
+ print(f"<th>{html.escape(name)}</th>")
387
+ print("</tr>")
388
+ for i in range(row_count):
389
+ print("<tr>")
390
+ for _, rows in table:
391
+ cell = "-"
392
+ try:
393
+ cell = rows[i]
394
+ except IndexError:
395
+ pass
396
+ print(f"<td>{html.escape(cell)}</td>")
397
+ print("</tr>")
398
+
399
+ print("</tr>")
400
+ print("</table>")
401
+
402
+
351
403
  @click.group(
352
404
  context_settings={
353
405
  "max_content_width": max(shutil.get_terminal_size().columns, 80),
@@ -386,6 +438,8 @@ cli.add_command(list_remote_cmd)
386
438
  cli.add_command(enable_cmd)
387
439
  cli.add_command(fetch_cmd)
388
440
  cli.add_command(list_pdks_cmd)
441
+ cli.add_command(list_libs_cmd)
442
+ cli.add_command(update_readme_lib_table_cmd)
389
443
 
390
444
  try:
391
445
  import ssl # noqa: F401
@@ -15,38 +15,38 @@
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
+ import importlib
18
19
  import os
19
- import sys
20
- import uuid
21
20
  import pathlib
21
+ import subprocess
22
+ import sys
22
23
  import tarfile
23
24
  import tempfile
24
- import importlib
25
- import subprocess
26
- from typing import Optional, List, Dict, Tuple, Union
25
+ import uuid
26
+ from typing import Dict, List, Optional, Tuple, Union
27
27
 
28
28
  import click
29
29
  import zstandard as zstd
30
30
  from rich.console import Console
31
31
  from rich.progress import Progress
32
32
 
33
- from ..github import (
34
- GitHubSession,
35
- get_commit_date,
36
- opt_github_token,
33
+ from ..click_common import (
34
+ arg_version,
35
+ opt_build,
36
+ opt_pdk,
37
+ opt_push,
37
38
  )
38
39
  from ..common import (
39
40
  Version,
40
- mkdirp,
41
41
  date_to_iso8601,
42
- )
43
- from ..click_common import (
44
- opt_push,
45
- opt_build,
46
- opt_pdk,
47
- arg_version,
42
+ mkdirp,
48
43
  )
49
44
  from ..families import Family, resolve_pdk_selector
45
+ from ..github import (
46
+ GitHubSession,
47
+ get_commit_date,
48
+ opt_github_token,
49
+ )
50
50
 
51
51
 
52
52
  def build(
@@ -13,11 +13,21 @@
13
13
  # limitations under the License.
14
14
  import os
15
15
  import re
16
- import sys
17
16
  import shutil
18
17
  import subprocess
18
+ import sys
19
+ from concurrent.futures import ThreadPoolExecutor
20
+ from pathlib import Path
21
+ from typing import Optional, Tuple
19
22
 
20
- from ciel.github import GitHubSession
23
+ from rich.progress import Progress
24
+
25
+ from ..common import (
26
+ Version,
27
+ mkdirp,
28
+ )
29
+ from ..github import GitHubSession
30
+ from .git_multi_clone import GitMultiClone
21
31
 
22
32
 
23
33
  def get_backup_path(at_path: str):
@@ -136,3 +146,100 @@ def patch_open_pdks(at_path: str):
136
146
  if gnu_sed_used:
137
147
  print("Patching GNU sed-only syntax in sky130 Makefile…")
138
148
  open_pdks_patch_gnu_sed(os.path.join(at_path, "sky130", "Makefile.in"))
149
+
150
+
151
+ def fetch_sources(
152
+ console,
153
+ family,
154
+ build_directory,
155
+ version,
156
+ jobs=1,
157
+ repo_path=None,
158
+ default_branch="main",
159
+ ) -> Tuple[str, Optional[str], Optional[str]]:
160
+ try:
161
+ if repo_path is None:
162
+ with Progress() as progress, ThreadPoolExecutor(
163
+ max_workers=jobs
164
+ ) as executor:
165
+ gmc = GitMultiClone(build_directory, progress)
166
+ future = executor.submit(
167
+ GitMultiClone.clone,
168
+ gmc,
169
+ family.repo.link,
170
+ version,
171
+ default_branch=default_branch,
172
+ )
173
+ repo = future.result()
174
+ current_task = progress.add_task("Updating submodules…", total=100)
175
+ repo.init_submodule(
176
+ callback=lambda x: progress.update(current_task, completed=x)
177
+ )
178
+ repo_path = repo.path
179
+ console.log(f"Done fetching {family.name}.")
180
+ else:
181
+ console.log(f"Using {family.name} at {repo_path} unaltered.")
182
+
183
+ return repo_path
184
+
185
+ except subprocess.CalledProcessError as e:
186
+ print(e)
187
+ print(e.stderr)
188
+ sys.exit(-1)
189
+
190
+
191
+ def trivial_build(family, build_directory, source_path):
192
+ # """Build"""
193
+ def filter(dir_s, files):
194
+ dir = Path(dir_s)
195
+ if dir.name == ".git":
196
+ return files
197
+ rejects = [".git", ".DS_Store"]
198
+ for file in files:
199
+ # ignore bad symlinks
200
+ if not (Path(dir) / file).resolve().exists():
201
+ rejects.append(file)
202
+ return rejects
203
+
204
+ try:
205
+ for variant in family.variants:
206
+ shutil.rmtree(os.path.join(build_directory, variant))
207
+ except FileNotFoundError:
208
+ pass
209
+ for variant in family.variants:
210
+ shutil.copytree(
211
+ os.path.join(source_path, variant),
212
+ os.path.join(build_directory, variant),
213
+ ignore=filter,
214
+ )
215
+
216
+
217
+ def install_build(console, family, build_directory, pdk_root, version):
218
+ with console.status("Adding build to list of installed versions…"):
219
+ version_directory = Version(version, family.name).get_dir(pdk_root)
220
+ if (
221
+ os.path.exists(version_directory)
222
+ and len(os.listdir(version_directory)) != 0
223
+ ):
224
+ backup_path = version_directory
225
+ it = 0
226
+ while os.path.exists(backup_path) and len(os.listdir(backup_path)) != 0:
227
+ it += 1
228
+ backup_path = Version(f"{version}.bk{it}", family.name).get_dir(
229
+ pdk_root
230
+ )
231
+ console.log(
232
+ f"Build already found at {version_directory}, moving to {backup_path}…"
233
+ )
234
+ shutil.move(version_directory, backup_path)
235
+
236
+ console.log("Copying…")
237
+ mkdirp(version_directory)
238
+
239
+ for variant in family.variants:
240
+ variant_build_path = os.path.join(build_directory, variant)
241
+ variant_install_path = os.path.join(version_directory, variant)
242
+ if os.path.isdir(variant_build_path):
243
+ shutil.copytree(variant_build_path, variant_install_path)
244
+
245
+ console.log("Done.")
@@ -0,0 +1,77 @@
1
+ # Copyright 2025 Ciel Contributors
2
+ #
3
+ # Adapted from the Volare project
4
+ #
5
+ # Copyright 2022-2023 Efabless Corporation
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ import os
19
+ import shutil
20
+ from datetime import datetime, timezone
21
+ from typing import Dict, List, Optional
22
+
23
+ from rich.console import Console
24
+
25
+ from ..common import (
26
+ get_ciel_dir,
27
+ mkdirp,
28
+ )
29
+ from ..families import Family
30
+ from .common import fetch_sources, install_build, trivial_build
31
+
32
+ FAMILY_INFO = Family.by_name["freepdk45"]
33
+
34
+
35
+ def build(
36
+ pdk_root: str,
37
+ pdk_variant: str,
38
+ version: str,
39
+ jobs: int = 1,
40
+ clear_build_artifacts: bool = True,
41
+ include_libraries: Optional[List[str]] = None,
42
+ using_repos: Optional[Dict[str, str]] = None,
43
+ ):
44
+ console = Console()
45
+ if include_libraries is not None:
46
+ console.log(
47
+ "Note: all libraries will be acquired as part of the trivial PDK build."
48
+ )
49
+
50
+ if using_repos is None:
51
+ using_repos = {}
52
+
53
+ build_directory = os.path.join(
54
+ get_ciel_dir(pdk_root, FAMILY_INFO.name), "build", version
55
+ )
56
+ timestamp = datetime.now(timezone.utc).strftime(
57
+ f"build_{FAMILY_INFO.name}-%Y-%m-%d-%H-%M-%S"
58
+ )
59
+ log_dir = os.path.join(build_directory, "logs", timestamp)
60
+ mkdirp(log_dir)
61
+
62
+ console.log(f"Logging to '{log_dir}'…")
63
+
64
+ source_path = fetch_sources(
65
+ console,
66
+ FAMILY_INFO,
67
+ build_directory,
68
+ version,
69
+ jobs,
70
+ using_repos.get("freepdk45"),
71
+ default_branch="master",
72
+ )
73
+ trivial_build(FAMILY_INFO, build_directory, source_path)
74
+ install_build(console, FAMILY_INFO, build_directory, pdk_root, version)
75
+
76
+ if clear_build_artifacts:
77
+ shutil.rmtree(build_directory)