~andyc/oil

661be8b0077cabc6775708365bb7de0c50025d37 — Andy C 2 months ago 409a96a dev-andy-10
[translation] _build/cpp/core_optview.h compiles with new GC runtime

- Test it with a shell script.  Fix to make the directory.
- Minor cleanups: remove used code, and reformat code
M build/codegen.sh => build/codegen.sh +28 -2
@@ 19,10 19,10 @@ set -o nounset
set -o pipefail
set -o errexit

REPO_ROOT=$(cd $(dirname $0)/..; pwd)
readonly REPO_ROOT
REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)

source build/common.sh
source cpp/NINJA-steps.sh  # compile_and_link

export PYTHONPATH='.:vendor/'



@@ 76,6 76,32 @@ option-cpp-gen() {
  log "  (core/optview_gen) -> $out_dir/core_optview.h"
}

test-optview() {
  mkdir -p _build/cpp
  option-cpp-gen

  local tmp_dir=_test/gen-cpp/core
  local bin_dir=_bin/cxx-asan/core
  mkdir -p $tmp_dir $bin_dir

  cat >$tmp_dir/optview_test.cc <<'EOF'
#include "_build/cpp/core_optview.h"

int main() {
  printf("OK optview_test\n");
  return 0;
}
EOF

  local bin=$bin_dir/optview_test

  compile_and_link cxx asan '' $bin \
    $tmp_dir/optview_test.cc

  log "RUN $bin"
  $bin
}

