Open kageiit opened 6 years ago
@kageiit I am looking forward to implement data binding support. Could you please guide me in implementing that.
@sangeetsuresh see https://github.com/uber/okbuck/commit/ebcea6f0950d37536e18e0bfe7ae6eb39ebf4064#diff-5d4ed6b6392a62dd46960742f4402601 for an example of how the transform cli was added to okbuck.
The process essentially consists of a few steps
java_binary
that has the databinding CLI as the main classgenrule
that runs the cli on them and outputs the sources required for compliationgenrule
as an input source to the andrid_library
rule@sangeetsuresh Just curious - are you actively working on this? I'm trying to figure out if I should rip out the minimal use of DataBinding in order to be able to use Buck/OkBuck
@erawhctim I am not actively working on it. I am just figuring out how to implement that in buck.
I am currently actively working on it. I have successfully built a demo project using a modified version of the generated BUCK file from okbuck.
basically I have:
it was actually pretty easy. I'm now working on understanding what is the best way to integrate it to okbuck/buck
@carlonzo Can you put that code in some repo so that I could also go through that. It will be helpful for me as I am also looking for implementing data binding for buck
Sure. I have it on a private repo until I cleanup the experiments, the I will publish
@carlonzo Can you put that code in some repo so that I could also go through that. It will be helpful for me as I am also looking for implementing data binding for buck
You can check https://github.com/carlonzo/BuckDatabindingDemo
the most important part is the file databinder.sh
to run before, then start the compilation with buck build bin_devDebug
. do not use okbuck as it will override the BUCK files.
I'm currently trying to write few genrule rules to remove the databinder.sh
file.
@kageiit I have few issues when I try to hookup the output of a genrule (which produces a folder with jave files) to the srcs
of the android_library
rule. are you aware if that is supposed to work? (do you have any example I can look at?) the only way I can make it work (partially. still get few compilation errors) is to generate a .src.zip
file and append it to the srcs.
@sangeetsuresh Actually I've finally debugged and fixed the issue with android_library
(I need to pass the generated java files as a zip to the srcs
list) this is the BUCK file with the rules: https://github.com/carlonzo/BuckDatabindingDemo/blob/buck-rules/app/BUCK
I will try now to cleanup (sorry @kageiit to bother, but as I'm a newbie can you have a look at the BUCK file above to see if you can spot any issue? I have still many absolute paths to convert. for example I have no idea how to pull the location of the output folder of the genrules in extra_arguments
in src_devDebug
rule. do you have any tip? )
.src.zip
is the way to go. Ill take a look at the buck files this week
@kageiit did you have some time to have a look?
mostly to check if there is any mistake (this my first time I use BUCK), and if you have any tips how I can avoid absolute paths in in extra_arguments
in src_devDebug
rule and in the genrule
s. Any suggestion is welcome :)
cc @raviagarwal7 ^ can help take a look as i will be on vacation for a bit
hi @raviagarwal7 can you let me know if you can take a look about the above? I want to start writing a PR to implement the data binding but I am stuck with few doubts. many thanks! cc @kageiit
hi @kageiit @raviagarwal7 I would like to continue the development as I believe we are not far from having a solution on okbuck to have databinding working.
As mentioned above the only issue that I believe needs to be solved are the absolute paths in the okbuck_android_module
rule which point to the generated files from the genrule
s. do you have any tip to fix that? is there any way I can add/create expandable variables pointing to the generated output folders? once I solved that I believe I have enough to try the development of a solution.
as a reference, here is a working buck file I would need to generate from okbuck https://github.com/carlonzo/BuckDatabindingDemo/blob/buck-rules/app/BUCK
thanks!
cmd = 'java -jar /Users/carlo/Projects/BuckApp/bins/android-data-binding-exec-3.4.0.jar PROCESS ' +
You can instead do
cmd = 'java -jar (location {}) PROCESS '.format(<android-data-binding-target) +
more info on location macro - https://buck.build/function/string_parameter_macros.html#content
Hi @raviagarwal7 , thanks for that. I can read that those macros only apply to genrule
, apk_genrule
, cxx_genrule
but my problem is mostly with the arguments in the extra_arguments
in the okbuck_android_module
(which I believe is an alias for the android_library
rule). anything that help me there?
extra_kotlinc_arguments seems to reference by relative path, that may be a pattern to follow if location
won't work.
Example:
extra_kotlinc_arguments = [
"-Xplugin=buck-out/gen/.okbuck/workspace/kotlin_home/kotlin_home/libexec/lib/kotlin-android-extensions.jar",
],
Thanks for the tip man. I'll have a look how it works!
Keep up the good works @carlonzo
I am new to buck - trying to understand how this databinding implementation is working, apologies if this is a basic question. How exactly are the PROCESS and GEN_BASE_CLASSES handled by android-data-binding-exec-3.4.0.jar - are those string args? When I look at the code here CLI I don't see where those are.
I see these args
package
minSdk
library
resInput
resOutput
layoutInfoOutput
zipLayoutInfo
Databinding has a CLI compiler that is in aosp (no artifact on maven.google.com yet). It is only two classes, but it allows ingesting layout xml files and outputting the metadata required by the databinding annotation processor to work correctly.
By using a genrule to pre-process the resources of a module, databinding support can be added in buck/okbuck