Browse Source

Use Go 1.4 'generate' to create XDR codec

Jakob Borg 11 năm trước cách đây
mục cha
commit
06fd2268d9

+ 1 - 3
build.go

@@ -284,9 +284,7 @@ func assets() {
 }
 }
 
 
 func xdr() {
 func xdr() {
-	for _, f := range []string{"internal/discover/packets", "internal/files/leveldb", "internal/protocol/message"} {
-		runPipe(f+"_xdr.go", "go", "run", "./Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go", "--", f+".go")
-	}
+	runPrint("go", "generate", "./internal/discover", "./internal/files", "./internal/protocol")
 }
 }
 
 
 func translate() {
 func translate() {

+ 3 - 0
internal/discover/packets.go

@@ -13,6 +13,9 @@
 // You should have received a copy of the GNU General Public License along
 // You should have received a copy of the GNU General Public License along
 // with this program. If not, see <http://www.gnu.org/licenses/>.
 // with this program. If not, see <http://www.gnu.org/licenses/>.
 
 
+//go:generate -command genxdr go run ../../Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go
+//go:generate genxdr -o packets_xdr.go packets.go
+
 package discover
 package discover
 
 
 const (
 const (

+ 3 - 0
internal/files/leveldb.go

@@ -13,6 +13,9 @@
 // You should have received a copy of the GNU General Public License along
 // You should have received a copy of the GNU General Public License along
 // with this program. If not, see <http://www.gnu.org/licenses/>.
 // with this program. If not, see <http://www.gnu.org/licenses/>.
 
 
+//go:generate -command genxdr go run ../../Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go
+//go:generate genxdr -o leveldb_xdr.go leveldb.go
+
 package files
 package files
 
 
 import (
 import (

+ 3 - 0
internal/protocol/message.go

@@ -13,6 +13,9 @@
 // You should have received a copy of the GNU General Public License along
 // You should have received a copy of the GNU General Public License along
 // with this program. If not, see <http://www.gnu.org/licenses/>.
 // with this program. If not, see <http://www.gnu.org/licenses/>.
 
 
+//go:generate -command genxdr go run ../../Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go
+//go:generate genxdr -o message_xdr.go message.go
+
 package protocol
 package protocol
 
 
 import "fmt"
 import "fmt"