1
+ .PHONY : build
2
+ build :
1
3
2
- # prepare system for build
3
- prepare :
4
- @echo " Preparing system for build..."
4
+ PROTOC_IMAGE =ocsf-schema-golang-protoc
5
+ PROTOC_VERSION =0.1.2
5
6
6
- sudo apt-get update
7
+ protocontainer :
8
+ docker build --load -t $(PROTOC_IMAGE ) :$(PROTOC_VERSION ) -f dev/protoc/protoc.Dockerfile dev/protoc/
7
9
8
- # install protobuf-compiler
9
- sudo apt-get install -y protobuf-compiler
10
- export PATH="$PATH:$(go env GOPATH)/bin"
11
- go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
12
- protoc --version
10
+ generate-proto : protocontainer
11
+ docker run --rm \
12
+ --mount type=bind,source= " $( PWD ) " ,target=/build \
13
+ $( PROTOC_IMAGE ) : $( PROTOC_VERSION ) \
14
+ generate-proto.sh
13
15
14
- # install jq
15
- sudo apt-get install -y jq
16
+ generate-go : protocontainer
17
+ docker run --rm \
18
+ --mount type=bind,source=" $( PWD) " ,target=/build \
19
+ $(PROTOC_IMAGE ) :$(PROTOC_VERSION ) \
20
+ generate-go.sh
16
21
17
- # install ocsf-tool
18
- make install-ocsf-tool
19
-
20
- # install buf
21
- make install-buf
22
-
23
- @echo "System is ready for build."
24
-
25
- # install homebrew
26
- install-homebrew :
27
- @echo " Installing homebrew..."
28
- curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash
29
-
30
- install-buf : install-homebrew
31
- @echo " Installing buf..."
32
- /home/linuxbrew/.linuxbrew/bin/brew install bufbuild/buf/buf
33
-
34
- # install ocsf-tool
35
- install-ocsf-tool :
36
- @echo " Installing latest version of ocsf-tool..."
37
- curl -sfL https://raw.githubusercontent.com/valllabh/ocsf-tool/main/download/download.sh | bash
38
-
39
- create-proto-files :
40
- @echo " Getting event list..."
41
- ./ocsf-tool/ocsf-tool schema-class-list --output ./schema/schema-class-list.json
42
-
43
- @echo "Creating proto files..."
44
- jq -r "[.[] | to_entries[] | .value] | join(\" \")" ./schema/schema-class-list.json | xargs ./ocsf-tool/ocsf-tool generate-proto --golang-root-package / --proto-output ./proto
45
-
46
- compile-proto : clean-output
47
- @echo " Compiling proto files..."
48
- /home/linuxbrew/.linuxbrew/bin/buf generate
49
-
50
- @echo " Preparing Enum Value Map..."
51
- bash ./enum-value/enum-value-map.sh
52
-
53
- clean-output :
54
- @echo " Cleaning output directory..."
55
- rm -rf ./ocsf
56
-
57
- generate-documentation :
58
- gomarkdoc ./ >> docs.md
59
-
60
- build : create-proto-files compile-proto
61
- @echo " Building Finished."
22
+ generate : generate-proto generate-go
0 commit comments