facebookarchive / xcbuild

Xcode-compatible build tool.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lex rules seem to hang

copumpkin opened this issue · comments

I'm trying to build adv_cmds (see here) and its mklocale build includes a sourcecode.lex step. As far as I can tell, xcbuild seems to invoke lex with no arguments, which just leaves it sitting waiting for input from stdin.

=== BUILD TARGET mklocale OF PROJECT adv_cmds WITH THE DEFAULT CONFIGURATION (Release) ===

Check dependencies

Write auxiliary files
write-file ./adv_cmds-dtrwmxwjdzlxpehhrqyfsyxzuhrx/Build/Intermediates/adv_cmds.build/Release/mklocale.build/Objects-normal/x86_64/mklocale.LinkFileList

Create product structure


    cd /private/var/folders/6j/566zczg137j_zbvhjh2zcpr80000gn/T/nix-build-adv_cmds-osx-10.11.6.drv-0/adv_cmds-163
    export DEVELOPER_DIR=/nix/store/kh862djq5h916c8bfhsrakhbgcwimin8-xcbuild-wrapper
    export PATH=...
    /nix/store/l9bwg5h8071921w7vw8vg8jg6a6gzgcj-nixpkgs.xctoolchain/usr/bin/lex

That last line is normally where xcbuild prints out the invocation before running it, so it seems to just be calling lex with no arguments and (seemingly) no stdin. I checked against the standard macOS lex and that also sits waiting for input on stdin.

I see that xcbuild has a spec for sourcecode.lex and I can see nothing obviously wrong with it, so I'm kinda stumped.

@grp @matthewbauer anything obviously wrong here?

Yeah, so for whatever reason xcbuild is not passing the input file to Lex. This file seems to be correct, though:

https://github.com/facebook/xcbuild/blob/master/Specifications/Tool/com.apple.compilers.lex.xcspec#L10-L61

compared to Lex.xcspec from Xcode SDK:

{   Identifier = com.apple.compilers.lex;
    Type = Tool;
    Name = "Lex";
    Class = PBXCompilerSpecificationLex;
    Description = "Lex Scanner Generator";
    ExecPath = "$(LEX)";
    ExecDescription = "Lex $(InputFile)";
    ProgressDescription = "Lexing $(CommandProgressByType) files";
    InputFileTypes = (sourcecode.lex);
    BuiltinJambaseRuleName = "ProcessUsingLex";
    IsArchitectureNeutral = YES;
    Options = (
        // Build options
        {   Name = LEX_CASE_INSENSITIVE_SCANNER;
            Type = Boolean;
            DefaultValue = NO;
            Category = BuildOptions;
            CommandLineFlag = "-i";
        },
        {   Name = LEX_SUPPRESS_DEFAULT_RULE;
            Type = Boolean;
            DefaultValue = NO;
            Category = BuildOptions;
            CommandLineFlag = "-s";
        },
        {   Name = LEX_INSERT_LINE_DIRECTIVES;
            Type = Boolean;
            DefaultValue = YES;
            Category = BuildOptions;
            CommandLineArgs = {
                NO = ("-L");
            };
        },
        {   Name = LEXFLAGS;
            Type = StringList;
            DefaultValue = ""; 
            FileTypes = (
                sourcecode.lex
            );
            Category = BuildOptions;
        },

        // Warnings
        {   Name = LEX_SUPPRESS_WARNINGS;
            Type = Boolean;
            DefaultValue = NO;
            Category = Warnings;
            CommandLineFlag = "-w";
        },
    );
}

I think we need a "LexResolver.cpp" file like these:

https://github.com/facebook/xcbuild/tree/0dce61fb1b87525d2bd1b50272c6abfcb2e0cfd4/Libraries/pbxbuild/Sources/Tool