Skip to content

Commit

Permalink
Move headers to include/wabt/ (#1998)
Browse files Browse the repository at this point in the history
This makes things easier for users and packagers of libwabt.
  • Loading branch information
alexreinking authored Sep 28, 2022
1 parent 520614a commit a4a77c1
Show file tree
Hide file tree
Showing 136 changed files with 539 additions and 534 deletions.
147 changes: 76 additions & 71 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ include(CheckTypeSize)
check_type_size(ssize_t SSIZE_T)
check_type_size(size_t SIZEOF_SIZE_T)

configure_file(src/config.h.in config.h @ONLY)
configure_file(src/config.h.in include/wabt/config.h @ONLY)

include_directories(${WABT_SOURCE_DIR} ${WABT_BINARY_DIR})

if (COMPILER_IS_MSVC)
if (WERROR)
Expand Down Expand Up @@ -254,124 +253,130 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${WABT_SOURCE_DIR}/cmake)

add_custom_target(everything)

set(WABT_LIBRARY_SRC
${WABT_BINARY_DIR}/config.h

src/apply-names.h
set(WABT_LIBRARY_CC
src/apply-names.cc
src/binary.h
src/binary.cc
src/binary-reader.h
src/binary-reader.cc
src/binary-reader-ir.h
src/binary-reader-ir.cc
src/binary-reader-logging.h
src/binary-reader-logging.cc
src/binary-writer.h
src/binary-writer.cc
src/binary-writer-spec.h
src/binary-reader.cc
src/binary-writer-spec.cc
src/binding-hash.h
src/binary-writer.cc
src/binary.cc
src/binding-hash.cc
src/color.h
src/color.cc
src/common.h
src/common.cc
src/config.h.in
src/config.cc
src/decompiler.h
src/decompiler-ast.h
src/decompiler-ls.h
src/decompiler-naming.h
src/config.h.in
src/decompiler.cc
src/error-formatter.h
src/error-formatter.cc
src/expr-visitor.h
src/expr-visitor.cc
src/feature.h
src/feature.cc
src/filenames.h
src/filenames.cc
src/generate-names.h
src/generate-names.cc
src/ir.h
src/ir.cc
src/ir-util.h
src/ir-util.cc
src/leb128.h
src/ir.cc
src/leb128.cc
src/lexer-source.h
src/lexer-source.cc
src/lexer-source-line-finder.h
src/lexer-source-line-finder.cc
src/literal.h
src/lexer-source.cc
src/literal.cc
src/opcode.h
src/opcode.cc
src/opcode-code-table.h
src/opcode-code-table.c
src/option-parser.h
src/opcode-code-table.c
src/opcode.cc
src/option-parser.cc
src/resolve-names.h
src/resolve-names.cc
src/shared-validator.h
src/shared-validator.cc
src/stream.h
src/stream.cc
src/string-util.h
src/token.h
src/token.cc
src/tracing.h
src/tracing.cc
src/type.h
src/type-checker.h
src/type-checker.cc
src/utf8.h
src/utf8.cc
src/validator.h
src/validator.cc
src/wast-lexer.h
src/wast-lexer.cc
src/wast-parser.h
src/wast-parser.cc
src/wat-writer.h
src/wat-writer.cc

# TODO(binji): Move this into its own library?
src/interp/binary-reader-interp.h
src/interp/binary-reader-interp.cc
src/interp/interp.h
src/interp/interp.cc
src/interp/interp-inl.h
src/interp/interp-math.h
src/interp/interp-util.h
src/interp/interp-util.cc
src/interp/istream.h
src/interp/istream.cc
)

set(WABT_LIBRARY_H
${WABT_BINARY_DIR}/include/wabt/config.h

include/wabt/apply-names.h
include/wabt/binary-reader-ir.h
include/wabt/binary-reader-logging.h
include/wabt/binary-reader.h
include/wabt/binary-writer-spec.h
include/wabt/binary-writer.h
include/wabt/binary.h
include/wabt/binding-hash.h
include/wabt/color.h
include/wabt/common.h
include/wabt/decompiler-ast.h
include/wabt/decompiler-ls.h
include/wabt/decompiler-naming.h
include/wabt/decompiler.h
include/wabt/error-formatter.h
include/wabt/expr-visitor.h
include/wabt/feature.h
include/wabt/filenames.h
include/wabt/generate-names.h
include/wabt/ir-util.h
include/wabt/ir.h
include/wabt/leb128.h
include/wabt/lexer-source-line-finder.h
include/wabt/lexer-source.h
include/wabt/literal.h
include/wabt/opcode-code-table.h
include/wabt/opcode.h
include/wabt/option-parser.h
include/wabt/resolve-names.h
include/wabt/shared-validator.h
include/wabt/stream.h
include/wabt/string-util.h
include/wabt/token.h
include/wabt/tracing.h
include/wabt/type-checker.h
include/wabt/type.h
include/wabt/utf8.h
include/wabt/validator.h
include/wabt/wast-lexer.h
include/wabt/wast-parser.h
include/wabt/wat-writer.h

# TODO(binji): Move this into its own library?
include/wabt/interp/binary-reader-interp.h
include/wabt/interp/interp-inl.h
include/wabt/interp/interp-math.h
include/wabt/interp/interp-util.h
include/wabt/interp/interp.h
include/wabt/interp/istream.h
)

set(WABT_LIBRARY_SRC ${WABT_LIBRARY_CC} ${WABT_LIBRARY_H})

add_library(wabt STATIC ${WABT_LIBRARY_SRC})
add_library(wabt::wabt ALIAS wabt)

target_compile_features(wabt PUBLIC cxx_std_17)
target_include_directories(
wabt
PUBLIC
"$<BUILD_INTERFACE:${WABT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${WABT_BINARY_DIR}/include>"
)

if (WABT_INSTALL_RULES)
install(
TARGETS wabt EXPORT wabt-targets
COMPONENT wabt-development
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/wabt"
)
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/wabt"
COMPONENT wabt-development
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.def"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/config.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/wabt/"
DIRECTORY "${WABT_SOURCE_DIR}/include/" "${WABT_BINARY_DIR}/include/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT wabt-development
)
endif ()
Expand Down Expand Up @@ -407,7 +412,7 @@ endif ()
# libwasm, which implenents the wasm C API
if (BUILD_LIBWASM)
add_library(wasm SHARED ${WABT_LIBRARY_SRC} src/interp/interp-wasm-c-api.cc)
target_link_libraries(wasm wabt)
target_link_libraries(wasm PUBLIC wabt)
target_include_directories(wasm PUBLIC third_party/wasm-c-api/include)
if (COMPILER_IS_MSVC)
target_compile_definitions(wasm PRIVATE "WASM_API_EXTERN=__declspec(dllexport)")
Expand Down
2 changes: 1 addition & 1 deletion src/apply-names.h → include/wabt/apply-names.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef WABT_APPLY_NAMES_H_
#define WABT_APPLY_NAMES_H_

