Skip to content

Commit

Permalink
Merge pull request #89 from mithro/submodules
Browse files Browse the repository at this point in the history
Changing to using submodules for core dependencies
  • Loading branch information
mithro committed Oct 4, 2015
2 parents 6da250e + a8cc8ae commit 92fd4c0
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 53 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@ firmware/lm32/firmware.elf
firmware/lm32/version.h
test/dump.png
build
misoc
makestuff
migen
misoc
*.pyc
*.pnm
16 changes: 14 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[submodule "firmware/fx2/fx2lib"]
path = firmware/fx2/fx2lib
[submodule "third_party/fx2lib"]
path = third_party/fx2lib
url = https://github.com/timvideos/fx2lib
[submodule "third_party/misoc"]
path = third_party/misoc
url = https://github.com/m-labs/misoc.git
[submodule "third_party/migen"]
path = third_party/migen
url = https://github.com/m-labs/migen.git
[submodule "third_party/liteeth"]
path = third_party/liteeth
url = https://github.com/enjoy-digital/liteeth.git
[submodule "third_party/litescope"]
path = third_party/litescope
url = https://github.com/enjoy-digital/litescope.git
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ $(error "Please 'source scripts/setup-env.sh'")
endif
endif

# Turn off Python's hash randomization
export PYTHONHASHSEED=0

BOARD ?= atlys
MSCDIR ?= build/misoc
MSCDIR ?= third_party/misoc
PROG ?= impact
TARGET ?= hdmi2usb
FILTER ?= tee
Expand Down Expand Up @@ -64,8 +67,13 @@ help:
all: clean gateware firmware
echo "Run 'make load' to load the firmware."

# Initialize submodules automatically
third_party/%/.git:
git submodule update --recursive --init $(dir $@)

# Gateware
gateware: $(addprefix gateware-,$(TARGETS))
MODULES=migen misoc liteeth litescope
gateware: $(addprefix gateware-,$(TARGETS)) $(addsuffix /.git,$(addprefix third_party/,$(MODULES)))
ifneq ($(OS),Windows_NT)
cd $(MSCDIR) && $(CMD) --csr_csv $(HDMI2USBDIR)/test/csr.csv build-csr-csv build-bitstream \
| $(FILTER) $(PWD)/build/output.$(DATE).log; (exit $${PIPESTATUS[0]})
Expand Down Expand Up @@ -101,4 +109,4 @@ clean:
touch $(MSCDIR)/software/include/generated/.keep_me)

