Lazarus

Programming => Operating Systems => Other => Topic started by: kveroneau on March 31, 2020, 03:13:30 am

Title: Docker image which can build both 16 and 32-bit MS-DOS apps
Post by: kveroneau on March 31, 2020, 03:13:30 am
I thought this would be the best sub-forum to post this under...

Do you need a consistent easy to grab development environment to build both 16-bit real-mode and 32-bit protected mode ObjectPascal programs in?  Well, I have the solution for you!  If you have access to Docker, either in a VM on Windows/Mac, or natively on your Linux workstation, you can either build my Dockerfile yourself with your own customization and FPC version, or pull a ready made FPC 3.2.0 RC1 Docker image I slapped together today!

I have tested both the i8086 and GO32v2 FPC targets in this Docker image and can confirm they run in DOS as expected.  This is a beta version of the next FPC release, so be warned that there might be some bugs and such, but this could be your chance to try compiling your current 16-bit and 32-bit programs on the latest and greatest FPC version to see if they run as expected and of course open bug reports if you notice anything off.

Dockerfile in my GitHub repo: https://github.com/kveroneau/fpc-docker/tree/master/Builder/fpc320

Docker image in Docker Hub: https://hub.docker.com/layers/kveroneau/fpc/3.2.0/images/sha256-e64ed3081691278903372ef8c5db72338bff6e4af4f5a7f964bc0045db93d4fd?context=explore

Command you can run right now(if you have Docker installed):

Code: Bash  [Select][+][-]
  1. $ docker run -it --rm -v `pwd`:/usr/src kveroneau/fpc:3.2.0
  2.  

This will make your current working directory available under /usr/src in the Docker container when it runs, so run this command in a directory where you have some source code you'd like to try and compile against FPC 3.2.0.

Here is how you can build for each target:

Code: GNU make  [Select][+][-]
  1. all: hello.com hello.exe hello32.exe
  2.  
  3. hello.com: hello.pas
  4.         ppcross8086 -o$@ -WmTiny -Wtcom $<
  5.  
  6. hello.exe: hello.pas
  7.         ppcross8086 -o$@ -WmTiny -Wtexe $<
  8.  
  9. hello32.exe: hello.pas
  10.         ppcross386 -o$@ -Tgo32v2 $<
  11.  
  12. clean:
  13.         rm -rf *.com *.exe *.a *.o
  14.  

If you used the docker command-line provided above, your host operating system should now contain a couple .EXE files and a .COM file within the same source directory you shared with the Docker container.  Easy stuff.

What is even cooler about this, is that you can create a nice shell script to run a Makefile from the current directory inside the Docker container, eg:

Code: Bash  [Select][+][-]
  1. #!/bin/sh
  2.  
  3. docker run -it --rm -v `pwd`:/usr/src kveroneau/fpc:3.2.0 make "$@"
  4.  

Running this script will spin up a temporary docker container to clean-room build your sources in the current directory using a modern Makefile.  When the docker container finishes, you should then see your binary files and also see the output from Make on your standard output.  This can obviously be used on something like a build server like Jenkins or CircleCI to automate builds.

Let me know if anybody has any questions, or needs some assistance in getting Docker up and running on their machines.
TinyPortal © 2005-2018