-
-
Notifications
You must be signed in to change notification settings - Fork 163
Oil Dev Cheat Sheet
andychu edited this page Nov 24, 2024
·
82 revisions
Here is a list of commands I often run.
The Contributing page walks you through the setup.
First you have to get dependencies, which is described on the Contributing page.
Do this every time you git pull
, or switch branches:
build/py.sh all # now interpreted bin/osh and bin/ysh are ready
. build/dev-shell.sh # put our build of python2 in your $PATH
./NINJA-config.sh # crawl Python deps and write build.ninja
Build:
ninja _bin/cxx-dbg/osh # or any other Ninja target
-
source devtools/completion.bash
gives you completion for the "two level structure" of shell files and functions. You can hit tab and then it will complete function names. (TODO: There is some flakiness if you hit tab in the wrong place, but it generally works. #797).
TODO(andy): replace with "BYO completion"
build/py.sh all # create the Python dev build
bin/osh -c 'echo hi' # directly run dev build
bin/ysh -c 'cd /tmp { echo hi }' # dev build of YSH
test/unit.sh all # run all Python unit tests
test/spec.sh smoke # run a single test suite
test/spec.sh smoke -r 0 -v # run a single test
test/spec-py.sh osh-all # run all OSH spec tests
test/spec-py.sh ysh-all # run all YSH spec tests
build/clean.sh # remove files created by build/py.sh all
devtools/types.sh check-oils # check the Oils codebase
devtools/types.sh soil-run
test/lint.sh soil-run
Reformatting Python:
devtools/format.sh install-yapf # install a specific version that we need to agree on
devtools/format.sh yapf-known # format all files we care about - SLOW
devtools/format.sh yapf-changed # better: make sure everything is committed on your branch,
# it only auto formats what's changed
devtools/format.sh yapf-files osh/cmd_eval.py # select specific files
Reformatting C++
# download and extract Clang (used for coverage and auto-formatting)
deps/from-binary.sh download-clang
deps/from-binary.sh extract-clang
devtools/format.sh all-cpp # reformat the C++ code. 'git diff' to see the result.
build/py.sh all # must build Python before building C++
./NINJA-config.sh # generate build.ninja
ninja _bin/cxx-dbg/osh
_bin/cxx-dbg/osh -c 'echo hi' # directly run oil-native
ninja _bin/cxx-opt/osh # optimized version
# run unit tests in these dirs
asdl/TEST.sh unit
cpp/TEST.sh unit
# Run all C++ unit tests
test/cpp-unit.sh all-tests
# run individual tests with a specific build variant
ninja _bin/cxx-asan/cpp/core_test && $_
ninja _bin/cxx-ubsan/cpp/core_test && $_
ninja _bin/cxx-gcverbose/cpp/core_test && $_
test/spec-cpp.sh run-file smoke # run a single suite against oil-native
test/spec-cpp.sh run-file smoke -r 0 -v # as above
test/spec-cpp.sh run-file smoke -r 0 -p > _tmp/0.sh # print code to file
_bin/cxx-dbg/osh _tmp/0.sh # run it directly
gdb --args _bin/cxx-dbg/osh _tmp/0.sh # debug it directly
test/spec-cpp.sh all # run all OSH tests with C++
build/clean.sh # cleans the C++ build too
mycpp/TEST.sh test-runtime # run the unit tests
mycpp/TEST.sh test-translator # compare mycpp/examples, includes "ninja mycpp-logs-equal"
ninja -j 1 mycpp-logs-equal # sometimes useful to run serially and isolate failure
ninja -t targets all | sort # list hundreds of targets (variants). Use with grep.
PYTHONPATH=.:mycpp mycpp/examples/parse.py # run python example directly
ninja _bin/cxx-asan/mycpp/examples/parse.mycpp # make sure C++ translation is up to date
_bin/cxx-asan/mycpp/examples/parse.mycpp # run C++ translation
# shell trick I use to automate the above
ninja _bin/cxx-asan/mycpp/examples/parse.mycpp && $_ # $_ runs last arg as command
BENCHMARK=1 _bin/cxx-opt/mycpp/examples/parse.mycpp # run optimized binary in benchmark mode
_bin/cxx-testgc/mycpp/gc_stress_test # run an individual test
_bin/cxx-testgc/mycpp/gc_stress_test -t test_foo # run an individual case (greatest.h supports -t)
# Run a Ninja task. The task file is "demanded" to run the examples/length.py file.
# TODO: the dependencies are a little weird here
rm _test/tasks/test/length.py.task.txt
ninja _test/tasks/test/length.py.task.txt
Wedges are used for dependencies in two places
- local dev, e.g. shells for spec test
- Soil CI
The idea is to maintain the CI and dev environments exactly in sync.
build/deps.sh install-debian-packages # dependencies to build the tarball dependencies!
build/deps.sh install-wedges-fast # install what you typically need, as above
build/deps.sh install-wedges-fast T # extra wedges like R-libs
build/deps.sh rm-oils-crap # if you want to start over !! removes /wedge and ~/wedge
Related: