Skip to content

Instantly share code, notes, and snippets.

@samdoshi
Last active March 23, 2016 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samdoshi/269510e6af71336e397a to your computer and use it in GitHub Desktop.
Save samdoshi/269510e6af71336e397a to your computer and use it in GitHub Desktop.
/diet-asf
/mod
/mod2
/earthsea
/kria
/libavr32
/meadowphysics
/teletype
/walk
/whitewhale
rm -rf earthsea
rm -rf kria
rm -rf libavr32
rm -rf meadowphysics
rm -rf teletype
rm -rf walk
rm -rf whitewhale
#!/usr/bin/env python3
"""
Clone a repo, keeping only the history of a whitelist of files.
Those files are followed as far as `git log --follow` can follow them.
The use of `--follow` also means a few extra files may be caught along the way,
though they are usually empty.
This is a one-off script for splitting the IPython repo,
not built for re-use. It could be updated to do so.
"""
import os, sys, time
import pipes
from subprocess import check_call as sh, check_output
import shutil
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('src', type=str, help="The source repo to clone")
parser.add_argument('dst', type=str, help="The destination of the new clone")
parser.add_argument('--file-list', '-f', type=str, nargs='+', help="Line-delimited file(s) containing paths to track.")
parser.add_argument('files', type=str, nargs='*',
help="Files whose history should be preserved. Filenames can be specified in files with --file-list.")
opts = parser.parse_args()
paths = opts.files or []
for path in opts.file_list or []:
with open(path) as f:
for line in f:
paths.append(line.strip())
assert paths, "need some paths to track"
src_repo = opts.src
repo_dir = opts.dst
if os.path.exists(repo_dir):
print("destination already exists: %s" % repo_dir)
sys.exit(1)
# some constants that should be arguments:
here = os.path.abspath(os.path.dirname(__file__))
get_history = os.path.join(here, 'get-filename-history')
index_filter = os.path.join(here, 'whitelist-index-filter')
sh(['git', 'clone', '-b', 'master', src_repo, repo_dir])
os.chdir(repo_dir)
check_output(['git', 'tag', '-d'] + check_output(['git', 'tag']).decode().split())
sh('git remote rm origin'.split())
print(repo_dir)
# count the number of files whose history we are tracking
count = 0
for path in paths:
if not os.path.isdir(path):
count += 1
for _, __, files in os.walk(path):
for f in files:
count += 1
print("Computing filename history to preserve")
print(paths)
tic = time.time()
whitelist = check_output([
get_history
] + paths).decode('utf8').splitlines()
toc = time.time()
assert whitelist
print('\n'.join(whitelist))
print("Spent %.1fs computing filename history of %i files (%i found)" % (
toc-tic, count, len(whitelist),
))
print("Filtering git history")
tic = time.time()
index_filter_cmd = ' '.join(map(pipes.quote,
[index_filter] + whitelist
))
sh([
'git', 'filter-branch', '--prune-empty', '--index-filter',
index_filter_cmd, '--', '--all',
], stdout=sys.stderr)
toc = time.time()
dt = toc-tic
hrs = dt // 60
mins = dt % 60
print("Spent %02i:%02i running filter-branch" % (hrs, mins))
# cleanup refs
sh('git update-ref -d refs/original/refs/heads/master'.split())
sh('git reflog expire --expire=now --all'.split())
shutil.rmtree(".git/logs")
sh('git gc --aggressive --prune=now'.split())
print(repo_dir)
#
# Copyright (c) 2009-2010 Atmel Corporation. All rights reserved.
#
# \asf_license_start
#
# \page License
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. The name of Atmel may not be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# 4. This software may only be redistributed and used in connection with an
# Atmel microcontroller product.
#
# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# \asf_license_stop
# project name
THIS = earthsea
# Path to top level ASF directory relative to this project directory.
PRJ_PATH = ../libavr32/asf
# Target CPU architecture: ap, ucr1, ucr2 or ucr3
ARCH = ucr1
# Target part: none, ap7xxx or uc3xxxxx
# PART = uc3b064
PART = uc3b0256
# Target device flash memory details (used by the avr32program programming
# tool: [cfi|internal]@address
FLASH = internal@0x80000000
# Clock source to use when programming; xtal, extclk or int
PROG_CLOCK = int
# Application target name. Given with suffix .a for library and .elf for a
# standalone application.
TARGET = $(THIS).elf
# List of C source files.
CSRCS = \
../src/main.c \
../libavr32/src/adc.c \
../libavr32/src/events.c \
../libavr32/src/init_trilogy.c \
../libavr32/src/init_common.c \
../libavr32/src/i2c.c \
../libavr32/src/monome.c \
../libavr32/src/timers.c \
../libavr32/src/notes.c \
../libavr32/src/usb.c \
../libavr32/src/util.c \
../libavr32/src/usb/ftdi/ftdi.c \
../libavr32/src/usb/ftdi/uhi_ftdi.c \
../libavr32/src/usb/hid/hid.c \
../libavr32/src/usb/hid/uhi_hid.c \
../libavr32/src/usb/midi/uhi_midi.c \
../libavr32/src/usb/midi/midi.c \
avr32/drivers/adc/adc.c \
avr32/drivers/flashc/flashc.c \
avr32/drivers/gpio/gpio.c \
avr32/drivers/intc/intc.c \
avr32/drivers/pm/pm.c \
avr32/drivers/pm/pm_conf_clocks.c \
avr32/drivers/pm/power_clocks_lib.c \
avr32/drivers/spi/spi.c \
avr32/drivers/tc/tc.c \
avr32/drivers/twi/twi.c \
avr32/drivers/usart/usart.c \
avr32/drivers/usbb/usbb_host.c \
avr32/utils/debug/print_funcs.c \
common/services/usb/class/msc/host/uhi_msc.c \
common/services/usb/class/msc/host/uhi_msc_mem.c \
common/services/spi/uc3_spi/spi_master.c \
common/services/usb/uhc/uhc.c \
common/services/clock/uc3b0_b1/sysclk.c
# List of assembler source files.
ASSRCS = \
avr32/utils/startup/trampoline_uc3.S \
avr32/drivers/intc/exception.S \
# List of include paths.
INC_PATH = \
../../src \
../src \
../src/usb \
../src/usb/ftdi \
../src/usb/hid \
../src/usb/midi \
../conf \
../conf/trilogy \
avr32/boards \
avr32/drivers/cpu/cycle_counter \
avr32/drivers/flashc \
avr32/drivers/gpio \
avr32/drivers/intc \
avr32/drivers/pm \
avr32/drivers/spi \
avr32/drivers/tc \
avr32/drivers/twi \
avr32/drivers/usart \
avr32/drivers/usbb \
avr32/utils \
avr32/utils/debug \
avr32/utils/preprocessor \
common/boards \
common/boards/user_board \
common/services/storage/ctrl_access \
common/services/clock \
common/services/delay \
common/services/usb/ \
common/services/usb/uhc \
common/services/usb/class/msc \
common/services/usb/class/msc/host \
common/services/usb/class/hid \
common/services/spi/uc3_spi \
common/utils
# Additional search paths for libraries.
LIB_PATH =
# List of libraries to use during linking.
LIBS =
# Path relative to top level directory pointing to a linker script.
# LINKER_SCRIPT = avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds
# LINKER_SCRIPT = avr32/drivers/flashc/flash_example/at32uc3b0256_evk1101/link_uc3b0256.lds
LINKER_SCRIPT = ../src/link_uc3b0256.lds
# Additional options for debugging. By default the common Makefile.in will
# add -g3.
DBGFLAGS =
# Application optimization used during compilation and linking:
# -O0, -O1, -O2, -O3 or -Os
OPTIMIZATION = -Os
# Extra flags to use when archiving.
ARFLAGS =
# Extra flags to use when assembling.
ASFLAGS =
# Extra flags to use when compiling.
CFLAGS =
# Extra flags to use when preprocessing.
#
# Preprocessor symbol definitions
# To add a definition use the format "-D name[=definition]".
# To cancel a definition use the format "-U name".
#
# The most relevant symbols to define for the preprocessor are:
# BOARD Target board in use, see boards/board.h for a list.
# EXT_BOARD Optional extension board in use, see boards/board.h for a list.
CPPFLAGS = \
-D BOARD=USER_BOARD -D UHD_ENABLE
# Extra flags to use when linking
LDFLAGS = \
-Wl,-e,_trampoline
# Pre- and post-build commands
PREBUILD_CMD =
POSTBUILD_CMD =
#!/usr/bin/env python
"""Get the history of a collection of filenames via `git log --follow`
A list of filenames is printed to stdout, one filename per line.
"""
import os
import sys
from subprocess import check_output
import logging
pjoin = os.path.join
logger = logging.getLogger()
logging.basicConfig(level=logging.INFO)
def get_filename_history(path):
"""Get the history of filenames, according to `git log --follow`"""
logger.info("Getting history for %s" % path)
if os.path.isdir(path):
paths = set()
for d, dirs, files in os.walk(path):
for name in dirs + files:
paths.update(get_filename_history(pjoin(d, name)))
return paths
out = check_output([
'git', 'log', '--follow', '--oneline',
'--name-only', '--format=%h',
path]).decode('utf8')
paths = set()
for line in out.splitlines()[2::3]:
paths.add(line.strip())
return paths
if __name__ == '__main__':
all_paths = set()
if not sys.argv[1:]:
print(__doc__)
sys.exit(1)
for path in sys.argv[1:]:
all_paths.update(get_filename_history(path))
for p in sorted(all_paths):
print(p)
#
# Copyright (c) 2009-2010 Atmel Corporation. All rights reserved.
#
# \asf_license_start
#
# \page License
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. The name of Atmel may not be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# 4. This software may only be redistributed and used in connection with an
# Atmel microcontroller product.
#
# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# \asf_license_stop
# project name
THIS = kria
# Path to top level ASF directory relative to this project directory.
PRJ_PATH = ../libavr32/asf
# Target CPU architecture: ap, ucr1, ucr2 or ucr3
ARCH = ucr1
# Target part: none, ap7xxx or uc3xxxxx
# PART = uc3b064
PART = uc3b0256
# Target device flash memory details (used by the avr32program programming
# tool: [cfi|internal]@address
FLASH = internal@0x80000000
# Clock source to use when programming; xtal, extclk or int
PROG_CLOCK = int
# Application target name. Given with suffix .a for library and .elf for a
# standalone application.
TARGET = $(THIS).elf
# List of C source files.
CSRCS = \
../src/main.c \
../libavr32/src/adc.c \
../libavr32/src/events.c \
../libavr32/src/i2c.c \
../libavr32/src/init_trilogy.c \
../libavr32/src/init_common.c \
../libavr32/src/monome.c \
../libavr32/src/timers.c \
../libavr32/src/usb.c \
../libavr32/src/util.c \
../libavr32/src/usb/ftdi/ftdi.c \
../libavr32/src/usb/ftdi/uhi_ftdi.c \
../libavr32/src/usb/hid/hid.c \
../libavr32/src/usb/hid/uhi_hid.c \
../libavr32/src/usb/midi/uhi_midi.c \
../libavr32/src/usb/midi/midi.c \
avr32/drivers/adc/adc.c \
avr32/drivers/flashc/flashc.c \
avr32/drivers/gpio/gpio.c \
avr32/drivers/intc/intc.c \
avr32/drivers/pm/pm.c \
avr32/drivers/pm/pm_conf_clocks.c \
avr32/drivers/pm/power_clocks_lib.c \
avr32/drivers/spi/spi.c \
avr32/drivers/tc/tc.c \
avr32/drivers/twi/twi.c \
avr32/drivers/usart/usart.c \
avr32/drivers/usbb/usbb_host.c \
avr32/utils/debug/print_funcs.c \
avr32/services/fs/fat/fat.c \
avr32/services/fs/fat/fat_unusual.c \
avr32/services/fs/fat/file.c \
avr32/services/fs/fat/navigation.c \
common/services/spi/uc3_spi/spi_master.c \
common/services/usb/uhc/uhc.c \
common/services/storage/ctrl_access/ctrl_access.c \
common/services/usb/class/msc/host/uhi_msc.c \
common/services/usb/class/msc/host/uhi_msc_mem.c \
common/services/clock/uc3b0_b1/sysclk.c
# List of assembler source files.
ASSRCS = \
avr32/utils/startup/trampoline_uc3.S \
avr32/drivers/intc/exception.S \
# List of include paths.
INC_PATH = \
../../src \
../src \
../src/usb \
../src/usb/ftdi \
../src/usb/hid \
../src/usb/midi \
../conf \
../conf/trilogy \
avr32/boards \
avr32/drivers/cpu/cycle_counter \
avr32/drivers/flashc \
avr32/drivers/gpio \
avr32/drivers/intc \
avr32/drivers/pm \
avr32/drivers/spi \
avr32/drivers/tc \
avr32/drivers/twi \
avr32/drivers/usart \
avr32/drivers/usbb \
avr32/utils \
avr32/utils/debug \
avr32/utils/preprocessor \
avr32/services/fs/fat \
common/boards \
common/boards/user_board \
common/services/storage/ctrl_access \
common/services/clock \
common/services/delay \
common/services/usb/ \
common/services/usb/uhc \
common/services/usb/class/hid \
common/services/usb/class/msc \
common/services/usb/class/msc/host \
common/services/usb/class/hid \
common/services/spi/uc3_spi \
common/utils
# Additional search paths for libraries.
LIB_PATH =
# List of libraries to use during linking.
LIBS =
# Path relative to top level directory pointing to a linker script.
# LINKER_SCRIPT = avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds
# LINKER_SCRIPT = avr32/drivers/flashc/flash_example/at32uc3b0256_evk1101/link_uc3b0256.lds
LINKER_SCRIPT = ../src/link_uc3b0256.lds
# Additional options for debugging. By default the common Makefile.in will
# add -g3.
DBGFLAGS =
# Application optimization used during compilation and linking:
# -O0, -O1, -O2, -O3 or -Os
OPTIMIZATION = -Os
# Extra flags to use when archiving.
ARFLAGS =
# Extra flags to use when assembling.
ASFLAGS =
# Extra flags to use when compiling.
CFLAGS =
# Extra flags to use when preprocessing.
#
# Preprocessor symbol definitions
# To add a definition use the format "-D name[=definition]".
# To cancel a definition use the format "-U name".
#
# The most relevant symbols to define for the preprocessor are:
# BOARD Target board in use, see boards/board.h for a list.
# EXT_BOARD Optional extension board in use, see boards/board.h for a list.
CPPFLAGS = \
-D BOARD=USER_BOARD -D UHD_ENABLE
# Extra flags to use when linking
LDFLAGS = \
-Wl,-e,_trampoline
# Pre- and post-build commands
PREBUILD_CMD =
POSTBUILD_CMD =
git clone mod mod2
pushd mod2
git filter-branch --tree-filter 'rm -rf xdk-asf-3.17.0' --prune-empty HEAD
git gc
popd
#
# Copyright (c) 2009-2010 Atmel Corporation. All rights reserved.
#
# \asf_license_start
#
# \page License
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. The name of Atmel may not be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# 4. This software may only be redistributed and used in connection with an
# Atmel microcontroller product.
#
# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# \asf_license_stop
# project name
THIS = meadowphysics
# Path to top level ASF directory relative to this project directory.
PRJ_PATH = ../libavr32/asf
# Target CPU architecture: ap, ucr1, ucr2 or ucr3
ARCH = ucr1
# Target part: none, ap7xxx or uc3xxxxx
# PART = uc3b064
PART = uc3b0256
# Target device flash memory details (used by the avr32program programming
# tool: [cfi|internal]@address
FLASH = internal@0x80000000
# Clock source to use when programming; xtal, extclk or int
PROG_CLOCK = int
# Application target name. Given with suffix .a for library and .elf for a
# standalone application.
TARGET = $(THIS).elf
# List of C source files.
CSRCS = \
../src/main.c \
../libavr32/src/adc.c \
../libavr32/src/events.c \
../libavr32/src/i2c.c \
../libavr32/src/init_trilogy.c \
../libavr32/src/init_common.c \
../libavr32/src/monome.c \
../libavr32/src/timers.c \
../libavr32/src/usb.c \
../libavr32/src/util.c \
../libavr32/src/usb/ftdi/ftdi.c \
../libavr32/src/usb/ftdi/uhi_ftdi.c \
../libavr32/src/usb/hid/hid.c \
../libavr32/src/usb/hid/uhi_hid.c \
../libavr32/src/usb/midi/uhi_midi.c \
../libavr32/src/usb/midi/midi.c \
avr32/drivers/adc/adc.c \
avr32/drivers/flashc/flashc.c \
avr32/drivers/gpio/gpio.c \
avr32/drivers/intc/intc.c \
avr32/drivers/pm/pm.c \
avr32/drivers/pm/pm_conf_clocks.c \
avr32/drivers/pm/power_clocks_lib.c \
avr32/drivers/spi/spi.c \
avr32/drivers/tc/tc.c \
avr32/drivers/twi/twi.c \
avr32/drivers/usart/usart.c \
avr32/drivers/usbb/usbb_host.c \
avr32/utils/debug/print_funcs.c \
common/services/usb/class/msc/host/uhi_msc.c \
common/services/usb/class/msc/host/uhi_msc_mem.c \
common/services/spi/uc3_spi/spi_master.c \
common/services/usb/uhc/uhc.c \
common/services/clock/uc3b0_b1/sysclk.c
# List of assembler source files.
ASSRCS = \
avr32/utils/startup/trampoline_uc3.S \
avr32/drivers/intc/exception.S \
# List of include paths.
INC_PATH = \
../../src \
../src \
../src/usb \
../src/usb/ftdi \
../src/usb/hid \
../src/usb/midi \
../conf \
../conf/trilogy \
avr32/boards \
avr32/drivers/cpu/cycle_counter \
avr32/drivers/flashc \
avr32/drivers/gpio \
avr32/drivers/intc \
avr32/drivers/pm \
avr32/drivers/spi \
avr32/drivers/tc \
avr32/drivers/twi \
avr32/drivers/usart \
avr32/drivers/usbb \
avr32/utils \
avr32/utils/debug \
avr32/utils/preprocessor \
common/boards \
common/boards/user_board \
common/services/storage/ctrl_access \
common/services/clock \
common/services/delay \
common/services/usb/ \
common/services/usb/uhc \
common/services/usb/class/msc \
common/services/usb/class/msc/host \
common/services/usb/class/hid \
common/services/spi/uc3_spi \
common/utils
# Additional search paths for libraries.
LIB_PATH =
# List of libraries to use during linking.
LIBS =
# Path relative to top level directory pointing to a linker script.
# LINKER_SCRIPT = avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds
# LINKER_SCRIPT = avr32/drivers/flashc/flash_example/at32uc3b0256_evk1101/link_uc3b0256.lds
LINKER_SCRIPT = ../src/link_uc3b0256.lds
# Additional options for debugging. By default the common Makefile.in will
# add -g3.
DBGFLAGS =
# Application optimization used during compilation and linking:
# -O0, -O1, -O2, -O3 or -Os
OPTIMIZATION = -Os
# Extra flags to use when archiving.
ARFLAGS =
# Extra flags to use when assembling.
ASFLAGS =
# Extra flags to use when compiling.
CFLAGS =
# Extra flags to use when preprocessing.
#
# Preprocessor symbol definitions
# To add a definition use the format "-D name[=definition]".
# To cancel a definition use the format "-U name".
#
# The most relevant symbols to define for the preprocessor are:
# BOARD Target board in use, see boards/board.h for a list.
# EXT_BOARD Optional extension board in use, see boards/board.h for a list.
CPPFLAGS = \
-D BOARD=USER_BOARD -D UHD_ENABLE
# Extra flags to use when linking
LDFLAGS = \
-Wl,-e,_trampoline
# Pre- and post-build commands
PREBUILD_CMD =
POSTBUILD_CMD =
git filter-branch -f --prune-empty --parent-filter /Users/sam/Scratch/monome-split/rewrite_parent.rb master
#!/usr/bin/ruby
old_parents = gets.chomp.gsub('-p ', ' ')
if old_parents.empty? then
new_parents = []
else
new_parents = `git show-branch --independent #{old_parents}`.split
end
puts new_parents.map{|p| '-p ' + p}.join(' ')
#!/bin/bash
set -e
GITHUB_USERAME=monome
# Earthsea
if [ ! -d "earthsea" ]; then
./clone-whitelist mod2 earthsea earthsea/Makefile earthsea/README earthsea/config.mk earthsea/flash.sh earthsea/main.c earthsea/update_firmware.command .gitignore LICENSE
pushd earthsea
git filter-branch -f --tree-filter 'rm -rf whitewhale' --prune-empty HEAD
../remove-merge-commits.sh
popd
fi
# Kria
if [ ! -d "kria" ]; then
./clone-whitelist mod2 kria kria/Makefile kria/config.mk kria/flash kria/flash.command kria/main.c .gitignore LICENSE
pushd kria
git filter-branch -f --tree-filter 'rm -rf whitewhale' --prune-empty HEAD
../remove-merge-commits.sh
popd
fi
# Meadowphysics
if [ ! -d "meadowphysics" ]; then
./clone-whitelist mod2 meadowphysics meadowphysics/Makefile meadowphysics/config.mk meadowphysics/flash meadowphysics/main.c meadowphysics/update-firmware.command .gitignore LICENSE
pushd meadowphysics
git filter-branch -f --tree-filter 'rm -rf whitewhale' --prune-empty HEAD
../remove-merge-commits.sh
popd
fi
# Skeleton
if [ ! -d "libavr32" ]; then
./clone-whitelist mod2 libavr32 skeleton/adc.c skeleton/adc.h skeleton/conf skeleton/events.c skeleton/events.h skeleton/fix.c skeleton/fix.h skeleton/font.c skeleton/font.h skeleton/fonts skeleton/i2c.c skeleton/i2c.h skeleton/init_common.c skeleton/init_common.h skeleton/init_teletype.c skeleton/init_teletype.h skeleton/init_trilogy.c skeleton/init_trilogy.h skeleton/kbd.c skeleton/kbd.h skeleton/libfixmath skeleton/link_uc3b0256.lds skeleton/link_uc3b0512.lds skeleton/monome.c skeleton/monome.h skeleton/notes.c skeleton/notes.h skeleton/region.c skeleton/region.h skeleton/screen.c skeleton/screen.h skeleton/timers.c skeleton/timers.h skeleton/types.h skeleton/usb skeleton/usb.c skeleton/usb.h skeleton/util.c skeleton/util.h .gitignore skeleton/ii.h LICENSE
pushd libavr32
git filter-branch -f --tree-filter 'rm -rf earthsea' --prune-empty HEAD
git filter-branch -f --tree-filter 'rm -rf teletype' --prune-empty HEAD
git filter-branch -f --tree-filter 'rm -rf whitewhale' --prune-empty HEAD
../remove-merge-commits.sh
popd
./update-libavr32.sh
pushd libavr32
git remote add origin git@github.com:$GITHUB_USERAME/libavr32.git
git push -f -u origin master
popd
fi
# Teletype
if [ ! -d "teletype" ]; then
./clone-whitelist mod2 teletype teletype/Makefile teletype/README.md teletype/changelog teletype/config.mk teletype/euclidean teletype/euclidean/data.c teletype/euclidean/data.h teletype/euclidean/euclidean.c teletype/euclidean/euclidean.h teletype/euclidean/euclidean.hs teletype/flash.sh teletype/help.h teletype/main.c teletype/sim teletype/sim/Makefile teletype/sim/slew.c teletype/sim/tt.c teletype/table.c teletype/table.h teletype/teletype.c teletype/teletype.h teletype/update_firmware.command .gitignore teletype/sim/.gitignore LICENSE
pushd teletype
git filter-branch -f --tree-filter 'rm -rf earthsea' --prune-empty HEAD
git filter-branch -f --tree-filter 'rm -rf whitewhale' --prune-empty HEAD
../remove-merge-commits.sh
popd
fi
# Walk
if [ ! -d "walk" ]; then
./clone-whitelist mod2 walk walk/Makefile walk/flash.sh walk/walk walk/walk.c .gitignore LICENSE
pushd walk
../remove-merge-commits.sh
git remote add origin git@github.com:$GITHUB_USERAME/walk.git
git push -f -u origin master
popd
fi
# Whitewhale
if [ ! -d "whitewhale" ]; then
./clone-whitelist mod2 whitewhale whitewhale/Makefile whitewhale/config.mk whitewhale/flash.command whitewhale/flash.sh whitewhale/main.c .gitignore LICENSE
pushd whitewhale
../remove-merge-commits.sh
popd
fi
for d in earthsea kria meadowphysics teletype whitewhale; do
if [ ! -d "$d/libavr32" ]; then
echo $d
pushd $d
git mv $d src
git commit -m "rename $d directory to src"
git submodule add https://github.com/$GITHUB_USERAME/libavr32.git libavr32
#git submodule add ../libavr32 libavr32
sed -i '' s/xdk-asf-3.17.0/libavr32\\/asf/g src/Makefile
cp ../$d.mk src/config.mk
git add src/Makefile
git add src/config.mk
git commit -m "add libavr32 submodule" -m "and update Makefile and config.mk"
git remote add origin git@github.com:$GITHUB_USERAME/$d.git
git push -f -u origin master
popd
fi
done
#
# Copyright (c) 2009-2010 Atmel Corporation. All rights reserved.
#
# \asf_license_start
#
# \page License
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. The name of Atmel may not be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# 4. This software may only be redistributed and used in connection with an
# Atmel microcontroller product.
#
# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# \asf_license_stop
# project name
THIS = teletype
# Path to top level ASF directory relative to this project directory.
PRJ_PATH = ../libavr32/asf
# Target CPU architecture: ap, ucr1, ucr2 or ucr3
# ARCH = ucr1
ARCH = ucr2
# Target part: none, ap7xxx or uc3xxxxx
# PART = uc3b064
# PART = uc3b0256
PART = uc3b0512
# Target device flash memory details (used by the avr32program programming
# tool: [cfi|internal]@address
FLASH = internal@0x80000000
# Clock source to use when programming; xtal, extclk or int
PROG_CLOCK = int
# Application target name. Given with suffix .a for library and .elf for a
# standalone application.
TARGET = $(THIS).elf
# List of C source files.
CSRCS = \
../src/main.c \
../src/table.c \
../src/teletype.c \
../src/euclidean/euclidean.c \
../src/euclidean/data.c \
../libavr32/src/adc.c \
../libavr32/src/events.c \
../libavr32/src/fix.c \
../libavr32/src/font.c \
../libavr32/src/i2c.c \
../libavr32/src/init_teletype.c \
../libavr32/src/init_common.c \
../libavr32/src/kbd.c \
../libavr32/src/region.c \
../libavr32/src/screen.c \
../libavr32/src/timers.c \
../libavr32/src/usb.c \
../libavr32/src/util.c \
../libavr32/src/usb/ftdi/ftdi.c \
../libavr32/src/usb/ftdi/uhi_ftdi.c \
../libavr32/src/usb/hid/hid.c \
../libavr32/src/usb/hid/uhi_hid.c \
../libavr32/src/usb/midi/uhi_midi.c \
../libavr32/src/usb/midi/midi.c \
avr32/drivers/adc/adc.c \
avr32/drivers/flashc/flashc.c \
avr32/drivers/gpio/gpio.c \
avr32/drivers/intc/intc.c \
avr32/drivers/pm/pm.c \
avr32/drivers/pm/pm_conf_clocks.c \
avr32/drivers/pm/power_clocks_lib.c \
avr32/drivers/spi/spi.c \
avr32/drivers/tc/tc.c \
avr32/drivers/twi/twi.c \
avr32/drivers/usart/usart.c \
avr32/drivers/usbb/usbb_host.c \
avr32/services/fs/fat/fat.c \
avr32/services/fs/fat/fat_unusual.c \
avr32/services/fs/fat/file.c \
avr32/services/fs/fat/navigation.c \
avr32/utils/debug/print_funcs.c \
common/services/storage/ctrl_access/ctrl_access.c \
common/services/usb/class/msc/host/uhi_msc.c \
common/services/usb/class/msc/host/uhi_msc_mem.c \
common/services/spi/uc3_spi/spi_master.c \
common/services/usb/uhc/uhc.c \
common/services/clock/uc3b0_b1/sysclk.c
# List of assembler source files.
ASSRCS = \
avr32/utils/startup/trampoline_uc3.S \
avr32/drivers/intc/exception.S \
# List of include paths.
INC_PATH = \
../../src \
../src \
../src/usb \
../src/usb/ftdi \
../src/usb/hid \
../src/usb/midi \
../conf \
../conf/teletype \
avr32/boards \
avr32/drivers/cpu/cycle_counter \
avr32/drivers/flashc \
avr32/drivers/gpio \
avr32/drivers/intc \
avr32/drivers/pm \
avr32/drivers/spi \
avr32/drivers/tc \
avr32/drivers/twi \
avr32/drivers/usart \
avr32/drivers/usbb \
avr32/utils \
avr32/utils/debug \
avr32/utils/preprocessor \
avr32/services/fs/fat \
common/boards \
common/boards/user_board \
common/services/storage/ctrl_access \
common/services/clock \
common/services/delay \
common/services/usb/ \
common/services/usb/uhc \
common/services/clock \
common/services/storage/ctrl_access \
common/services/usb/class/msc \
common/services/usb/class/msc/host \
common/services/usb/class/hid \
common/services/spi/uc3_spi \
common/utils
# Additional search paths for libraries.
LIB_PATH =
# List of libraries to use during linking.
LIBS =
# Path relative to top level directory pointing to a linker script.
# LINKER_SCRIPT = avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds
# LINKER_SCRIPT = avr32/drivers/flashc/flash_example/at32uc3b0256_evk1101/link_uc3b0256.lds
# LINKER_SCRIPT = ../system/link_uc3b0256.lds
LINKER_SCRIPT = ../src/link_uc3b0512.lds
# Additional options for debugging. By default the common Makefile.in will
# add -g3.
DBGFLAGS =
# Application optimization used during compilation and linking:
# -O0, -O1, -O2, -O3 or -Os
OPTIMIZATION = -Os
# Extra flags to use when archiving.
ARFLAGS =
# Extra flags to use when assembling.
ASFLAGS =
# Extra flags to use when compiling.
CFLAGS = -fshort-enums
# Extra flags to use when preprocessing.
#
# Preprocessor symbol definitions
# To add a definition use the format "-D name[=definition]".
# To cancel a definition use the format "-U name".
#
# The most relevant symbols to define for the preprocessor are:
# BOARD Target board in use, see boards/board.h for a list.
# EXT_BOARD Optional extension board in use, see boards/board.h for a list.
CPPFLAGS = \
-D BOARD=USER_BOARD -D UHD_ENABLE
# Extra flags to use when linking
LDFLAGS = \
-Wl,-e,_trampoline
# Pre- and post-build commands
PREBUILD_CMD =
POSTBUILD_CMD =
#!/bin/bash
pushd libavr32
git mv skeleton/conf conf
git mv skeleton src
git commit -m "moved skeleton/conf to root, renamed skeleton to src"
cp -r ../diet-asf/asf asf
git add asf
git commit -m "add (diet) asf 3.30"
popd
#!/usr/bin/env python
"""For use in `git filter-branch --index-filter`,
this is an index filter that excludes all files *not* in the given whitelist.
"""
import sys
from subprocess import check_output, check_call
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i+n]
whitelist = set(sys.argv[1:])
all_files = set(check_output(['git', 'ls-files']).decode('utf8').splitlines())
to_rm = all_files.difference(whitelist)
if to_rm:
for chunk in chunks(list(to_rm), 100):
out = check_output(['git', 'rm', '--cache'] + chunk).decode('utf8').splitlines()
#
# Copyright (c) 2009-2010 Atmel Corporation. All rights reserved.
#
# \asf_license_start
#
# \page License
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. The name of Atmel may not be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# 4. This software may only be redistributed and used in connection with an
# Atmel microcontroller product.
#
# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# \asf_license_stop
# project name
THIS = whitewhale
# Path to top level ASF directory relative to this project directory.
PRJ_PATH = ../libavr32/asf
# Target CPU architecture: ap, ucr1, ucr2 or ucr3
ARCH = ucr1
# Target part: none, ap7xxx or uc3xxxxx
# PART = uc3b064
PART = uc3b0256
# Target device flash memory details (used by the avr32program programming
# tool: [cfi|internal]@address
FLASH = internal@0x80000000
# Clock source to use when programming; xtal, extclk or int
PROG_CLOCK = int
# Application target name. Given with suffix .a for library and .elf for a
# standalone application.
TARGET = $(THIS).elf
# List of C source files.
CSRCS = \
../src/main.c \
../libavr32/src/adc.c \
../libavr32/src/events.c \
../libavr32/src/i2c.c \
../libavr32/src/init_trilogy.c \
../libavr32/src/init_common.c \
../libavr32/src/monome.c \
../libavr32/src/timers.c \
../libavr32/src/usb.c \
../libavr32/src/util.c \
../libavr32/src/usb/ftdi/ftdi.c \
../libavr32/src/usb/ftdi/uhi_ftdi.c \
../libavr32/src/usb/hid/hid.c \
../libavr32/src/usb/hid/uhi_hid.c \
../libavr32/src/usb/midi/uhi_midi.c \
../libavr32/src/usb/midi/midi.c \
avr32/drivers/adc/adc.c \
avr32/drivers/flashc/flashc.c \
avr32/drivers/gpio/gpio.c \
avr32/drivers/intc/intc.c \
avr32/drivers/pm/pm.c \
avr32/drivers/pm/pm_conf_clocks.c \
avr32/drivers/pm/power_clocks_lib.c \
avr32/drivers/spi/spi.c \
avr32/drivers/tc/tc.c \
avr32/drivers/twi/twi.c \
avr32/drivers/usart/usart.c \
avr32/drivers/usbb/usbb_host.c \
avr32/utils/debug/print_funcs.c \
common/services/usb/class/msc/host/uhi_msc.c \
common/services/usb/class/msc/host/uhi_msc_mem.c \
common/services/spi/uc3_spi/spi_master.c \
common/services/usb/uhc/uhc.c \
common/services/clock/uc3b0_b1/sysclk.c
# List of assembler source files.
ASSRCS = \
avr32/utils/startup/trampoline_uc3.S \
avr32/drivers/intc/exception.S \
# List of include paths.
INC_PATH = \
../../src \
../src \
../src/usb \
../src/usb/ftdi \
../src/usb/hid \
../src/usb/midi \
../conf \
../conf/trilogy \
avr32/boards \
avr32/drivers/cpu/cycle_counter \
avr32/drivers/flashc \
avr32/drivers/gpio \
avr32/drivers/intc \
avr32/drivers/pm \
avr32/drivers/spi \
avr32/drivers/tc \
avr32/drivers/twi \
avr32/drivers/usart \
avr32/drivers/usbb \
avr32/utils \
avr32/utils/debug \
avr32/utils/preprocessor \
common/boards \
common/boards/user_board \
common/services/storage/ctrl_access \
common/services/clock \
common/services/delay \
common/services/usb/ \
common/services/usb/uhc \
common/services/usb/class/msc \
common/services/usb/class/msc/host \
common/services/usb/class/hid \
common/services/spi/uc3_spi \
common/utils
# Additional search paths for libraries.
LIB_PATH =
# List of libraries to use during linking.
LIBS =
# Path relative to top level directory pointing to a linker script.
# LINKER_SCRIPT = avr32/utils/linker_scripts/at32uc3b/0256/gcc/link_uc3b0256.lds
# LINKER_SCRIPT = avr32/drivers/flashc/flash_example/at32uc3b0256_evk1101/link_uc3b0256.lds
LINKER_SCRIPT = ../../libavr32/src/link_uc3b0256.lds
# Additional options for debugging. By default the common Makefile.in will
# add -g3.
DBGFLAGS =
# Application optimization used during compilation and linking:
# -O0, -O1, -O2, -O3 or -Os
OPTIMIZATION = -Os
# Extra flags to use when archiving.
ARFLAGS =
# Extra flags to use when assembling.
ASFLAGS =
# Extra flags to use when compiling.
CFLAGS =
# Extra flags to use when preprocessing.
#
# Preprocessor symbol definitions
# To add a definition use the format "-D name[=definition]".
# To cancel a definition use the format "-U name".
#
# The most relevant symbols to define for the preprocessor are:
# BOARD Target board in use, see boards/board.h for a list.
# EXT_BOARD Optional extension board in use, see boards/board.h for a list.
CPPFLAGS = \
-D BOARD=USER_BOARD -D UHD_ENABLE
# Extra flags to use when linking
LDFLAGS = \
-Wl,-e,_trampoline
# Pre- and post-build commands
PREBUILD_CMD =
POSTBUILD_CMD =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment