Skip to content

Commit

Permalink
Merge pull request #9 from tmck-code/build_less_items
Browse files Browse the repository at this point in the history
Build less items
  • Loading branch information
tmck-code authored Feb 1, 2022
2 parents 17293a8 + b935ce1 commit 62955c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ build/release: build/docker
@docker create --name pokesay pokesay-go:latest
@docker cp pokesay:/usr/local/src/pokesay-linux-amd64 .
@docker cp pokesay:/usr/local/src/pokesay-darwin-amd64 .
@docker cp pokesay:/usr/local/src/pokesay-windows-amd64 .
@docker cp pokesay:/usr/local/src/pokesay-windows-amd64.exe .
@docker cp pokesay:/usr/local/src/pokesay-android-arm64 .
@docker rm -f pokesay

Expand Down
5 changes: 2 additions & 3 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \
parallel make gcc libmagickwand-dev ncurses-dev fortune-mod fortunes

ENV PATH "/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.11/bin-q16:/usr/include/ImageMagick-6/:$PATH"
RUN git clone --depth 1 git://github.com/rossy/img2xterm \
RUN git clone --depth 1 git://github.com/denilsonsa/img2xterm \
&& (cd img2xterm && make && make install)

ENV DOCKER_BUILD_DIR /tmp/original
Expand All @@ -28,7 +27,7 @@ RUN go mod tidy \
RUN go run /usr/local/src/build/build_cows.go \
-from /tmp/original/pokesprite/ \
-to /tmp/cows/ \
-skip '["resources/", "misc/"]'
-skip '["resources/", "misc/", "icons/", "items/", "items-outline/"]'

ADD cmd/ /usr/local/src/cmd/
RUN go-bindata -nometadata -nomemcopy -prefix /tmp/ /tmp/cows/... && \
Expand Down
20 changes: 11 additions & 9 deletions build/build_cows.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ func findFiles(dirpath string, ext string, skip []string) []string {
return fpaths
}

func img2xterm(sourceFpath string) []byte {
func img2xterm(sourceFpath string) (error, []byte) {
out, err := exec.Command("bash", "-c", fmt.Sprintf("/usr/local/bin/img2xterm %s | grep \"\\S\"", sourceFpath)).Output()

if err != nil {
log.Fatal(err)
}
return out
return err, out
}

func convertPngToCow(sourceDirpath string, sourceFpath string, destDirpath string, wg *sync.WaitGroup, pbar *progressbar.ProgressBar) {
Expand All @@ -77,10 +74,15 @@ func convertPngToCow(sourceDirpath string, sourceFpath string, destDirpath strin

destFpath := filepath.Join(destDir, strings.ReplaceAll(filepath.Base(sourceFpath), ".png", ".cow"))

err := os.WriteFile(destFpath, img2xterm(sourceFpath), 0644)
time.Sleep(0)
if err != nil {
log.Fatal(err)
// Some conversions are failing with something about colour channels
// Can't be bothered resolving atm, so just skip past any failed conversions
imgErr, converted := img2xterm(sourceFpath)
if imgErr == nil {
err := os.WriteFile(destFpath, converted, 0644)
time.Sleep(0)
if err != nil {
log.Fatal(err)
}
}
pbar.Add(1)
}
Expand Down

0 comments on commit 62955c2

Please sign in to comment.