!******************************************************************************!
! Test BUILD command
!
! @Author:  Neon Ngo
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  if baseline then
    ! NXM-3755 since NeXtMidas 4.0.1
    invoke isGradleBuildCommand nxm.sys.lib.Shell.isGradleBuildCommand()
    invoke envNMCXXExists       java.lang.System.getEnv("NM_CXX")
    invoke envNMCCExists        java.lang.System.getEnv("NM_CC")
    if isGradleBuildCommand and envNMCXXExists eqs "NULL" and envNMCCExists eqs "NULL" then
      info "SKIPPING ^{reg.main.name} since fails inside Gradle build command when env vars NM_CXX and NM_CC are undefined"
    else
      ! since 2.9.0: test BUG 2302
      build/noexit/warn=false name=all area= opt=sys
      assert/text="^{reg.main.name}: BUILD all name= opt=SYS" TRUE

      ! native code compiling are generally not setup under Windows, so test under UNIX only
      if ^{env.NMROOT} EQS "classpath:" then
        INFO "^reg.main.name: Skipping building of native code as it is not included in JAR file"
      else

        if env.ostype eqs "UNIX" then
          ! since 3.3.1: test BUG 2507
          build/bldtypes=native/count=numCompiled * libm sys
          ! There is only 1 native file (Fft.c) under sys/libm at this time
          res expCount 1
          assert/text="^{reg.main.name}: 'BUILD/BLDTYPES=native * libm sys' built expected files" numCompiled == expCount
        else
          info "SKIPPING test for /BLDTYPES=Native switch under ^{ENV.OSTYPE}"
        endif
      endif
    endif
  endif

  %test_build_cmdstatus ! NXM-3780 Since NeXtMidas 4.1.2

endmacro

!******************************************************************************!
procedure processException m:emsg
  assert/text="^{reg.main.name}: Unexpected exception: ^emsg.data" FALSE
  if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
return