.DEFAULT_GOAL := help
.PHONY: all load-gateware load flash gateware firmware
.PHONY: all load-gateware load flash gateware firmware third_party/*
2 changes: 1 addition & 1 deletion Makefile.fx2
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gateware-fx2:
cp hdl/encoder/vhdl/header.hex $(MSCDIR)/build/header.hex

# Firmware for the Cypress FX2
firmware-fx2:
firmware-fx2: third_party/fx2lib/.git
$(MAKE) -C firmware/fx2

load-fx2: firmware-fx2
Expand Down
2 changes: 1 addition & 1 deletion Makefile.lm32
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ help-lm32:
gateware-lm32: firmware-lm32
@true

firmware-lm32:
firmware-lm32: third_party/misoc/.git
cd $(MSCDIR) && $(CMD) build-headers
$(MAKE) -C firmware/lm32 all

Expand Down
10 changes: 5 additions & 5 deletions firmware/fx2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# make AS8051=asx8051
#
TARGET := hdmi2usb
FX2LIBDIR := fx2lib
FX2LIBDIR := ../../third_party/fx2lib
LIBS := $(FX2LIBDIR)/lib/fx2.lib
INCS := -I sdcc -I$(FX2LIBDIR)/include -I.

Expand Down Expand Up @@ -80,17 +80,17 @@ all: $(TARGET).hex

$(CC_SRCS) $(AS_SRCS): $(FX2LIBDIR)/lib/fx2.lib

$(FX2LIBDIR)/lib/fx2.lib: $(FX2LIBDIR)/Makefile
$(FX2LIBDIR)/lib/fx2.lib: $(FX2LIBDIR)/.git
cd $(dir $@) && make -j1

# We depend on a file inside the directory as git creates an
# empty dir for us.
#
# Note that although we have the variable FX2LIBDIR, the submodule
# magic will always check it out in fx2lib/
$(FX2LIBDIR)/Makefile:
git submodule init
git submodule update
$(FX2LIBDIR)/.git:
git submodule init $@
git submodule update --recursive $@

$(TARGET).hex: $(CC_OBJS) $(AS_OBJS)
$(Q_LINK)$(CC) $(CFLAGS) -o $@ $+ $(LIBS)
Expand Down
2 changes: 1 addition & 1 deletion firmware/fx2/prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <delay.h>
#include "prog.h"
#include "defs.h"
#include "../../vendorCommands.h"
#include "vendorCommands.h"
#include "debug.h"

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion firmware/fx2/prog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define PROG_H

#include <makestuff.h>
#include "../../vendorCommands.h"
#include "vendorCommands.h"

// Default TDO=PD0, TDI=PD1, TMS=PD2 & TCK=PD3. In reality this is overwritten
// at runtime by livePatch().
Expand Down
2 changes: 1 addition & 1 deletion firmware/lm32/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# XXX remove this
MSCDIR=../../build/misoc
MSCDIR=../../third_party/misoc
include $(MSCDIR)/software/common.mak

OBJECTS=isr.o processor.o hdmi_in0.o hdmi_in1.o pattern.o edid.o pll.o ci.o config.o encoder.o i2c.o main.o
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if [ -e HDMI2USB-misoc-firmware ]; then
cd HDMI2USB-misoc-firmware
git pull || exit 1
else
git clone $GIT_REPO || exit 1
git clone --recurse-submodules $GIT_REPO || exit 1
cd HDMI2USB-misoc-firmware
git checkout $GIT_BRANCH || exit 1
fi
Expand Down
45 changes: 15 additions & 30 deletions scripts/get-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ SETUP_SRC=$(realpath ${BASH_SOURCE[0]})
SETUP_DIR=$(dirname $SETUP_SRC)
TOP_DIR=$(realpath $SETUP_DIR/..)
BUILD_DIR=$TOP_DIR/build
THIRD_DIR=$TOP_DIR/third_party

set -x
set -e

echo " This script is: $SETUP_SRC"
echo " Firmware directory: $TOP_DIR"
echo " Build directory is: $BUILD_DIR"
echo " 3rd party directory is: $THIRD_DIR"

# Check the build dir
if [ ! -d $BUILD_DIR ]; then
Expand Down Expand Up @@ -100,37 +102,26 @@ export PATH=$CONDA_DIR/bin:$PATH
conda install sdcc
)

# git submodules
git submodule update --recursive
git submodule foreach \
git submodule update --recursive --init

# migen
MIGEN_DIR=$BUILD_DIR/migen
MIGEN_DIR=$THIRD_DIR/migen
(
if [ ! -d $MIGEN_DIR ]; then
cd $BUILD_DIR
git clone https://github.com/m-labs/migen.git
cd migen
else
cd $MIGEN_DIR
git pull
fi
#cd vpi
cd $MIGEN_DIR
cd vpi
#make all
#sudo make install
)
export PYTHONPATH=$MIGEN_DIR:$PYTHONPATH
python3 -c "import migen"

# misoc
MISOC_DIR=$BUILD_DIR/misoc
MISOC_DIR=$THIRD_DIR/misoc
(
if [ ! -d $MISOC_DIR ]; then
cd $BUILD_DIR
git clone https://github.com/m-labs/misoc.git
cd misoc
else
cd $MISOC_DIR
git pull
fi
git submodule init
git submodule update
cd $MISOC_DIR
cd tools
make
)
Expand All @@ -139,16 +130,10 @@ $MISOC_DIR/tools/flterm --help
python3 -c "import misoclib"

# liteeth
LITEETH_DIR=$BUILD_DIR/liteeth
LITEETH_DIR=$THIRD_DIR/liteeth
(
if [ ! -d $LITEETH_DIR ]; then
cd $BUILD_DIR
git clone https://github.com/enjoy-digital/liteeth.git
cd liteeth
else
cd $LITEETH_DIR
git pull
fi
cd $LITEETH_DIR
true
)
export PYTHONPATH=$LITEETH_DIR:$PYTHONPATH
python3 -c "import liteeth"
Expand Down
9 changes: 6 additions & 3 deletions scripts/setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SETUP_SRC=$(realpath ${BASH_SOURCE[0]})
SETUP_DIR=$(dirname $SETUP_SRC)
TOP_DIR=$(realpath $SETUP_DIR/..)
BUILD_DIR=$TOP_DIR/build
THIRD_DIR=$TOP_DIR/third_party


if [ $SOURCED = 0 ]; then
Expand All @@ -29,6 +30,7 @@ fi
echo " This script is: $SETUP_SRC"
echo " Firmware directory: $TOP_DIR"
echo " Build directory is: $BUILD_DIR"
echo " 3rd party directory is: $THIRD_DIR"

# Check the build dir
if [ ! -d $BUILD_DIR ]; then
Expand Down Expand Up @@ -59,17 +61,18 @@ CONDA_DIR=$BUILD_DIR/conda
export PATH=$CONDA_DIR/bin:$PATH

# migen
MIGEN_DIR=$BUILD_DIR/migen
MIGEN_DIR=$THIRD_DIR/migen
export PYTHONPATH=$MIGEN_DIR:$PYTHONPATH
python3 -c "import migen" || (echo "migen broken"; return)

# misoc
MISOC_DIR=$BUILD_DIR/misoc
MISOC_DIR=$THIRD_DIR/misoc
export PYTHONPATH=$MISOC_DIR:$PYTHONPATH
$MISOC_DIR/tools/flterm --help || (echo "misoc flterm broken"; return)
python3 -c "import misoclib" || (echo "misoc broken"; return)

# liteeth
LITEETH_DIR=$BUILD_DIR/liteeth
LITEETH_DIR=$THIRD_DIR/liteeth
export PYTHONPATH=$LITEETH_DIR:$PYTHONPATH
python3 -c "import liteeth" || (echo "liteeth broken"; return)

Expand Down
1 change: 1 addition & 0 deletions third_party/liteeth
Submodule liteeth added at e61c22
1 change: 1 addition & 0 deletions third_party/litescope
Submodule litescope added at 9cc05d
1 change: 1 addition & 0 deletions third_party/migen
Submodule migen added at ef92aa
1 change: 1 addition & 0 deletions third_party/misoc
Submodule misoc added at 8e860e
63 changes: 63 additions & 0 deletions third_party/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

set -e

TARGETS=${@-$(find * -maxdepth 0 -type d)}

COMMIT_MSG=$(tempfile) || exit
trap "rm -f -- '$COMMIT_MSG'" EXIT

cat > $COMMIT_MSG <<EOF
Updating submodules.
EOF

DIRTY=0
for TARGET in $TARGETS; do
pushd $TARGET > /dev/null
VERSION=$(git describe --always --dirty)
echo -n "$TARGET version ($VERSION) " | grep --color -E "dirty|$"
if echo $VERSION | grep -q "dirty"; then
DIRTY=1
fi
popd > /dev/null
done

if [ $DIRTY -eq 0 ]; then
echo "All targets clean, good to update."
else
echo "Some target are dirty, can't update."
exit 1
fi

for TARGET in $TARGETS; do
(
cd $TARGET
echo
echo "$TARGET checking for updates.."
BEFORE_VER=$(git describe --always --dirty)
git fetch origin | sed -e's/^/ /'
git checkout origin/master | sed -e's/^/ /'
AFTER_VER=$(git describe --always --dirty)
if [ x"$BEFORE_VER" = x"$AFTER_VER" ]; then
echo "$TARGET is unchanged"
else
echo "Move $TARGET from $BEFORE_VER to $AFTER_VER"
cat >> $COMMIT_MSG <<EOF
* $TARGET changed from $BEFORE_VER to $AFTER_VER
EOF
fi
echo
)
git add $TARGET
done

cat >> $COMMIT_MSG <<EOF
Full submodule status
--
EOF
git submodule status >> $COMMIT_MSG
echo "" >> $COMMIT_MSG

git commit -F- < $COMMIT_MSG

0 comments on commit 92fd4c0

Please sign in to comment.