-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using glide for go package vendor #2627
Changes from 5 commits
155e40e
9c853c2
a7f9625
cee264f
6f7a9dd
ff4eaa2
9b12404
43df615
eefcfed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. | ||
# | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
|
@@ -79,6 +79,9 @@ if(WITH_GOLANG) | |
set(GOPATH "${CMAKE_CURRENT_BINARY_DIR}/go") | ||
file(MAKE_DIRECTORY ${GOPATH}) | ||
set(PADDLE_IN_GOPATH "${GOPATH}/src/github.com/PaddlePaddle/Paddle") | ||
file(MAKE_DIRECTORY "${PADDLE_IN_GOPATH}") | ||
set(PADDLE_GO_PATH "${CMAKE_SOURCE_DIR}/go") | ||
|
||
add_custom_target(go_path) | ||
add_custom_command(TARGET go_path | ||
# Symlink Paddle directory into GOPATH | ||
|
@@ -89,7 +92,22 @@ if(WITH_GOLANG) | |
# We can't run `go get -d ./...` for every target, because | ||
# multiple `go get` can not run concurrently, but make need to be | ||
# able to run with multiple jobs. | ||
COMMAND env GOPATH=${GOPATH} ${CMAKE_Go_COMPILER} get -d ./go/... | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
if (GLIDE_INSTALL) | ||
if(EXISTS $ENV{GOPATH}/bin/glide) | ||
set(GLIDE "$ENV{GOPATH}/bin/glide") | ||
else() | ||
message(FATAL_ERROR "no glide executeble found: $ENV{GOPATH}/bin/glide") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This requires user to install glide, maybe we can install for them using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, good point. Thanks. |
||
endif() | ||
|
||
add_custom_target(go_vendor) | ||
add_custom_command(TARGET go_vendor | ||
COMMAND env GOPATH=${GOPATH} ${GLIDE} install | ||
WORKING_DIRECTORY "${PADDLE_IN_GOPATH}/go" | ||
) | ||
add_dependencies(go_vendor go_path) | ||
endif() | ||
|
||
endif(WITH_GOLANG) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,59 +17,59 @@ | |
# generic.cmake defines CMakes functions that look like Bazel's | ||
# building rules (https://bazel.build/). | ||
# | ||
# | ||
# | ||
# ------------------------------------------- | ||
# C++ CUDA C++ Go | ||
# ------------------------------------------- | ||
# cc_library nv_library go_library | ||
# cc_binary nv_binary go_binary | ||
# cc_test nv_test go_test | ||
# ------------------------------------------- | ||
# | ||
# | ||
# To build a static library example.a from example.cc using the system | ||
# compiler (like GCC): | ||
# | ||
# | ||
# cc_library(example SRCS example.cc) | ||
# | ||
# | ||
# To build a static library example.a from multiple source files | ||
# example{1,2,3}.cc: | ||
# | ||
# | ||
# cc_library(example SRCS example1.cc example2.cc example3.cc) | ||
# | ||
# | ||
# To build a shared library example.so from example.cc: | ||
# | ||
# | ||
# cc_library(example SHARED SRCS example.cc) | ||
# | ||
# | ||
# To build a library using Nvidia's NVCC from .cu file(s), use the nv_ | ||
# prefixed version: | ||
# | ||
# | ||
# nv_library(example SRCS example.cu) | ||
# | ||
# | ||
# To specify that a library new_example.a depends on other libraies: | ||
# | ||
# | ||
# cc_library(new_example SRCS new_example.cc DEPS example) | ||
# | ||
# | ||
# Static libraries can be composed of other static libraries: | ||
# | ||
# | ||
# cc_library(composed DEPS dependent1 dependent2 dependent3) | ||
# | ||
# | ||
# To build an executable binary file from some source files and | ||
# dependent libraries: | ||
# | ||
# | ||
# cc_binary(example SRCS main.cc something.cc DEPS example1 example2) | ||
# | ||
# | ||
# To build an executable binary file using NVCC, use the nv_ prefixed | ||
# version: | ||
# | ||
# | ||
# nv_binary(example SRCS main.cc something.cu DEPS example1 example2) | ||
# | ||
# | ||
# To build a unit test binary, which is an executable binary with | ||
# GoogleTest linked: | ||
# | ||
# | ||
# cc_test(example_test SRCS example_test.cc DEPS example) | ||
# | ||
# | ||
# To build a unit test binary using NVCC, use the nv_ prefixed version: | ||
# | ||
# | ||
# nv_test(example_test SRCS example_test.cu DEPS example) | ||
# | ||
# It is pretty often that executable and test binaries depend on | ||
|
@@ -278,27 +278,32 @@ function(go_library TARGET_NAME) | |
set(${TARGET_NAME}_LIB_PATH "${CMAKE_CURRENT_BINARY_DIR}/${${TARGET_NAME}_LIB_NAME}" CACHE STRING "output library path for target ${TARGET_NAME}") | ||
|
||
file(GLOB GO_SOURCE RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.go") | ||
string(REPLACE "${PADDLE_GO_PATH}/" "" CMAKE_CURRENT_SOURCE_REL_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD | ||
COMMAND rm "${${TARGET_NAME}_LIB_PATH}" | ||
# Golang build source code | ||
COMMAND env GOPATH=${GOPATH} ${CMAKE_Go_COMPILER} build ${BUILD_MODE} | ||
-o "${${TARGET_NAME}_LIB_PATH}" | ||
${GO_SOURCE} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | ||
add_dependencies(${TARGET_NAME} go_path) | ||
"./${CMAKE_CURRENT_SOURCE_REL_DIR}/${GO_SOURCE}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am curious the code works before, why now need to be under GOPATH? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When compiling with vendor package, |
||
# must run under GOPATH | ||
WORKING_DIRECTORY "${PADDLE_IN_GOPATH}/go") | ||
add_dependencies(${TARGET_NAME} go_vendor) | ||
endfunction(go_library) | ||
|
||
function(go_binary TARGET_NAME) | ||
set(options OPTIONAL) | ||
set(oneValueArgs "") | ||
set(multiValueArgs SRCS DEPS) | ||
cmake_parse_arguments(go_binary "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
string(REPLACE "${PADDLE_GO_PATH}/" "" CMAKE_CURRENT_SOURCE_REL_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
add_custom_command(OUTPUT ${TARGET_NAME}_timestamp | ||
COMMAND env GOPATH=${GOPATH} ${CMAKE_Go_COMPILER} build | ||
-o "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}" | ||
${go_library_SRCS} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | ||
add_custom_target(${TARGET_NAME} ALL DEPENDS ${TARGET_NAME}_timestamp ${go_binary_DEPS}) | ||
"./${CMAKE_CURRENT_SOURCE_REL_DIR}/${go_binary_SRCS}" | ||
WORKING_DIRECTORY "${PADDLE_IN_GOPATH}/go") | ||
# TODO: don't know what ${TARGET_NAME}_link does | ||
add_custom_target(${TARGET_NAME} ALL DEPENDS go_vendor ${TARGET_NAME}_timestamp ${go_binary_DEPS}) | ||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} DESTINATION bin) | ||
endfunction(go_binary) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor/ | ||
.glide/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
add_subdirectory(pserver/cclient) | ||
add_subdirectory(cmd/pserver) | ||
add_subdirectory(cmd/master) | ||
add_subdirectory(master/c) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
go_binary(master SRC master.go) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
go_binary(pserver SRCS pserver.go) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package: github.com/PaddlePaddle/Paddle/go | ||
import: | ||
- package: github.com/PaddlePaddle/recordio | ||
- package: github.com/coreos/etcd | ||
version: ^3.2.1 | ||
subpackages: | ||
- clientv3 | ||
- clientv3/concurrency | ||
- package: github.com/namsral/flag | ||
version: ^1.7.4-pre | ||
- package: github.com/sirupsen/logrus | ||
version: ^1.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
go_library(paddle_master SHARED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR!
I think we need a design doc for this work. In particular,
The design doc, together with discussions with it, would be a deposit of the reasons/thoughts we have in mind, and would be valuable for future contributors to understand the situation so could they move on towards further improvements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll add a design doc before going on working with this PR.
I thought previous discussions in #2583 is the reason why I'm working on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posted here: #2643