Skip to content

Commit

Permalink
Support patch-based synthesis. (#4)
Browse files Browse the repository at this point in the history
This should be easier to follow and keep up to date.
  • Loading branch information
floitsch authored Aug 9, 2023
1 parent 46cb0d2 commit 640b3aa
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 181 deletions.
27 changes: 27 additions & 0 deletions tools/main.toit
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cli
import host.file
import host.directory
import host.pipe
import writer show Writer
import .gist as gist
import .git
Expand Down Expand Up @@ -162,15 +163,37 @@ variant_synthesize
--chip=chip
--ui=ui

apply_directory_patch_ --patch_path/string --directory/string --strip/int=1:
patch := file.read_content patch_path
args := ["patch", "-d", directory]
if strip > 0:
args.add "-p$strip"
stream := pipe.to args
writer := Writer stream
writer.write patch
writer.close

apply_file_patch_ --patch_path/string --file_path/string:
patch := file.read_content patch_path
args := ["patch", file_path]
stream := pipe.to args
writer := Writer stream
writer.write patch
writer.close

ensure_main_ dir/string --toit_root/string --chip/string:
if file.is_directory "$dir/main": return
main_path := toit_main_path_for_ --chip=chip
copy_directory --from="$toit_root/$main_path" --to="$dir/main"
if file.is_file "$dir/main.patch":
apply_directory_patch_ --patch_path="$dir/main.patch" --directory=dir

ensure_partitions_ dir/string --toit_root/string --chip/string:
if file.is_file "$dir/partitions.csv": return
partition_path := toit_partition_path_for_ --chip=chip
copy_file --from="$toit_root/$partition_path" --to="$dir/partitions.csv"
if file.is_file "$dir/partitions.csv.patch":
apply_file_patch_ --patch_path="$dir/partitions.csv.patch" --file_path="$dir/partitions.csv"

ensure_sdkconfig_ dir/string --toit_root/string --chip/string:
if file.is_file "$dir/sdkconfig" or file.is_file "$dir/sdkconfig.defaults": return
Expand All @@ -180,8 +203,12 @@ ensure_sdkconfig_ dir/string --toit_root/string --chip/string:

if file.is_file "$toit_root/$sdk_config_path":
copy_file --from="$toit_root/$sdk_config_path" --to="$dir/sdkconfig"
if file.is_file "$dir/sdkconfig.patch":
apply_file_patch_ --patch_path="$dir/sdkconfig.patch" --file_path="$dir/sdkconfig"
if file.is_file "$toit_root/$sdk_config_defaults_path":
copy_file --from="$toit_root/$sdk_config_defaults_path" --to="$dir/sdkconfig.defaults"
if file.is_file "$dir/sdkconfig.defaults.patch":
apply_file_patch_ --patch_path="$dir/sdkconfig.defaults.patch" --file_path="$dir/sdkconfig.defaults"

create_cmakelists_ dir/string --toit_root/string --sdk_path/string --chip/string --ui/cli.Ui:
if file.is_file "$dir/CMakeLists.txt":
Expand Down
100 changes: 0 additions & 100 deletions variants/esp32-eth-clk-out17/sdkconfig.defaults

This file was deleted.

5 changes: 5 additions & 0 deletions variants/esp32-eth-clk-out17/sdkconfig.defaults.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
41a42,45
> # CONFIG_ETH_RMII_CLK_INPUT is not set
> CONFIG_ETH_RMII_CLK_OUTPUT=y
> # CONFIG_ETH_RMII_CLK_OUTPUT_GPIO0 is not set
> CONFIG_ETH_RMII_CLK_OUT_GPIO=17
81 changes: 0 additions & 81 deletions variants/esp32s3-spiram-octo/sdkconfig.defaults

This file was deleted.

4 changes: 4 additions & 0 deletions variants/esp32s3-spiram-octo/sdkconfig.defaults.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
26c26
< CONFIG_SPIRAM_MODE_QUAD=y
---
> CONFIG_SPIRAM_MODE_OCT=y

0 comments on commit 640b3aa

Please sign in to comment.