mirror of
				https://github.com/glebarez/go-sqlite.git
				synced 2025-10-31 11:06:26 +08:00 
			
		
		
		
	Update generator.go.
modified: generator.go modified: main.c
This commit is contained in:
		
							
								
								
									
										40
									
								
								generator.go
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								generator.go
									
									
									
									
									
								
							| @@ -77,8 +77,6 @@ func ftrace(s string, args ...interface{}) { | |||||||
| 	fmt.Fprintf(os.Stderr, "# %%s:%%d: %%v\n", path.Base(fn), fl, fmt.Sprintf(s, args...)) | 	fmt.Fprintf(os.Stderr, "# %%s:%%d: %%v\n", path.Base(fn), fl, fmt.Sprintf(s, args...)) | ||||||
| 	os.Stderr.Sync() | 	os.Stderr.Sync() | ||||||
| } | } | ||||||
|  |  | ||||||
| func Xsqlite3PendingByte() int32 { return _sqlite3PendingByte } |  | ||||||
| ` | ` | ||||||
|  |  | ||||||
| 	prologueTest = `// Code generated by ccgo. DO NOT EDIT. | 	prologueTest = `// Code generated by ccgo. DO NOT EDIT. | ||||||
| @@ -118,7 +116,6 @@ func main() { | |||||||
| 		#define SQLITE_WITHOUT_MSIZE 1 | 		#define SQLITE_WITHOUT_MSIZE 1 | ||||||
|  |  | ||||||
| 		int sqlite3PendingByte; | 		int sqlite3PendingByte; | ||||||
|  |  | ||||||
| 		` | 		` | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -170,7 +167,7 @@ func errStr(err error) string { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func build(predef string, tus [][]string, qualifiers []string, opts ...cc.Opt) ([]*cc.TranslationUnit, []byte) { | func build(predef string, tus [][]string, ccgoOpts []ccgo.Option, opts ...cc.Opt) ([]*cc.TranslationUnit, []byte) { | ||||||
| 	ndbg := "" | 	ndbg := "" | ||||||
| 	if *ndebug { | 	if *ndebug { | ||||||
| 		ndbg = "#define NDEBUG 1" | 		ndbg = "#define NDEBUG 1" | ||||||
| @@ -231,7 +228,7 @@ func build(predef string, tus [][]string, qualifiers []string, opts ...cc.Opt) ( | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	var out buffer.Bytes | 	var out buffer.Bytes | ||||||
| 	if err := ccgo.New(build, &out, ccgo.Packages(qualifiers)); err != nil { | 	if err := ccgo.New(build, &out, ccgoOpts...); err != nil { | ||||||
| 		log.Fatal(err) | 		log.Fatal(err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -265,7 +262,7 @@ func macros(buf io.Writer, ast *cc.TranslationUnit) { | |||||||
| 		switch t := m.Type; t.Kind() { | 		switch t := m.Type; t.Kind() { | ||||||
| 		case | 		case | ||||||
| 			cc.Int, cc.UInt, cc.Long, cc.ULong, cc.LongLong, cc.ULongLong, | 			cc.Int, cc.UInt, cc.Long, cc.ULong, cc.LongLong, cc.ULongLong, | ||||||
| 			cc.Float, cc.LongDouble, cc.Bool: | 			cc.Float, cc.Double, cc.LongDouble, cc.Bool: | ||||||
| 			fmt.Fprintf(buf, "X%s = %v\n", v, m.Value) | 			fmt.Fprintf(buf, "X%s = %v\n", v, m.Value) | ||||||
| 		case cc.Ptr: | 		case cc.Ptr: | ||||||
| 			switch t := t.Element(); t.Kind() { | 			switch t := t.Element(); t.Kind() { | ||||||
| @@ -406,14 +403,24 @@ func sqlite() { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	pth := filepath.Join(repo, "sqlite-amalgamation-"+version) | 	pth := filepath.Join(repo, "sqlite-amalgamation-"+version) | ||||||
| 	sqlite3 := filepath.Join(pth, "sqlite3.c") | 	ast, _ := build( | ||||||
| 	asta, src := build( |  | ||||||
| 		defines, | 		defines, | ||||||
| 		[][]string{ | 		[][]string{ | ||||||
|  | 			{filepath.Join(pth, "sqlite3.h")}, | ||||||
| 			{"main.c"}, | 			{"main.c"}, | ||||||
| 			{sqlite3}, |  | ||||||
| 		}, | 		}, | ||||||
| 		nil, | 		[]ccgo.Option{ccgo.Library()}, | ||||||
|  | 		cc.EnableAnonymousStructFields(), | ||||||
|  | 		cc.IncludePaths([]string{pth}), | ||||||
|  | 	) | ||||||
|  | 	sqlite3 := filepath.Join(pth, "sqlite3.c") | ||||||
|  | 	_, src := build( | ||||||
|  | 		defines, | ||||||
|  | 		[][]string{ | ||||||
|  | 			{sqlite3}, | ||||||
|  | 			{"main.c"}, | ||||||
|  | 		}, | ||||||
|  | 		[]ccgo.Option{ccgo.Library()}, | ||||||
| 		cc.EnableAnonymousStructFields(), | 		cc.EnableAnonymousStructFields(), | ||||||
| 		cc.IncludePaths([]string{pth}), | 		cc.IncludePaths([]string{pth}), | ||||||
| 	) | 	) | ||||||
| @@ -425,7 +432,7 @@ func sqlite() { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	fmt.Fprintf(&b, prologueSqlite, lic, strings.TrimSpace(tidyComments(header(sqlite3)))) | 	fmt.Fprintf(&b, prologueSqlite, lic, strings.TrimSpace(tidyComments(header(sqlite3)))) | ||||||
| 	macros(&b, asta[0]) | 	macros(&b, ast[0]) | ||||||
| 	b.Write(src) | 	b.Write(src) | ||||||
| 	b2, err := format.Source(b.Bytes()) | 	b2, err := format.Source(b.Bytes()) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| @@ -436,6 +443,7 @@ func sqlite() { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	dst := fmt.Sprintf(filepath.Join("internal", "bin", "bin_%s_%s.go"), runtime.GOOS, runtime.GOARCH) | 	dst := fmt.Sprintf(filepath.Join("internal", "bin", "bin_%s_%s.go"), runtime.GOOS, runtime.GOARCH) | ||||||
|  | 	b2 = bytes.Replace(b2, []byte("var Xsqlite3PendingByte int32"), []byte("func Xsqlite3PendingByte() int32 { return _sqlite3PendingByte }"), 1) | ||||||
| 	if err := ioutil.WriteFile(dst, b2, 0664); err != nil { | 	if err := ioutil.WriteFile(dst, b2, 0664); err != nil { | ||||||
| 		log.Fatal(err) | 		log.Fatal(err) | ||||||
| 	} | 	} | ||||||
| @@ -460,7 +468,7 @@ func mpTest() { | |||||||
| 			{filepath.Join(sqlitePth, "sqlite3.c")}, | 			{filepath.Join(sqlitePth, "sqlite3.c")}, | ||||||
| 			{test}, | 			{test}, | ||||||
| 		}, | 		}, | ||||||
| 		[]string{"bin"}, | 		[]ccgo.Option{ccgo.Packages([]string{"bin"})}, | ||||||
| 		cc.EnableAnonymousStructFields(), | 		cc.EnableAnonymousStructFields(), | ||||||
| 		cc.IncludePaths([]string{sqlitePth}), | 		cc.IncludePaths([]string{sqlitePth}), | ||||||
| 	) | 	) | ||||||
| @@ -506,7 +514,7 @@ func threadTest1() { | |||||||
| 			{filepath.Join(sqlitePth, "sqlite3.c")}, | 			{filepath.Join(sqlitePth, "sqlite3.c")}, | ||||||
| 			{test}, | 			{test}, | ||||||
| 		}, | 		}, | ||||||
| 		[]string{"bin"}, | 		[]ccgo.Option{ccgo.Packages([]string{"bin"})}, | ||||||
| 		cc.EnableAnonymousStructFields(), | 		cc.EnableAnonymousStructFields(), | ||||||
| 		cc.IncludePaths([]string{".", sqlitePth, filepath.Join(repo, "sqlite-src-"+version, "src")}), | 		cc.IncludePaths([]string{".", sqlitePth, filepath.Join(repo, "sqlite-src-"+version, "src")}), | ||||||
| 	) | 	) | ||||||
| @@ -551,7 +559,7 @@ func threadTest2() { | |||||||
| 			{filepath.Join(sqlitePth, "sqlite3.c")}, | 			{filepath.Join(sqlitePth, "sqlite3.c")}, | ||||||
| 			{test}, | 			{test}, | ||||||
| 		}, | 		}, | ||||||
| 		[]string{"bin"}, | 		[]ccgo.Option{ccgo.Packages([]string{"bin"})}, | ||||||
| 		cc.EnableAnonymousStructFields(), | 		cc.EnableAnonymousStructFields(), | ||||||
| 		cc.IncludePaths([]string{".", sqlitePth, filepath.Join(repo, "sqlite-src-"+version, "src")}), | 		cc.IncludePaths([]string{".", sqlitePth, filepath.Join(repo, "sqlite-src-"+version, "src")}), | ||||||
| 	) | 	) | ||||||
| @@ -598,7 +606,7 @@ func threadTest3() { | |||||||
| 			{filepath.Join(repo, "sqlite-src-"+version, "src", "test_multiplex.c")}, | 			{filepath.Join(repo, "sqlite-src-"+version, "src", "test_multiplex.c")}, | ||||||
| 			{test}, | 			{test}, | ||||||
| 		}, | 		}, | ||||||
| 		[]string{"bin"}, | 		[]ccgo.Option{ccgo.Packages([]string{"bin"})}, | ||||||
| 		cc.EnableAnonymousStructFields(), | 		cc.EnableAnonymousStructFields(), | ||||||
| 		cc.IncludePaths([]string{".", sqlitePth, filepath.Join(repo, "sqlite-src-"+version, "src")}), | 		cc.IncludePaths([]string{".", sqlitePth, filepath.Join(repo, "sqlite-src-"+version, "src")}), | ||||||
| 	) | 	) | ||||||
| @@ -643,7 +651,7 @@ func threadTest4() { | |||||||
| 			{filepath.Join(sqlitePth, "sqlite3.c")}, | 			{filepath.Join(sqlitePth, "sqlite3.c")}, | ||||||
| 			{test}, | 			{test}, | ||||||
| 		}, | 		}, | ||||||
| 		[]string{"bin"}, | 		[]ccgo.Option{ccgo.Packages([]string{"bin"})}, | ||||||
| 		cc.EnableAnonymousStructFields(), | 		cc.EnableAnonymousStructFields(), | ||||||
| 		cc.IncludePaths([]string{".", sqlitePth, filepath.Join(repo, "sqlite-src-"+version, "src")}), | 		cc.IncludePaths([]string{".", sqlitePth, filepath.Join(repo, "sqlite-src-"+version, "src")}), | ||||||
| 	) | 	) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jan Mercl
					Jan Mercl