Running WSL bash scripts as pre-build/post-build events

This forum is for all Flare issues not related to any of the other categories.
Post Reply
chrispitude
Propeller Head
Posts: 58
Joined: Thu Mar 23, 2017 12:23 pm

Running WSL bash scripts as pre-build/post-build events

Post by chrispitude »

Hi all,

If you are running Windows 10 and you haven't tried out WSL (Windows Subsystem for Linux), try it! It's an amazingly useful amalgam of Windows and Linux that lets you run Linux scripts and binaries directly on your Windows machine.

As a simple example, I placed the following three lines in the pre-build script

Code: Select all

chdir /D $(ProjectDirectory)
bash.exe -c 'Project/BuildScripts/pre.sh'
Then I make the BuildScripts directory and create the following script file, using vim within a bash shell (to avoid any linefeed interpretation issues):

Code: Select all

pubs@PC-PUBS:/mnt/c/Users/pubs/Documents/my_test_project$ cat Project/BuildScripts/pre.sh
#!/bin/bash
find . -name "*.htm" > files.txt
After the build completes, there is a files.txt file in the project directory that shows all the HTML source filenames:
pubs@PC-PUBS:/mnt/c/Users/pubs/Documents/my_test_project$ ls -l files.txt
-rwxrwxrwx 1 root root 195719 Apr 10 10:15 files.txt
pubs@PC-PUBS:/mnt/c/Users/pubs/Documents/my_test_project$ wc files.txt
3163 4071 195719 files.txt
Note that these commands are running from within the Project directory in the Windows filesystem, but with the full power of just about anything you can run in Linux!

There is one wrinkle to pre-build and post-built scripts I haven't figured out yet, though. How can I get output from my build scripts included in the *.mclog file?
SteveS
Senior Propellus Maximus
Posts: 2089
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: Running WSL bash scripts as pre-build/post-build events

Post by SteveS »

But you can do that on the Windows command line:

Code: Select all

DIR *.* >> list.txt
:wink:
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Running WSL bash scripts as pre-build/post-build events

Post by nielsf »

Or PowerShell:
Get-ChildItem -Name -Recurse -Filter *.htm > files.txt
-----
Flaring in Copenhagen, Denmark
Post Reply