Skip to content

[Feature] --input-dir option for 'batch-compile' subcommand

Problem this merge request solves

See #40

New Behavior

  • Allow multiple source files/directories without specifying an 'input-dir'
  • Only allow files inside 'input-dir' if '--input-dir' option was provided
  • Compile every .blp file inside 'input dir' if only 'input-dir' is provided along with an 'output-dir'

Important Note

Pipeline failed not because of some bug but because blueprint-regression-tests' blueprint-compiler commands are not yet updated for the new behavior of batch-compile subcommand introduced in this merge request

Example Commands and their Results

Let's assume we have a directory named 'indir' with following structure

 external.blp
 indir
├──  dir1
│  ├──  dir4
│  │  ├──  dir5
│  │  │  ├──  file8.blp
│  │  │  └──  file9.ext
│  │  └──  file5.blp
│  ├──  dir6
│  │  └──  file6.blp
│  └──  file3.blp
├──  dir2
│  ├──  dir7
│  │  └──  file7.blp
│  └──  file4.blp
├──  dir3
├──  file1.blp
└──  file2.ext
  • When --input-dir is provided
    • Command

      blueprint-compiler batch-compile outdir --input-dir=indir

      Result

       outdir
      ├──  dir1
      │  ├──  dir4
      │  │  ├──  dir5
      │  │  │  └──  file8.ui
      │  │  └──  file5.ui
      │  ├──  dir6
      │  │  └──  file6.ui
      │  └──  file3.ui
      ├──  dir2
      │  ├──  dir7
      │  │  └──  file7.ui
      │  └──  file4.ui
      └──  file1.ui

      Note: indir/file2.ext and indir/dir1/dir4/dir5/file9.ext are ignored since they are not blueprint files. And outdir has the same structure as indir.

    • Command

      blueprint-compiler batch-compile outdir indir/dir1/dir4 indir/dir2/file4.blp indir/file2.ext --input-dir=indir

      Result

       outdir
      ├──  dir1
      │  └──  dir4
      │     ├──  dir5
      │     │  └──  file8.ui
      │     └──  file5.ui
      ├──  dir2
      │  └──  file4.ui
      └──  file2.ui

      Note: outdir has the same structure as indir but only contains provided files/directories. And file2.ext was also compiled because even though it's extension is not .blp, it was explicitly provided on command-line.

    • Command

      blueprint-compiler batch-compile outdir indir/file1.blp external.blp indir/file2.ext --input-dir=indir

      Result

       outdir
      └──  file1.ui

      Error Message

      error: input file/directory 'external.blp' is not in input directory 'indir'

      Note: Compiler error-ed out when trying to compile external.blp. So, file1.blp was compiled because it was provided (and hence processed) before external.blp but file2.ext was not compiled because it was provided (and hence was supposed to be processed) after external.blp.

  • When --input-dir is not provided
    • Command

      blueprint-compiler batch-compile outdir indir

      Result

       outdir
      └──  indir
         ├──  dir1
         │  ├──  dir4
         │  │  ├──  dir5
         │  │  │  └──  file8.ui
         │  │  └──  file5.ui
         │  ├──  dir6
         │  │  └──  file6.ui
         │  └──  file3.ui
         ├──  dir2
         │  ├──  dir7
         │  │  └──  file7.ui  
         │  └──  file4.ui
         └──  file1.ui

      Note: indir/file2.ext and indir/dir1/dir4/dir5/file9.ext are ignored since they are not blueprint files. And indir has become a sub-directory of outdir.

    • Command

      blueprint-compiler batch-compile outdir indir/dir1/dir4 indir/dir2/file4.blp external.blp

      Result

       outdir
      ├──  dir4
      │  ├──  dir5
      │  │  └──  file8.ui
      │  └──  file5.ui
      ├──  external.ui
      └──  file4.ui

      Note: All three sources (dir4, file4.blp, and external.blp) are put directly in outdir. And the source directory dir4 has retained it internal structure.

    • Command

      # What user types
      blueprint-compiler batch-compile outdir indir/*
      # What shell executes
      blueprint-compiler batch-compile outdir indir/dir1 indir/dir2 indir/dir3 indir/file1.blp indir/file2.ext

      Result

       outdir
      ├──  dir1
      │  ├──  dir4
      │  │  ├──  dir5
      │  │  │  └──  file8.ui
      │  │  └──  file5.ui
      │  ├──  dir6
      │  │  └──  file6.ui
      │  └──  file3.ui
      ├──  dir2
      │  ├──  dir7
      │  │  └──  file7.ui
      │  └──  file4.ui
      ├──  file1.ui
      └──  file2.ui

      Note: outdir has the same directory structure as indir. And file2.ext was also compiled because it was provided explicitly but file9.ext was not compiled because it was not provided explicitly.

Edited by Mazhar Hussain

Merge request reports