Skip to content
Vladimir Panteleev edited this page May 6, 2016 · 1 revision
#!/bin/bash
set -eu

rm -rf src-clean-imports
cp -a src src-clean-imports

for F in $(find src-clean-imports -name '*.d')
do
	echo "// DustMiteNoRemoveStart" > "$F".tmp
	while IFS= read -r LINE
	do
		if [[ "$LINE" =~ ^import\ .*\;$ ]]
		then
			echo "// DustMiteNoRemoveStop"
		fi
		echo "$LINE"
		if [[ "$LINE" =~ import\ .*\;$ ]]
		then
			echo "// DustMiteNoRemoveStart"
		fi

		#echo "Line: $LINE"
	done < "$F" >> "$F".tmp
	echo "// DustMiteNoRemoveStop" >> "$F".tmp
	mv "$F.tmp" "$F"
done

( cd src-clean-imports && make -f posix.mak clean ; find -name '*.o' -delete )

dustmite --split '*.d:lines' src-clean-imports 'make -f posix.mak check'

#dmd -o- -J. $(find -name '*.d')
#access.d aggregate.d aliasthis.d apply.d argtypes.d arrayop.d arraytypes.d attrib.d builtin.d canthrow.d clone.d complex.d cond.d constfold.d cppmangle.d ctfeexpr.d dcast.d dclass.d declaration.d delegatize.d denum.d dimport.d dinifile.d dinterpret.d dmacro.d dmangle.d dmodule.d doc.d dscope.d dstruct.d dsymbol.d dtemplate.d dversion.d entity.d errors.d escape.d expression.d func.d globals.d hdrgen.d id.d identifier.d impcnvtab.d imphint.d init.d inline.d intrange.d json.d lexer.d lib.d link.d mars.d mtype.d nogc.d nspace.d opover.d optimize.d parse.d sapply.d sideeffect.d statement.d staticassert.d target.d tokens.d traits.d utf.d visitor.d typinf.d objc_stubs.d libelf.d scanelf.d backend.d irstate.d toelfdebug.d toctype.d gluelayer.d root/aav.d root/array.d root/file.d root/filename.d root/longdouble.d root/man.d root/outbuffer.d root/port.d root/response.d root/rmem.d root/rootobject.d root/speller.d root/stringtable.d newdelete.o glue.a backend.a

for F in $(find src-clean-imports.reduced -name '*.d')
do
	grep -vF DustMiteNoRemove "$F" > "$F".tmp
	mv "$F.tmp" "$F"
done

( cd src-clean-imports.reduced && find -name '*.d' -exec mv '{}' '../src/{}' ';' )

rm -rf src-clean-imports src-clean-imports.reduced