#include "src/common.h"
#include "wabt/common.h"

namespace wabt {

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/binary-reader-ir.h → include/wabt/binary-reader-ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef WABT_BINARY_READER_IR_H_
#define WABT_BINARY_READER_IR_H_

#include "src/common.h"
#include "src/error.h"
#include "wabt/common.h"
#include "wabt/error.h"

namespace wabt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef WABT_BINARY_READER_LOGGING_H_
#define WABT_BINARY_READER_LOGGING_H_

#include "src/binary-reader.h"
#include "wabt/binary-reader.h"

namespace wabt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef WABT_BINARY_READER_NOP_H_
#define WABT_BINARY_READER_NOP_H_

#include "src/binary-reader.h"
#include "wabt/binary-reader.h"

namespace wabt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include <map>
#include <string>

#include "src/common.h"
#include "src/feature.h"
#include "src/stream.h"
#include "wabt/common.h"
#include "wabt/feature.h"
#include "wabt/stream.h"

namespace wabt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <map>
#include <vector>

#include "src/common.h"
#include "src/opcode.h"
#include "wabt/common.h"
#include "wabt/opcode.h"

namespace wabt {

Expand Down
10 changes: 5 additions & 5 deletions src/binary-reader.h → include/wabt/binary-reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include <stdint.h>
#include <string_view>

#include "src/binary.h"
#include "src/common.h"
#include "src/error.h"
#include "src/feature.h"
#include "src/opcode.h"
#include "wabt/binary.h"
#include "wabt/common.h"
#include "wabt/error.h"
#include "wabt/feature.h"
#include "wabt/opcode.h"

namespace wabt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include <utility>
#include <vector>

#include "src/binary-writer.h"
#include "src/common.h"
#include "src/ir.h"
#include "wabt/binary-writer.h"
#include "wabt/common.h"
#include "wabt/ir.h"

namespace wabt {

Expand Down
8 changes: 4 additions & 4 deletions src/binary-writer.h → include/wabt/binary-writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#ifndef WABT_BINARY_WRITER_H_
#define WABT_BINARY_WRITER_H_

#include "src/common.h"
#include "src/feature.h"
#include "src/opcode.h"
#include "src/stream.h"
#include "wabt/common.h"
#include "wabt/feature.h"
#include "wabt/opcode.h"
#include "wabt/stream.h"

namespace wabt {

Expand Down
2 changes: 1 addition & 1 deletion src/binary.h → include/wabt/binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef WABT_BINARY_H_
#define WABT_BINARY_H_

#include "src/common.h"
#include "wabt/common.h"

#define WABT_BINARY_MAGIC 0x6d736100
#define WABT_BINARY_VERSION 1
Expand Down
2 changes: 1 addition & 1 deletion src/binding-hash.h → include/wabt/binding-hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <unordered_map>
#include <vector>

#include "src/common.h"
#include "wabt/common.h"

namespace wabt {

Expand Down
2 changes: 1 addition & 1 deletion src/c-writer.h → include/wabt/c-writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef WABT_C_WRITER_H_
#define WABT_C_WRITER_H_

#include "src/common.h"
#include "wabt/common.h"

namespace wabt {

Expand Down
2 changes: 1 addition & 1 deletion src/cast.h → include/wabt/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <memory>
#include <type_traits>

#include "src/common.h"
#include "wabt/common.h"

// Modeled after LLVM's dynamic casts:
// http://llvm.org/docs/ProgrammersManual.html#the-isa-cast-and-dyn-cast-templates
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions src/common.h → include/wabt/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
#include <type_traits>
#include <vector>

#include "config.h"
#include "wabt/config.h"

#include "src/base-types.h"
#include "src/make-unique.h"
#include "src/result.h"
#include "src/string-format.h"
#include "src/type.h"
#include "wabt/base-types.h"
#include "wabt/make-unique.h"
#include "wabt/result.h"
#include "wabt/string-format.h"
#include "wabt/type.h"

#define WABT_FATAL(...) fprintf(stderr, __VA_ARGS__), exit(1)
#define WABT_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
Expand Down
8 changes: 4 additions & 4 deletions src/decompiler-ast.h → include/wabt/decompiler-ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#ifndef WABT_DECOMPILER_AST_H_
#define WABT_DECOMPILER_AST_H_

#include "src/cast.h"
#include "src/generate-names.h"
#include "src/ir-util.h"
#include "src/ir.h"
#include "wabt/cast.h"
#include "wabt/generate-names.h"
#include "wabt/ir-util.h"
#include "wabt/ir.h"

#include <map>

Expand Down
Loading

0 comments on commit a4a77c1

Please sign in to comment.