Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ All of the following inputs are optional.
- `coverage`:
- Boolean that determines whether code coverage is turned on by adding `--coverage` to `CFLAGS`, `CXXFLAGS` and `LDFLAGS`.
- default: `'true'`
- `CONFIGFLAGS`:
- Additional arguments to be passed to configure.
- default: `''`
- `build-needed-pkgs`:
- Build packages needed by this package. Options are: true, false, recursive.
- default: `'recursive'`
- `build-suggested-pkgs`:
- Build packages suggested by this package. Options are: true, false, recursive.
- default: `'true'`
- `build-extensions`:
- Build packages needed for extensions by this package. Options are: true, false, recursive.
- default: `'true'`

### What's new in v3

- The inputs `build-needed-pkgs`, `build-suggested-pkgs` and `build-extensions` were
added. Setting these to `true` will also compile the relevant dependencies, and setting
them to `recursive` will also compile the dependencies' dependencies, etc.

### What's new in v2

Expand Down Expand Up @@ -43,9 +61,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: gap-actions/setup-gap@v2
- uses: gap-actions/build-pkg@v1
- uses: actions/checkout@v6
- uses: gap-actions/setup-gap@v3
- uses: gap-actions/build-pkg@v3
```

## Contact
Expand Down
224 changes: 125 additions & 99 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,115 +32,141 @@ env:
runs:
using: "composite"
steps:
- name: "Validate input"
shell: bash
run: |
validate_boolean() {
local input=$1
local option_name=$2
if ! [[ "$input" =~ ^(true|false)$ ]]; then
echo "::error::Invalid value for option $option_name. Expected 'true' or 'false', but found '$input'"
exit 1;
fi
}

validate_opts() {
local input=$1
local option_name=$2
if ! [[ "$input" =~ ^(true|false|recursive)$ ]]; then
echo "::error::Invalid value for option $option_name. Expected 'true', 'false' or 'recursive' but found '$input'"
exit 1;
fi
}

validate_boolean "${{ inputs.coverage }}" coverage
validate_opts "${{ inputs.build-needed-pkgs }}" build-needed-pkgs
validate_opts "${{ inputs.build-suggested-pkgs }}" build-suggested-pkgs
validate_opts "${{ inputs.build-extensions }}" build-extensions

- name: "Build the package itself"
shell: bash
run: |
set -ex

GAPROOT=${GAPROOT-$HOME/gap}

# ensure coverage is turned on
if [[ "${{ inputs.coverage }}" = "true" ]]; then
export CFLAGS="$CFLAGS --coverage"
export CXXFLAGS="$CXXFLAGS --coverage"
export LDFLAGS="$LDFLAGS --coverage"
fi

# adjust build flags for 32bit builds
if [[ "${{ inputs.ABI }}" = 32 ]]; then
export CFLAGS="$CFLAGS -m32"
export CXXFLAGS="$CXXFLAGS -m32"
export LDFLAGS="$LDFLAGS -m32"
fi

# build this package, if necessary
if [[ -x prerequisites.sh ]]; then
./prerequisites.sh $GAPROOT
fi
if [[ -x autogen.sh ]]; then
./autogen.sh
fi
if grep Autoconf ./configure > /dev/null
then
./configure --with-gaproot=$GAPROOT ${{ inputs.CONFIGFLAGS }}
make -j4 V=1
elif [[ -x configure ]]; then
./configure ${{ inputs.CONFIGFLAGS }} $GAPROOT
make -j4 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS"
fi
set -ex

GAPROOT=${GAPROOT-$HOME/gap}

# ensure coverage is turned on
if [[ "${{ inputs.coverage }}" = "true" ]]; then
export CFLAGS="$CFLAGS --coverage"
export CXXFLAGS="$CXXFLAGS --coverage"
export LDFLAGS="$LDFLAGS --coverage"
fi

# adjust build flags for 32bit builds
if [[ "${{ inputs.ABI }}" = 32 ]]; then
export CFLAGS="$CFLAGS -m32"
export CXXFLAGS="$CXXFLAGS -m32"
export LDFLAGS="$LDFLAGS -m32"
fi

# build this package, if necessary
if [[ -x prerequisites.sh ]]; then
./prerequisites.sh $GAPROOT
fi
if [[ -x autogen.sh ]]; then
./autogen.sh
fi
if grep Autoconf ./configure > /dev/null
then
./configure --with-gaproot=$GAPROOT ${{ inputs.CONFIGFLAGS }}
make -j4 V=1
elif [[ -x configure ]]; then
./configure ${{ inputs.CONFIGFLAGS }} $GAPROOT
make -j4 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS"
fi

- name: "Determine the package's dependencies"
shell: bash
run: |
$GAP -A -q <<GAPInput
# Get the name of this package
Read("PackageInfo.g");;
orig := LowercaseString( GAPInfo.PackageInfoCurrent.PackageName );;

todo := [ orig ];;
done := [];;
depth := 1;

while not IsEmpty( todo ) do
curr := Remove( todo );
Print( "Now handling package '", curr, "' (depth ",depth,")\n");
AddSet( done, curr );
info := GAPInfo.PackagesInfo.(curr)[1];

# Needed packages
if ( IsBound( info.Dependencies.NeededOtherPackages ) and (
"${{ inputs.build-needed-pkgs }}" = "recursive" or
( "${{ inputs.build-needed-pkgs }}" = "true" and depth = 1 )
)) then
for pkg in info.Dependencies.NeededOtherPackages do
name := LowercaseString( pkg[1] );
Print( " - needs package '", name, "'\n" );
if not name in done then
AddSet( todo, name );
fi;
od;
# Get the name of this package
Read("PackageInfo.g");;
orig := LowercaseString( GAPInfo.PackageInfoCurrent.PackageName );;

todo := [ orig ];;
done := [];;
depth := 1;

while not IsEmpty( todo ) do
curr := Remove( todo );
Print( "Now handling package '", curr, "' (depth ",depth,")\n");
AddSet( done, curr );
info := GAPInfo.PackagesInfo.(curr)[1];

# Needed packages
if ( IsBound( info.Dependencies.NeededOtherPackages ) and (
"${{ inputs.build-needed-pkgs }}" = "recursive" or
( "${{ inputs.build-needed-pkgs }}" = "true" and depth = 1 )
)) then
for pkg in info.Dependencies.NeededOtherPackages do
name := LowercaseString( pkg[1] );
Print( " - needs package '", name, "'\n" );
if not name in done then
AddSet( todo, name );
fi;

# Suggested packages
if ( IsBound( info.Dependencies.SuggestedOtherPackages ) and (
"${{ inputs.build-suggested-pkgs }}" = "recursive" or
( "${{ inputs.build-suggested-pkgs }}" = "true" and depth = 1 )
)) then
for pkg in info.Dependencies.SuggestedOtherPackages do
name := LowercaseString( pkg[1] );
Print( " - suggests package '", name, "'\n" );
if not name in done then
AddSet( todo, name );
fi;
od;
od;
fi;

# Suggested packages
if ( IsBound( info.Dependencies.SuggestedOtherPackages ) and (
"${{ inputs.build-suggested-pkgs }}" = "recursive" or
( "${{ inputs.build-suggested-pkgs }}" = "true" and depth = 1 )
)) then
for pkg in info.Dependencies.SuggestedOtherPackages do
name := LowercaseString( pkg[1] );
Print( " - suggests package '", name, "'\n" );
if not name in done then
AddSet( todo, name );
fi;

# Package extensions
if ( IsBound( info.Extensions ) and (
"${{ inputs.build-extensions }}" = "recursive" or
( "${{ inputs.build-extensions }}" = "true" and depth = 1 )
)) then
for ext in info.Extensions do
for pkg in ext.needed do
name := LowercaseString( pkg[1] );
Print( " - needs package '", name, "' for an extension\n" );
if not name in done then
AddSet( todo, name );
fi;
od;
od;
fi;

depth := depth + 1;;
od;

# We already built the package being tested!
RemoveSet( done, orig );;

# Cannot use RUNNER_TEMP on Cygwin...
PrintTo( "__GAP_PKGS_TO_BUILD__.txt", JoinStringsWithSeparator( done, " " ) );

QUIT;
od;
fi;

# Package extensions
if ( IsBound( info.Extensions ) and (
"${{ inputs.build-extensions }}" = "recursive" or
( "${{ inputs.build-extensions }}" = "true" and depth = 1 )
)) then
for ext in info.Extensions do
for pkg in ext.needed do
name := LowercaseString( pkg[1] );
Print( " - needs package '", name, "' for an extension\n" );
if not name in done then
AddSet( todo, name );
fi;
od;
od;
fi;

depth := depth + 1;;
od;

# We already built the package being tested!
RemoveSet( done, orig );;

# Cannot use RUNNER_TEMP on Cygwin...
PrintTo( "__GAP_PKGS_TO_BUILD__.txt", JoinStringsWithSeparator( done, " " ) );

QUIT;
GAPInput

# ... so put the contents in an environement variable ...
Expand Down