I'm trying to build a multi-dist executable using Travis CI which will put the built executables on github.
I want the name to be somename.os.arch.
When I build locally via command line, I use the -o param and the env vars $GOOS & $GOARCH e.g.: go build -o somename.$GOOS.$GOARCH
However, I cannot specify this for TravisCI using their build_args as other steps fail (not understanding -o flag)
Is there a Go build config file I can create to set the build output name?
Override script. If you mean gobuild_args instead of build_args, it is only passed to the default command go test ./..., so I don't think it would work.
Related
I am trying to make a Taskfile.yml file for building go application, but I can't quite understand the need of "GOFLAGS=-mod=mod" command before go build main.go.
reference: https://dev.to/aurelievache/learning-go-by-examples-part-3-create-a-cli-app-in-go-1h43
So there are two things here
GOFLAGS
this is nothing but an environment variable(if you don't understand what an environment variable is, think of it like a value that can be accessed by any process in your current environment. These values are maintained by the OS).
So this GOFLAGS variable has a space separated list of flags that will automatically be passed to the appropriate go commands.
The flag we are setting here is mod, this flag is applicable to the go build command and may not be applicable to other go commands.
If you are curious how go does this, refer to this change request
Since we are mentioning this as part of the command, this environment variable is temporarily set and is not actually exported.
what does setting -mod=mod flag, actually do during go build?
The -mod flag controls whether go.mod may be automatically updated and whether the vendor directory is used.
-mod=mod tells the go command to ignore the vendor directory and to automatically update go.mod, for example, when an imported package is not provided by any known module.
Refer this.
Therefore
GOFLAGS="-mod=mod" go build main.go
is equivalent to
go build -mod=mod main.go
In Xcode, pressing ⌘B (build target) can build the project, it will generate the build in the path ~/Library/Developer/Xcode/DerivedData/{AppName}-{hash}.
How could I know the whole path of the build (with the hash value) by a script? Can I find that path in my .xcodeproj?
When I use ⇧⌘U (build test target only), where can I find the test target build?
The build paths can be controlled using BUILT_PRODUCTS_DIR , PROJECT_TEMP_DIR , CONFIGURATION_BUILD_DIR and CONFIGURATION_TEMP_DIR etc . https://help.apple.com/xcode/mac/11.4/#/itcaec37c2a6
There's no need to extract them from some non-public file format specification.
If you must do it, init a temporary git repo with a xcodeproj file in it. Commit it. Make a change in one of the variables and then run git diff.
How could I know the whole path of the build (with the hash value) by a script?
Change to the same folder where your project or workspace is
Run xcodebuild -showBuildSettings
May need to add the proper scheme or target. See man xcodebuild
See sample below to find by script
When I ... build for test target only, where can I find the test target build?
It will be in the same folder with a name similar to <Test_Target_Name>-Runner.app. This is useful as you can use for Cloud device testing services.
# This example works with Xcode project with a single scheme
# Echo to stdout
xcodebuild -showBuildSettings
xcodebuild -showBuildSettings | grep CONFIGURATION_BUILD_DIR
# save to a variable for use in your script
# A little brutal, so I'm open to other ways to do this.
CONFIGURATION_BUILD_DIR=$(xcodebuild -showBuildSettings 2> /dev/null | grep CONFIGURATION_BUILD_DIR | sed 's/[ ]*CONFIGURATION_BUILD_DIR = //')
echo $CONFIGURATION_BUILD_DIR
If you are using Xcode Server Bots
cd ${XCS_PRIMARY_REPO_DIR}
xcodebuild -showBuildSettings
Sample output:
/Users/roblabs/Library/Developer/Xcode/DerivedData/openmaptiles-ios-demo-eectbiabcmhajpdbcoqnaipiaqpd/Build/Products/Release-iphoneos
As noted in https://stackoverflow.com/a/57512068,
The default value is $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
For further documentation on the build setting properties, see Build Setting Reference at developer.apple.com. The link that #puio listed is also useful.
I am making a Go project containing a few packages. Those are data structures (and there will be algorithms as well). My project root looks like this:
C:.
├───array
├───binary_tree
├───heap
└───list
The thing is, I want to add like a CI. So I would have a job checking if all packages build and if all tests pass.
Unfortunately, I can't run go build on project root. I have to pass whole path to it. I mean I could write a script which calls go build X/Y/foo and then go build X/Y/bar, but the CI on GitLab (docker image) won't have those paths, it will just git clone my repo and that's it (cuz I cannot run it on a relative path from project root, but a relative path from GOPATH, so like github.com/dabljues/project_name/array). And what about the test?
So the question there would be: Can I somehow run go build and go test for all the packages in the Go project? (located in separate folders)
Use a Makefile. Define the targets and instruction to compile them.
For example define the following in a Makefile
build:
go build -o bin/main main.go
run:
go run main.go
To run just invoke : make build
Short of it is in the title... I'm trying to have the headerfile that cgo already creates cgo_export.h - but sticks in the working directory - created in a static location that I can reliably access (as working directories can and should change). Directly using cgo provides for a -headerfile option, but I see no such option within the build options of go build, nor a way of passing options to cgo from go build.
Besides using a second run of cgo(or some script to grab the header each time from the working directory) is there any way to produce the header file with go build
I am trying to set up a multi-configuration project in Jenkins with a single user-defined axis (call it "axis"). The value associated with each configuration would then be used to invoke top-level maven targets in ${axis}/pom.xml. The trouble is, I can't find the proper syntax for this, if indeed it does exist (${axis}, $axis, $AXIS, and ${env.axis} all fail). I would think it would be shell syntax, which it doesn't seem to be, but regardless it should be either simple or impossible. Is it possible?
Is your Jenkins installation running on Windows?
For each Custom Axis, an environment variable is created. You can refer to your custom axis using ${axis} if your server is running Linux, but on Windows you must refer to it as %axis%
${axis}/pom.xml should work in my experience.
I appreciate that OP has solved this in a different way, but for the record the following works in Hudson in Windows and Linux. I haven't tried it in Jenkins:
The syntax you need for this is simply $axis/pom.xml
I defined an axis of BuildProfile=compile unitTest integrationTest
And in the Maven 3 configuration (under Advanced properties) a POM file of $BuildProfile/pom.xml
The resulting builds gave the following output in the console (edited for brevity):
[1.7.0_25] $ C:\Users...\bin\mvn.bat clean install -V -B
-DBuildProfile=compile -f compile/pom.xml
[1.7.0_25] $ C:\Users...\bin\mvn.bat clean install -V -B
-DBuildProfile=unitTest -f unitTest/pom.xml
[1.7.0_25] $ C:\Users...\bin\mvn.bat clean install -V -B
-DBuildProfile=integrationTests -f integrationTests/pom.xml
We use a jdk axis and just use the name of the jdk so I think you could just use axis/pom.xml