Skip to content

Commit

Permalink
Continue Starlarkification of j2objc_aspect
Browse files Browse the repository at this point in the history
I've Starlarkified "java" function and its related functions.

"proto" part from j2objc_aspect is already Starlarkified. "build_aspect" is the next part.

PiperOrigin-RevId: 538140848
Change-Id: I9575f60c1658cf9f9350a0b52b058d5bc54e4daf
  • Loading branch information
kotlaja authored and copybara-github committed Jun 6, 2023
1 parent 14c8411 commit 5cd4ff0
Show file tree
Hide file tree
Showing 6 changed files with 384 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,27 @@ public boolean experimentalJ2ObjcHeaderMap() {
return experimentalJ2ObjcHeaderMap;
}

@Override
public boolean getExperimentalJ2ObjcHeaderMapForStarlark(StarlarkThread thread)
throws EvalException {
checkPrivateAccess(thread);
return experimentalJ2ObjcHeaderMap;
}

/**
* Returns whether to use a shorter path for generated header files.
*/
public boolean experimentalShorterHeaderPath() {
return experimentalShorterHeaderPath;
}

@Override
public boolean experimentalShorterHeaderPathforStarlark(StarlarkThread thread)
throws EvalException {
checkPrivateAccess(thread);
return experimentalShorterHeaderPath;
}

/** Returns whether objc_library should build generated files using ARC (-fobjc-arc). */
public boolean compileWithARC() {
return translationFlags.contains(J2OBJC_USE_ARC_FLAG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.google.devtools.build.lib.packages.Type;
import com.google.devtools.build.lib.rules.cpp.CcCompilationContext;
import com.google.devtools.build.lib.rules.cpp.CcLinkingContext;
import com.google.devtools.build.lib.rules.cpp.CppModuleMap.UmbrellaHeaderStrategy;
import com.google.devtools.build.lib.rules.objc.IntermediateArtifacts.AlwaysLink;
import com.google.devtools.build.lib.shell.ShellUtils;
import com.google.devtools.build.lib.shell.ShellUtils.TokenizationException;
import com.google.devtools.build.lib.vfs.PathFragment;
Expand Down Expand Up @@ -173,6 +175,21 @@ public IntermediateArtifacts createIntermediateArtifacts(
return new IntermediateArtifacts(starlarkRuleContext.getRuleContext());
}

@StarlarkMethod(
name = "j2objc_create_intermediate_artifacts",
documented = false,
parameters = {
@Param(name = "ctx", positional = false, named = true),
})
public IntermediateArtifacts j2objcCreateIntermediateArtifacts(
StarlarkRuleContext starlarkRuleContext) {
return new IntermediateArtifacts(
starlarkRuleContext.getRuleContext(),
/* archiveFileNameSuffix= */ "_j2objc",
UmbrellaHeaderStrategy.GENERATE,
AlwaysLink.TRUE);
}

@StarlarkMethod(
name = "create_compilation_artifacts",
documented = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@ public interface J2ObjcConfigurationApi extends StarlarkValue {

@StarlarkMethod(name = "j2objc_library_migration", documented = false, useStarlarkThread = true)
boolean j2objcLibraryMigrationForStarlark(StarlarkThread thread) throws EvalException;

@StarlarkMethod(
name = "experimental_shorter_header_path",
documented = false,
useStarlarkThread = true)
boolean experimentalShorterHeaderPathforStarlark(StarlarkThread thread) throws EvalException;

@StarlarkMethod(
name = "experimental_j2objc_header_map",
documented = false,
useStarlarkThread = true)
boolean getExperimentalJ2ObjcHeaderMapForStarlark(StarlarkThread thread) throws EvalException;
}
Loading

0 comments on commit 5cd4ff0

Please sign in to comment.