Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Updates to the new build system #210

Merged
merged 2 commits into from
Aug 3, 2017
Merged

Conversation

ThadHouse
Copy link
Member

Jenkins will fail until I update the scripts there, which I will do in a bit.

@ThadHouse ThadHouse force-pushed the newBuild branch 10 times, most recently from 73772e5 to f7f3cd2 Compare August 1, 2017 20:49
binaries {
withType(SharedLibraryBinarySpec) { binary ->
if (binary.component.name == 'ntcoreJNI') {
from(binary.sharedLibraryFile) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this cause this to get resolved eagerly at configuration time? Don't you want this to get resolved at task runtime?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not. The native builds handle eagerly configuring this. It does get resolved at runtime.

config.gradle Outdated

def buildAll = project.hasProperty('buildAll')

def windows64PlatformDetect = { config->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this closure take an arg but never use it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always forget in gradle you can ignore closure arguments. There are other cases where that config is used, but I can remove it from here.

publish.gradle Outdated
project(':arm:wpiutil').build.dependsOn outputVersions
project(':arm:ntcore').build.dependsOn outputVersions
}
def licenseFile = new File("$rootDir/license.txt")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just use file("$rootDir/license.txt")

publish.gradle Outdated
model {
tasks {
it.each {
if (it.name.contains('jniHeaders')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might also want to check that the type is a CopySpec?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah probably.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the task it is looking at is not a copy task, so that doesn't work. This is one of the few cases where it is just hard to get something out of the model.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What type is it then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading through that code, just as an aside, its much better practice to create types for your tasks. Doing so allows you to use the annotations @Input, @InputDirectory, @Output, @OutputDirectory ect... That allow your build to do things better with task avoidance (speeding up the build).
Additionally, doing so would allow you to take advantage of the new gradle build cache where you can share the output of tasks on a central server (or even on your personal machine) to avoid running tasks that you've already run before.

Additionally, I worry that the lack of any sort of type system here will make this code unmaintainable by anyone in the future. Without a solid set of tests to prove that what the build is creating is correct it's much harder for new developers to dive in without the fear of breaking something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are the annotations different from just declaring Inputs and Outputs on the task, which I already do. Also, until all the native stuff supports the build cache (which none of it does currently), I don't think its necessary to take the extra work. I do agree that adding a custom type for this might be a good idea however. I just wish the team had commented on this weeks ago when I asked for help and suggestions rather then waiting until we were wanting to merge it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JLLeitschuh I created custom types for my tasks. I didn't add anything to them, since the default task worked just fine, but it does let me do type checking.

publish.gradle Outdated
if (project.hasProperty('makeDesktop')) {
artifact nat.ntcoreZip, {
classifier = 'desktop'
def createComponentZipTasks = { components, name, base, type, project, func ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe turn this into a more strongly typed groovy function instead of using a closure since there are so many inputs? It would help others read it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Something similar to this is used in most of the repo's, so thats a good idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to pass on this, because I use a few script globals, and switching to a function breaks that, with the workarounds looking super hacky

public class TestClass {
@Test
public void generalTestCase() {
assertEquals(true, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this testing? Perhaps a bit more documentation if you are actually expecting something here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was more to verify that tests were actually running, and the test below is to make sure the JNI linking actually works. I'll remove the general one, and move the JNI one to it's own package.

@@ -0,0 +1,17 @@
import org.junit.BeforeClass;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be in the default package. This is not really done even in test systems. You should put this test in its own package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will move it.

@ThadHouse ThadHouse force-pushed the newBuild branch 3 times, most recently from 67288bf to d2b3077 Compare August 3, 2017 02:48
public static final int NT_NET_MODE_CLIENT = 0x02;
public static final int NT_NET_MODE_STARTING = 0x04;
public static final int NT_NET_MODE_FAILURE = 0x08;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an unintentional revert. Are you synced up to the latest master?

@@ -154,7 +136,6 @@ else if (System.getProperty("os.name").startsWith("Mac"))
// public static native byte[] getRpcResultNonblocking(int callUid) throws RpcNoResponseException;

public static native void setNetworkIdentity(String name);
public static native int getNetworkMode();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

publish.gradle Outdated

task outputVersions() {
description = 'Prints the versions of ntcore and wpiutil to a file for use by the downstream packaging project'
description = 'Prints the versions of wpiutil to a file for use by the downstream packaging project'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/wpiutil/ntcore/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

build.gradle Outdated

apply from: 'publish.gradle'

task wrapper(type: Wrapper) {
gradleVersion = '3.3'
gradleVersion = '4.0.1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we bump to 4.0.2?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@ThadHouse ThadHouse force-pushed the newBuild branch 2 times, most recently from ac7409f to d2fe992 Compare August 3, 2017 15:45
publish.gradle Outdated
it.each {
if (it.name.contains('jniHeaders')) {
from (it.outputs.files) {
into '/'
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this execute? It looks like it runs during task configuration time, not at task run time? Is that what you want?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does execute at run time. Otherwise copy and zip tasks would be absolutely useless.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain how that's possible? It seems like the receiver of the call to from is project not the task. As you said above, the task is of type DefaultTask which doesn't have a from method on it.

If the receiver of the from call is project then it would be executed immediately.

What is the receiver of the from call?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cppSourcesZip. GitHub is just splitting the lines wierdly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooooh. That makes so much more sense.

Fixes mac builds

Updates plugin to fix mac builds

Removes unnecessary closure variable

Plugin 1.2.4

Updates plugin to 1.2.5

Uses plugin .6

plugin 1.7

Plugin 1.2.8

Fixes review issues
@PeterJohnson PeterJohnson merged commit 5df7463 into wpilibsuite:master Aug 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants