-
-
Save cr1901/4af8c04a04ba22aebb0af4faeca11b43 to your computer and use it in GitHub Desktop.
Prepare an upstream migen/misoc for merging into litex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
set -x | |
set -e | |
function git_commit { | |
git commit -a -m"litex import: $1" | |
} | |
mkdir -p repos | |
( | |
cd repos | |
if [ ! -d migen ]; then | |
git clone https://github.com/m-labs/migen.git | |
else | |
( | |
cd migen | |
git fetch-all | |
) | |
fi | |
if [ ! -d misoc ]; then | |
git clone https://github.com/m-labs/misoc.git | |
else | |
( | |
cd misoc | |
git fetch-all | |
) | |
fi | |
if [ ! -d litex ]; then | |
git clone https://github.com/enjoy-digital/litex.git | |
else | |
( | |
cd litex | |
git fetch-all | |
) | |
fi | |
) | |
DIR=$(echo temp.$(date +%Y%m%d-%H%M%S)) | |
mkdir $DIR | |
cd $DIR | |
git clone ../repos/migen/.git migen | |
( | |
cd migen | |
mkdir litex | |
touch litex/__init__.py | |
git add litex/__init__.py | |
git mv migen litex/gen | |
git_commit "Move migen to litex.gen" | |
# Moving the build dir around | |
git mv litex/gen/build litex/build | |
git_commit "Move migen.build to litex.build" | |
# Moving the platforms around | |
mkdir litex/boards | |
touch litex/boards/__init__.py | |
git add litex/boards/__init__.py | |
git mv litex/build/platforms litex/boards/platforms | |
git_commit "Moving migen.build.platforms to litex.boards.platforms." | |
# License file. | |
git mv LICENSE litex/gen/MIGEN_LICENSE | |
git_commit "Moving the Migen License file" | |
cat > litex/gen/MIGEN_LICENSE.header <<EOF | |
Unless otherwise noted, Migen is copyright (C) 2011-2017 M-Labs Limited. | |
The simulation extension (as mentioned in the comments at the beginning of the | |
corresponding source files) is copyright (C) 2012 Vermeer Manufacturing Co. | |
See original copyright notice below; | |
---- | |
EOF | |
cat litex/gen/MIGEN_LICENSE.header litex/gen/MIGEN_LICENSE \ | |
> litex/gen/MIGEN_LICENSE.new | |
mv litex/gen/MIGEN_LICENSE.new litex/gen/MIGEN_LICENSE | |
rm litex/gen/MIGEN_LICENSE.header | |
git_commit "Appending header to the MiSoC License file" | |
# Remove migen specific files | |
git rm .gitignore | |
git rm conda/migen/meta.yaml | |
git rm README.md | |
git rm setup.py | |
git_commit "Removing Migen top level files." | |
cd .. | |
) | |
git clone ../repos/misoc/.git misoc | |
( | |
cd misoc | |
mkdir litex | |
git mv misoc litex/soc | |
git_commit "Move misoc to litex.soc." | |
# Move the cores around | |
( | |
cd litex/soc/cores | |
# Move the CPUs into the CPU directory | |
mkdir cpu | |
touch cpu/__init__.py | |
git add cpu/__init__.py | |
git mv lm32 cpu/lm32 | |
git mv mor1kx cpu/mor1kx | |
git mv vexriscv cpu/vexriscv | |
git_commit "Moving misoc CPU cores." | |
# Remove the cores that are provided by liteeth | |
git rm -rf liteeth_mini | |
git_commit "Removing cores provided by liteeth." | |
# Remove the cores that are provided by litevideo | |
git rm -rf dvi_sampler | |
git rm -rf framebuffer | |
git_commit "Removing cores provided by litevideo." | |
) | |
# Removing lasmi | |
git rm -rf litex/soc/cores/lasmicon | |
git rm litex/soc/interconnect/dma_lasmi.py | |
git rm litex/soc/interconnect/wishbone2lasmi.py | |
git_commit "Removing LASMI." | |
# Remove the cores that are provided by litedram | |
git rm litex/soc/cores/sdram_model.py | |
git rm -rf litex/soc/cores/sdram_phy | |
git rm litex/soc/cores/sdram_settings.py | |
git rm litex/soc/cores/sdram_tester.py | |
git rm -rf litex/soc/cores/minicon | |
git rm litex/soc/cores/dfii.py | |
git rm litex/soc/interconnect/dfi.py | |
git_commit "Removing cores provided by litedram." | |
# License file. | |
git mv LICENSE litex/soc/MISOC_LICENSE | |
git_commit "Moving the MiSoC License file" | |
cat > litex/soc/MISOC_LICENSE.header <<EOF | |
Unless otherwise noted, Migen is copyright (C) 2011-2017 M-Labs Limited. | |
The simulation extension (as mentioned in the comments at the beginning of the | |
corresponding source files) is copyright (C) 2012 Vermeer Manufacturing Co. | |
See original copyright notice below; | |
---- | |
EOF | |
cat litex/soc/MISOC_LICENSE.header litex/soc/MISOC_LICENSE \ | |
> litex/soc/MISOC_LICENSE.new | |
mv litex/soc/MISOC_LICENSE.new litex/soc/MISOC_LICENSE | |
rm litex/soc/MISOC_LICENSE.header | |
git_commit "Appending header to the MiSoC License file" | |
# Moving the boards files | |
mkdir litex/boards | |
touch litex/boards/__init__.py | |
git add litex/boards/__init__.py | |
git mv litex/soc/targets litex/boards/targets | |
git_commit "Moving misoc.soc.targets to litex.boards.targets." | |
# Remove migen specific files | |
git rm .gitignore | |
git rm conda/misoc/meta.yaml | |
git rm CONTRIBUTING.rst | |
git rm README | |
git rm setup.py | |
git rm MANIFEST.in | |
git_commit "Removing top level files." | |
) | |
mkdir litex-merge | |
( | |
cd litex-merge | |
git init | |
git remote add migen ../migen/.git | |
git fetch migen | |
git remote add misoc ../misoc/.git | |
git fetch misoc | |
# Merge migen + misoc | |
git merge migen/master | |
git merge misoc/master --allow-unrelated-histories -m "Merging migen and misoc for litex merge." | |
# Doing renames | |
# -e"s/misoc.cores.dvi_sampler/litevideo.???/g" \ | |
# -e"s/misoc.cores.framebuffer/litevideo.???/g" \ | |
sed -i \ | |
-e"s/misoc.cores.liteeth_mini/liteeth/g" \ | |
-e"s/liteeth.mac/liteeth.core.mac/g" \ | |
$(find -name \*.py) \ | |
$(find -name \*.rst) \ | |
git_commit "Doing renames for liteeth." | |
sed -i \ | |
-e"s/misoc.cores.sdram_settings/litedram.modules/g" \ | |
-e"s/misoc.cores.sdram_phy/litedram.phy/g" \ | |
-e's/ "minicon",//g' \ | |
$(find -name \*.py) \ | |
$(find -name \*.rst) \ | |
git_commit "Doing renames for litedram." | |
sed -i \ | |
-e's/Migen/LiteX/g' \ | |
-e's/MiSoC/LiteX/g' \ | |
-e's/LiteX gen/LiteX/g' \ | |
-e's/migen"/litex"/g' \ | |
-e"s/migen'/litex'/g" \ | |
-e's/misoc"/litex"/g' \ | |
-e"s/misoc'/litex'/g" \ | |
-e"s/misoc.targets/litex.boards.targets/g" \ | |
-e"s/misoc.cores.lm32/litex.soc.cores.cpu.lm32/g" \ | |
-e"s/misoc.cores.mor1kx/litex.soc.cores.cpu.mor1kx/g" \ | |
-e"s/misoc.cores/litex.soc.cores/g" \ | |
-e"s/migen.build.platforms/litex.boards.platforms/g" \ | |
-e"s/migen.build/litex.build/g" \ | |
-e"s^/migen/^/litex/^g" \ | |
-e"s^migen_^litex_^g" \ | |
-e"s^misoc_^litex_^g" \ | |
-e"s^github.com/m-labs^github.com/enjoy-digital^g" \ | |
-e"s/misoc/litex.soc/g" \ | |
-e"s/migen.fhdl import verilog/litex.gen.fhdl import verilog/g" \ | |
-e"s/migen.fhdl.verilog/litex.gen.fhdl.verilog/g" \ | |
-e"s/dfii_/sdram_dfii_/g" \ | |
-e"s/MISOC_DIRECTORY/SOC_DIRECTORY/g" \ | |
-e"s/CSR_DFII_BASE/CSR_SDRAM_BASE/g" \ | |
-e"s^LiteX/LiteX^Migen/LiteX^g" \ | |
$(find -name \*.py) \ | |
$(find -name \*.rst) \ | |
$(find -name Makefile) \ | |
$(find litex/soc/software -name \*.c) \ | |
git_commit "Doing renames for LiteX." | |
# -e"s/DFII_/SDRAM_DFII_/g" \ | |
sed -i \ | |
-e's/\(sink\|source\|fifo_in\|fifo_out\).ack/\1.ready/g' \ | |
-e's/\(sink\|source\|fifo_in\|fifo_out\).stb/\1.valid/g' \ | |
-e's/\(sink\|source\|fifo_in\|fifo_out\).eop/\1.last/g' \ | |
$(find -name \*.py) \ | |
$(find -name \*.rst) \ | |
git_commit "Doing renames for stream interface." | |
sed -i \ | |
-e's/import migen/import litex/g' \ | |
-e"s/'migen.'/'litex.'/g" \ | |
doc/conf.py \ | |
git_commit "Fixing up docs." | |
sed -i \ | |
-e"s@misoc/cores/lm32@litex/soc/cores/cpu/lm32@g" \ | |
-e"s@misoc/cores/mor1kx@litex/soc/cores/cpu/mor1kx@g" \ | |
-e"s@misoc@litex/soc@g" \ | |
.gitmodules | |
git_commit "Fixing up .gitmodules" | |
git branch to-merge | |
# Get litex for the merging | |
git remote add upstream ../../repos/litex/.git | |
git fetch upstream | |
git merge upstream/master || true | |
git checkout upstream/master .gitignore | |
git checkout upstream/master LICENSE | |
git checkout upstream/master MANIFEST.in | |
git checkout upstream/master README | |
git checkout upstream/master setup.py | |
git checkout to-merge doc | |
git checkout to-merge examples | |
) | |
echo $DIR/litex-merge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment