Search code examples
visual-studiobisonflex-lexer

Win flex-bison always returns 1 when inside Visual Studio 2015 but works when run manually


I installed Win flex-bison which integrates with VS. This allows the projects to contain .l and .y files. The problem is when I try to compile with VS I get

1>------ Build started: Project: pasms64, Configuration: Release Win32 ------
1>  Process "pasm64.l" flex file
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Addins\win_flex_bison-latest\custom_build_rules\win_flex_bison_custom_build.targets(129,5): error MSB3721: The command "call win_flex.exe --outfile="pasm64.flex.c" --wincompat --noline  "pasm64.l"" exited with code 1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

When I run manually from the command line it works fine.

C:\Users\jaret\OneDrive\Desktop\Pet\Pasm\pasm64>cd C:\Users\jaret\OneDrive\Desktop\Pet\Pasm\pasm64

C:\Users\jaret\OneDrive\Desktop\Pet\Pasm\pasm64>call win_flex.exe --outfile="pasm64.flex.c" --wincompat --noline  "pasm64.l"

C:\Users\jaret\OneDrive\Desktop\Pet\Pasm\pasm64>

The props files for VS

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup
    Condition="'$(BisonBeforeTargets)' == '' and '$(BisonAfterTargets)' == '' and '$(ConfigurationType)' != 'Makefile'">
    <BisonBeforeTargets>Midl</BisonBeforeTargets>
    <BisonAfterTargets>CustomBuild</BisonAfterTargets>
  </PropertyGroup>
  <PropertyGroup>
    <BisonDependsOn
      Condition="'$(ConfigurationType)' != 'Makefile'">_SelectedFiles;$(BisonDependsOn)</BisonDependsOn>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <Bison>
      <OutputFile>%(Filename).tab.cpp</OutputFile>
      <DefinesFile>%(Filename).tab.h</DefinesFile>
      <CommandLineTemplate>call win_bison.exe [AllOptions] [AdditionalOptions] "%(Filename)%(Extension)"</CommandLineTemplate>
      <Outputs>%(RootDir)%(Directory)%(OutputFile);</Outputs>
      <ExecutionDescription>Process "%(Filename)%(Extension)" bison file</ExecutionDescription>
    </Bison>
  </ItemDefinitionGroup>
  <PropertyGroup
    Condition="'$(FlexBeforeTargets)' == '' and '$(FlexAfterTargets)' == '' and '$(ConfigurationType)' != 'Makefile'">
    <FlexBeforeTargets>Midl</FlexBeforeTargets>
    <FlexAfterTargets>CustomBuild</FlexAfterTargets>
  </PropertyGroup>
  <PropertyGroup>
    <FlexDependsOn
      Condition="'$(ConfigurationType)' != 'Makefile'">_SelectedFiles;$(FlexDependsOn)</FlexDependsOn>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <Flex>
      <OutputFile>%(Filename).flex.cpp</OutputFile>
      <Wincompat>true</Wincompat>
      <CommandLineTemplate>call win_flex.exe [AllOptions] [AdditionalOptions] "%(Filename)%(Extension)"</CommandLineTemplate>
      <Outputs>%(RootDir)%(Directory)%(OutputFile);</Outputs>
      <ExecutionDescription>Process "%(Filename)%(Extension)" flex file</ExecutionDescription>
    </Flex>
  </ItemDefinitionGroup>
</Project>

My question why does this not work when run from the props file. and is there anything I can do to fix this.


Solution

  • The issue is a path issue. I figured this out by using a custom build step. When I used full path for the files it works as expected. There is nothing worse than a silent failure,