MarlinFirmware / Configurations

Configurations for Marlin Firmware
https://marlinfw.org
GNU General Public License v3.0
1.98k stars 3.33k forks source link

🔧 Update supported Simulator displays #1049

Closed thisiskeithb closed 1 month ago

thisiskeithb commented 2 months ago

Description

Benefits

More complete list of supported displays in Simulator config.

Related Issues

thisiskeithb commented 2 months ago

Silly CI test! BOARD_SIMULATED is valid: https://github.com/MarlinFirmware/Marlin/blob/af8dcc6ee8cdc86b879ce7bc0ee9d799d5597270/Marlin/src/core/boards.h#L533-L537

//
// Simulations
//

#define BOARD_SIMULATED               9999

Hmm. That board number doesn't match what's reported in the CI error:

Error: Can't find target(s) for SIMULATED (999).

thisiskeithb commented 2 months ago

@ellensp found a CI workaround: Add a comment after 9999 in boards.h like the other boards. i.e.:

//
// Simulations
//

#define BOARD_SIMULATED               9999  // Native or Simulation
ellensp commented 2 months ago

First issue is with regular expression

BNUM=$( sed -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )

expects there to be characters after the board number eg

#define BOARD_CUSTOM                  9998  // Custom pins definition for development and/or rare boards

but the one we want does not have anything after the number

#define BOARD_SIMULATED               9999

This returns 999

this is the fix

BNUM=$( sed -E 's/^.+BOARD_[^ ]+ +([0-9]+)(.|$)+$/\1/' <<<"$BLINE" )
thisiskeithb commented 2 months ago

this is the fix

CI still fails, but it now reports the correct board number (9999).

ellensp commented 2 months ago

Second issue

ENVS=( $( grep -EA1 "MB\(.*\b$MB\b.*\)" Marlin/src/pins/pins.h | grep -E "#include.+//.+env:[^ ]+" | grep -oE "env:[^ ]+" | sed -E "s/env://" ) )

Is looking for env: in the pins line for the motherboard.

bur the simulator is special and does not have envs:

#elif MB(SIMULATED)
  #include "linux/pins_RAMPS_LINUX.h"               // Native or Simulation                 lin:linux_native mac:simulator_macos_debug mac:simulator_macos_release win:simulator_windows lin:simulator_linux_debug lin:simulator_linux_release

It has lin:, win:, and mac:

ellensp commented 2 months ago

This updated line seems to fix it…

ENVS=( $( grep -EA1 "MB\(.*\b$MB\b.*\)" Marlin/src/pins/pins.h | grep -E "(#include.+//.+)(env|lin):[^ ]+" | grep -oE "(env|lin):[^ ]+" | sed -E "s/(env|lin)://" ) )

resulting in: Building environment linux_native for board SIMULATED (9999)... Edit: linux_native is not correct for simulator

ellensp commented 2 months ago

default env should not be linux native for the simulator force it to use simulator_linux_release try this (reverts the lin: search and checks for the special case SIMULATED)

    # For each directory containing a changed config file, copy the .h files and build the code:
    - name: Test all changed config files
      run: |
        cd Marlin
        IFS=$'\n'
        for dir in $DIRS; do
          # Copy all .h files from the directory into the Marlin subfolder
          echo "Building Configurations in $dir ..."
          cp ../"$dir"/*.h Marlin/

          # Strip out #error lines so it can build
          sed -i~ -e "20,30{/#error/d}" "Marlin/Configuration.h"
          rm -f "Marlin/Configuration.h~"

          # Build Marlin with PlatformIO
          MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | sed 's/BOARD_//;s/\r//' )
          [[ -z $MB ]] && { echo "::error::Can't read MOTHERBOARD setting." ; exit 3; }

          BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h )
          BNUM=$( sed -E 's/^.+BOARD_[^ ]+ +([0-9]+)(.|$)+$/\1/' <<<"$BLINE" )
          BDESC=$( sed -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
          [[ -z $BNUM ]] && { echo "::error::Can't find BOARD_$MB in core/boards.h." ; exit 3; }
          if [ "$MB" == "SIMULATED" ]
          then
            ENVS=$"simulator_linux_release"
          else
            ENVS=( $( grep -EA1 "MB\(.*\b$MB\b.*\)" Marlin/src/pins/pins.h | grep -E "#include.+//.+env:[^ ]+" | grep -oE "env:[^ ]+" | sed -E "s/env://" ) )
          fi
          [[ -z $ENVS ]] && { echo "::error::Can't find target(s) for $MB ($BNUM)." ; exit 3; }
          [[ ${#ENVS[*]} == 1 ]] && TARGET=$ENVS || TARGET="${ENVS[0]}"

          echo "Building environment $TARGET for board $MB ($BNUM)..." ; echo
          pio run -s -e $TARGET

          # Reset the repo directory so the next iteration starts clean
          git reset --hard HEAD
        done
ellensp commented 2 months ago

this is now the virtual machine needing the following installed to build the sim gcc [9.3.0, 10.2.0]: libsdl2-dev[2.0.10], libsdl2-net-dev[2.0.1], libglm-dev[0.9.9.7, 0.9.9.8]

thisiskeithb commented 2 months ago

I've moved CI fixes to #1050

thisiskeithb commented 2 months ago

Rebased on current import-2.1.x since https://github.com/MarlinFirmware/Configurations/pull/1050 has been merged.