Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tools/build_third_party.py #328

Merged
merged 8 commits into from
Jul 4, 2018
Merged

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Jul 4, 2018

This PR tries to solve #312. I added tools/build_third_party.py, which runs gclient and yarn for updating gclient deps and npm deps.

I moved the place of node_modules from js/ to third_party/ (and made the symlink js/node_modules to point it) to enable separating third_party to a different repository and store all deps in it.

# --------------------
# This script updates the third party dependencies of deno.
#
# - Get Depot Tools and make sure it's in your path.
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be nice to print an error when depot tools aren't available/found

Copy link
Contributor

Choose a reason for hiding this comment

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

ditto for the yarn dep

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the comment! I agree. I'll try it.

Copy link
Member

Choose a reason for hiding this comment

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

Actually I prefer not adding extra code for those checks. run() will fail with a stack trace that can diagnose that issue. This script is not user facing.

.gitignore Outdated
@@ -2,7 +2,7 @@
/out/

# npm deps
node_modules
/third_party/node_modules
Copy link
Contributor

Choose a reason for hiding this comment

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

please don't change this line - we might have multiple node_modules in near future

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the comment! I updated the line.

@ry ry mentioned this pull request Jul 4, 2018
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

Great - thank you!

I have a few comments...

.travis.yml Outdated
@@ -28,7 +28,7 @@ install:
- curl -sSf https://sh.rustup.rs | sh -s -- -y
- export PATH=$HOME/.cargo/bin:$PATH
- rustc --version
- (cd js; yarn)
- (cd third_party; yarn)
- (cd third_party; gclient sync -j2 --no-history)
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to replace these lines with ./tools/build_third_party.py ?

Copy link
Member Author

Choose a reason for hiding this comment

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

If dropping -j2 doesn't cause a problem, then that should work. I'll try that on this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yes - that should be fine. (I think gclient is -j1 by default and I was just testing to see if -j2 made things faster - it doesn't - but it got left in)

@@ -54,12 +54,12 @@
resolved "https://registry.yarnpkg.com/@types/long/-/long-3.0.32.tgz#f4e5af31e9e9b196d8e5fca8a5e2e20aa3d60b69"
Copy link
Member

Choose a reason for hiding this comment

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

Can you do this PR without upgrading the deps?

# coding=utf-8
#
# build_third_party.py
# --------------------
Copy link
Member

Choose a reason for hiding this comment

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

Lines 2-5 are unnecessary


root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
third_party_path = os.path.join(root_path, "third_party")
script_name = "build_third_party.py"
Copy link
Member

@ry ry Jul 4, 2018

Choose a reason for hiding this comment

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

I think sync_third_party.py is a better name. What do you think?

build_third_party.py is better.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. This script doesn't build things, but basically updates the deps.

Copy link
Member

Choose a reason for hiding this comment

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

@kt3k actually I changed my mind- it is only syncing now, but it will be doing more "build" type things later - like creating symlinks (see comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

OK.

it will be doing more "build" type things later - like creating symlinks

That's why you called this build_* first.


def main():
os.chdir(third_party_path)
print "cwd=" + third_party_path
Copy link
Member

Choose a reason for hiding this comment

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

Remove debug print

print "cwd=" + third_party_path
run(["gclient", "sync", "--no-history"])
run(["yarn"])
print "✨ Done (" + script_name + ")"
Copy link
Member

@ry ry Jul 4, 2018

Choose a reason for hiding this comment

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

Remove emoji

print "✨ Done (" + script_name + ")"

def run(args):
print "+" + " ".join(args)
Copy link
Member

Choose a reason for hiding this comment

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

Remove "+" +

@ghost
Copy link

ghost commented Jul 4, 2018

I am waiting for your stabilized build scripts so that I can put them in #323. The essence is three files:

Since #323 doesn't touch .travis.yml, updating it would have no effect on CI. It might help you explore different build scripts for various Linux platforms that can be emulated in Docker. Travis CI is just one of the cases. We might want automated build on Azure/AWS/GCP etc. down the road. It is easy to write specific development/test/deployment work flows in docker compose. No need to be limited to the specific platform the library authors are working on.

@ry
Copy link
Member

ry commented Jul 4, 2018

@ontouchstart Let's land this bit first. I will review #323 soon - sorry for the delay - but switching to docker is a lower priority and needs to be thought thru carefully.

@ry
Copy link
Member

ry commented Jul 4, 2018

Eventually this script should also create //third_party/.gclient and //third_party/package.json symlinks during run-time. The reason is that when //third_party becomes a git submodule, it shouldn't have symlinks that reach outside of the repo.

Ideally we would be able to rm -rf third_party; ./tools/build_third_party.py and everything would be the same.

(PS we have a windows compatible symlink function in python here .. maybe we should start a python library of common utilities and that routine can be used here.)


root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
third_party_path = os.path.join(root_path, "third_party")
script_name = "sync_third_party.py"
Copy link
Member

@ry ry Jul 4, 2018

Choose a reason for hiding this comment

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

Rename file back to build_third_party.py
Use __file__ here

print "Done (" + script_name + ")"

def run(args):
print " ".join(args)
Copy link
Member

Choose a reason for hiding this comment

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

Run yapf across this file. I think there's inconstant quotation marks.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM after renaming to build_third_party.py again.

README.md Outdated

(cd js; yarn install)
Generate ninja configuration files.
Copy link
Member

Choose a reason for hiding this comment

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

s/configuration//

# - You need yarn installed as well.
# https://yarnpkg.com/lang/en/docs/install/
# Use gclient_config.py to modify the git deps.
# Use js/package.json to modify the npm deps.
Copy link
Member

Choose a reason for hiding this comment

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

Consider using absolute paths when talking about the configuration files:

Use //gclient_config.py to modify the git deps.
Use //js/package.json to modify the npm deps.

@ry ry merged commit 2060bc9 into denoland:master Jul 4, 2018
@kt3k kt3k deleted the feature/build-third-party branch July 4, 2018 13:11
piscisaureus pushed a commit to piscisaureus/deno that referenced this pull request Oct 7, 2019
hardfist pushed a commit to hardfist/deno that referenced this pull request Aug 7, 2024
…noland#328)

Needed to solve denoland#20528 where we
need to skip pumping V8 message loop for some time.

Also adds "JsRuntime::with_event_loop" helper to run a future concurrently
with the event loop.
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.

4 participants