FAQ
Hi All,

I have multiple build environments - compiler/linker paths being different
And need to support different build flags (on same build machine) - Ex:
sometimes build with 32 bit libs and sometimes with 64 bit libs.

I am doing this now by what seems like an abuse of pkg-config approach
provided in Go.
I need inputs if there is a better way.

Current handling is below. Not so nice part is that I need to source the
buildenv.sh before building the package via "go build" so that my
pkg-config gets picked.

*<gopath>/src/pkgname/*
buildenv.sh
pkg-config
pkgname.go

*buildenv.sh (masks pkg-config of the system)*
cd $GOPATH/src/pkgname
chmod +x pkg-config
export PATH=`pwd`:$PATH

*pkg-config:*

#!/bin/bash

OPTION=$1
INCLUDE_PATH=<relative include path>
COMPILE_OPTIONS="<option here>"
LINK_OPTIONS="<option here>"
  if [ <environment-1> ]; then
COMPILE_ROOT=ENV1_PATH
LINK_GCC=GCC_ENV1_LIBS
LINK_OWN=OWN_ENV2_LIBS
# .....
else
COMPILE_ROOT=ENV2_PATH
LINK_GCC=GCC_ENV2_LIBS
LINK_OWN=OWN_ENV2_LIBS
# .....
fi
  if [ ${OPTION} == "--cflags" ]; then
echo "-I ${COMPILE_ROOT}/${INCLUDE_PATH} ${COMPILE_OPTIONS}"
exit 0
fi
  if [ ${OPTION} == "--libs" ]; then
echo "-L ${LINK_GCC}/usr/lib64 -L ${LINK_OWN}/usr/lib64 ${LINK_OPTIONS}"
exit 0
fi

thanks & Br,
Shivakumar GN

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Albert Strasheim at May 6, 2013 at 6:41 pm
    Hello
    On Sunday, May 5, 2013 4:14:37 AM UTC+2, Shivakumar GN wrote:

    I have multiple build environments - compiler/linker paths being different
    And need to support different build flags (on same build machine) - Ex:
    sometimes build with 32 bit libs and sometimes with 64 bit libs.
    You might be able to use build tags. Look for "tags" in these pages:

    http://tip.golang.org/cmd/go/
    http://tip.golang.org/pkg/go/build/

    However, given the complexity of your environment, having a top-level
    build.sh or Makefile that invokes go build after setting up the environment
    might not be the worst solution.

    Cheers

    Albert

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shivakumar GN at May 8, 2013 at 1:55 am

    On Tue, May 7, 2013 at 12:11 AM, Albert Strasheim wrote:

    Hello

    You might be able to use build tags. Look for "tags" in these pages:

    Thanks for the hint. Will probably turnout to be a similar one as now. But
    useful to know such this option exists.


    However, given the complexity of your environment, having a top-level
    build.sh or Makefile that invokes go build after setting up the environment
    might not be the worst solution.

    This is how my environment is.

    thanks
    Shivakumar GN

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 5, '13 at 2:14a
activeMay 8, '13 at 1:55a
posts3
users2
websitegolang.org

2 users in discussion

Shivakumar GN: 2 posts Albert Strasheim: 1 post

People

Translate

site design / logo © 2022 Grokbase