GVKun编程网logo

com.facebook.buck.rules.BuildRuleParams的实例源码(仿facebook源码)

32

对于com.facebook.buck.rules.BuildRuleParams的实例源码感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解仿facebook源码,并且为您提供关于com.f

对于com.facebook.buck.rules.BuildRuleParams的实例源码感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解仿facebook源码,并且为您提供关于com.facebook.android.AsyncFacebookRunner的实例源码、com.facebook.android.BuildConfig的实例源码、com.facebook.buck.model.BuildTarget的实例源码、com.facebook.buck.model.Flavored的实例源码的宝贵知识。

本文目录一览:

com.facebook.buck.rules.BuildRuleParams的实例源码(仿facebook源码)

com.facebook.buck.rules.BuildRuleParams的实例源码(仿facebook源码)

项目:buck-cutom    文件:CxxPreprocessables.java   
/**
 * Build the {@link SymlinkTree} rule using the original build params from a target node.
 * In particular,make sure to drop all dependencies from the original build rule params,* as these are modeled via {@link CxxHeader}.
 */
public static SymlinkTree createHeaderSymlinkTreebuildrule(
    BuildTarget target,buildruleParams params,Path root,ImmutableMap<Path,SourcePath> links) {

  return new SymlinkTree(
      params.copyWithChanges(
          HEADER_SYMLINK_TREE_TYPE,target,// Symlink trees never need to depend on anything.
          ImmutableSortedSet.<buildrule>of(),ImmutableSortedSet.<buildrule>of()),root,links);
}
项目:buck-cutom    文件:CxxPreprocessables.java   
/**
 * Setup a build rule that updates whenever any header or header dependency changes.
 * This includes the hash of the header contents and all corresponding transitive
 * header dependencies.  This should be depended on by any compile rules generated
 * for this higher level rule to make sure we re-compile if any headers change.
 */
public static CxxHeader createHeaderbuildrule(
    BuildTarget target,SourcePath> headers) {

  // Todo(agallagher): In the common case,C/C++ sources only actually use a small
  // subset of all the headers in their transitive include search space,so this setup
  // will cause a lot of false rebuilds.  Long-term,we should add some sort of dep-file
  // support to avoid this.
  buildruleParams headerParams = params.copyWithChanges(
      HEADERS_TYPE,/* declaredDeps */ ImmutableSortedSet.copyOf(
          SourcePaths.filterbuildruleInputs(headers.values())),/* declaredDeps */ ImmutableSortedSet.<buildrule>of());
  return new CxxHeader(headerParams,headers);
}
项目:buck-cutom    文件:CxxCompilableEnhancer.java   
/**
 * @return a set of {@link CxxCompile} rules preprocessing,compiling,and assembling the
 *    given input {@link CxxSource} sources.
 */
public static ImmutableSortedSet<buildrule> createCompilebuildrules(
    buildruleParams params,buildruleResolver resolver,Path compiler,CxxPreprocessorInput preprocessorInput,ImmutableList<String> compilerFlags,Iterable<CxxSource> sources) {

  ImmutableSortedSet.Builder<buildrule> rules = ImmutableSortedSet.naturalOrder();

  // Iterate over the input C/C++ sources that we need to preprocess,assemble,and compile,// and generate compile rules for them.
  for (CxxSource source : sources) {
    rules.add(createCompilebuildrule(
        params,resolver,compiler,preprocessorInput,compilerFlags,source));
  }

  return rules.build();
}
项目:buck-cutom    文件:JavaBinary.java   
public JavaBinary(
    buildruleParams params,@Nullable String mainClass,@Nullable SourcePath manifestFile,boolean mergeManifests,@Nullable Path MetaInfDirectory,ImmutableSet<String> blacklist,DirectoryTraverser directoryTraverser) {
  super(params);
  this.mainClass = mainClass;
  this.manifestFile = manifestFile;
  this.mergeManifests = mergeManifests;
  this.MetaInfDirectory = MetaInfDirectory;
  this.blacklist = blacklist;

  this.directoryTraverser = Preconditions.checkNotNull(directoryTraverser);
}
项目:buck-cutom    文件:PythonBinaryDescriptionTest.java   
@Test
public void thatMainSourcePathPropagatesToDeps() {
  buildruleResolver resolver = new buildruleResolver();

  Genrule genrule = GenruleBuilder.createGenrule(BuildTargetFactory.newInstance("//:gen"))
      .setout("blah.py")
      .build();
  buildruleParams params = buildruleParamsFactory.createTrivialbuildruleParams(
      BuildTargetFactory.newInstance("//:bin"));
  PythonBinaryDescription desc = new PythonBinaryDescription(PEX_PATH);
  PythonBinaryDescription.Arg arg = desc.createUnpopulatedConstructorArg();
  arg.deps = Optional.of(ImmutableSortedSet.<buildrule>of());
  arg.main = new buildruleSourcePath(genrule);
  buildrule rule = desc.createbuildrule(params,arg);
  assertEquals(
      ImmutableSortedSet.<buildrule>of(genrule),rule.getDeps());
}
项目:buck-cutom    文件:PythonLibraryDescription.java   
@Override
public <A extends Arg> PythonLibrary createbuildrule(
    buildruleParams params,A args) {
  return new PythonLibrary(
      params,PythonUtil.toModuleMap(
          params.getBuildTarget(),"srcs",params.getBuildTarget().getBasePath(),args.srcs.or(ImmutableSortedSet.<SourcePath>of())),"resources",args.resources.or(ImmutableSortedSet.<SourcePath>of())));
}
项目:buck-cutom    文件:GenruleDescription.java   
@Override
public <A extends Arg> Genrule createbuildrule(
    buildruleParams params,A args) {
  ImmutableList<SourcePath> srcs = args.srcs.get();
  ImmutableSortedSet<buildrule> exTradeps = ImmutableSortedSet.<buildrule>naturalOrder()
      .addAll(params.getExTradeps())
      .addAll(SourcePaths.filterbuildruleInputs(srcs))
      .build();

  return new Genrule(
      params.copyWithExTradeps(exTradeps),srcs,args.cmd,args.bash,args.cmdExe,args.out,params.getPathAbsolutifier());
}
项目:buck-cutom    文件:JavaTestBuilder.java   
public JavaTest build(buildruleResolver resolver) {
  buildruleParams params = new FakebuildruleParamsBuilder(target)
      .setType(JavaTestDescription.TYPE)
      .setDeps(deps.build())
      .build();
  JavaTest test = new JavaTest(
      params,srcs.build(),resources.build(),labels.build(),contacts.build(),proguardConfig,/* additionalClasspathEntries */ ImmutableSet.<Path>of(),Javacoptions.DEFAULTS,vmArgs,sourcesUnderTest.build(),Optional.<Path>absent());
  resolver.addToIndex(test);
  return test;
}
项目:buck-cutom    文件:GenruleBuilder.java   
public Genrule build() {
  final ImmutableSortedSet<buildrule> depRules = ImmutableSortedSet.copyOf(deps);
  args.deps = Optional.of(depRules);
  args.srcs = Optional.of(FluentIterable
      .from(srcs.build())
      .transform(SourcePaths.TO_SOURCE_PATH)
      .toList());

  buildruleParams params = new FakebuildruleParamsBuilder(target)
      .setDeps(depRules)
      .setType(GenruleDescription.TYPE)
      .setProjectFilesystem(
          new ProjectFilesystem(Paths.get(".")) {
            @Override
            public Function<Path,Path> getAbsolutifier() {
              return Optional.fromNullable(absolutifier)
                  .or(IdentityPathAbsolutifier.getIdentityAbsolutifier());
            }
          })
      .build();
  return description.createbuildrule(params,new buildruleResolver(),args);
}
项目:buck-cutom    文件:ArchivesTest.java   
@Test
public void testThatOriginalBuildParamsDepsDoNotPropagatetoArchive() {

  // Create an `Archive` rule using build params with an existing dependency,// as if coming from a `TargetNode` which had declared deps.  These should *not*
  // propagate to the `Archive` rule,since it only cares about dependencies generating
  // it's immediate inputs.
  buildrule dep = new Fakebuildrule(
      buildruleParamsFactory.createTrivialbuildruleParams(
          BuildTargetFactory.newInstance("//:fake")));
  BuildTarget target = BuildTargetFactory.newInstance("//:archive");
  buildruleParams params =
      new FakebuildruleParamsBuilder(BuildTargetFactory.newInstance("//:dummy"))
          .setDeps(ImmutableSortedSet.of(dep))
          .build();
  Archive archive = Archives.createArchiveRule(
      target,params,DEFAULT_ARCHIVER,DEFAULT_OUTPUT,DEFAULT_INPUTS);

  // Verify that the archive rules dependencies are empty.
  assertEquals(archive.getDeps(),ImmutableSortedSet.<buildrule>of());
}
项目:buck-cutom    文件:NdkLibrary.java   
protected NdkLibrary(
    buildruleParams params,Set<SourcePath> sources,List<String> flags,boolean isAsset,Optional<String> ndkVersion) {
  super(params);
  this.isAsset = isAsset;

  BuildTarget buildTarget = params.getBuildTarget();
  this.makefileDirectory = buildTarget.getBasePathWithSlash();
  this.lastPathComponent = "__lib" + buildTarget.getShortName();
  this.buildArtifactsDirectory = getBuildArtifactsDirectory(buildTarget,true /* isScratchDir */);
  this.genDirectory = getBuildArtifactsDirectory(buildTarget,false /* isScratchDir */);

  Preconditions.checkArgument(!sources.isEmpty(),"Must include at least one file (Android.mk?) in ndk_library rule");
  this.sources = ImmutableSortedSet.copyOf(sources);
  this.flags = ImmutableList.copyOf(flags);

  this.ndkVersion = Preconditions.checkNotNull(ndkVersion);
}
项目:buck-cutom    文件:ApkGenrule.java   
ApkGenrule(
    buildruleParams params,List<SourcePath> srcs,Optional<String> cmd,Optional<String> bash,Optional<String> cmdExe,Function<Path,Path> relativetoAbsolutePathFunction,InstallableApk apk) {
  super(params,cmd,bash,cmdExe,/* out */ params.getBuildTarget().getShortName() + ".apk",relativetoAbsolutePathFunction);

  this.apk = Preconditions.checkNotNull(apk);
  this.relativetoAbsolutePathFunction =
      Preconditions.checkNotNull(relativetoAbsolutePathFunction);
}
项目:buck-cutom    文件:AndroidLibraryGraphEnhancer.java   
public AndroidLibraryGraphEnhancer(
    BuildTarget buildTarget,buildruleParams buildruleParams,Javacoptions javacoptions) {
  Preconditions.checkNotNull(buildTarget);
  this.dummyRDotJavaBuildTarget = BuildTarget.builder(buildTarget)
      .setFlavor(DUMMY_R_DOT_JAVA_FLAVOR)
      .build();
  this.originalbuildruleParams = Preconditions.checkNotNull(buildruleParams);
  // Override javacoptions because DummyRDotJava doesn't require annotation processing
  // params data and more importantly,because javacoptions' rule key is not available when
  // DummyRDotJava is built.
  Preconditions.checkNotNull(javacoptions);
  this.javacoptions = Javacoptions.builder(Javacoptions.DEFAULTS)
      .setJavaCompilerEnvironment(javacoptions.getJavaCompilerEnvironment())
      .build();
}
项目:buck-cutom    文件:AndroidBuildConfigJavaLibraryTest.java   
@Test
public void testAddToCollector() {
  BuildTarget buildTarget = BuildTargetFactory.newInstance("//foo:bar");
  buildruleParams params = new FakebuildruleParamsBuilder(buildTarget).build();
  AndroidBuildConfigJavaLibrary buildConfigJavaLibrary = AndroidBuildConfigDescription
      .createbuildrule(
        params,"com.example.buck",/* values */ BuildConfigFields.fromFieldDeclarations(
            Collections.singleton("String foo = \"bar\"")),/* valuesFile */ Optional.<SourcePath>absent(),/* useConstantExpressions */ false);

  AndroidPackageableCollector collector = new AndroidPackageableCollector(buildTarget);
  buildConfigJavaLibrary.addToCollector(collector);
  AndroidPackageableCollection collection = collector.build();
  assertEquals(
      ImmutableMap.of(
          "com.example.buck",BuildConfigFields.fromFields(ImmutableList.of(
              new BuildConfigFields.Field("String","foo","\"bar\"")))),collection.buildConfigs);
}
项目:buck-cutom    文件:PrebuiltNativeLibraryDescription.java   
@Override
public <A extends Args> PrebuiltNativeLibrary createbuildrule(
    buildruleParams params,A args) {
  ImmutableSortedSet<Path> librarySources;
  try {
    librarySources = ImmutableSortedSet.copyOf(
        params.getProjectFilesystem().getFilesUnderPath(args.nativeLibs));
  } catch (IOException e) {
    throw new HumanReadableException(e,"Error traversing directory %s.",args.nativeLibs);
  }

  return new PrebuiltNativeLibrary(
      params,args.nativeLibs,args.isAsset.or(false),librarySources
  );
}
项目:onos    文件:OnosJar.java   
public OnosJar(buildruleParams params,SourcePathResolver resolver,Set<? extends SourcePath> srcs,Set<? extends SourcePath> resources,Optional<Path> generatedSourceFolder,Optional<SourcePath> proguardConfig,ImmutableList<String> postprocessClassesCommands,ImmutableSortedSet<buildrule> exportedDeps,ImmutableSortedSet<buildrule> providedDeps,SourcePath abiJar,boolean trackClassUsage,ImmutableSet<Path> additionalClasspathEntries,CompiletoJarStepFactory compileStepFactory,Optional<Path> resourcesRoot,Optional<SourcePath> manifestFile,Optional<String> mavenCoords,ImmutableSortedSet<BuildTarget> tests,ImmutableSet<Pattern> classesToRemoveFromJar,Optional<String> webContext,Optional<String> apiTitle,Optional<String> apiVersion,Optional<String> apiPackage,Optional<String> apiDescription,Optional<ImmutableSortedMap<String,SourcePath>> includedResources) {
    super(params,resources,generatedSourceFolder,postprocessClassesCommands,exportedDeps,providedDeps,abiJar,trackClassUsage,additionalClasspathEntries,compileStepFactory,resourcesRoot,manifestFile,mavenCoords,tests,classesToRemoveFromJar);
    this.webContext = webContext;
    this.apiTitle = apiTitle;
    this.apiVersion = apiVersion;
    this.apiPackage = apiPackage;
    this.apiDescription = apiDescription;
    this.includedResources = includedResources;
    this.mavendeps = computeMavendeps();
}
项目:buck-cutom    文件:BuckExtension.java   
public BuckExtension(
    buildruleParams params,ImmutableSortedSet<? extends SourcePath> srcs,ImmutableSortedSet<? extends SourcePath> resources) {
  super(params);
  this.srcs = Preconditions.checkNotNull(srcs);
  this.resources = Preconditions.checkNotNull(resources);

  BuildTarget target = params.getBuildTarget();
  this.output = BuildTargets.getGenPath(target,"%s-buck.jar");
  this.abi = BuildTargets.getGenPath(target,"%s-buck.abi");
  this.working = BuildTargets.getBinPath(target,"__%s__");
}
项目:buck-cutom    文件:GenAidlDescription.java   
@Override
public <A extends Arg> GenAidl createbuildrule(
    buildruleParams params,A args) {
  return new GenAidl(
      params,args.aidl,args.importPath);
}
项目:buck-cutom    文件:AaptPackageResourcesTest.java   
/**
 * Tests an android_binary with zero dependent android_library rules that contains an assets
 * directory.
 */