flag-gen-mypy() {
  local out=_devbuild/gen/arg_types.py
  frontend/flag_gen.py mypy > $out

M core/optview_gen.py => core/optview_gen.py +6 -1
@@ 24,7 24,12 @@ def main(argv):
#define OPTVIEW_H

#include "_build/cpp/option_asdl.h"
#include "mycpp/mylib_leaky.h"
#ifdef LEAKY_BINDINGS
  #include "mycpp/mylib_leaky.h"
#else
  #include "mycpp/gc_heap.h"
  using gc_heap::List;
#endif

namespace optview {


M cpp/NINJA-steps.sh => cpp/NINJA-steps.sh +0 -1
@@ 12,7 12,6 @@ set -o errexit
#eval 'set -o pipefail'

REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
readonly REPO_ROOT

. build/common.sh  # for $BASE_CXXFLAGS


M cpp/gc_binding_test.cc => cpp/gc_binding_test.cc +1 -1
@@ 11,8 11,8 @@ using gc_heap::StackRoots;  // no-op
using mylib::StrFromC;
#else
#include "mycpp/gc_heap.h"
using gc_heap::StrFromC;
using gc_heap::StackRoots;
using gc_heap::StrFromC;
#endif

TEST qsn_test() {

M cpp/leaky_binding_test.cc => cpp/leaky_binding_test.cc +1 -1
@@ 13,8 13,8 @@
#include "leaky_frontend_match.h"
#include "leaky_libc.h"
#include "leaky_osh.h"
#include "leaky_stdlib.h"
#include "leaky_pylib.h"
#include "leaky_stdlib.h"
#include "vendor/greatest.h"

namespace Id = id_kind_asdl::Id;

M cpp/leaky_frontend_flag_spec.h => cpp/leaky_frontend_flag_spec.h +0 -3
@@ 123,9 123,6 @@ Tuple2<args::_Attributes*, args::Reader*> ParseLikeEcho(

args::_Attributes* ParseMore(Str* spec_name, args::Reader* arg_r);

Tuple2<args::_Attributes*, args::Reader*> ParseOilCmdVal(
    Str* spec_name, runtime_asdl::cmd_value__Argv* cmd_val);

}  // namespace flag_spec

#endif  // FRONTEND_FLAG_SPEC_H

M cpp/leaky_preamble.h => cpp/leaky_preamble.h +2 -2
@@ 5,7 5,7 @@
// clang-format on

#include <errno.h>
#include <fcntl.h>  // F_DUPFD used directly
#include <fcntl.h>     // F_DUPFD used directly
#include <sys/wait.h>  // WIFSIGNALED, etc. called DIRECTLY

#include "leaky_dumb_alloc.h"  // change the allocator


@@ 36,8 36,8 @@ using id_kind_asdl::Kind_t;
#include "leaky_libc.h"
#include "leaky_osh.h"
#include "leaky_pgen2.h"
#include "leaky_stdlib.h"
#include "leaky_pylib.h"
#include "leaky_stdlib.h"
#include "qsn.h"
#include "segfault_handler.h"


M cpp/leaky_stdlib.cc => cpp/leaky_stdlib.cc +1 -1
@@ 18,8 18,8 @@
#include "cpp/leaky_core_error.h"
#include "cpp/leaky_core_pyerror.h"
#include "mycpp/mylib_leaky.h"
using mylib::StrFromC;
using mylib::OverAllocatedStr;
using mylib::StrFromC;

namespace fcntl_ {


M cpp/qsn.h => cpp/qsn.h +2 -2
@@ 7,15 7,15 @@
#include "mycpp/mylib_leaky.h"
using gc_heap::StackRoots;  // no-op
using mylib::AllocStr;
using mylib::StrFromC;
using mylib::OverAllocatedStr;
using mylib::StrFromC;
#else
#include "mycpp/gc_heap.h"
using gc_heap::AllocStr;
using gc_heap::StrFromC;
using gc_heap::OverAllocatedStr;
using gc_heap::StackRoots;
using gc_heap::Str;
using gc_heap::StrFromC;
#endif

namespace qsn {

M mycpp/gc_heap_test.cc => mycpp/gc_heap_test.cc +1 -1
@@ 17,7 17,6 @@ using gc_heap::Obj;
using gc_heap::Param;

using gc_heap::AllocStr;
using gc_heap::StrFromC;
using gc_heap::Dict;
using gc_heap::GlobalStr;
using gc_heap::List;


@@ 28,6 27,7 @@ using gc_heap::OverAllocatedStr;
using gc_heap::Slab;
using gc_heap::StackRoots;
using gc_heap::Str;
using gc_heap::StrFromC;

// Constants
using gc_heap::kEmptyString;

M mycpp/gc_stress_test.cc => mycpp/gc_stress_test.cc +1 -1
@@ 8,12 8,12 @@
//#include "mylib2.h"  // gBuf

using gc_heap::Alloc;
using gc_heap::StrFromC;
using gc_heap::Dict;
using gc_heap::List;
using gc_heap::NewList;
using gc_heap::StackRoots;
using gc_heap::Str;
using gc_heap::StrFromC;
// using gc_heap::kEmptyString;

using gc_heap::gHeap;

M mycpp/my_runtime.h => mycpp/my_runtime.h +1 -1
@@ 17,11 17,11 @@

// TODO: Don't use 'using' in header
using gc_heap::AllocStr;
using gc_heap::StrFromC;
using gc_heap::Dict;
using gc_heap::List;
using gc_heap::StackRoots;
using gc_heap::Str;
using gc_heap::StrFromC;

class IndexError {};
class ValueError {};

M mycpp/my_runtime_test.cc => mycpp/my_runtime_test.cc +1 -1
@@ 9,12 9,12 @@
#include "vendor/greatest.h"

using gc_heap::Alloc;
using gc_heap::StrFromC;
using gc_heap::Dict;
using gc_heap::gHeap;
using gc_heap::kEmptyString;
using gc_heap::NewList;
using gc_heap::StackRoots;
using gc_heap::StrFromC;

GLOBAL_STR(kStrFood, "food");
GLOBAL_STR(kWithNull, "foo\0bar");

M mycpp/mylib2_test.cc => mycpp/mylib2_test.cc +1 -1
@@ 5,9 5,9 @@
#include "vendor/greatest.h"

using gc_heap::Alloc;
using gc_heap::StrFromC;
using gc_heap::kEmptyString;
using gc_heap::StackRoots;
using gc_heap::StrFromC;

TEST split_once_test() {
  log("split_once()");

M test/cpp-unit.sh => test/cpp-unit.sh +2 -0
@@ 14,6 14,8 @@ source soil/common.sh  # find-dir-html
all-tests() {
  ./NINJA_config.py

  build/codegen.sh test-optview

  # uses Ninja to run (cxx, testgc) variant.  Could also run (clang, ubsan),
  # which finds more bugs.
  mycpp/test.sh soil-run