1
- all : gen extractor
1
+ all : extractor ql/lib/go.dbscheme
2
+
3
+ ifeq ($(OS ) ,Windows_NT)
4
+ EXE = .exe
5
+ CODEQL_PLATFORM = win64
6
+ else
7
+ EXE =
8
+ UNAME_S := $(shell uname -s)
9
+ ifeq ($(UNAME_S ) ,Linux)
10
+ CODEQL_PLATFORM = linux64
11
+ endif
12
+ ifeq ($(UNAME_S ) ,Darwin)
13
+ CODEQL_PLATFORM = osx64
14
+ endif
15
+ endif
16
+
17
+ CODEQL_TOOLS = $(addprefix codeql-tools/,autobuild.cmd autobuild.sh baseline-config-empty.json baseline-config-vendor.json configure-baseline.cmd configure-baseline.sh identify-environment.cmd identify-environment.sh index.cmd index.sh pre-finalize.cmd pre-finalize.sh tracing-config.lua)
2
18
3
19
EXTRACTOR_PACK_OUT = build/codeql-extractor-go
4
20
5
- .PHONY : extractor gen clean autoformat check-formatting
21
+ BINARIES = go-extractor go-tokenizer go-autobuilder go-build-runner go-bootstrap go-gen-dbscheme
22
+
23
+ .PHONY : tools tools-codeql tools-codeql-full clean autoformat \
24
+ tools-linux64 tools-osx64 tools-win64 check-formatting
6
25
7
26
clean :
27
+ rm -rf tools/bin tools/linux64 tools/osx64 tools/win64 tools/net tools/opencsv
8
28
rm -rf $(EXTRACTOR_PACK_OUT ) build/stats build/testdb
9
29
10
30
autoformat :
@@ -27,11 +47,66 @@ endif
27
47
qhelp-to-markdown :
28
48
scripts/qhelp-to-markdown.sh ql/src " $( QHELP_OUT_DIR) "
29
49
30
- extractor :
31
- bazel run :create-extractor-pack
50
+ tools : tools-codeql tools/tokenizer.jar
51
+
52
+ .PHONY : $(addsuffix $(EXE ) ,$(addprefix tools/bin/,$(BINARIES ) ) )
53
+ $(addsuffix $(EXE ) ,$(addprefix tools/bin/,$(BINARIES ) ) ) :
54
+ go build -C extractor -mod=vendor -o ../$@ ./cli/$(basename $(@F ) )
55
+
56
+ tools-codeql : tools-$(CODEQL_PLATFORM )
57
+
58
+ tools-codeql-full : tools-linux64 tools-osx64 tools-win64
59
+
60
+ tools-linux64 : $(addprefix tools/linux64/,$(BINARIES ) )
61
+
62
+ .PHONY : $(addprefix tools/linux64/,$(BINARIES ) )
63
+ $(addprefix tools/linux64/,$(BINARIES ) ) :
64
+ GOOS=linux GOARCH=amd64 go build -C extractor -mod=vendor -o ../$@ ./cli/$(@F )
65
+
66
+ tools-osx64 : $(addprefix tools/osx64/,$(BINARIES ) )
67
+
68
+ .PHONY : $(addprefix tools/osx64/,$(BINARIES ) )
69
+ $(addprefix tools/osx64/,$(BINARIES ) ) :
70
+ GOOS=darwin GOARCH=amd64 go build -C extractor -mod=vendor -o ../$@ .amd64 ./cli/$(@F )
71
+ GOOS=darwin GOARCH=arm64 go build -C extractor -mod=vendor -o ../$@ .arm64 ./cli/$(@F )
72
+ lipo -create $@ .amd64 $@ .arm64 -output $@
73
+ rm $@ .amd64 $@ .arm64
74
+
75
+ tools-win64 : $(addsuffix .exe,$(addprefix tools/win64/,$(BINARIES ) ) )
76
+
77
+ .PHONY : $(addsuffix .exe,$(addprefix tools/win64/,$(BINARIES ) ) )
78
+ $(addsuffix .exe,$(addprefix tools/win64/,$(BINARIES ) ) ) :
79
+ env GOOS=windows GOARCH=amd64 go build -C extractor -mod=vendor -o ../$@ ./cli/$(basename $(@F ) )
80
+
81
+ .PHONY : extractor-common extractor extractor-full
82
+ extractor-common : codeql-extractor.yml LICENSE ql/lib/go.dbscheme \
83
+ tools/tokenizer.jar $(CODEQL_TOOLS )
84
+ rm -rf $(EXTRACTOR_PACK_OUT )
85
+ mkdir -p $(EXTRACTOR_PACK_OUT )
86
+ cp codeql-extractor.yml LICENSE ql/lib/go.dbscheme ql/lib/go.dbscheme.stats $(EXTRACTOR_PACK_OUT )
87
+ mkdir $(EXTRACTOR_PACK_OUT ) /tools
88
+ cp -r tools/tokenizer.jar $(CODEQL_TOOLS ) $(EXTRACTOR_PACK_OUT ) /tools
89
+ cp -r downgrades $(EXTRACTOR_PACK_OUT )
90
+
91
+ extractor : extractor-common tools-codeql
92
+ cp -r tools/$(CODEQL_PLATFORM ) $(EXTRACTOR_PACK_OUT ) /tools
93
+
94
+ extractor-full : extractor-common tools-codeql-full
95
+ cp -r $(addprefix tools/,linux64 osx64 win64) $(EXTRACTOR_PACK_OUT ) /tools
96
+
97
+ tools/tokenizer.jar : tools/net/sourceforge/pmd/cpd/GoLanguage.class
98
+ jar cf $@ -C tools net
99
+ jar uf $@ -C tools opencsv
100
+
101
+ tools/net/sourceforge/pmd/cpd/GoLanguage.class : extractor/net/sourceforge/pmd/cpd/GoLanguage.java
102
+ javac -cp extractor -d tools $<
103
+ rm tools/net/sourceforge/pmd/cpd/AbstractLanguage.class
104
+ rm tools/net/sourceforge/pmd/cpd/SourceCode.class
105
+ rm tools/net/sourceforge/pmd/cpd/TokenEntry.class
106
+ rm tools/net/sourceforge/pmd/cpd/Tokenizer.class
32
107
33
- gen :
34
- bazel run :gen
108
+ ql/lib/go.dbscheme : tools/ $( CODEQL_PLATFORM ) /go-gen-dbscheme $( EXE )
109
+ $< $@
35
110
36
111
build/stats/src.stamp :
37
112
mkdir -p $(@D ) /src
@@ -48,7 +123,7 @@ test: all build/testdb/check-upgrade-path
48
123
codeql test run -j0 ql/test --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency --compilation-cache=$(cache )
49
124
# use GOOS=linux because GOOS=darwin GOARCH=386 is no longer supported
50
125
env GOOS=linux GOARCH=386 codeql$(EXE) test run -j0 ql/test/query-tests/Security/CWE-681 --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency --compilation-cache=$(cache)
51
- cd extractor; bazel test ...
126
+ cd extractor; go test -mod=vendor ./ ...
52
127
bash extractor-smoke-test/test.sh || (echo "Extractor smoke test FAILED"; exit 1)
53
128
54
129
.PHONY : build/testdb/check-upgrade-path
0 commit comments