Clean up CD build process

This commit is contained in:
Kevin Lange 2016-12-15 20:53:34 +09:00
parent fa58b9a7be
commit fd455516ed
4 changed files with 69 additions and 139 deletions

View File

@ -12,6 +12,7 @@ NM = i686-pc-toaru-nm
CXX= i686-pc-toaru-g++
AR = i686-pc-toaru-ar
AS = i686-pc-toaru-as
STRIP = i686-pc-toaru-strip
# Build flags
CFLAGS = -O2 -std=c99
@ -20,6 +21,8 @@ CFLAGS += -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-format
CFLAGS += -pedantic -fno-omit-frame-pointer
CFLAGS += -D_KERNEL_
STRIP_LIBS = 1
ASFLAGS = --32
# Kernel autoversioning with git sha
@ -53,12 +56,20 @@ USER_LIBFILES = $(shell find userspace -wholename '*/lib/*' -name '*.c')
LIBC=hdd/usr/lib/libc.so
# Userspace output files (so we can define metatargets)
NONTEST_C = $(foreach f,$(USER_CFILES),$(if $(findstring /tests/,$f),,$f))
NONTEST_CXX = $(foreach f,$(USER_CXXFILES),$(if $(findstring /tests/,$f),,$f))
NONTEST = $(foreach file,$(NONTEST_C),$(patsubst %.c,hdd/bin/%,$(notdir ${file})))
NONTEST += $(foreach file,$(NONTEST_CXX),$(patsubst %.c++,hdd/bin/%,$(notdir ${file})))
NONTEST += $(foreach file,$(USER_CSTATICFILES),$(patsubst %.static.c,hdd/bin/%,$(notdir ${file})))
NONTEST += $(foreach file,$(USER_LIBFILES),$(patsubst %.c,hdd/usr/lib/libtoaru-%.so,$(notdir ${file})))
NONTEST += $(LIBC) hdd/bin/init hdd/lib/ld.so
USERSPACE = $(foreach file,$(USER_CFILES),$(patsubst %.c,hdd/bin/%,$(notdir ${file})))
USERSPACE += $(foreach file,$(USER_CXXFILES),$(patsubst %.c++,hdd/bin/%,$(notdir ${file})))
USERSPACE += $(foreach file,$(USER_CSTATICFILES),$(patsubst %.static.c,hdd/bin/%,$(notdir ${file})))
USERSPACE += $(foreach file,$(USER_LIBFILES),$(patsubst %.c,hdd/usr/lib/libtoaru-%.so,$(notdir ${file})))
USERSPACE += $(LIBC) hdd/bin/init hdd/lib/ld.so
#USERSPACE += $(foreach file,$(USER_LIBFILES),$(patsubst %.c,%.o,${file}))
CORE_LIBS = $(patsubst %.c,%.o,$(wildcard userspace/lib/*.c))
@ -200,7 +211,10 @@ kernel/symbols.o: ${KERNEL_ASMOBJS} ${KERNEL_OBJS} util/generate_symbols.py
kernel/sys/version.o: kernel/*/*.c kernel/*.c
hdd/mod/%.ko: modules/%.c ${HEADERS}
hdd/mod:
@mkdir -p hdd/mod
hdd/mod/%.ko: modules/%.c ${HEADERS} | hdd/mod
@${BEG} "CC" "$< [module]"
@${CC} -T modules/link.ld -I./kernel/include -nostdlib ${CFLAGS} -c -o $@ $< ${ERRORS}
@${END} "CC" "$< [module]"
@ -230,7 +244,7 @@ define user-c-rule
$1: $2 $(shell util/auto-dep.py --deps $2) $(LIBC)
@${BEG} "CCSO" "$$<"
@${CC} -o $$@ $(USER_CFLAGS) -shared -fPIC $$(shell util/auto-dep.py --cflags $$<) $$< $$(shell util/auto-dep.py --libs $$<) -lc ${ERRORS}
@if [ "x$(STRIP_LIBS)" = "x1" ]; then i686-pc-toaru-strip $$@; fi
@if [ "x$(STRIP_LIBS)" = "x1" ]; then ${STRIP} $$@; fi
@${END} "CCSO" "$$<"
endef
$(foreach file,$(USER_LIBFILES),$(eval $(call user-c-rule,$(patsubst %.c,hdd/usr/lib/libtoaru-%.so,$(notdir ${file})),${file})))
@ -291,7 +305,7 @@ hdd/usr/lib/libc.so: ${TOOLCHAIN}/lib/libc.a | hdd/usr/lib
@${AR} d libc.a lib_a-reallocr.o
@${AR} d libc.a lib_a-vallocr.o
@${CC} -shared -o $@ -Wl,--whole-archive libc.a -Wl,--no-whole-archive ${ERRORS}
@if [ "x$(STRIP_LIBS)" = "x1" ]; then i686-pc-toaru-strip $@; fi
@if [ "x$(STRIP_LIBS)" = "x1" ]; then ${STRIP} $@; fi
@rm libc.a
@${END} "SO" "$@"
@ -308,7 +322,7 @@ define basic-so-wrapper
hdd/usr/lib/lib$(1).so: ${TOOLCHAIN}/lib/lib$(1).a
@${BEG} "SO" "$$@"
@${CC} -shared -Wl,-soname,lib$(1).so -o hdd/usr/lib/lib$(1).so -Lhdd/usr/lib -Wl,--whole-archive ${TOOLCHAIN}/lib/lib$(1).a -Wl,--no-whole-archive $2
@if [ "x$(STRIP_LIBS)" = "x1" ]; then i686-pc-toaru-strip $$@; fi
@if [ "x$(STRIP_LIBS)" = "x1" ]; then ${STRIP} $$@; fi
@${END} "SO" "$$@"
endef
@ -338,13 +352,47 @@ toaruos-disk.img: ${USERSPACE} util/devtable
cdrom: toaruos.iso
cdrom-big: toaruos-big.iso
hdd/usr/share/terminfo/t/toaru: util/toaru.tic
@mkdir -p hdd/usr/share/terminfo/t
@cp $< $@
toaruos.iso:
util/make-cdrom.sh
FORCE:
toaruos-big.iso:
util/make-cdrom-big.sh
_cdrom: FORCE
@-rm -rf _cdrom
@cp -r util/cdrom _cdrom
_cdrom/mod: modules _cdrom
@mv hdd/mod $@
_cdrom/kernel: toaruos-kernel _cdrom
@cp $< $@
BLACKLIST = hdd/usr/share/wallpapers/grandcanyon.png
BLACKLIST += hdd/usr/share/wallpapers/paris.png
BLACKLIST += hdd/usr/share/wallpapers/southbay.png
BLACKLIST += hdd/usr/share/wallpapers/yokohama.png
BLACKLIST += hdd/usr/share/wallpapers/yosemite.png
_cdrom/ramdisk.img: ${NONTEST} hdd/usr/share/wallpapers util/devtable hdd/usr/share/terminfo/t/toaru _cdrom
@${BEG} "hdd" "Generating a ramdisk image..."
@rm -f $(filter-out ${NONTEST},${USERSPACE})
@rm -f ${BLACKLIST}
@${STRIP} hdd/bin/*
@${GENEXT} -B 4096 -d hdd -D util/devtable -U -b 16384 -N 2048 $@
@${END} "hdd" "Generated ramdisk image"
_cdrom/ramdisk.img.gz: _cdrom/ramdisk.img
@gzip $<
toaruos.iso: _cdrom/ramdisk.img.gz _cdrom/kernel _cdrom/mod
@${BEG} "ISO" "Building a CD image"
@if grep precise /etc/lsb-release; then grub-mkrescue -o $@ _cdrom; else grub-mkrescue -d /usr/lib/grub/i386-pc --compress=xz -o $@ _cdrom -- -quiet 2> /dev/null; fi
@${END} "ISO" "Building a CD image"
@git checkout hdd/usr/share/wallpapers
@mv _cdrom/mod hdd/mod
@rm -r _cdrom
@${INFO} "--" "CD generated"
##############
# ctags #

View File

@ -0,0 +1,11 @@
clock,clock-win,Clock
applications-painting,draw,Draw!
julia,julia,Julia Fractals
gears,gears,Gears
drawlines,drawlines,Lines
snow,make-it-snow,Make it Snow
pixman-demo,pixman-demo,Pixman Demo
plasma,plasma,Plasma
applications-simulation,game,RPG Demo
utilities-terminal,terminal,Terminal
ttk-demo,ttk-demo,TTK Demo

View File

@ -1,57 +0,0 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Ensure we're in the root of the git repo.
cd $DIR/..
# Check that we're trying to build with our own toolchain,
# as it installs things to hdd/ and we're going to reset
# that directory to a clean slate (which will lose, eg.
# includes, libraries, etc.)
if [[ $TOOLCHAIN/ = $PWD/* ]]; then
echo "You should not try to build CD ISOs from your active"
echo "development repository, as the process is destructive"
echo "in its attempts to build small ramdisks."
echo ""
echo "Instead, create a new clone of your repository,"
echo "activate your development toolchain, and then run this"
echo "script again."
exit 1
fi
BLACKLIST="userspace/tests/*"
# Rebuild
echo "Rebuilding... (ignore warnings about time skew, this is intentional)"
eval rm $BLACKLIST
touch -d tomorrow toaruos-disk.img
make
i686-pc-toaru-strip hdd/bin/*
echo "Cloning CD source directory..."
rm -rf cdrom
cp -r util/cdrom cdrom
mv hdd/mod cdrom/mod
mkdir -p hdd/usr/share/terminfo/t
cp util/toaru.tic hdd/usr/share/terminfo/t/toaru
cat > hdd/home/local/.desktop.conf <<EOF
# wallpaper=/usr/share/wallpapers/yosemite.png
EOF
echo "Generating ramdisk..."
genext2fs -B 4096 -d hdd -D util/devtable -U -b 65536 -N 1024 cdrom/ramdisk.img
gzip cdrom/ramdisk.img
echo "Installing kernel..."
cp toaruos-kernel cdrom/kernel
echo "Building ISO..."
grub-mkrescue -d /usr/lib/grub/i386-pc -o toaruos-big.iso cdrom
echo "Restoring modules directory to hdd/mod..."
mv cdrom/mod hdd/mod
rm -r cdrom
eval git checkout $BLACKLIST

View File

@ -1,72 +0,0 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Ensure we're in the root of the git repo.
cd $DIR/..
# Check that we're trying to build with our own toolchain,
# as it installs things to hdd/ and we're going to reset
# that directory to a clean slate (which will lose, eg.
# includes, libraries, etc.)
if [[ $TOOLCHAIN/ = $PWD/* ]]; then
echo "You should not try to build CD ISOs from your active"
echo "development repository, as the process is destructive"
echo "in its attempts to build small ramdisks."
echo ""
echo "Instead, create a new clone of your repository,"
echo "activate your development toolchain, and then run this"
echo "script again."
exit 1
fi
BLACKLIST="userspace/tests/* hdd/usr/share/wallpapers/{grandcanyon,paris,southbay,yokohama,yosemite}.png"
# Rebuild
echo "Rebuilding... (ignore warnings about time skew, this is intentional)"
eval rm $BLACKLIST
touch -d tomorrow toaruos-disk.img
make STRIP_LIBS=1
i686-pc-toaru-strip hdd/bin/*
echo "Cloning CD source directory..."
rm -rf cdrom
cp -r util/cdrom cdrom
mv hdd/mod cdrom/mod
mkdir -p hdd/usr/share/terminfo/t
cp util/toaru.tic hdd/usr/share/terminfo/t/toaru
cat > hdd/home/local/.menu.desktop <<EOF
clock,clock-win,Clock
applications-painting,draw,Draw!
julia,julia,Julia Fractals
gears,gears,Gears
drawlines,drawlines,Lines
snow,make-it-snow,Make it Snow
pixman-demo,pixman-demo,Pixman Demo
plasma,plasma,Plasma
applications-simulation,game,RPG Demo
utilities-terminal,terminal,Terminal
ttk-demo,ttk-demo,TTK Demo
EOF
echo "Generating ramdisk..."
genext2fs -B 4096 -d hdd -D util/devtable -U -b 16384 -N 2048 cdrom/ramdisk.img
gzip cdrom/ramdisk.img
echo "Installing kernel..."
cp toaruos-kernel cdrom/kernel
echo "Building ISO..."
if grep precise /etc/lsb-release; then
# Hack for travis build hosts (old grub-mkrescue, no -d)
grub-mkrescue -o toaruos.iso cdrom
else
grub-mkrescue -d /usr/lib/grub/i386-pc --compress=xz -o toaruos.iso cdrom
fi
echo "Restoring modules directory to hdd/mod..."
mv cdrom/mod hdd/mod
rm -r cdrom
eval git checkout $BLACKLIST