Skip to content
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

Issue 5725: Added support for commonsrc+pluginsrc folders #197

Merged
merged 1 commit into from
Apr 19, 2021

Conversation

JCash
Copy link
Contributor

@JCash JCash commented Apr 16, 2021

Can build .proto files into engine + plugin source
Can generate a plugin .jar file

Can build .proto files into engine + plugin source
Can generate a plugin .jar file
@JCash JCash requested a review from Jhonnyg April 16, 2021 07:26
apt-get install -y --no-install-recommends \
# setuptools for protobuf builder
python-setuptools

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should move this higher up in the Dockerfile, together with the other python related stuff.

@@ -145,7 +151,10 @@
this.platform = platform;
this.sdk = sdk;

// TODO: Add a way to merge these platform configs: common -> platform -> arch-platform
this.commonPlatformConfig = config.platforms.get("common");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not ideal to have two variables, but I'll add a merge function later.

v = templateExecutor.execute(v, envContext);
processExecutor.putEnv(k, v);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we have a merge function for platform configs, this wouldn't be needed.

@@ -320,6 +339,9 @@ static boolean isListOfStrings(List<Object> list) {
private Map<String, Object> context(Map<String, Object> manifestContext) throws ExtenderException {
Map<String, Object> context = new HashMap<>(config.context);

if (commonPlatformConfig != null) {
context = Extender.mergeContexts(context, commonPlatformConfig.context);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "context" is a simple Map<String, Object>, and we already have a merge function for those.

return includes;
}

private File addCompileFileCpp_Internal(int index, File extDir, File src, Map<String, Object> manifestContext, String cmd, List<String> commands) throws IOException, InterruptedException, ExtenderException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The old name "compileFile" was now a misnomer, since it only sets up the command.

LOGGER.info("No C++ source found for plugin. Skipping {}", extDir);
} else {
// We leave the C++ protobuf support for a later date
List<File> generatedFiles = new ArrayList<>();//generateProtoSrcForPlugin(extDir, manifestContext, protoFiles, "cpp");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently disabled until later.
We want to be able to use C++ code to transform data (e.g. textures)

String command = templateExecutor.execute(commonPlatformConfig.jarCmd, context);
processExecutor.execute(command);

outputFiles.add(outputJar);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

List the output files that are to be sent back to the client.

for (String extensionSymbol : keys) {
symbols.add(extensionSymbol);

List<String> symbols = getSortedKeys(manifestConfigs.keySet());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We sort them so that it's easier to compare builds when debugging

@@ -1715,6 +1971,7 @@ else if (platform.contains("web")) {
outputFiles.addAll(buildAndroid(platform));
}
outputFiles.addAll(buildEngine());
outputFiles.addAll(buildPipelinePlugin());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Send back all generated plugins (currently .jar file and "_pb2.py" files)

@@ -86,4 +87,34 @@ public void setCwd(File cwd) {
public void putLog(String msg) {
output.append(msg);
}

public static void executeCommands(ProcessExecutor processExecutor, List<String> commands) throws IOException, InterruptedException, ExtenderException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved from Extender.java


static final String FOLDER_ENGINE_SRC = "src"; // source for the engine library
static final String FOLDER_PLUGIN_SRC = "pluginsrc";// source for the pipeline/format plugins
static final String FOLDER_COMMON_SRC = "commonsrc";// common source shared between both types
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These names are now part of the api.
Are they good enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is plugin the word we are going to use? When talking to users or when users discuss Defold I see the following three used to describe what we call a Library project in the documentation:

  • (Native) extension
  • library
  • plugin
  • dependency

And soon an extension project will also contain source code for the editor right? That folder would probably be named editorsrc?

What about buildsrc, buildersrc or pipelinesrc?

commonsrc is good I think. It could also be named sharedsrc but I believe we use common elsewhere to indicate shared things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"plugin" was a collecting term for all plugins (bob and editor)

"buildsrc" is too ambigous I think. All source is built.

"pipelinesrc" is better.

I don't think we'll want a separate "editorsrc". I consider that part still a "plugin"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's good to separate the meanings of the the terms (as we already do).
I wouldn't want to call everything "extensions" or "libraries".

Also, I don't really consider them confusing.
But I agree that we should be more specific when referring to them

  • (Defold) library
  • Dependency is the link to a library
  • (Native) extension - statically linked source code. Avaialble through the Defold Library system.
  • Plugin (a separate file/bundle to add code)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose "pluginsrc" over "pipelinesrc" because it was shorter, but more importantly because "plugin" is a well known concept. But as you mention, it might be confusing for others.

objs.add(ExtenderUtil.getRelativePath(jobDirectory, o));
i++;
}
ProcessExecutor.executeCommands(processExecutor, commands); // in parallel
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the name of the function indicate parallelism somehow? So the comments aren't necessary

Copy link
Contributor

@Jhonnyg Jhonnyg left a comment

Choose a reason for hiding this comment

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

Looks good!

@JCash JCash merged commit 3912eca into dev Apr 19, 2021
@JCash JCash deleted the issue-5725-build-server-protoc branch April 19, 2021 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants