Skip to content

deploy_scripts#765

Closed
juj wants to merge 1 commit into
WebAssembly:masterfrom
juj:deploy_scripts
Closed

deploy_scripts#765
juj wants to merge 1 commit into
WebAssembly:masterfrom
juj:deploy_scripts

Conversation

@juj

@juj juj commented Oct 13, 2016

Copy link
Copy Markdown
Collaborator

Deploy scripts that are utilized at runtime to bin/ directory, so that the build directory can be packaged as a standalone toolchain.

At present -s BINARYEN_ROOT needs to point to the root directory of a Binaryen git repository. When bundling Binaryen for distribution, we'd like to minimize the number of extra files, so having the output bin/ directory be a root of all distributable build artifacts would be a clean way to do it. These copy steps deploy all files needed at runtime to the bin/ directory.

@juj

juj commented Oct 13, 2016

Copy link
Copy Markdown
Collaborator Author

The try build currently fails because it needs this line, so probably good to merge after #771.

…t the build directory can be packaged as a standalone toolchain.
@juj

juj commented Oct 13, 2016

Copy link
Copy Markdown
Collaborator Author

Actually, given that Travis is saying something else red about #771, updated this PR to carry the above change.

@dschuff

dschuff commented Oct 13, 2016

Copy link
Copy Markdown
Member

Wouldn't it be more conventional to just use CMake install targets instead? IIRC In some cases CMake actually does useful things when it installs (e.g. rewriting rpaths), so we probably should prefer that to just copying the build directory when we make distribution packages.

@juj

juj commented Oct 13, 2016

Copy link
Copy Markdown
Collaborator Author

The CMake install step would probably just complicate here, since that would require doing an install before being able to use the build products. I don't think it's worth to start complicating the build steps more.

@dschuff

dschuff commented Oct 13, 2016

Copy link
Copy Markdown
Member

Hm. I do still think we want to have a working install step, but I agree that it's nice to also be able to use the build products in place for testing. So maybe we can just do both.

@dschuff

dschuff commented Oct 13, 2016

Copy link
Copy Markdown
Member

Also (and this is beyond the scope of this particular PR) but binaryen.js and wasm.js aren't really scripts we expect users to run directly, right? They just get packaged into larger things generated by emscripten or other packaging, so it probably doesn't make sense to have them in the bin directory in the installed location (especially if there's going to be a distro-style packaging). Maybe <prefix>/lib or <prefix>/share? Not sure.

@juj

juj commented Oct 13, 2016

Copy link
Copy Markdown
Collaborator Author

They are referenced e.g. in https://github.com/kripken/emscripten/pull/4623/files#diff-ae40e645f84e893ce5d037b5efc53be6R1973. I did not want to change the directory structure more than necessary (just look at both bin/ and without), so I let binaryen.js and wasm.js live in the same directory they were at, which is originally from https://github.com/WebAssembly/binaryen/tree/master/bin.

@dschuff

dschuff commented Oct 13, 2016

Copy link
Copy Markdown
Member

Yeah, for this PR it's fine. I'm just saying I think we should move them in the future, and update the references.

Comment thread check.py
not_executable_suffix = ['.txt', '.js']
executables = sorted(filter(lambda x: not any(x.endswith(s) for s in
not_executable_suffix),
not_executable_suffix) and os.path.isfile(x),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this check it isn't a directory?

did something change in this PR that adds a new directory?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the FILE(COPY) command below adds new directories under bin/, for example bin/js.

Comment thread CMakeLists.txt
INSTALL(TARGETS wasm-dis DESTINATION bin)

# Deploy scripts that are utilized at runtime to bin/ directory, so that the build directory can be packaged as a standalone toolchain.
FILE(COPY "${CMAKE_CURRENT_SOURCE_DIR}/scripts" DESTINATION "${PROJECT_BINARY_DIR}/bin/")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

at what time would these operations happen?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These occur right during the CMake configure step.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh right, during configure? That's not going to work if the scripts are updated, will it? Is there something that forces a reconfigure if they change, is that automatic?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately there is no simple spot to do it for dynamic copying. Being at configure time means that after making a change, one can reissue cmake to redeploy, so that's something that will always occur on CI etc.

The full CMake'y way with dependency analysis would be to create build targets out of them and have the build action be a copy command with add_custom_command(OUTPUT, ...), but that is a bit messy because it needs a target to build the files in, so either create a virtual target that only has the copyable files, or piggyback on another target project to build. If this is a concern, I can take a peek, but generally prefer to keep it simple.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At first I thought it's not urgent to do the better fix, as normally we don't use code from the bin/ dir. But actually this + the emscripten PR makes us use stuff from bin/, like the js glue code file? That means that as I debug it, I'd need to remember to manually do cmake all the time - which sounds error prone and burdensome.

And actually, even having to run make to get the js glue code file to be copied to bin/ seems like a worse developer experience than we have now.

Overall it seems the old way, of using the js glue from the src dir, etc. and not using more stuff in bin/ is better - except for when creating a distribution, I guess. So doing something special for a distribution might be an alternative?

@dschuff dschuff Oct 13, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still think having install targets is the 'right' way to do this.
When creating a distribution, we don't want to depend on a source dir, and I don't think we want this stuff in the bin dir; we want it in some other dir: probably lib, share or some subdir of one of those. For local testing, I don't care too much; we can add something to check.py to handle things to avoid having to run the install step if we want, I'm happy to always do out-of-tree builds, or whatever.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Alright, let me retract this pull request and figure something better out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants