-
Notifications
You must be signed in to change notification settings - Fork 19
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
Added support for building C/C++ libraries via bob #326
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -976,14 +976,12 @@ public boolean accept(File pathname) { | |
return outputFiles; | ||
} | ||
|
||
private void buildExtension(File manifest, Map<String, Object> manifestContext) throws IOException, InterruptedException, ExtenderException { | ||
private List<File> buildExtensionInternal(File manifest, Map<String, Object> manifestContext, List<File> srcDirs, File libraryOut) throws IOException, InterruptedException, ExtenderException { | ||
LOGGER.info("buildExtension"); | ||
|
||
File extDir = manifest.getParentFile(); | ||
|
||
// Gather all the C++ files | ||
List<File> srcDirs = new ArrayList<>(); | ||
srcDirs.add(new File(extDir, FOLDER_COMMON_SRC)); | ||
srcDirs.add(new File(extDir, FOLDER_ENGINE_SRC)); | ||
// Gather all the source files | ||
List<File> srcFiles = ExtenderUtil.listFiles(srcDirs, platformConfig.sourceRe); | ||
|
||
// Added in 1.4.9 | ||
|
@@ -1007,17 +1005,39 @@ private void buildExtension(File manifest, Map<String, Object> manifestContext) | |
objs.addAll(compileExtensionSourceFiles(extDir, manifestContext, srcFiles)); | ||
|
||
// Create c++ library | ||
File lib = null; | ||
if (platformConfig.writeLibPattern != null) { | ||
File lib; | ||
if (libraryOut != null) | ||
lib = libraryOut; | ||
else | ||
lib = createBuildFile(String.format(platformConfig.writeLibPattern, manifestContext.get("extension_name") + "_" + getNameUUID())); | ||
} else { | ||
lib = uniqueTmpFile("lib", ".a"); // Deprecated, remove in a few versions | ||
} | ||
|
||
List<File> outputFiles = new ArrayList<>(); | ||
outputFiles.add(lib); | ||
|
||
Map<String, Object> context = createContext(manifestContext); | ||
context.put("tgt", lib); | ||
context.put("objs", objs); | ||
String command = templateExecutor.execute(platformConfig.libCmd, context); | ||
processExecutor.execute(command); | ||
|
||
return outputFiles; | ||
} | ||
|
||
private List<File> buildExtension(File manifest, Map<String, Object> manifestContext) throws IOException, InterruptedException, ExtenderException { | ||
LOGGER.info("buildExtension"); | ||
File extDir = manifest.getParentFile(); | ||
List<File> srcDirs = new ArrayList<>(); | ||
srcDirs.add(new File(extDir, FOLDER_COMMON_SRC)); | ||
srcDirs.add(new File(extDir, FOLDER_ENGINE_SRC)); | ||
return buildExtensionInternal(manifest, manifestContext, srcDirs, null); | ||
} | ||
|
||
private List<File> buildLibrary(File manifest, Map<String, Object> manifestContext) throws IOException, InterruptedException, ExtenderException { | ||
LOGGER.info("buildLibrary"); | ||
List<File> srcDirs = new ArrayList<>(); | ||
srcDirs.add(uploadDirectory); | ||
String libName = String.format(platformConfig.writeLibPattern, manifestContext.get("extension_name")); | ||
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. Making it easy to control the library name from bob |
||
return buildExtensionInternal(manifest, manifestContext, srcDirs, new File(buildDirectory, libName)); | ||
} | ||
|
||
private List<File> buildPipelineExtension(File manifest, Map<String, Object> manifestContext) throws IOException, InterruptedException, ExtenderException { | ||
|
@@ -2073,6 +2093,34 @@ private boolean shouldBuildEngine() { | |
private boolean shouldBuildPlugins() { | ||
return shouldBuildArtifact("plugins"); | ||
} | ||
private boolean shouldBuildLibrary() { | ||
return shouldBuildArtifact("library"); | ||
} | ||
|
||
private List<File> buildLibraries() throws ExtenderException { | ||
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 is a shortened copy of buildEngine() without the linker step. |
||
System.out.printf("buildLibrary\n"); | ||
|
||
if (!shouldBuildLibrary()) { | ||
return new ArrayList<>(); | ||
} | ||
LOGGER.info("Building library for platform {} with extension source {}", platform, uploadDirectory); | ||
|
||
List<File> outputFiles = new ArrayList<>(); | ||
try { | ||
List<String> symbols = getSortedKeys(manifestConfigs.keySet()); | ||
for (String extensionSymbol : symbols) { | ||
Map<String, Object> extensionContext = manifestConfigs.get(extensionSymbol); | ||
File manifest = manifestFiles.get(extensionSymbol); | ||
|
||
// TODO: Thread this step | ||
outputFiles.addAll(buildLibrary(manifest, extensionContext)); | ||
} | ||
|
||
return outputFiles; | ||
} catch (IOException | InterruptedException e) { | ||
throw new ExtenderException(e, processExecutor.getOutput()); | ||
} | ||
} | ||
|
||
private List<File> buildEngine() throws ExtenderException { | ||
if (!shouldBuildEngine()) { | ||
|
@@ -2090,7 +2138,7 @@ private List<File> buildEngine() throws ExtenderException { | |
File manifest = manifestFiles.get(extensionSymbol); | ||
|
||
// TODO: Thread this step | ||
buildExtension(manifest, extensionContext); | ||
outputFiles.addAll(buildExtension(manifest, extensionContext)); | ||
} | ||
|
||
File resourceFile = null; | ||
|
@@ -2152,11 +2200,6 @@ private List<File> buildPipelinePlugin() throws ExtenderException { | |
} | ||
} | ||
|
||
private void putLog(String msg) { | ||
System.out.printf(msg); | ||
processExecutor.putLog(msg); | ||
} | ||
|
||
private List<File> copyAndroidJniFolders(String platform) throws ExtenderException { | ||
List<File> jniFolders = getAndroidJniFolders(platform); | ||
if (jniFolders.isEmpty()) { | ||
|
@@ -2441,7 +2484,10 @@ List<File> build() throws ExtenderException { | |
if (platform.endsWith("android")) { | ||
outputFiles.addAll(buildAndroid(platform)); | ||
} | ||
outputFiles.addAll(buildEngine()); | ||
if (shouldBuildLibrary()) | ||
outputFiles.addAll(buildLibraries()); | ||
else | ||
outputFiles.addAll(buildEngine()); | ||
outputFiles.addAll(buildPipelinePlugin()); | ||
File log = writeLog(); | ||
if (log.exists()) { | ||
|
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.
Mostly same as before, but can override the output library file