@Test
public void testCreateallAssetsDirectoryWithZeroAssetsDirectories() throws IOException {
  ResourcesFilter resourcesFilter = EasyMock.createMock(ResourcesFilter.class);
  EasyMock.replay(resourcesFilter);

  buildruleParams params = new FakebuildruleParamsBuilder(
      BuildTarget.builder("//java/src/com/facebook/base","apk")
          .setFlavor("aapt_package")
          .build())
      .build();

  // One android_binary rule that depends on the two android_library rules.
  AaptPackageResources aaptPackageResources = new AaptPackageResources(
      params,/* manifest */ new TestSourcePath("java/src/com/facebook/base/AndroidManifest.xml"),resourcesFilter,ImmutableSet.<Path>of(),PackageType.DEBUG,/* cpuFilters */ ImmutableSet.<TargetcpuType>of());

  // Build up the parameters needed to invoke createallAssetsDirectory().
  ImmutableList.Builder<Step> commands = ImmutableList.builder();

  // Invoke createallAssetsDirectory(),the method under test.
  Optional<Path> allAssetsDirectory = aaptPackageResources.createallAssetsDirectory(
      /* assetsDirectories */ ImmutableSet.<Path>of(),commands,new FakeProjectFilesystem());
  EasyMock.verify(resourcesFilter);

  // Verify that no assets/ directory is used.
  assertFalse("There should not be an assets/ directory to pass to aapt.",allAssetsDirectory.isPresent());
  assertTrue("There should not be any commands to build up an assets/ directory.",commands.build().isEmpty());
}
项目:buck-cutom    文件:CxxLibraryDescription.java   
@Override
public <A extends Arg> CxxLibrary createbuildrule(
    buildruleParams params,A args) {

  // Extract the C/C++ sources from the constructor arg.
  ImmutableList<CxxSource> srcs =
      CxxDescriptionEnhancer.parseCxxSources(
          params.getBuildTarget(),args.srcs.or(ImmutableList.<SourcePath>of()));

  // Extract the header map from the our constructor arg.
  ImmutableMap<Path,SourcePath> headers =
      CxxDescriptionEnhancer.parseHeaders(
          params.getBuildTarget(),args.headers.or((ImmutableList.<SourcePath>of())));

  return CxxDescriptionEnhancer.createCxxLibrarybuildrules(
      params,cxxBuckConfig,args.preprocessorFlags.or(ImmutableList.<String>of()),args.propagatedPpFlags.or(ImmutableList.<String>of()),headers,args.compilerFlags.or(ImmutableList.<String>of()),srcs);
}
项目:buck-cutom    文件:Archive.java   
public Archive(
    buildruleParams params,Path archiver,Path output,ImmutableList<Path> inputs) {
  super(params);
  this.archiver = Preconditions.checkNotNull(archiver);
  this.output = Preconditions.checkNotNull(output);
  this.inputs = Preconditions.checkNotNull(inputs);
}
项目:buck-cutom    文件:AuditOwnerCommandTest.java   
@Override
public <A extends FakeArg> buildrule createbuildrule(
    buildruleParams params,A args) {
  return new Fakebuildrule(params);
}
项目:buck-cutom    文件:ShTestDescription.java   
@Override
public <A extends Arg> ShTest createbuildrule(
    buildruleParams params,A args) {
  return new ShTest(params,args.test,args.labels.get());
}
项目:buck-cutom    文件:ProjectGeneratorTest.java   
@Test(expected = HumanReadableException.class)
public void testLibraryPrivateHeaderWithHeaderMaps() throws IOException {
  buildruleParams params =
      new FakebuildruleParamsBuilder(BuildTarget.builder("//foo","lib").build())
          .setType(AppleLibraryDescription.TYPE)
          .build();
  AppleNativeTargetDescriptionArg arg =
      appleLibraryDescription.createUnpopulatedConstructorArg();
  arg.configs = ImmutableMap.of(
      "Debug",ImmutableList.<Either<Path,ImmutableMap<String,String>>>of());
  arg.srcs = ImmutableList.of(
      AppleSource.ofSourceGroup(
          new Pair<>(
              "HeaderGroup2",ImmutableList.of(
                  AppleSource.ofSourcePathWithFlags(
                      new Pair<SourcePath,String>(new TestSourcePath("blech.h"),"private"))))));
  arg.frameworks = ImmutableSortedSet.of();
  arg.deps = Optional.absent();
  arg.gid = Optional.absent();
  arg.headerPathPrefix = Optional.absent();
  arg.useBuckHeaderMaps = Optional.of(true);
  buildrule rule = appleLibraryDescription.createbuildrule(params,arg);

  ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(
      ImmutableSet.of(rule),ImmutableSet.of(rule.getBuildTarget()));

  projectGenerator.createXcodeProjects();
}
项目:buck-cutom    文件:JavaBinaryDescription.java   
@Override
public <A extends Args> JavaBinary createbuildrule(
    buildruleParams params,A args) {
  return new JavaBinary(
      params,args.mainClass.orNull(),args.manifestFile.orNull(),args.mergeManifests.or(true),args.MetaInfDirectory.orNull(),args.blacklist.or(ImmutableSortedSet.<String>of()),new DefaultDirectoryTraverser());
}
项目:buck-cutom    文件:CxxCompilableEnhancerTest.java   
@Test
public void createCompilebuildrulePropagatesBuilRuleSourcePathDeps() {
  BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
  buildruleParams params = buildruleParamsFactory.createTrivialbuildruleParams(target);
  buildruleResolver resolver = new buildruleResolver();

  CxxPreprocessorInput cxxPreprocessorInput = new CxxPreprocessorInput(
      ImmutableSet.<BuildTarget>of(),ImmutableList.<String>of(),ImmutableList.<Path>of(),ImmutableList.<Path>of());


  String name = "foo/bar.cpp";
  Fakebuildrule dep = createFakebuildrule("//:test");
  SourcePath input = new buildruleSourcePath(dep);
  Path output = CxxCompilableEnhancer.getCompileOutputPath(target,name);
  CxxSource cxxSource = new CxxSource(name,input,output);

  CxxCompile cxxCompile = CxxCompilableEnhancer.createCompilebuildrule(
      params,CxxCompilables.DEFAULT_CXX_COMPILER,cxxPreprocessorInput,cxxSource);

  assertEquals(ImmutableSortedSet.<buildrule>of(dep),cxxCompile.getDeps());
}
项目:buck-cutom    文件:DefaultJavaLibraryTest.java   
private static buildrule createDefaultJavaLibaryRuleWithAbiKey(
    @Nullable final String partialAbiHash,BuildTarget buildTarget,ImmutableSet<String> srcs,ImmutableSortedSet<buildrule> deps,ImmutableSortedSet<buildrule> exportedDeps) {
  ImmutableSortedSet<SourcePath> srcsAsPaths = FluentIterable.from(srcs)
      .transform(MorePaths.TO_PATH)
      .transform(SourcePaths.TO_SOURCE_PATH)
      .toSortedSet(Ordering.natural());

  buildruleParams buildruleParams = new FakebuildruleParamsBuilder(buildTarget)
      .setDeps(ImmutableSortedSet.copyOf(deps))
      .setType(JavaLibraryDescription.TYPE)
      .build();

  return new DefaultJavaLibrary(
      buildruleParams,srcsAsPaths,/* resources */ ImmutableSet.<SourcePath>of(),/* proguardConfig */ Optional.<Path>absent(),/* postprocessClassesCommands */ ImmutableList.<String>of(),/* providedDeps */ ImmutableSortedSet.<buildrule>of(),/* resourcesRoot */ Optional.<Path>absent()) {
    @Override
    public Sha1HashCode getAbiKey() {
      if (partialAbiHash == null) {
        return super.getAbiKey();
      } else {
        return createtotalAbiKey(new Sha1HashCode(partialAbiHash));
      }
    }
  };
}
项目:buck-cutom    文件:JavaThriftLibrary.java   
public JavaThriftLibrary(
    buildruleParams params,ImmutableSortedSet<SourcePath> srcs) {
  super(params);
  this.srcs = Preconditions.checkNotNull(srcs);
  this.genPath = BuildTargets.getGenPath(getBuildTarget(),"__thrift_%s__");
  this.srcJarOutputPath = genPath.resolve("gen-java" + JavacStep.SRC_ZIP);
}
项目:buck-cutom    文件:GwtModule.java   
GwtModule(
    buildruleParams params,ImmutableSortedSet<SourcePath> filesForGwtModule) {
  super(params);
  BuildTarget target = params.getBuildTarget();
  this.outputFile = BuildTargets.getGenPath(
      target,"__gwt_module_%s__/" + target.getShortName() + ".jar");
  this.filesForGwtModule = Preconditions.checkNotNull(filesForGwtModule);
}
项目:buck-cutom    文件:PrebuiltJarTest.java   
@Before
public void setUp() {
  buildruleParams buildruleParams =
      new FakebuildruleParamsBuilder(BuildTarget.builder("//lib","junit").build()).build();

  junitJarRule = new PrebuiltJar(buildruleParams,new PathSourcePath(PATH_TO_JUNIT_JAR),Optional.<SourcePath>of(new TestSourcePath("lib/junit-4.11-sources.jar")),/* gwtJar */ Optional.<SourcePath>absent(),Optional.of("http://junit-team.github.io/junit/javadoc/latest/"));
}
项目:buck-cutom    文件:GenParcelableDescription.java   
@Override
public <A extends Arg> GenParcelable createbuildrule(
    buildruleParams params,A args) {
  return new GenParcelable(params,args.srcs);
}
项目:buck-cutom    文件:AndroidManifestTest.java   
private AndroidManifest createSimpleAndroidManifestRule() {
  // First,create the AndroidManifest object.
  buildruleParams buildruleParams = buildruleParamsFactory.createTrivialbuildruleParams(
      BuildTarget.builder("//java/com/example","manifest").build());
  AndroidManifestDescription description = new AndroidManifestDescription();
  AndroidManifestDescription.Arg arg = description.createUnpopulatedConstructorArg();
  arg.skeleton = new TestSourcePath("java/com/example/AndroidManifestSkeleton.xml");
  arg.deps = Optional.<ImmutableSortedSet<buildrule>>of(ImmutableSortedSet.<buildrule>of());
  return description.createbuildrule(buildruleParams,arg);
}
项目:buck-cutom    文件:ShTest.java   
protected ShTest(
    buildruleParams params,SourcePath test,Set<Label> labels) {
  super(params);
  this.test = Preconditions.checkNotNull(test);
  this.labels = ImmutableSet.copyOf(labels);
}
项目:buck-cutom    文件:CxxCompilableEnhancerTest.java   
@Test
public void createCompilebuildrulePropagatesCxxPreprocessorDeps() {
  BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
  buildruleParams params = buildruleParamsFactory.createTrivialbuildruleParams(target);
  buildruleResolver resolver = new buildruleResolver();

  Fakebuildrule dep = resolver.addToIndex(createFakebuildrule("//:dep1"));

  CxxPreprocessorInput cxxPreprocessorInput = new CxxPreprocessorInput(
      ImmutableSet.of(dep.getBuildTarget()),ImmutableList.<Path>of());

  String name = "foo/bar.cpp";
  SourcePath input = new PathSourcePath(target.getBasePath().resolve(name));
  Path output = CxxCompilableEnhancer.getCompileOutputPath(target,cxxCompile.getDeps());
}
项目:buck-cutom    文件:AndroidBuildConfigTest.java   
private static AndroidBuildConfig createSimpleBuildConfigRule() {
  // First,create the BuildConfig object.
  BuildTarget buildTarget = BuildTarget.builder("//java/com/example","build_config").build();
  buildruleParams params = new FakebuildruleParamsBuilder(buildTarget)
      .setType(AndroidBuildConfigDescription.TYPE)
      .build();
  return new AndroidBuildConfig(
      params,/* javaPackage */ "com.example",/* values */ BuildConfigFields.empty(),/* useConstantExpressions */ false);
}
项目:buck-cutom    文件:PythonBinary.java   
protected PythonBinary(
    buildruleParams params,Path pathToPex,Path main,PythonPackageComponents components) {
  super(params);
  this.pathToPex = Preconditions.checkNotNull(pathToPex);
  this.main = Preconditions.checkNotNull(main);
  this.components = Preconditions.checkNotNull(components);
}
项目:buck-cutom    文件:PythonLibrary.java   
protected PythonLibrary(
    buildruleParams params,SourcePath> srcs,SourcePath> resources) {
  super(params);
  this.srcs = Preconditions.checkNotNull(srcs);
  this.resources = Preconditions.checkNotNull(resources);
}
项目:buck-cutom    文件:AppleTestDescription.java   
@Override
public <A extends Arg> AppleTest createbuildrule(
    buildruleParams params,A args) {
  return new AppleTest(params,args);
}
项目:buck-cutom    文件:AppleBundle.java   
AppleBundle(
    buildruleParams params,AppleBundleDescription.Arg args) {
  super(params);
  this.extension = Preconditions.checkNotNull(args.extension);
  this.infoPlist = Preconditions.checkNotNull(args.infoPlist);
  this.binary = args.binary;
}
项目:buck-cutom    文件:AppleLibraryDescription.java   
@Override
public <A extends AppleNativeTargetDescriptionArg> AppleLibrary createbuildrule(
    buildruleParams params,A args) {
  return new AppleLibrary(
      params,args,TargetSources.ofAppleSources(args.srcs),archiver,params.getBuildTarget().getFlavor().equals(DYNAMIC_LIBRARY));
}

com.facebook.android.AsyncFacebookRunner的实例源码

com.facebook.android.AsyncFacebookRunner的实例源码

项目:facebook-android-sdk    文件:Tests.java   
public void onComplete(Bundle values) {
    final String postId = values.getString("post_id");
    if (postId != null) {
        Log.d("Facebook-Example","Dialog Success! post_id=" + postId);
        new AsyncFacebookRunner(authenticatedFacebook).request(postId,new TestPostRequestListener());
    } else {
        Tests.this.runOnUiThread(new Runnable() {
            public void run() {
                wallPostText.setText("Wall Post Failure");
                wallPostText.setTextColor(Color.RED);
            }
        });
    }
}
项目:Socialite    文件:FacebookConnector.java   
@Override
public void logout() {
    SessionEvents.onlogoutBegin(SessionListenerType.FACEBOOK_SESSION_LISTENER);
    AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(this.facebook);
    asyncRunner.logout(activity.getApplicationContext(),new logoutRequestListener());
}
项目:kaorisan    文件:LoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    loginActivity = this;
    sqliteDatabaseAdapter.setContext(this);

    checkGooglePlayServices();

    mPlusClient = new PlusClient.Builder(this,this,this)
    .setVisibleActivities("http://schemas.google.com/AddActivity","http://schemas.google.com/BuyActivity").setScopes(Scopes.PLUS_LOGIN,Scopes.PLUS_PROFILE).build();

    btnLoginGoogle = (Button) findViewById(R.id.btn_login_google);
    initGoogleButton();

    genKeyHash();
    resource = getResources();

    DebugLog.logd("On create");

    // Create the Facebook Object using the app id.
    if (Utility.mFacebook == null) {
        Utility.mFacebook = new Facebook(APP_ID);
    }
    // Instantiate the asynrunner object for asynchronous api calls.
    if (Utility.mAsyncRunner == null) {
        Utility.mAsyncRunner = new AsyncFacebookRunner(Utility.mFacebook);
    }

    SessionStore.restore(Utility.mFacebook,this);

    SessionEvents.addAuthListener(authenListener);
    SessionEvents.addlogoutListener(logoutListener);

    Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

    btnLoginFaceBook = (Button) findViewById(R.id.btn_login_facebook);
    initFacebookButton();

    SessionEvents.addAuthListener(mSessionListener);
    SessionEvents.addlogoutListener(mSessionListener);

    if (Utility.mFacebook.isSessionValid() && islogout == 0 && currentSocial == Social.FACEBOOK) {
        DebugLog.logd("On facebook Create");
        if (Utils.checkInternetConnect(this)) {
            requestGetUserData();
        }
    }

    if (currentSocial == Social.GOOGLE && islogout == 0) {
        DebugLog.logd("On Google Create");
        mPlusClient.connect();
    }
    checklogout();

}
项目:kaorisan    文件:LoginActivity.java   
private void checklogout() {

        if (islogout == 1 && NetworkUtil.NETWORK_STATE != NetworkUtil.TYPE_NOT_CONNECTED) {
            if (currentSocial == Social.FACEBOOK) {
                if (Utility.mFacebook.isSessionValid()) {
                    SessionEvents.onlogoutBegin();
                    AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(Utility.mFacebook);

                    try {
                        if (showProcess != null) {
                            if (showProcess.isShowing()) {
                                showProcess.dismiss();
                            }
                            showProcess = null;
                        }

                        showProcess = new ProgressDialog(this);
                        showProcess.setCancelable(false);
                        showProcess.setTitle(getResources().getString(R.string.txt_logout));

                        showProcess.show();
                    } catch (Exception ex) {
                        DebugLog.logd("checklogout ??? Do not kNow what happen with show process," +
                                "maybe the facebook already hace show process");
                    }
                    asyncRunner.logout(this,new logoutRequestListener());
                }

                if(TaskActivity.taskActivity != null){
                    TaskActivity.taskActivity.finish();
                }
            } else if (currentSocial == Social.GOOGLE) {
                DebugLog.logd("On google logout");
                mPlusClient.disconnect();

            }

            if(CacheData.getInstant().getTokenKaorisan() != null){
                if(!CacheData.getInstant().getTokenKaorisan().isEmpty()){
                    DebugLog.logd("Delete token kaorisan in sqlite");
//                  UserDao.deleteUser(CacheData.getInstant().getTokenKaorisan());
                    UserDao.setCurrentUser("","0","","");
                }
            }
        }

        if(CacheData.getInstant().getCurrentUser() != null){
            if(CacheData.getInstant().getCurrentUser().getPushToken() != null && islogout == 1){
                if (GCMRegistrar.isRegisteredOnServer(TaskActivity.taskActivity)) {
                    ServerUtilities.unregister(TaskActivity.taskActivity,CacheData.getInstant().getCurrentUser().getPushToken());
                    Log.i(TAG,"Unregister server");
                } else {
                    // This callback results from the call to unregister made on
                    // ServerUtilities when the registration to the server Failed.
                    Log.i(TAG,"Ignoring unregister callback");
                }
            }
        }

        Utils.resetCacheData();
        islogout = 0;
    }
项目:IPRJapp    文件:Tutorial_1.java   
@SuppressWarnings("deprecation")
@Override
   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);        

        if (savedInstanceState != null)

            TutoRes = savedInstanceState.getInt("TutoRes");
        facebook = new Facebook(APP_ID);
        AsyncFacebookRunner   mAsyncRunner = new AsyncFacebookRunner(facebook);
        //loginFacebook();

requestwindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.tutorial_1);
//setLogin();



Session.openActiveSession(this,true,new Session.StatusCallback() {


    @Override
    public void call(final Session session,SessionState state,Exception exception) {
        if (session.isOpened()) {

            Request.newMeRequest(session,new Request.GraphUserCallback() {

                  @Override
                  public void onCompleted(GraphUser user,Response response) {

                      if (user != null) {

                        //welcome = (TextView) findViewById(R.id.welcome);                      
                        Userid = user.getId();
                        User_name= user.getFirstName();


                        }
                  }
                }).executeAsync();
            }
    }
  }); 



final Button  Button = (Button) findViewById(R.id.button1);

Button.setonClickListener(new View.OnClickListener() {

       @Override
      public void onClick(View v) {

        if(Userid != null && User_name != null){

             Intent intent = new Intent();
             intent.setClass(Tutorial_1.this,Tutorial_2.class);
             db.addUsuario(new Usuario(User_name,Userid));
            startActivity(intent);
             finish();


        }

        else {

            Toast.makeText(getApplicationContext(),"Aguarde o carregamento dos dados do perfil do Facebook",Toast.LENGTH_SHORT).show();

        }

       }

});
   }

com.facebook.android.BuildConfig的实例源码

com.facebook.android.BuildConfig的实例源码

项目:AndroidbackendlessChat    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com",but may
 * be overridden to,e.g.,"beta.facebook.com" to direct requests at a different domain. This method should
 * never be called from production code.
 *
 * @param facebookDomain the base domain to use instead of "facebook.com"
 */
public static void setFacebookDomain(String facebookDomain) {
    if (!BuildConfig.DEBUG) {
        Log.w(TAG,"WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:chat-sdk-android-push-firebase    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:yelo-android    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:BrillaMXAndroid    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:aquaplay    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:TP-Formation-Android    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:AutoTimeHelper    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:snake-game-aws    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:BrainStudio    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:KlyphMessenger    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:Shorcial    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:Team-Alice    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:CampusFeedv2    文件:NativeProtocol.java   
private static List<NativeAppInfo> buildFacebookAppList() {
    List<NativeAppInfo> list = new ArrayList<NativeAppInfo>();

    // Katana needs to be the first thing in the list since it will get selected as the default FACEBOOK_APP_INFO
    list.add(FACEBOOK_APP_INFO);

    if(BuildConfig.DEBUG) {
        list.add(new WakizashiAppInfo());
    }

    return list;
}
项目:Abelana-Android    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:WatsiAndroidApp    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:Qtino.SharingKit    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:maven-multilib-sample-app    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:DualRunner    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:ShopAfter    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:MeNextAndroid    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:MisterWok    文件:NativeProtocol.java   
private static List<NativeAppInfo> buildFacebookAppList() {
    List<NativeAppInfo> list = new ArrayList<NativeAppInfo>();

    // Katana needs to be the first thing in the list since it will get selected as the default FACEBOOK_APP_INFO
    list.add(FACEBOOK_APP_INFO);

    if(BuildConfig.DEBUG) {
        list.add(new WakizashiAppInfo());
    }

    return list;
}
项目:CanYouSinkMe    文件:NativeProtocol.java   
private static List<NativeAppInfo> buildFacebookAppList() {
    List<NativeAppInfo> list = new ArrayList<NativeAppInfo>();

    // Katana needs to be the first thing in the list since it will get selected as the default FACEBOOK_APP_INFO
    list.add(FACEBOOK_APP_INFO);

    if(BuildConfig.DEBUG) {
        list.add(new WakizashiAppInfo());
    }

    return list;
}
项目:CanYouSinkMe    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:Classparticipation2    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:Klyph    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:Wabbit-Messenger---android-client    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:LostAndFound    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:UbiNomadLib    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:Nefete    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:PetTinder    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:StoryTeller    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:barterli_android    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:HereAStory-Android    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:android-skeleton-project    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:FacebookImageShareIntent    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:openkit-android    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:stepout    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:bladedroid    文件:Settings.java   
/**
 * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com","WARNING: Calling setFacebookDomain from non-DEBUG code.");
    }

    Settings.facebookDomain = facebookDomain;
}
项目:AndroidbackendlessChat    文件:Utility.java   
public static void logd(String tag,Exception e) {
    if (BuildConfig.DEBUG && tag != null && e != null) {
        Log.d(tag,e.getClass().getSimpleName() + ": " + e.getMessage());
    }
}
项目:AndroidbackendlessChat    文件:Utility.java   
public static void logd(String tag,String msg) {
    if (BuildConfig.DEBUG && tag != null && msg != null) {
        Log.d(tag,msg);
    }
}

com.facebook.buck.model.BuildTarget的实例源码

com.facebook.buck.model.BuildTarget的实例源码

项目:buck-cutom    文件:DexProducedFromJavaLibraryThatContainsClassFilesTest.java   
@Test
public void testObserverMethods() {
  JavaLibrary accumulateClassNames = createMock(JavaLibrary.class);
  expect(accumulateClassNames.getClassNamesToHashes())
      .andReturn(ImmutableSortedMap.of("com/example/Foo",HashCode.fromString("cafebabe")))
      .anyTimes();

  replayAll();

  BuildTarget buildTarget = BuildTarget.builder("//foo","bar").build();
  buildruleParams params = new FakebuildruleParamsBuilder(buildTarget).build();
  DexProducedFromJavaLibrary preDexWithClasses =
      new DexProducedFromJavaLibrary(params,accumulateClassNames);
  assertNull(preDexWithClasses.getPathToOutputFile());
  assertTrue(Iterables.isEmpty(preDexWithClasses.getInputsToComparetoOutput()));
  assertEquals(Paths.get("buck-out/gen/foo/bar.dex.jar"),preDexWithClasses.getPathToDex());
  assertTrue(preDexWithClasses.hasOutput());

  verifyAll();
}
项目:buck-cutom    文件:ProjectCommand.java   
ImmutableList<String> getAnnotationProcessingTargets(ProjectCommandOptions options)
    throws BuildTargetException,BuildFileParseException,IOException,InterruptedException {
  return ImmutableList.copyOf(
      Iterables.transform(
          Iterables.getonlyElement(
              createPartialGraphs(
                  Optional.of(ANNOTATION_PREDICATE),Optional.<RuleJsonPredicate>absent(),Optional.<AssociatedRulePredicate>absent(),options))
              .getTargets(),new Function<BuildTarget,String>() {
            @Override
            public String apply(BuildTarget target) {
              return target.getFullyQualifiedname();
            }
          }));
}
项目:buck-cutom    文件:TestCommandTest.java   
/**
 * If the source paths specified are all generated files,then our path to source tmp
 * should be absent.
 */
@Test
public void testGeneratedSourceFile() {
  Path pathToGenFile = GEN_PATH.resolve("GeneratedFile.java");
  assertTrue(MorePaths.isGeneratedFile(pathToGenFile));

  ImmutableSortedSet<Path> javaSrcs = ImmutableSortedSet.of(pathToGenFile);
  JavaLibrary javaLibrary = new FakeJavaLibrary(BuildTarget.builder("//foo","bar").build())
      .setJavaSrcs(javaSrcs);

  DefaultJavaPackageFinder defaultJavaPackageFinder =
      createMock(DefaultJavaPackageFinder.class);

  Object[] mocks = new Object[] {defaultJavaPackageFinder};
  replay(mocks);

  ImmutableSet<String> result = TestCommand.getPathToSourceFolders(
      javaLibrary,Optional.of(defaultJavaPackageFinder),new FakeProjectFilesystem());

  assertTrue("No path should be returned if the library contains only generated files.",result.isEmpty());

  verify(mocks);
}
项目:buck-cutom    文件:ProjectGeneratorTest.java   
@Test(expected = HumanReadableException.class)
public void shouldRejectUnkNownBuildSettingsInFrameworkEntries() throws IOException {
  buildrule rule = createbuildruleWithDefaults(
      BuildTarget.builder("//foo","rule")
          .setFlavor(AppleLibraryDescription.DYNAMIC_LIBRARY)
          .build(),ImmutableSortedSet.<buildrule>of(),appleLibraryDescription,new Function<AppleNativeTargetDescriptionArg,AppleNativeTargetDescriptionArg>() {
        @Override
        public AppleNativeTargetDescriptionArg apply(AppleNativeTargetDescriptionArg input) {
          input.frameworks = ImmutableSortedSet.of("$FOOBAR/libfoo.a");
          return input;
        }
      }
  );

  ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(
      ImmutableSet.of(rule),ImmutableSet.of(rule.getBuildTarget()));
  projectGenerator.createXcodeProjects();
}
项目:buck-cutom    文件:RuleKeyTest.java   
@Test
public void ensureSetsAreHandledProperly() {
  BuildTarget target = BuildTargetFactory.newInstance("//foo/bar:baz");
  Fakebuildrule rule = new Fakebuildrule(new buildruleType("example"),target);
  rule.setRuleKey(RuleKey.TO_RULE_KEY.apply("cafebabe"));
  rule.setoutputFile("cheese.txt");

  ImmutableSortedSet<SourcePath> sourcePaths = ImmutableSortedSet.<SourcePath>of(
      new buildruleSourcePath(rule),new TestSourcePath("alpha/beta"));
  ImmutableSet<String> strings = ImmutableSet.of("one","two");

  RuleKey.Builder.RuleKeyPair reflective = createEmptyRuleKey()
      .setReflectively("sourcePaths",sourcePaths)
      .setReflectively("strings",strings)
      .build();

  RuleKey.Builder.RuleKeyPair manual = createEmptyRuleKey()
      .setSourcePaths("sourcePaths",sourcePaths)
      .set("strings",strings)
      .build();

  assertEquals(manual.getTotalRuleKey(),reflective.getTotalRuleKey());
}
项目:buck-cutom    文件:ParserTest.java   
@Test
public void whenAllRulesThenSingleTargetRequestedThenRulesAreParsedOnce()
    throws BuildFileParseException,BuildTargetException,InterruptedException {
  TestProjectBuildFileParserFactory buildFileParserFactory =
      new TestProjectBuildFileParserFactory(filesystem,buildruleTypes);
  Parser parser = createParser(emptyBuildTargets(),buildFileParserFactory);

  parser.filterallTargetsInProject(
      filesystem,Lists.<String>newArrayList(),alwaysTrue(),new TestConsole(),ImmutableMap.<String,String>of());
  BuildTarget foo = BuildTarget.builder("//java/com/facebook","foo").build();
  parser.parseBuildFilesForTargets(
      ImmutableList.of(foo),BuckEventBusFactory.newInstance(),String>of());

  assertEquals("Should have cached build rules.",1,buildFileParserFactory.calls);
}
项目:buck-cutom    文件:buildruleFactoryParamsTest.java   
@Test
public void testGetoptionalIntegerAttributeWithValue() {
  BuildTarget target = BuildTargetFactory.newInstance("//src/com/facebook:Main");

  Map<String,Object> instance = ImmutableMap.<String,Object>of(
      "some_value",42);

  buildruleFactoryParams params = new buildruleFactoryParams(
      instance /* instance */,filesystem,parser,target,new FakeRuleKeyBuilderFactory());

  assertEquals(Optional.of(42),params.getoptionalIntegerAttribute("some_value"));
}
项目:buck-cutom    文件:DefaultOndiskBuildInfoTest.java   
@Test
public void whenMetadataEmptyStringThenGetRuleKeyWithoutDepsReturnsAbsent() {
  ProjectFilesystem projectFilesystem = EasyMock.createMock(ProjectFilesystem.class);
  EasyMock.expect(
      projectFilesystem.readFileIfItExists(
          Paths.get("buck-out/bin/foo/bar/.baz/Metadata/" +
                  BuildInfo.MetaDATA_KEY_FOR_RULE_KEY_WITHOUT_DEPS)))
      .andReturn(Optional.of(""));
  EasyMock.replay(projectFilesystem);

  BuildTarget buildTarget = BuildTarget.builder("//foo/bar","baz").build();
  DefaultOndiskBuildInfo ondiskBuildInfo = new DefaultOndiskBuildInfo(
      buildTarget,projectFilesystem);
  assertEquals(Optional.absent(),ondiskBuildInfo.getRuleKeyWithoutDeps());

  EasyMock.verify(projectFilesystem);
}
项目:buck-cutom    文件:AuditOwnerCommandTest.java   
@Test
public void verifyMissingFilesAreCorrectlyReported() throws CmdLineException {
  // All files will be directories Now
  FakeProjectFilesystem filesystem = new FakeProjectFilesystem() {
    @Override
    public File getFileForRelativePath(String pathRelativetoProjectRoot) {
      return new MissingFile(getRootPath(),pathRelativetoProjectRoot);
    }
  };

  // Inputs that should be treated as missing files
  ImmutableSet<String> inputs = ImmutableSet.of(
      "java/somefolder/badfolder/somefile.java","java/somefolder/perfect.java","com/test/subtest/random.java");

  BuildTarget target = BuildTarget.builder("//base","name").build();
  TargetNode<?> targetNode = createTargetNode(target,ImmutableSet.<Path>of());

  AuditOwnerCommand command = createAuditOwnerCommand(filesystem);
  AuditOwnerCommand.OwnersReport report = command.generateOwnersReport(targetNode,inputs,false);
  assertTrue(report.owners.isEmpty());
  assertTrue(report.nonFileInputs.isEmpty());
  assertTrue(report.inputsWithNoOwners.isEmpty());
  assertEquals(inputs,report.nonExistentInputs);
}
项目:buck-cutom    文件:TestCommandTest.java   
/**
 * If the source paths specified are from the new unified source tmp then we should return
 * the correct source tmp corresponding to the unified source path.
 */
@Test
public void testUnifiedSourceFile() {
  Path pathToNonGenFile = Paths.get("java/package/SourceFile1.java");
  assertFalse(MorePaths.isGeneratedFile(pathToNonGenFile));

  ImmutableSortedSet<Path> javaSrcs = ImmutableSortedSet.of(pathToNonGenFile);
  JavaLibrary javaLibrary = new FakeJavaLibrary(BuildTarget.builder("//foo","bar").build())
      .setJavaSrcs(javaSrcs);

  DefaultJavaPackageFinder defaultJavaPackageFinder =
      createMock(DefaultJavaPackageFinder.class);
  expect(defaultJavaPackageFinder.getPathsFromroot()).andReturn(pathsFromroot);

  Object[] mocks = new Object[] {defaultJavaPackageFinder};
  replay(mocks);

  ImmutableSet<String> result = TestCommand.getPathToSourceFolders(
      javaLibrary,new FakeProjectFilesystem());

  assertEquals("All non-generated source files are under one source tmp.",ImmutableSet.of("java/"),result);

  verify(mocks);
}
项目:buck-cutom    文件:ArchivesTest.java   
@Test
public void testThatOriginalBuildParamsDepsDoNotPropagatetoArchive() {

  // Create an `Archive` rule using build params with an existing dependency,// as if coming from a `TargetNode` which had declared deps.  These should *not*
  // propagate to the `Archive` rule,since it only cares about dependencies generating
  // it's immediate inputs.
  buildrule dep = new Fakebuildrule(
      buildruleParamsFactory.createTrivialbuildruleParams(
          BuildTargetFactory.newInstance("//:fake")));
  BuildTarget target = BuildTargetFactory.newInstance("//:archive");
  buildruleParams params =
      new FakebuildruleParamsBuilder(BuildTargetFactory.newInstance("//:dummy"))
          .setDeps(ImmutableSortedSet.of(dep))
          .build();
  Archive archive = Archives.createArchiveRule(
      target,params,DEFAULT_ARCHIVER,DEFAULT_OUTPUT,DEFAULT_INPUTS);

  // Verify that the archive rules dependencies are empty.
  assertEquals(archive.getDeps(),ImmutableSortedSet.<buildrule>of());
}
项目:buck-cutom    文件:DefaultOndiskBuildInfoTest.java   
@Test
   public void whenMetadataValidRuleKeyThenGetRuleKeyReturnsKey() {
  ProjectFilesystem projectFilesystem = EasyMock.createMock(ProjectFilesystem.class);
  String key = "fa";
  EasyMock.expect(
      projectFilesystem.readFileIfItExists(
          Paths.get("buck-out/bin/foo/bar/.baz/Metadata/" + BuildInfo.MetaDATA_KEY_FOR_RULE_KEY)))
      .andReturn(Optional.of(key));
  EasyMock.replay(projectFilesystem);

  BuildTarget buildTarget = BuildTarget.builder("//foo/bar",projectFilesystem);
  assertEquals(Optional.of(new RuleKey(key)),ondiskBuildInfo.getRuleKey());

  EasyMock.verify(projectFilesystem);
}
项目:buck-cutom    文件:ConstructorArgMarshallerTest.java   
@Test
public void upperBoundGenericTypesCauseValuesToBeSetToTheUpperBound()
    throws ConstructorArgMarshalException {

  class Dto implements ConstructorArg {
    public List<? extends SourcePath> yup;
  }

  BuildTarget target = BuildTargetFactory.newInstance("//will:happen");
  ruleResolver.addToIndex(target,new Fakebuildrule(new buildruleType("example"),target));
  Dto dto = new Dto();
  marshaller.populate(
      ruleResolver,buildruleFactoryParams(ImmutableMap.<String,Object>of(
          "yup",ImmutableList.of(target.getFullyQualifiedname()))),dto);

  buildruleSourcePath path = new buildruleSourcePath(new Fakebuildrule(ruleType,target));
  assertEquals(ImmutableList.of(path),dto.yup);
}
项目:buck-cutom    文件:PartialGraph.java   
private static PartialGraph parseAndCreateGraphFromTargets(
    ImmutableSet<BuildTarget> targets,Iterable<String> includes,Parser parser,BuckEventBus eventBus,Console console,ImmutableMap<String,String> environment)
    throws BuildTargetException,InterruptedException {

  Preconditions.checkNotNull(parser);

  // Now that the Parser is loaded up with the set of all build rules,use it to create a
  // DependencyGraph of only the targets we want to build.
  ActionGraph graph = parser.parseBuildFilesForTargets(
      targets,includes,eventBus,console,environment);

  return new PartialGraph(graph,targets);
}
项目:buck-cutom    文件:GenruleTest.java   
@Test
public void testGetoutputNameMethod() {
  BuildTarget target = BuildTargetFactory.newInstance("//:test");

  // Sample data of output names to test with Genrule
  ImmutableList<String> names = ImmutableList.of(
      "out.txt","out/file.txt");

  // Create genrules using the names above and verify the output name method returns
  // them.
  for (String name : names) {
    Genrule genrule = GenruleBuilder
        .createGenrule(target)
        .setout(name)
        .build();
    assertEquals(name,genrule.getoutputName());
  }
}
项目:buck-cutom    文件:ApplebuildrulesTest.java   
@Test
public void testAppleLibraryIsNotXcodeTargetTestbuildruleType() throws Exception {
  buildruleParams params =
      new FakebuildruleParamsBuilder(BuildTarget.builder("//foo","lib").build())
          .setType(AppleLibraryDescription.TYPE)
          .build();
  AppleNativeTargetDescriptionArg arg =
      appleLibraryDescription.createUnpopulatedConstructorArg();
  arg.configs = ImmutableMap.of();
  arg.srcs = ImmutableList.of();
  arg.frameworks = ImmutableSortedSet.of();
  arg.deps = Optional.absent();
  arg.gid = Optional.absent();
  arg.headerPathPrefix = Optional.absent();
  arg.useBuckHeaderMaps = Optional.absent();
  AppleLibrary libraryRule =
      appleLibraryDescription.createbuildrule(params,new buildruleResolver(),arg);

  assertFalse(Applebuildrules.isXcodeTargetTestbuildrule(libraryRule));
}
项目:buck-cutom    文件:ProjectTest.java   
@Test
public void testDoNotIgnoreAllOfBuckOut() {
  ProjectFilesystem projectFilesystem = EasyMock.createMock(ProjectFilesystem.class);
  ImmutableSet<Path> ignorePaths = ImmutableSet.of(Paths.get("buck-out"),Paths.get(".git"));
  EasyMock.expect(projectFilesystem.getIgnorePaths()).andReturn(ignorePaths);
  EasyMock.replay(projectFilesystem);

  BuildTarget buildTarget = BuildTarget.builder("//","base").build();
  buildrule buildrule = new Fakebuildrule(JavaLibraryDescription.TYPE,buildTarget);
  Module module = new Module(buildrule,buildTarget);

  Project.addRootExcludes(module,buildrule,projectFilesystem);

  ImmutableSortedSet<SourceFolder> expectedExcludeFolders =
      ImmutableSortedSet.orderedBy(Module.ALPHABETIZER)
      .add(new SourceFolder("file://$MODULE_DIR$/.git",/* isTestSource */ false))
      .add(new SourceFolder("file://$MODULE_DIR$/buck-out/bin",/* isTestSource */ false))
      .add(new SourceFolder("file://$MODULE_DIR$/buck-out/log",/* isTestSource */ false))
      .build();
  assertEquals("Specific subfolders of buck-out should be excluded rather than all of buck-out.",expectedExcludeFolders,module.excludeFolders);

  EasyMock.verify(projectFilesystem);
}
项目:buck-cutom    文件:TargetsCommand.java   
/**
 * @param referencedpaths All of these paths must be relative to the project root.
 */
public TargetsCommandPredicate(
    PartialGraph partialGraph,ImmutableSet<buildruleType> buildruleTypes,ImmutableSet<String> referencedpaths,ImmutableSet<BuildTarget> matchingbuildrules) {
  this.graph = partialGraph.getActionGraph();
  this.buildruleTypes = Preconditions.checkNotNull(buildruleTypes);
  this.matchingbuildrules = Preconditions.checkNotNull(matchingbuildrules);

  Preconditions.checkNotNull(referencedpaths);
  if (!referencedpaths.isEmpty()) {
    this.referencedInputs = MorePaths.asPaths(referencedpaths);
    Buildfiletree tree = new InMemoryBuildfiletree(partialGraph.getTargets());
    basePathOfTargets = Sets.newHashSet();
    dependentTargets = Sets.newHashSet();
    for (Path input : referencedInputs) {
      basePathOfTargets.add(tree.getBasePathOfAncestorTarget(input));
    }
  } else {
    basePathOfTargets = ImmutableSet.of();
    dependentTargets = ImmutableSet.of();
  }
}
项目:buck-cutom    文件:ParserTest.java   
@Test
public void whenSingleTargetThenAllRulesRequestedThenRulesAreParsedTwice()
    throws BuildFileParseException,buildFileParserFactory);

  BuildTarget foo = BuildTarget.builder("//java/com/facebook",String>of());
  parser.filterallTargetsInProject(
      filesystem,String>of());

  assertEquals("Should have replaced build rules",2,buildFileParserFactory.calls);
}
项目:buck-cutom    文件:AuditOwnerCommandTest.java   
@Test
public void verifyInputsWithoutOwnersAreCorrectlyReported() throws CmdLineException {
  FakeProjectFilesystem filesystem = new FakeProjectFilesystem() {
    @Override
    public File getFileForRelativePath(String pathRelativetoProjectRoot) {
      return new ExistingFile(getRootPath(),pathRelativetoProjectRoot);
    }
  };

  // Inputs that should be treated as existing files
  ImmutableSet<String> inputs = ImmutableSet.of(
      "java/somefolder/badfolder/somefile.java","com/test/subtest/random.java");
  ImmutableSet<Path> inputPaths = MorePaths.asPaths(inputs);

  BuildTarget target = BuildTarget.builder("//base",false);
  assertTrue(report.owners.isEmpty());
  assertTrue(report.nonFileInputs.isEmpty());
  assertTrue(report.nonExistentInputs.isEmpty());
  assertEquals(inputPaths,report.inputsWithNoOwners);
}
项目:buck-cutom    文件:DefaultOndiskBuildInfoTest.java   
@Test
public void whenMetadataValidRuleKeyThenGetRuleKeyWithoutDepsReturnsKey() {
  ProjectFilesystem projectFilesystem = EasyMock.createMock(ProjectFilesystem.class);
  String key = "fa";
  EasyMock.expect(
      projectFilesystem.readFileIfItExists(
          Paths.get("buck-out/bin/foo/bar/.baz/Metadata/" +
                  BuildInfo.MetaDATA_KEY_FOR_RULE_KEY_WITHOUT_DEPS)))
      .andReturn(Optional.of(key));
  EasyMock.replay(projectFilesystem);

  BuildTarget buildTarget = BuildTarget.builder("//foo/bar",ondiskBuildInfo.getRuleKeyWithoutDeps());

  EasyMock.verify(projectFilesystem);
}
项目:buck-cutom    文件:ExportFile.java   
@VisibleForTesting
ExportFile(buildruleParams params,ExportFileDescription.Arg args) {
  super(params);
  BuildTarget target = params.getBuildTarget();
  if (args.src.isPresent()) {
    this.src = args.src.get();
  } else {
    this.src = new PathSourcePath(target.getBasePath().resolve(target.getShortName()));
  }

  final String outName = args.out.or(target.getShortName());
  this.out = BuckConstant.GEN_PATH.resolve(target.getBasePath()).resolve(outName);
}
项目:buck-cutom    文件:CxxDescriptionEnhancer.java   
/**
 * @return a map of header locations to input {@link SourcePath} objects formed by parsing the
 *    input {@link SourcePath} objects for the "headers" parameter.
 */
public static ImmutableMap<Path,SourcePath> parseHeaders(
    BuildTarget target,Iterable<SourcePath> inputs) {

  return CxxPreprocessables.resolveHeaderMap(
      target,SourcePaths.getSourcePathNames(
          target,"headers",inputs));
}
项目:buck-cutom    文件:CxxDescriptionEnhancer.java   
/**
 * @return a list {@link CxxSource} objects formed by parsing the input {@link SourcePath}
 *    objects for the "srcs" parameter.
 */
public static ImmutableList<CxxSource> parseCxxSources(
    BuildTarget target,Iterable<SourcePath> inputs) {

  return CxxCompilableEnhancer.resolveCxxSources(
      target,"srcs",inputs));
}
项目:buck-cutom    文件:AndroidLibraryGraphEnhancerTest.java   
@Test
public void testemptyResources() {
  BuildTarget buildTarget = BuildTarget.builder("//java/com/example","library").build();
  AndroidLibraryGraphEnhancer graphEnhancer = new AndroidLibraryGraphEnhancer(
      buildTarget,new FakebuildruleParamsBuilder(buildTarget).build(),Javacoptions.DEFAULTS);
  Optional<DummyRDotJava> result = graphEnhancer.createBuildableForAndroidResources(
      new buildruleResolver(),/* createdBuildableIfEmptyDeps */ false);
  assertFalse(result.isPresent());
}
项目:buck-cutom    文件:GenruleTest.java   
@Test
public void ensureFilesInSubdirectoriesAreKeptInSubDirectories() throws IOException {
  BuildTarget target = BuildTargetFactory.newInstance("//:example");
  buildrule rule = GenruleBuilder.createGenrule(target)
      .setRelativetoAbsolutePathFunctionForTesting(ABSOLUTIFIER)
      .setBash("ignored")
      .addSrc(Paths.get("in-dir.txt"))
      .addSrc(Paths.get("foo/bar.html"))
      .addSrc(Paths.get("other/place.txt"))
      .setout("example-file")
      .build();

  ImmutableList.Builder<Step> builder = ImmutableList.builder();
  ((Genrule) rule).addSymlinkCommands(builder);
  ImmutableList<Step> commands = builder.build();

  String baseTmpPath = GEN_DIR + "/example__srcs/";

  assertEquals(3,commands.size());
  MkdirAndSymlinkFileStep linkCmd = (MkdirAndSymlinkFileStep) commands.get(0);
  assertEquals(Paths.get("in-dir.txt"),linkCmd.getSource());
  assertEquals(Paths.get(baseTmpPath + "in-dir.txt"),linkCmd.getTarget());

  linkCmd = (MkdirAndSymlinkFileStep) commands.get(1);
  assertEquals(Paths.get("foo/bar.html"),linkCmd.getSource());
  assertEquals(Paths.get(baseTmpPath + "foo/bar.html"),linkCmd.getTarget());

  linkCmd = (MkdirAndSymlinkFileStep) commands.get(2);
  assertEquals(Paths.get("other/place.txt"),linkCmd.getSource());
  assertEquals(Paths.get(baseTmpPath + "other/place.txt"),linkCmd.getTarget());
}
项目:buck-cutom    文件:ProjectGenerator.java   
private ConfigInXcodeLayout(
    BuildTarget buildTarget,Optional<Path> projectLevelConfigFile,String> projectLevelInlinesettings,Optional<Path> targetLevelConfigFile,String> targetLevelInlinesettings) {
  this.buildTarget = Preconditions.checkNotNull(buildTarget);
  this.projectLevelConfigFile =
      Preconditions.checkNotNull(projectLevelConfigFile);
  this.projectLevelInlinesettings = Preconditions.checkNotNull(projectLevelInlinesettings);
  this.targetLevelConfigFile = Preconditions.checkNotNull(targetLevelConfigFile);
  this.targetLevelInlinesettings = Preconditions.checkNotNull(targetLevelInlinesettings);
}
项目:buck-cutom    文件:CxxPreprocessablesTest.java   
@Test
public void getTransitiveCxxPreprocessorinput() {

  // Setup a simple CxxPreprocessorDep which contributes components to preprocessing.
  BuildTarget cppDepTarget1 = BuildTargetFactory.newInstance("//:cpp1");
  CxxPreprocessorInput input1 = new CxxPreprocessorInput(
      ImmutableSet.of(cppDepTarget1),ImmutableList.of("-Dtest=yes"),ImmutableList.of(Paths.get("foo/bar"),Paths.get("hello")),ImmutableList.of(Paths.get("/usr/include")));
  BuildTarget depTarget1 = BuildTargetFactory.newInstance("//:dep1");
  FakeCxxPreprocessorDep dep1 = createFakeCxxPreprocessorDep(depTarget1,input1);

  // Setup another simple CxxPreprocessorDep which contributes components to preprocessing.
  BuildTarget cppDepTarget2 = BuildTargetFactory.newInstance("//:cpp2");
  CxxPreprocessorInput input2 = new CxxPreprocessorInput(
      ImmutableSet.of(cppDepTarget2),ImmutableList.of("-DBLAH"),ImmutableList.of(Paths.get("goodbye")),ImmutableList.of(Paths.get("test")));
  BuildTarget depTarget2 = BuildTargetFactory.newInstance("//:dep2");
  FakeCxxPreprocessorDep dep2 = createFakeCxxPreprocessorDep(depTarget2,input2);

  // Create a normal dep which depends on the two CxxPreprocessorDep rules above.
  BuildTarget depTarget3 = BuildTargetFactory.newInstance("//:dep3");
  Fakebuildrule dep3 = createFakebuildrule(depTarget3,dep1,dep2);

  // Verify that getTransitiveCxxPreprocessorInput gets all CxxPreprocessorInput objects
  // from the relevant rules above.
  CxxPreprocessorInput expected = CxxPreprocessorInput.concat(
      ImmutableList.of(input1,input2));
  CxxPreprocessorInput actual = CxxPreprocessables.getTransitiveCxxPreprocessorInput(
      ImmutableList.<buildrule>of(dep3));
  assertEquals(expected,actual);
}
项目:buck-cutom    文件:ProjectGeneratorTest.java   
@Test
public void testCoreDataModelRuleAddsReference() throws IOException {
  buildrule modelRule = createbuildruleWithDefaults(
      BuildTarget.builder("//foo","model").build(),coreDataModelDescription,new Function<CoreDataModelDescription.Arg,CoreDataModelDescription.Arg>() {
        @Override
        public CoreDataModelDescription.Arg apply(CoreDataModelDescription.Arg args) {
          args.path = new TestSourcePath("foo.xcdatamodel").asReference();
          return args;
        }
      });

  buildrule libraryRule = createbuildruleWithDefaults(
      BuildTarget.builder("//foo","lib").build(),ImmutableSortedSet.of(modelRule),appleLibraryDescription);


  ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(
      ImmutableSet.of(libraryRule),ImmutableSet.of(libraryRule.getBuildTarget()));

  projectGenerator.createXcodeProjects();

  PBXProject project = projectGenerator.getGeneratedProject();
  PBXGroup targetGroup =
      project.getMainGroup().getorCreateChildGroupByName(libraryRule.getFullyQualifiedname());
  PBXGroup resourcesGroup = targetGroup.getorCreateChildGroupByName("Resources");

  assertthat(resourcesGroup.getChildren(),hasSize(1));

  PBXFileReference modelReference = (PBXFileReference) Iterables.get(
      resourcesGroup.getChildren(),0);
  assertEquals("foo.xcdatamodel",modelReference.getName());
}
项目:buck-cutom    文件:AuditOwnerCommandTest.java   
/**
 * Verify that owners are correctly detected:
 *  - one owner,multiple inputs
 */
@Test
public void verifyInputsWithOneOwnerAreCorrectlyReported() throws CmdLineException {
  FakeProjectFilesystem filesystem = new FakeProjectFilesystem() {
    @Override
    public File getFileForRelativePath(String pathRelativetoProjectRoot) {
      return new ExistingFile(getRootPath(),pathRelativetoProjectRoot);
    }
  };

  ImmutableSet<String> inputs = ImmutableSet.of(
      "java/somefolder/badfolder/somefile.java",inputPaths);

  AuditOwnerCommand command = createAuditOwnerCommand(filesystem);
  AuditOwnerCommand.OwnersReport report = command.generateOwnersReport(targetNode,false);
  assertTrue(report.nonFileInputs.isEmpty());
  assertTrue(report.nonExistentInputs.isEmpty());
  assertTrue(report.inputsWithNoOwners.isEmpty());

  assertEquals(inputs.size(),report.owners.size());
  assertTrue(report.owners.containsKey(targetNode));
  assertEquals(targetNode.getInputs(),report.owners.get(targetNode));
}
项目:buck-cutom    文件:NativeLinkableInput.java   
public NativeLinkableInput(
    ImmutableSet<BuildTarget> targets,ImmutableList<Path> inputs,ImmutableList<String> args) {

  this.targets = Preconditions.checkNotNull(targets);
  this.inputs = Preconditions.checkNotNull(inputs);
  this.args = Preconditions.checkNotNull(args);
}
项目:buck-cutom    文件:CxxCompilableEnhancerTest.java   
@Test
public void createCompilebuildrulePropagatesBuilRuleSourcePathDeps() {
  BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
  buildruleParams params = buildruleParamsFactory.createTrivialbuildruleParams(target);
  buildruleResolver resolver = new buildruleResolver();

  CxxPreprocessorInput cxxPreprocessorInput = new CxxPreprocessorInput(
      ImmutableSet.<BuildTarget>of(),ImmutableList.<String>of(),ImmutableList.<Path>of(),ImmutableList.<Path>of());


  String name = "foo/bar.cpp";
  Fakebuildrule dep = createFakebuildrule("//:test");
  SourcePath input = new buildruleSourcePath(dep);
  Path output = CxxCompilableEnhancer.getCompileOutputPath(target,name);
  CxxSource cxxSource = new CxxSource(name,input,output);

  CxxCompile cxxCompile = CxxCompilableEnhancer.createCompilebuildrule(
      params,resolver,CxxCompilables.DEFAULT_CXX_COMPILER,cxxPreprocessorInput,cxxSource);

  assertEquals(ImmutableSortedSet.<buildrule>of(dep),cxxCompile.getDeps());
}
项目:buck-cutom    文件:FakeJavaLibrary.java   
public FakeJavaLibrary(
    buildruleType type,BuildTarget target,ImmutableSortedSet<buildrule> deps,ImmutableSet<BuildTargetPattern> visibilityPatterns) {
  super(type,deps,visibilityPatterns);
  this.visibilityPatterns = visibilityPatterns;
}
项目:buck-cutom    文件:DefaultJavaLibraryTest.java   
@Override
public buildrule createRule(BuildTarget target) {
  return JavaLibraryBuilder.createBuilder(target)
      .addSrc(Paths.get("MyClass.java"))
      .setProguardConfig(Paths.get("MyProguardConfig"))
      .build(new buildruleResolver());
}
项目:buck-cutom    文件:EventSerializationTest.java   
private buildrule generateFakebuildrule() {
  BuildTarget buildTarget = BuildTargetFactory.newInstance("//fake:rule");
  Fakebuildrule result = new Fakebuildrule(
      JavaLibraryDescription.TYPE,buildTarget,ImmutableSet.<BuildTargetPattern>of());
  result.setRuleKey(new RuleKey("aaaa"));
  return result;
}
项目:buck-cutom    文件:GwtBinary.java   
/**
 * @param modules The GWT modules to build with the GWT compiler.
 * @param moduleDeps The rules passed to the {@code module_deps} argument in the build file.
 */
GwtBinary(
    buildruleParams buildruleParams,ImmutableSortedSet<String> modules,List<String> vmArgs,Style style,boolean draftCompile,int optimize,int localWorkers,boolean strict,List<String> experimentalArgs,ImmutableSortedSet<buildrule> moduleDeps,ImmutableSortedSet<Path> gwtModuleJars) {
  super(buildruleParams);
  BuildTarget buildTarget = buildruleParams.getBuildTarget();
  this.outputFile = BuildTargets.getGenPath(
      buildTarget,"__gwt_binary_%s__/" + buildTarget.getShortName() + ".zip");
  this.modules = Preconditions.checkNotNull(modules);
  Preconditions.checkArgument(
      !modules.isEmpty(),"Must specify at least one module for %s.",buildTarget);
  this.vmArgs = ImmutableList.copyOf(vmArgs);
  this.style = Preconditions.checkNotNull(style);
  this.draftCompile = draftCompile;

  // No need for bounds-checking this int because GWT does it internally: http://bit.ly/1kFN5M7.
  this.optimize = optimize;

  Preconditions.checkArgument(localWorkers > 0,"localWorkers must be greater than zero: %d",localWorkers);
  this.localWorkers = localWorkers;

  this.strict = strict;
  this.experimentalArgs = ImmutableList.copyOf(experimentalArgs);
  this.moduleDeps = Preconditions.checkNotNull(moduleDeps);
  this.gwtModuleJars = Preconditions.checkNotNull(gwtModuleJars);
}
项目:buck-cutom    文件:JavaLibraryDescription.java   
@Override
public <A extends Arg> buildrule createbuildrule(
    buildruleParams params,buildruleResolver resolver,A args) {
  BuildTarget target = params.getBuildTarget();

  // We kNow that the flavour we're being asked to create is valid,since the check is done when
  // creating the action graph from the target graph.

  if (JavaLibrary.SRC_JAR.equals(target.getFlavor())) {
    return new JavaSourceJar(params,args.srcs.get());
  }

  Javacoptions.Builder javacoptions = JavaLibraryDescription.getJavacoptions(args,javacEnv);

  AnnotationProcessingParams annotationParams =
      args.buildAnnotationProcessingParams(target,params.getProjectFilesystem());
  javacoptions.setAnnotationProcessingData(annotationParams);

  return new DefaultJavaLibrary(
      params,args.srcs.get(),validateResources(args,params.getProjectFilesystem()),args.proguardConfig,args.postprocessClassesCommands.get(),args.exportedDeps.get(),args.providedDeps.get(),/* additionalClasspathEntries */ ImmutableSet.<Path>of(),javacoptions.build(),args.resourcesRoot);
}
项目:buck-cutom    文件:GwtModule.java   
GwtModule(
    buildruleParams params,ImmutableSortedSet<SourcePath> filesForGwtModule) {
  super(params);
  BuildTarget target = params.getBuildTarget();
  this.outputFile = BuildTargets.getGenPath(
      target,"__gwt_module_%s__/" + target.getShortName() + ".jar");
  this.filesForGwtModule = Preconditions.checkNotNull(filesForGwtModule);
}
项目:buck-cutom    文件:CxxPreprocessablesTest.java   
@Test
public void resolveHeaderMap() {
  BuildTarget target = BuildTargetFactory.newInstance("//hello/world:test");
  ImmutableMap<String,SourcePath> headerMap = ImmutableMap.<String,SourcePath>of(
      "foo/bar.h",new TestSourcePath("header1.h"),"foo/hello.h",new TestSourcePath("header2.h"));

  // Verify that the resolveHeaderMap returns sane results.
  ImmutableMap<Path,SourcePath> expected = ImmutableMap.<Path,SourcePath>of(
      target.getBasePath().resolve("foo/bar.h"),target.getBasePath().resolve("foo/hello.h"),new TestSourcePath("header2.h"));
  ImmutableMap<Path,SourcePath> actual = CxxPreprocessables.resolveHeaderMap(
      target,headerMap);
  assertEquals(expected,actual);
}
项目:buck-cutom    文件:ParserTest.java   
@Test
public void testGeneratedDeps()
    throws IOException,InterruptedException {
  // Execute parseBuildFilesForTargets() with a target in a valid file but a bad rule name.
  tempDir.newFolder("java","com","facebook","generateddeps");

  File testGeneratedDepsBuckFile = tempDir.newFile(
      "java/com/facebook/generateddeps/" + BuckConstant.BUILD_RULES_FILE_NAME);
  Files.write(
      "java_library(name = 'foo')\n" +
          "java_library(name = 'bar')\n" +
          "add_deps(name = 'foo',deps = [':bar'])\n",testGeneratedDepsBuckFile,Charsets.UTF_8);

  BuildTarget fooTarget = BuildTarget.builder("//java/com/facebook/generateddeps","foo").build();

  BuildTarget barTarget = BuildTarget.builder("//java/com/facebook/generateddeps","bar").build();
  Iterable<BuildTarget> buildTargets = ImmutableList.of(fooTarget,barTarget);
  Iterable<String> defaultIncludes = ImmutableList.of();

  ActionGraph graph = testParser.parseBuildFilesForTargets(
      buildTargets,defaultIncludes,String>of());

  buildrule fooRule = graph.findbuildruleByTarget(fooTarget);
  assertNotNull(fooRule);
  buildrule barRule = graph.findbuildruleByTarget(barTarget);
  assertNotNull(barRule);

  assertEquals(ImmutableSet.of(barRule),fooRule.getDeps());
}

com.facebook.buck.model.Flavored的实例源码

com.facebook.buck.model.Flavored的实例源码

项目:buck    文件:UnexpectedFlavorException.java   
private static ImmutableSet<Flavor> getInvalidFlavors(Flavored flavored,BuildTarget target) {
  ImmutableSet.Builder<Flavor> builder = ImmutableSet.builder();
  for (Flavor flavor : target.getFlavors()) {
    if (!flavored.hasFlavors(ImmutableSet.of(flavor))) {
      builder.add(flavor);
    }
  }
  return builder.build();
}
项目:buck    文件:AuditFlavorsCommand.java   
private void printFlavors(
    ImmutableList<TargetNode<?,?>> targetNodes,CommandRunnerParams params) {
  DirtyPrintStreamDecorator stdout = params.getConsole().getStdOut();
  for (TargetNode<?,?> node : targetNodes) {
    Description<?> description = node.getDescription();
    stdout.println(node.getBuildTarget().getFullyQualifiedname());
    if (description instanceof Flavored) {
      Optional<ImmutableSet<FlavorDomain<?>>> flavorDomains =
          ((Flavored) description).flavorDomains();
      if (flavorDomains.isPresent()) {
        for (FlavorDomain<?> domain : flavorDomains.get()) {
          ImmutableSet<UserFlavor> userFlavors =
              RichStream.from(domain.getFlavors().stream())
                  .filter(UserFlavor.class)
                  .collect(ImmutableSet.toImmutableSet());
          if (userFlavors.isEmpty()) {
            continue;
          }
          stdout.printf(" %s\n",domain.getName());
          for (UserFlavor flavor : userFlavors) {
            String flavorLine = String.format("  %s",flavor.getName());
            String flavorDescription = flavor.getDescription();
            if (flavorDescription.length() > 0) {
              flavorLine += String.format(" -> %s",flavorDescription);
            }
            flavorLine += "\n";
            stdout.printf(flavorLine);
          }
        }
      } else {
        stdout.println(" unkNown");
      }
    } else {
      stdout.println(" no flavors");
    }
  }
}
项目:buck    文件:AuditFlavorsCommand.java   
private void printJsonFlavors(
    ImmutableList<TargetNode<?,CommandRunnerParams params) throws IOException {
  DirtyPrintStreamDecorator stdout = params.getConsole().getStdOut();
  SortedMap<String,SortedMap<String,String>>> targetsJson = new TreeMap<>();
  for (TargetNode<?,?> node : targetNodes) {
    Description<?> description = node.getDescription();
    SortedMap<String,String>> flavorDomainsJson = new TreeMap<>();

    if (description instanceof Flavored) {
      Optional<ImmutableSet<FlavorDomain<?>>> flavorDomains =
          ((Flavored) description).flavorDomains();
      if (flavorDomains.isPresent()) {
        for (FlavorDomain<?> domain : flavorDomains.get()) {
          ImmutableSet<UserFlavor> userFlavors =
              RichStream.from(domain.getFlavors().stream())
                  .filter(UserFlavor.class)
                  .collect(ImmutableSet.toImmutableSet());
          if (userFlavors.isEmpty()) {
            continue;
          }
          SortedMap<String,String> flavorsJson =
              userFlavors
                  .stream()
                  .collect(
                      ImmutableSortedMap.toImmutableSortedMap(
                          Ordering.natural(),UserFlavor::getName,UserFlavor::getDescription));
          flavorDomainsJson.put(domain.getName(),flavorsJson);
        }
      } else {
        flavorDomainsJson.put("unkNown",new TreeMap<>());
      }
    }
    String targetName = node.getBuildTarget().getFullyQualifiedname();
    targetsJson.put(targetName,flavorDomainsJson);
  }

  ObjectMappers.WRITER.writeValue(stdout,targetsJson);
}
项目:buck    文件:MultiarchFileTest.java   
@Test
public void shouldAllowMultiplePlatformFlavors() {
  assertTrue(
      ((Flavored) description)
          .hasFlavors(
              ImmutableSet.of(
                  InternalFlavor.of("iphoneos-i386"),InternalFlavor.of("iphoneos-x86_64"))));
}
项目:buck-cutom    文件:Parser.java   
@Nullable
public TargetNode<?> get(BuildTarget buildTarget) {
  // Fast path.
  TargetNode<?> toReturn = memoizedTargetNodes.get(buildTarget);
  if (toReturn != null) {
    return toReturn;
  }

  BuildTarget unflavored = buildTarget.getUnflavoredTarget();
  List<Map<String,Object>> rules = state.getRawRules(unflavored.getBuildFilePath());
  for (Map<String,Object> map : rules) {

    if (!buildTarget.getShortNameOnly().equals(map.get("name"))) {
      continue;
    }

    buildruleType buildruleType = parsebuildruleTypeFromrawRule(map);
    targetsToFile.put(
        unflavored,normalize(Paths.get((String) map.get("buck.base_path")))
            .resolve("BUCK").toAbsolutePath());

    Description<?> description = repository.getDescription(buildruleType);
    if (description == null) {
      throw new HumanReadableException("Unrecognized rule %s while parsing %s%s.",buildruleType,BuildTarget.BUILD_TARGET_PREFIX,unflavored.getBuildFilePath());
    }

    if ((description instanceof Flavored) &&
        !((Flavored) description).hasFlavor(buildTarget.getFlavor())) {
      throw new HumanReadableException("Unrecognized flavor in target %s while parsing %s%s.",buildTarget,buildTarget.getBuildFilePath());
    }

    buildruleFactoryParams factoryParams = new buildruleFactoryParams(
        map,repository.getFilesystem(),buildTargetParser,// Although we store the rule by its unflavoured name,when we construct it,we need the
        // flavour.
        buildTarget,ruleKeyBuilderFactory);
    TargetNode<?> targetNode;
    try {
      targetNode = new TargetNode<>(description,factoryParams);
    } catch (NoSuchBuildTargetException e) {
      //
      throw new HumanReadableException(e);
    }

    TargetNode<?> existingTargetNode = memoizedTargetNodes.put(buildTarget,targetNode);
    if (existingTargetNode != null) {
      throw new HumanReadableException("Duplicate deFinition for " + unflavored);
    }

    // PMD considers it bad form to return while in a loop.
  }

  return memoizedTargetNodes.get(buildTarget);
}
项目:buck    文件:JsFlavorValidationCommonTest.java   
private Flavored getTestInstance() {
  return TEST_DATA.get(description);
}

今天的关于com.facebook.buck.rules.BuildRuleParams的实例源码仿facebook源码的分享已经结束,谢谢您的关注,如果想了解更多关于com.facebook.android.AsyncFacebookRunner的实例源码、com.facebook.android.BuildConfig的实例源码、com.facebook.buck.model.BuildTarget的实例源码、com.facebook.buck.model.Flavored的实例源码的相关知识,请在本站进行查询。

本文标签: