diff --git a/.circleci/config.yml b/.circleci/config.yml index e21abe9f61..331c1e8e00 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,7 +45,7 @@ jobs: - run: name: test.py command: | - source emsdk_env.sh + source emsdkpy/emsdk_env.sh test/test.py test-mac: macos: @@ -64,7 +64,7 @@ jobs: - run: name: test.py command: | - source emsdk_env.sh + source emsdkpy/emsdk_env.sh test/test.py test-windows: executor: @@ -90,7 +90,7 @@ jobs: - run: name: test.py command: | - source emsdk_env.sh + source emsdkpy/emsdk_env.sh python test/test.py - run: diff --git a/.gitignore b/.gitignore index 0d794d22d0..2c0c7530d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ *.pyc __pycache__ +emsdk.egg-info +dist +build # Support for --embedded configs /.emscripten @@ -10,26 +13,26 @@ __pycache__ /.emscripten_sanity_wasm # Tags files that get generated at runtime -/emscripten-releases-tot.txt +emsdkpy/emscripten-releases-tot.txt # File that get download/extracted by emsdk itself -/ccache -/gnu -/upstream -/fastcomp -/fastcomp-clang/ -/llvm -/ninja -/releases -/clang -/emscripten -/git -/node -/python -/temp -/zips -/crunch -/java -/mingw -/spidermonkey -/binaryen +emsdkpy/ccache +emsdkpy/gnu +emsdkpy/upstream +emsdkpy/fastcomp +emsdkpy/fastcomp-clang/ +emsdkpy/llvm +emsdkpy/ninja +emsdkpy/releases +emsdkpy/clang +emsdkpy/emscripten +emsdkpy/git +emsdkpy/node +emsdkpy/python +emsdkpy/temp +emsdkpy/zips +emsdkpy/crunch +emsdkpy/java +emsdkpy/mingw +emsdkpy/spidermonkey +emsdkpy/binaryen diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000000..71081d7f16 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include emsdk diff --git a/README.md b/README.md index 33c7c60c4b..44f4876488 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ That explains how to use the emsdk to get the latest binary builds (without compiling from source). Basically, that amounts to ``` -./emsdk install latest -./emsdk activate latest +emsdkpy/emsdk install latest +emsdkpy/emsdk activate latest ``` ## SDK Concepts @@ -100,8 +100,8 @@ available tools, run `emsdk list`. * If a tool/SDK is currently active, a star * will be shown next to it. * If a tool/SDK is currently active, but the terminal your are calling emsdk from does not have `PATH` and environment set up to utilize that tool, a star - in parentheses (\*) will be shown next to it. Run `emsdk_env.bat` (Windows) or - `source ./emsdk_env.sh` (Linux and OS X) to set up the environment for the + in parentheses (\*) will be shown next to it. Run `emsdkpy/emsdk_env.bat` (Windows) or + `source emsdkpy/emsdk_env.sh` (Linux and OS X) to set up the environment for the calling terminal. ### How do I install a tool/SDK version? diff --git a/docker/Dockerfile b/docker/Dockerfile index cf2cd4c0d7..cf7acee4f8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -23,7 +23,7 @@ COPY . ${EMSDK} RUN echo "## Install Emscripten" \ && cd ${EMSDK} \ - && ./emsdk install ${EMSCRIPTEN_VERSION} \ + && emsdkpy/emsdk install ${EMSCRIPTEN_VERSION} \ && echo "## Done" # This generates configuration that contains all valid paths according to installed SDK @@ -31,7 +31,7 @@ RUN echo "## Install Emscripten" \ # currently create the sanity file. RUN cd ${EMSDK} \ && echo "## Generate standard configuration" \ - && ./emsdk activate ${EMSCRIPTEN_VERSION} \ + && emsdkpy/emsdk activate ${EMSCRIPTEN_VERSION} \ && chmod 777 ${EMSDK}/upstream/emscripten \ && chmod -R 777 ${EMSDK}/upstream/emscripten/cache \ && echo "int main() { return 0; }" > hello.c \ @@ -41,7 +41,7 @@ RUN cd ${EMSDK} \ # Cleanup Emscripten installation and strip some symbols RUN echo "## Aggressive optimization: Remove debug symbols" \ - && cd ${EMSDK} && . ./emsdk_env.sh \ + && cd ${EMSDK} && . emsdkpy/emsdk_env.sh \ # Remove debugging symbols from embedded node (extra 7MB) && strip -s `which node` \ # Tests consume ~80MB disc space diff --git a/emsdkpy/__init__.py b/emsdkpy/__init__.py new file mode 100644 index 0000000000..3cada642a0 --- /dev/null +++ b/emsdkpy/__init__.py @@ -0,0 +1 @@ +from .emsdk import main # noqa diff --git a/emcmdprompt.bat b/emsdkpy/emcmdprompt.bat similarity index 100% rename from emcmdprompt.bat rename to emsdkpy/emcmdprompt.bat diff --git a/emscripten-releases-tags.json b/emsdkpy/emscripten-releases-tags.json similarity index 100% rename from emscripten-releases-tags.json rename to emsdkpy/emscripten-releases-tags.json diff --git a/emsdk b/emsdkpy/emsdk similarity index 100% rename from emsdk rename to emsdkpy/emsdk diff --git a/emsdk.bat b/emsdkpy/emsdk.bat similarity index 100% rename from emsdk.bat rename to emsdkpy/emsdk.bat diff --git a/emsdk.ps1 b/emsdkpy/emsdk.ps1 similarity index 100% rename from emsdk.ps1 rename to emsdkpy/emsdk.ps1 diff --git a/emsdk.py b/emsdkpy/emsdk.py similarity index 99% rename from emsdk.py rename to emsdkpy/emsdk.py index 1b5fc79a54..47290a5485 100644 --- a/emsdk.py +++ b/emsdkpy/emsdk.py @@ -2554,7 +2554,7 @@ def set_active_tools(tools_to_activate, permanently_activate, system): # Construct a .bat or .ps1 script that will be invoked to set env. vars and PATH # We only do this on cmd or powershell since emsdk.bat/ps1 is able to modify the - # calling shell environment. On other shell `source emsdk_env.sh` is + # calling shell environment. On other shell `source emsdkpy/emsdk_env.sh` is # required. if CMD or POWERSHELL: # always set local environment variables since permanently activating will only set the registry settings and @@ -2833,7 +2833,9 @@ def expand_sdk_name(name, activating): return name -def main(args): +def main(): + args = sys.argv[1:] + if not args: errlog("Missing command; Type 'emsdk help' to get a list of commands.") return 1 @@ -3156,7 +3158,7 @@ def print_tools(t): print('Items marked with * are activated for the current user.') if has_partially_active_tools[0]: - env_cmd = 'emsdk_env.bat' if WINDOWS else 'source ./emsdk_env.sh' + env_cmd = 'emsdk_env.bat' if WINDOWS else 'source emsdkpy/emsdk_env.sh' print('Items marked with (*) are selected for use, but your current shell environment is not configured to use them. Type "' + env_cmd + '" to set up your current shell to use them' + (', or call "emsdk activate --permanent " to permanently activate them.' if WINDOWS else '.')) if not arg_old: print('') @@ -3166,7 +3168,7 @@ def print_tools(t): if is_emsdk_sourced_from_github(): print('Run "git pull" to pull in the latest list.') else: - print('Run "./emsdk update" to pull in the latest list.') + print('Run "emsdkpy/emsdk update" to pull in the latest list.') return 0 elif cmd == 'construct_env': @@ -3268,4 +3270,4 @@ def print_tools(t): if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) + sys.exit(main()) diff --git a/emsdk_env.bat b/emsdkpy/emsdk_env.bat similarity index 100% rename from emsdk_env.bat rename to emsdkpy/emsdk_env.bat diff --git a/emsdk_env.csh b/emsdkpy/emsdk_env.csh similarity index 89% rename from emsdk_env.csh rename to emsdkpy/emsdk_env.csh index 187d4c5438..5192b1f602 100644 --- a/emsdk_env.csh +++ b/emsdkpy/emsdk_env.csh @@ -5,11 +5,11 @@ # because it won't have any effect then. # That is, always run this script with # -# source ./emsdk_env.csh +# source emsdkpy/emsdk_env.csh # # instead of just plainly running with # -# ./emsdk_env.csh +# emsdkpy/emsdk_env.csh # # which won't have any effect. set SRC=($_) diff --git a/emsdk_env.fish b/emsdkpy/emsdk_env.fish similarity index 80% rename from emsdk_env.fish rename to emsdkpy/emsdk_env.fish index 29f6f4647b..b4bbd7ed77 100644 --- a/emsdk_env.fish +++ b/emsdkpy/emsdk_env.fish @@ -1,5 +1,5 @@ #In your Fish configuration, add this line: -#alias emsdk_setup ". /path/to/emsdk/emsdk_env.fish" +#alias emsdk_setup ". /path/to/emsdk/emsdkpy/emsdk_env.fish" #Now, when you want to use the SDK, run this alias first to set up #your environment. diff --git a/emsdk_env.ps1 b/emsdkpy/emsdk_env.ps1 similarity index 100% rename from emsdk_env.ps1 rename to emsdkpy/emsdk_env.ps1 diff --git a/emsdk_env.sh b/emsdkpy/emsdk_env.sh similarity index 94% rename from emsdk_env.sh rename to emsdkpy/emsdk_env.sh index 8f76de7522..409a202f27 100644 --- a/emsdk_env.sh +++ b/emsdkpy/emsdk_env.sh @@ -10,15 +10,15 @@ # because it won't have any effect then. # That is, always run this script with # -# . /path/to/emsdk_env.sh +# . /path/to/emsdkpy/emsdk_env.sh # # or # -# source /path/to/emsdk_env.sh +# source /path/to/emsdkpy/emsdk_env.sh # # instead of just plainly running with # -# ./emsdk_env.sh +# emsdkpy/emsdk_env.sh # # which won't have any effect. diff --git a/emsdk_manifest.json b/emsdkpy/emsdk_manifest.json similarity index 100% rename from emsdk_manifest.json rename to emsdkpy/emsdk_manifest.json diff --git a/legacy-binaryen-tags.txt b/emsdkpy/legacy-binaryen-tags.txt similarity index 100% rename from legacy-binaryen-tags.txt rename to emsdkpy/legacy-binaryen-tags.txt diff --git a/legacy-emscripten-tags.txt b/emsdkpy/legacy-emscripten-tags.txt similarity index 100% rename from legacy-emscripten-tags.txt rename to emsdkpy/legacy-emscripten-tags.txt diff --git a/llvm-tags-64bit.txt b/emsdkpy/llvm-tags-64bit.txt similarity index 100% rename from llvm-tags-64bit.txt rename to emsdkpy/llvm-tags-64bit.txt diff --git a/scripts/create_release.py b/scripts/create_release.py index a7438f2cc1..d309727ebf 100755 --- a/scripts/create_release.py +++ b/scripts/create_release.py @@ -49,7 +49,7 @@ def main(args): release_info['releases'] = OrderedDict(reversed(releases)) release_info['aliases']['latest'] = new_version - with open(os.path.join(root_dir, 'emscripten-releases-tags.json'), 'w') as f: + with open(os.path.join(root_dir, 'emsdkpy', 'emscripten-releases-tags.json'), 'w') as f: f.write(json.dumps(release_info, indent=2)) f.write('\n') diff --git a/scripts/update_bazel_workspace.sh b/scripts/update_bazel_workspace.sh index b2f707892d..e38c5178a5 100755 --- a/scripts/update_bazel_workspace.sh +++ b/scripts/update_bazel_workspace.sh @@ -12,7 +12,7 @@ cd $(dirname $0)/.. # If the previous command succeeded. We are in the emsdk root. Check to make # sure the files and directories we need are present. if [[ $? = 0 ]]; then - if [[ ! -f emscripten-releases-tags.json ]]; then + if [[ ! -f emsdkpy/emscripten-releases-tags.json ]]; then echo "Cannot find emscripten-releases-tags.json." ERR=1 fi @@ -38,7 +38,7 @@ URL2=/wasm-binaries # Get commit hash for $1 version get_hash () { - echo $(grep "$1" emscripten-releases-tags.json | grep -v latest | grep -v asserts | cut -f4 -d\") + echo $(grep "$1" emsdkpy/emscripten-releases-tags.json | grep -v latest | grep -v asserts | cut -f4 -d\") } # Get sha256 for $1 os $2 extname $3 hash $4 architecture @@ -65,7 +65,7 @@ append_revision () { # Get the latest version number from emscripten-releases-tag.json. VER=$(grep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \ - emscripten-releases-tags.json \ + emsdkpy/emscripten-releases-tags.json \ | sed --expression "s/\./\\\./g") append_revision ${VER} diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000..d6a87e6dcf --- /dev/null +++ b/setup.cfg @@ -0,0 +1,26 @@ +[metadata] +name = emsdk +version = 3.1.9 +description = Emscripten SDK +long_description = file: README.md +long_description_content_type = text/markdown +license_file = LICENSE +author = Emscripten authors +url = https://github.com/emscripten-core/emsdk +platforms = Windows, Linux, Mac OS X +keywords = emscripten, sdk + +[bdist_wheel] +universal = 1 + +[options] +include_package_data = True +packages = find: +python_requires = >=3.7 + +[options.entry_points] +console_scripts = + emsdk = emsdkpy.emsdk:main + +[options.package_data] +emsdkpy = emsdk, *.txt, *.bat, *.csh, *.fish, *.ps1, *.sh, *.json diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000..b908cbe55c --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +import setuptools + +setuptools.setup() diff --git a/test/test.bat b/test/test.bat index 9fea0c1f43..43a3407066 100755 --- a/test/test.bat +++ b/test/test.bat @@ -1,7 +1,7 @@ :: equivilent of test.sh as windows bat file set PATH=%PATH%;%PYTHON_BIN% -CALL emsdk install latest -CALL emsdk activate latest -CALL emsdk_env.bat +CALL emsdkpy/emsdk install latest +CALL emsdkpy/emsdk activate latest +CALL emsdkpy/emsdk_env.bat CALL python -c "import sys; print(sys.executable)" CALL emcc.bat -v diff --git a/test/test.py b/test/test.py index deb7240082..402d9ded38 100755 --- a/test/test.py +++ b/test/test.py @@ -15,13 +15,13 @@ emconfig = os.environ['EM_CONFIG'] upstream_emcc = os.path.join('upstream', 'emscripten', 'emcc') fastcomp_emcc = os.path.join('fastcomp', 'emscripten', 'emcc') -emsdk = './emsdk' +emsdk = 'emsdkpy/emsdk' if WINDOWS: upstream_emcc += '.bat' fastcomp_emcc += '.bat' - emsdk = 'emsdk.bat' + emsdk = 'emsdkpy/emsdk.bat' else: - emsdk = './emsdk' + emsdk = 'emsdkpy/emsdk' # Utilities @@ -81,7 +81,7 @@ def hack_emsdk(marker, replacement): # Set up -TAGS = json.loads(open('emscripten-releases-tags.json').read()) +TAGS = json.loads(open('emsdkpy/emscripten-releases-tags.json').read()) # Tests diff --git a/test/test.sh b/test/test.sh index 9d8171e79b..000157fb06 100755 --- a/test/test.sh +++ b/test/test.sh @@ -7,26 +7,26 @@ set -e # Test that arbitrary (non-released) versions can be installed and # activated. -./emsdk install sdk-upstream-5c776e6a91c0cb8edafca16a652ee1ee48f4f6d2 -./emsdk activate sdk-upstream-5c776e6a91c0cb8edafca16a652ee1ee48f4f6d2 -source ./emsdk_env.sh +emsdkpy/emsdk install sdk-upstream-5c776e6a91c0cb8edafca16a652ee1ee48f4f6d2 +emsdkpy/emsdk activate sdk-upstream-5c776e6a91c0cb8edafca16a652ee1ee48f4f6d2 +source emsdkpy/emsdk_env.sh which emcc emcc -v # Install an older version of the SDK that requires EM_CACHE to be # set in the environment, so that we can test it is later removed -./emsdk install sdk-fastcomp-3b8cff670e9233a6623563add831647e8689a86b -./emsdk activate sdk-fastcomp-3b8cff670e9233a6623563add831647e8689a86b -source ./emsdk_env.sh +emsdkpy/emsdk install sdk-fastcomp-3b8cff670e9233a6623563add831647e8689a86b +emsdkpy/emsdk activate sdk-fastcomp-3b8cff670e9233a6623563add831647e8689a86b +source emsdkpy/emsdk_env.sh which emcc emcc -v test -n "$EM_CACHE" # Install the latest version of the SDK which is the expected precondition # of test.py. -./emsdk install latest -./emsdk activate latest -source ./emsdk_env.sh --build=Release +emsdkpy/emsdk install latest +emsdkpy/emsdk activate latest +source emsdkpy/emsdk_env.sh --build=Release # Test that EM_CACHE was unset test -z "$EM_CACHE" diff --git a/test/test_activation.ps1 b/test/test_activation.ps1 index 1aa0a97c9b..8050558d3a 100644 --- a/test/test_activation.ps1 +++ b/test/test_activation.ps1 @@ -13,10 +13,10 @@ $PATH_Process_BEFORE = [System.Environment]::GetEnvironmentVariable("PATH", "Pro try { - & "$repo_root/emsdk.ps1" install latest + & "$repo_root/emsdkpy/emsdk.ps1" install latest $esc = '--%' - & "$repo_root/emsdk.ps1" activate latest $esc $env:PERMANENT_FLAG $env:SYSTEM_FLAG + & "$repo_root/emsdkpy/emsdk.ps1" activate latest $esc $env:PERMANENT_FLAG $env:SYSTEM_FLAG if ($env:SYSTEM_FLAG) { $env_type = "Machine" diff --git a/test/test_bazel.sh b/test/test_bazel.sh index f52daa4473..ef1c579c3b 100755 --- a/test/test_bazel.sh +++ b/test/test_bazel.sh @@ -7,10 +7,10 @@ set -e # Get the latest version number from emscripten-releases-tag.json. VER=$(grep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \ - emscripten-releases-tags.json \ + emsdkpy/emscripten-releases-tags.json \ | sed --expression "s/\./\\\./g") # Based on the latest version number, get the commit hash for that version. -HASH=$(grep "\"${VER}\"" emscripten-releases-tags.json \ +HASH=$(grep "\"${VER}\"" emsdkpy/emscripten-releases-tags.json \ | grep -v latest \ | cut -f4 -d\") @@ -31,4 +31,4 @@ bazel build //:hello-embind-wasm --compilation_mode dbg # debug # Test use of the closure compiler bazel build //:hello-embind-wasm --compilation_mode opt # release # This function should not be minified if the externs file is loaded correctly. -grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js \ No newline at end of file +grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js diff --git a/test/test_bazel_mac.sh b/test/test_bazel_mac.sh index 0a26a0c245..970061a905 100755 --- a/test/test_bazel_mac.sh +++ b/test/test_bazel_mac.sh @@ -7,10 +7,10 @@ set -e # Get the latest version number from emscripten-releases-tag.json. VER=$(ggrep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \ - emscripten-releases-tags.json \ + emsdkpy/emscripten-releases-tags.json \ | sed "s/\./\\\./g") # Based on the latest version number, get the commit hash for that version. -HASH=$(grep "\"${VER}\"" emscripten-releases-tags.json \ +HASH=$(grep "\"${VER}\"" emsdkpy/emscripten-releases-tags.json \ | grep -v latest \ | cut -f4 -d\") diff --git a/test/test_path_preservation.ps1 b/test/test_path_preservation.ps1 index b894954564..df7efe56ab 100644 --- a/test/test_path_preservation.ps1 +++ b/test/test_path_preservation.ps1 @@ -13,10 +13,10 @@ $PATH_Process_BEFORE = [System.Environment]::GetEnvironmentVariable("PATH", "Pro try { - & "$repo_root/emsdk.ps1" install latest + & "$repo_root/emsdkpy/emsdk.ps1" install latest $esc = '--%' - & "$repo_root/emsdk.ps1" activate latest $esc $env:PERMANENT_FLAG $env:SYSTEM_FLAG + & "$repo_root/emsdkpy/emsdk.ps1" activate latest $esc $env:PERMANENT_FLAG $env:SYSTEM_FLAG $PATH_USER = [System.Environment]::GetEnvironmentVariable("PATH", "User") $PATH_MACHINE = [System.Environment]::GetEnvironmentVariable("PATH", "Machine") diff --git a/test/test_source_env.sh b/test/test_source_env.sh index 71a3e4070a..b879e58c7b 100755 --- a/test/test_source_env.sh +++ b/test/test_source_env.sh @@ -29,11 +29,11 @@ mkdir -p "$ABS_LINK_DIR" (cd $DIR/.. && ln -s `pwd` "$ABS_LINK_DIR/emsdk") (cd $DIR/.. && ln -s `pwd`/emsdk_env.sh "$ABS_LINK_DIR") -PATH1="$DIR/../emsdk_env.sh" -PATH2="$REL_LINK_DIR/emsdk/emsdk_env.sh" -PATH3="$REL_LINK_DIR/emsdk_env.sh" -PATH4="$ABS_LINK_DIR/emsdk/emsdk_env.sh" -PATH5="$ABS_LINK_DIR/emsdk_env.sh" +PATH1="$DIR/../emsdkpy/emsdk_env.sh" +PATH2="$REL_LINK_DIR/emsdk/emsdkpy/emsdk_env.sh" +PATH3="$REL_LINK_DIR/emsdkpy/emsdk_env.sh" +PATH4="$ABS_LINK_DIR/emsdk/emsdkpy/emsdk_env.sh" +PATH5="$ABS_LINK_DIR/emsdkpy/emsdk_env.sh" assert_emcc() { current=$1