-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: binary constraints format (#514)
* Add compile cli cmd This adds a "compile" command to the CLI. This is where compilation will be controlled. A notion of "legacy" versus "non-legacy" is patched in. This goal here is to retain the ability to read legacy bin files using the original format (for now). However, writing them is not really supported at this time. * support binary encoding / decoding This adds support for binary encoding / decoding of HIR schema's via the gob format. To help ensure consistency between compiled source files and encoded binary files, all tests are additionally run through a filter which encodes and then decodes the file before running the test. This also makes a breaking constraint by using an option to implement the vanishing domain, instead of a pointer. This seems to serialise better.
- Loading branch information
1 parent
a725493
commit 3a770dd
Showing
50 changed files
with
702 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var compileCmd = &cobra.Command{ | ||
Use: "compile [flags] constraint_file(s)", | ||
Short: "compile constraints into a binary package.", | ||
Long: `Compile a given set of constraint file(s) into a single binary package which can | ||
be subsequently used without requiring a full compilation step.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if len(args) != 1 { | ||
fmt.Println(cmd.UsageString()) | ||
os.Exit(1) | ||
} | ||
stdlib := !GetFlag(cmd, "no-stdlib") | ||
debug := GetFlag(cmd, "debug") | ||
legacy := GetFlag(cmd, "legacy") | ||
output := GetString(cmd, "output") | ||
// Parse constraints | ||
hirSchema := readSchema(stdlib, debug, legacy, args) | ||
// Serialise as a gob file. | ||
writeHirSchema(hirSchema, legacy, output) | ||
}, | ||
} | ||
|
||
//nolint:errcheck | ||
func init() { | ||
rootCmd.AddCommand(compileCmd) | ||
compileCmd.Flags().Bool("debug", false, "enable debugging constraints") | ||
compileCmd.Flags().StringP("output", "o", "a.bin", "specify output file.") | ||
compileCmd.MarkFlagRequired("output") | ||
} |
Oops, something went wrong.