Skip to content

Commit a8d7a9e

Browse files
authored
chore: support go generate and mod (linuxdeepin#37)
* chore: support go generate and mod as title * chore: optimize directory structure - rename gir-generator to generator - move gi to generator/ - move go files from lib.in to generate dirs * chore: update license as title
1 parent 9237895 commit a8d7a9e

File tree

120 files changed

+27740
-8980
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+27740
-8980
lines changed

.reuse/dep5

+13-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@ Copyright: None
1414
License: CC0-1.0
1515

1616
# Project file
17-
Files: gogtk-demo/wscript lib.in/cairo-1.0/types_386.go lib.in/cairo-1.0/types_amd64.go
17+
Files:
18+
gio-2.0/*.h
19+
gio-2.0/*.c
20+
glib-2.0/*.h
21+
glib-2.0/*.c
22+
gobject-2.0/*.h
23+
gobject-2.0/*.c
24+
gudev-1.0/*.h
25+
gudev-1.0/*.c
26+
glib-2.0/testdata/deepin-terminal.desktop
27+
go.mod
28+
go.sum
1829
Copyright: None
1930
License: GPL-3.0-or-later
2031

@@ -29,7 +40,7 @@ Copyright: None
2940
License: CC0-1.0
3041

3142
# README
32-
Files: *.md src/gi/README README.zh_CN.md
43+
Files: *.md generator/gi/README README.zh_CN.md
3344
Copyright: UnionTech Software Technology Co., Ltd.
3445
License: CC-BY-4.0
3546

@@ -52,4 +63,3 @@ License: GPL-3.0-or-later
5263
Files: vendor/*
5364
Copyright: UnionTech Software Technology Co., Ltd.
5465
License: GPL-3.0-or-later
55-

Makefile

+5-44
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,16 @@
11
PREFIX = /usr
2-
GOBUILD = go build
3-
GOTEST = go build
4-
GORUN = go run
5-
OUT_GIR_DIR = out/src/github.com/linuxdeepin/go-gir/
6-
export GO111MODULE=off
72

83
all: build
94

10-
CURRENT_DIR = $(shell pwd)
11-
export GOPATH = $(CURDIR):$(CURDIR)/out
5+
build: test
126

13-
GENERATOR = out/gir-generator
14-
15-
build: glib-2.0 gobject-2.0 gio-2.0 gudev-1.0 copyfile
16-
17-
generator:
18-
mkdir -p $(OUT_GIR_DIR)
19-
cd src/gir-generator && ${GOBUILD} -o $(CURRENT_DIR)/${GENERATOR}
20-
21-
copyfile:
22-
cp -r lib.in/gobject-2.0 $(OUT_GIR_DIR)
23-
cp -r lib.in/gio-2.0 $(OUT_GIR_DIR)
24-
cp -r lib.in/glib-2.0 $(OUT_GIR_DIR)
25-
cp -r lib.in/gudev-1.0 $(OUT_GIR_DIR)
26-
27-
glib-2.0: lib.in/glib-2.0/glib.go.in lib.in/glib-2.0/config.json generator
28-
${GENERATOR} -o $(OUT_GIR_DIR)$@ $<
29-
30-
gobject-2.0: lib.in/gobject-2.0/gobject.go.in lib.in/gobject-2.0/config.json generator
31-
${GENERATOR} -o $(OUT_GIR_DIR)$@ $<
32-
33-
gio-2.0: lib.in/gio-2.0/gio.go.in lib.in/gio-2.0/config.json generator
34-
${GENERATOR} -o $(OUT_GIR_DIR)$@ $<
35-
36-
gudev-1.0: lib.in/gudev-1.0/gudev.go.in lib.in/gudev-1.0/config.json generator
37-
${GENERATOR} -o $(OUT_GIR_DIR)$@ $<
7+
generate:
8+
go generate ./...
389

3910
test:
40-
cd $(OUT_GIR_DIR)gobject-2.0 && ${GOTEST}
41-
cd $(OUT_GIR_DIR)gio-2.0 && ${GOTEST}
42-
cd $(OUT_GIR_DIR)glib-2.0 && ${GOTEST}
43-
cd $(OUT_GIR_DIR)gudev-1.0 && ${GOTEST}
44-
@echo "Memory Testing"
45-
#${GORUN} test/memory.go 阻塞打包
11+
go test github.com/linuxdeepin/go-gir/...
4612

4713
install:
48-
install -d $(DESTDIR)$(PREFIX)/share/gocode/src/github.com/linuxdeepin/go-gir $(DESTDIR)$(PREFIX)/bin
49-
cp -r $(OUT_GIR_DIR)* $(DESTDIR)$(PREFIX)/share/gocode/src/github.com/linuxdeepin/go-gir
50-
cp out/gir-generator $(DESTDIR)$(PREFIX)/bin/
51-
52-
clean:
53-
rm -fr out
14+
cp -r * $(DESTDIR)$(PREFIX)/share/gocode/src/github.com/linuxdeepin/go-gir
5415

5516
.PHONY: test

gen.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-FileCopyrightText: 2018 - 2022 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
package gir
6+
7+
//go:generate go run ./generator -o glib-2.0 lib.in/glib-2.0/glib.go.in
8+
//go:generate go run ./generator -o gobject-2.0 lib.in/gobject-2.0/gobject.go.in
9+
//go:generate go run ./generator -o gio-2.0 lib.in/gio-2.0/gio.go.in
10+
//go:generate go run ./generator -o gudev-1.0 lib.in/gudev-1.0/gudev.go.in

src/gir-generator/binding_generator.go renamed to generator/binding_generator.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77
"bufio"
88
"bytes"
99
"fmt"
10-
"gi"
1110
"os"
1211
"strings"
12+
13+
"github.com/linuxdeepin/go-gir/generator/gi"
1314
)
1415

1516
type binding_generator struct {

src/gir-generator/cairo.go renamed to generator/cairo.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package main
66

77
import (
88
"bytes"
9-
"gi"
9+
10+
"github.com/linuxdeepin/go-gir/generator/gi"
1011
)
1112

1213
func cairo_go_type_for_interface(bi *gi.BaseInfo, flags type_flags) string {
File renamed without changes.

src/gir-generator/function_builder.go renamed to generator/function_builder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package main
66

77
import (
8-
"gi"
8+
"github.com/linuxdeepin/go-gir/generator/gi"
99
)
1010

1111
type function_builder struct {
File renamed without changes.
File renamed without changes.

src/gir-generator/main.go renamed to generator/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import (
99
"encoding/json"
1010
"flag"
1111
"fmt"
12-
"gi"
1312
"io/ioutil"
1413
"os"
1514
"path/filepath"
1615
"strings"
16+
17+
"github.com/linuxdeepin/go-gir/generator/gi"
1718
)
1819

1920
var config config_type
File renamed without changes.

src/gir-generator/type.go renamed to generator/type.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ package main
99
import (
1010
"bytes"
1111
"fmt"
12-
"gi"
1312
"strings"
1413
"unsafe"
14+
15+
"github.com/linuxdeepin/go-gir/generator/gi"
1516
)
1617

1718
func force_pointer(x string) string {

src/gir-generator/typeconv.go renamed to generator/typeconv.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ package main
77
import (
88
"bytes"
99
"fmt"
10-
"gi"
1110
"strings"
11+
12+
"github.com/linuxdeepin/go-gir/generator/gi"
1213
)
1314

1415
func cgo_array_to_go_array(elem *gi.TypeInfo, name string) string {
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)