Skip to content

Commit

Permalink
A bit of vendoring for GO build
Browse files Browse the repository at this point in the history
  • Loading branch information
rupor-github committed Sep 4, 2015
1 parent 142ee86 commit 06abe23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,20 @@ install(TARGETS libsplit DESTINATION ${DEST_DIR} CONFIGURATIONS Release)

# Proper go build structure will be here
set(GO_PATH "${CMAKE_BINARY_DIR}/go")
configure_file ("${PROJECT_SOURCE_DIR}/cmake/version.go.in" "${GO_PATH}/src/libget2/version.go")
include_directories("${PROJECT_BINARY_DIR}")

find_package(Git REQUIRED)
find_package(Go 1.4 REQUIRED)
file(GLOB SRCS_LIBGET2 RELATIVE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/libget2/*.go)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/libget2.exe
DEPENDS ${SRCS_LIBGET2}
DEPENDS ${SRCS_LIBGET2} "${GO_PATH}/src/libget2/version.go"
# setting up source tree
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/libget2/ ${GO_PATH}/src/libget2
COMMAND ${CMAKE_COMMAND} -E env GOROOT=${GO_ROOT} GOPATH=${GO_PATH} ${GO_EXECUTABLE} get golang.org/x/net/proxy
# vendoring packages (COMMAND ${CMAKE_COMMAND} -E env GOROOT=${GO_ROOT} GOPATH=${GO_PATH} ${GO_EXECUTABLE} get golang.org/x/net/proxy)
COMMAND ${CMAKE_COMMAND} -E env ${GIT_EXECUTABLE} clone https://go.googlesource.com/net go/src/golang.org/x/net
COMMAND ${CMAKE_COMMAND} -E env ${GIT_EXECUTABLE} --git-dir ${GO_PATH}/src/golang.org/x/net/.git --work-tree ${GO_PATH}/src/golang.org/x/net checkout --detach db8e4de5b2d6653f66aea53094624468caad15d2
# Building
COMMAND ${CMAKE_COMMAND} -E env GOROOT=${GO_ROOT} GOPATH=${GO_PATH} ${GO_EXECUTABLE} build libget2
COMMENT "Building GO program")
add_custom_target(libget2 ALL DEPENDS ${CMAKE_BINARY_DIR}/libget2.exe)
Expand Down
6 changes: 6 additions & 0 deletions cmake/version.go.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main

func getVersion() string {
return "@PRJ_VERSION_MAJOR@.@PRJ_VERSION_MINOR@"
}

2 changes: 1 addition & 1 deletion libget2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func getFiles(files []string, url, dest string) (err error) {

func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "\nTool to download library updates\nVersion 2.0\n\n")
fmt.Fprintf(os.Stderr, "\nTool to download library updates\nVersion %s\n\n", getVersion())
fmt.Fprintf(os.Stderr, "Usage: %s [options]\n\n", os.Args[0])
flag.PrintDefaults()
}
Expand Down

0 comments on commit 06abe23

Please sign in to comment.