-
Notifications
You must be signed in to change notification settings - Fork 27
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
Easy Signing #94
Merged
Merged
Easy Signing #94
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
compiling/gdx-jnigen-gradle/src/main/java/com/badlogic/gdx/jnigen/gradle/JnigenSignTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.badlogic.gdx.jnigen.gradle; | ||
|
||
import com.badlogic.gdx.jnigen.BuildConfig; | ||
import com.badlogic.gdx.jnigen.BuildTarget; | ||
import com.badlogic.gdx.jnigen.FileDescriptor; | ||
import com.badlogic.gdx.jnigen.build.RuntimeEnv; | ||
import com.badlogic.gdx.jnigen.build.ToolFinder; | ||
import com.badlogic.gdx.jnigen.build.ToolchainExecutor; | ||
import groovy.lang.Closure; | ||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.tasks.TaskAction; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.inject.Inject; | ||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class JnigenSignTask extends DefaultTask { | ||
|
||
|
||
private static final Logger log = LoggerFactory.getLogger(JnigenSignTask.class); | ||
|
||
private final JnigenExtension ext; | ||
|
||
private BuildTarget buildTarget; | ||
|
||
@Inject | ||
public JnigenSignTask(JnigenExtension ext) { | ||
this.ext = ext; | ||
|
||
setGroup("jnigen"); | ||
setDescription("Signs native libraries"); | ||
} | ||
|
||
public void setBuildTarget (BuildTarget buildTarget) { | ||
this.buildTarget = buildTarget; | ||
} | ||
|
||
@TaskAction | ||
public void run() { | ||
BuildConfig buildConfig = new BuildConfig(ext.sharedLibName, ext.subProjectDir + ext.temporaryDir, ext.subProjectDir + ext.libsDir, ext.subProjectDir + ext.jniDir, null, new FileDescriptor(ext.subProjectDir)); | ||
RuntimeEnv env = new RuntimeEnv(); | ||
List<String> args = new ArrayList<>(); | ||
switch (buildTarget.os) { | ||
case Windows: | ||
Map<String, String> params = ext.signing.getJsignParams(); | ||
params.put("file", buildTarget.getTargetBinaryFile(buildConfig).getPath()); | ||
Closure<?> jsign = (Closure<?>) ext.project.getExtensions().getByName("jsign"); | ||
jsign.call(params); | ||
break; | ||
case MacOsX: | ||
case IOS: | ||
File codesign = ToolFinder.getToolFile("codesign", env, true); | ||
args.add("-s"); | ||
args.add(ext.signing.getIdentity()); | ||
args.add("-f"); | ||
args.add(buildTarget.getTargetBinaryFile(buildConfig).getPath()); | ||
ToolchainExecutor.execute(codesign, new File(""), args, new ToolchainExecutor.ToolchainCallback() { | ||
@Override | ||
public void onInfoMessage(String message) { | ||
log.info(message); | ||
} | ||
|
||
@Override | ||
public void onErrorMessage(String message) { | ||
log.error(message); | ||
} | ||
|
||
@Override | ||
public void onSuccess() { | ||
log.info("Signing successful"); | ||
} | ||
|
||
@Override | ||
public void onFail(int statusCode) { | ||
log.error("Signing failed with status code: {}", statusCode); | ||
} | ||
}); | ||
break; | ||
case Linux: | ||
case Android: | ||
log.warn("Signing not supported for {}", buildTarget.os); | ||
break; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...dx-jnigen-gradle/src/main/java/com/badlogic/gdx/jnigen/gradle/JnigenSigningExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.badlogic.gdx.jnigen.gradle; | ||
|
||
import java.util.Map; | ||
|
||
public class JnigenSigningExtension { | ||
private Map<String, String> jsignParams; | ||
private String identity; | ||
|
||
public Map<String, String> getJsignParams() { | ||
return jsignParams; | ||
} | ||
|
||
public void setJsignParams(Map<String, String> jsignParams) { | ||
this.jsignParams = jsignParams; | ||
} | ||
|
||
public String getIdentity() { | ||
return identity; | ||
} | ||
|
||
public void setIdentity(String identity) { | ||
this.identity = identity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could we maybe add the jnigenSign task conditionally, based on whether signing was configured?
And if signing is configured, adding something like:
jnigenBuildTask.finalizedBy(jnigenSignTask)
?Conceptionally I feel like signing belongs more to the packaging step, but I guess that doesn't work well with the current jnigen setup that packages everything on a linux host.
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.
I added a check to add the tasks only when configured.
I don't really have an opinion on
finalizedBy
ordependsOn