diff --git a/README.md b/README.md index 9312d935f3..b4869211b0 100644 --- a/README.md +++ b/README.md @@ -1,100 +1,37 @@ -# Ninja - -Ninja is a small build system with a focus on speed. -https://ninja-build.org/ - -See [the manual](https://ninja-build.org/manual.html) or -`doc/manual.asciidoc` included in the distribution for background -and more details. - -Binaries for Linux, Mac and Windows are available on - [GitHub](https://github.com/ninja-build/ninja/releases). -Run `./ninja -h` for Ninja help. - -Installation is not necessary because the only required file is the -resulting ninja binary. However, to enable features like Bash -completion and Emacs and Vim editing modes, some files in misc/ must be -copied to appropriate locations. - -If you're interested in making changes to Ninja, read -[CONTRIBUTING.md](CONTRIBUTING.md) first. - -## Building Ninja itself - -You can either build Ninja via the custom generator script written in Python or -via CMake. For more details see -[the wiki](https://github.com/ninja-build/ninja/wiki). - -### Python - -``` -./configure.py --bootstrap -``` - -This will generate the `ninja` binary and a `build.ninja` file you can now use -to build Ninja with itself. - -If you have a GoogleTest source directory, you can build the tests -by passing its path with `--gtest-source-dir=PATH` option, or the -`GTEST_SOURCE_DIR` environment variable, e.g.: - -``` -./configure.py --bootstrap --gtest-source-dir=/path/to/googletest -./ninja all # build ninja_test and other auxiliary binaries -./ninja_test` # run the unit-test suite. -``` - -Use the CMake build below if you want to use a preinstalled binary -version of the library. - -### CMake - -``` -cmake -Bbuild-cmake -cmake --build build-cmake -``` - -The `ninja` binary will now be inside the `build-cmake` directory (you can -choose any other name you like). - -To run the unit tests: - -``` -./build-cmake/ninja_test -``` - -## Generating documentation - -### Ninja Manual - -You must have `asciidoc` and `xsltproc` in your PATH, then do: - -``` -./configure.py -ninja manual doc/manual.pdf -``` - -Which will generate `doc/manual.html`. - -To generate the PDF version of the manual, you must have `dblatext` in your PATH then do: - -``` -./configure.py # only if you didn't do it previously. -ninja doc/manual.pdf -``` - -Which will generate `doc/manual.pdf`. - -### Doxygen documentation - -If you have `doxygen` installed, you can build documentation extracted from C++ -declarations and comments to help you navigate the code. Note that Ninja is a standalone -executable, not a library, so there is no public API, all details exposed here are -internal. - -``` -./configure.py # if needed -ninja doxygen -``` - -Then open `doc/doxygen/html/index.html` in a browser to look at it. +# Shadowdash Converter +## Build +```sh +./build.sh +``` +This will create the converter in the `debug-build` directory with debug symbols with the name 'shadowdash'. + +## Run +```sh +./debug-build/shadowdash -f +``` +If `-f` argument is not given, it will use the `build.ninja` file in the current working directory. +Output file is named `output.cc`. Output is also printed on stdout. + +## Test Suite +```sh +cd converter +./run-tests.sh +``` +This will run the converter with input `build.ninja` files from the `converter/testing/` directory. + +## Directory Structure +```sh +- README.md # readme for the converter +- build.sh # builds the converter binary in debug-build/ folder with the name shadowdash +- src/ # contains the converter source code, previously contained ninja source code +- converter/ + - include/ + - manifest.h # contains definitions for shadowdash namespace that are required to compile the output of the converter into a library + - testing/ + - example.build.ninja + - example.zlib.ninja + - run-tests.sh +``` + +## Converter Implementation +- The converter converts any given `build.ninja` to Team 5's single file language spec. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000..4844434397 --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +cmake -DCMAKE_BUILD_TYPE=Debug -B debug-build +cmake --build debug-build --parallel --config Debug --target ninja +mv debug-build/ninja debug-build/shadowdash diff --git a/converter/include/manifest.h b/converter/include/manifest.h new file mode 100644 index 0000000000..58db681a5f --- /dev/null +++ b/converter/include/manifest.h @@ -0,0 +1,234 @@ +#pragma once + +#include +#include +#include +#include + +namespace shadowdash { + +class Token { +public: + enum Type { LITERAL, VAR }; + + Token(Type type, std::string value) + : type_(type), value_(std::move(value)) { + //std::cout << "creating " << type << " : " << value_ << std::endl; + } + + Token(std::string value) : Token(Token::LITERAL, std::move(value)) { + //std::cout << "creating LITERAL: " << value_ << std::endl; + } + + Token(const char* value) : Token(Token::LITERAL, std::string(value)) { + //std::cout << "creating LITERAL: " << value << std::endl; + } + + Type type_; + std::string value_; +}; + +// Overload operator<< for Token +std::ostream& operator<<(std::ostream& os, const Token& token) { + os << (token.type_ == Token::LITERAL ? "LITERAL" : "VAR") << ": " << token.value_; + return os; +} + +Token operator"" _l(const char* value, std::size_t len) { + return Token(Token::Type::LITERAL, std::string(value, len)); +} + +Token operator"" _v(const char* value, std::size_t len) { + return Token(Token::Type::VAR, std::string(value, len)); +} + +class str { +public: + str(std::vector tokens) : tokens_(std::move(tokens)) { + //std::cout << "creating str: "; + for (const auto& token : tokens_) { + //std::cout << token << " "; + } + //std::cout << std::endl; + } + + std::vector tokens_; +}; + +// Overload operator<< for str +std::ostream& operator<<(std::ostream& os, const str& s) { + os << "str: ["; + for (const auto& token : s.tokens_) { + os << token << ", "; + } + os << "]"; + return os; +} + +using binding = std::pair; +using map = std::vector; + +class list { +public: + list(std::vector values) : values_(std::move(values)) { + //std::cout << "creating list: "; + for (const auto& value : values_) { + //std::cout << value << " "; + } + //std::cout << std::endl; + } + + std::vector values_; +}; + +// Overload operator<< for list +std::ostream& operator<<(std::ostream& os, const list& l) { + os << "list: ["; + for (const auto& value : l.values_) { + os << value << ", "; + } + os << "]"; + return os; +} + +class var { +public: + var(const char* name, str value) : name_(name), value_(std::move(value)) {} + + const char* name_; + str value_; +}; + +// Overload operator<< for var +std::ostream& operator<<(std::ostream& os, const var& v) { + os << "var: " << v.name_ << ", " << v.value_; + return os; +} + + +class rule { +public: + enum SPECIAL_RULE { + phony + }; + + union _rule { + _rule() : sp_rule(phony) {} + _rule(map bindings) : bindings_(std::move(bindings)) {} + _rule(SPECIAL_RULE sr) : sp_rule(sr) {} + ~_rule() {} + + map bindings_; + SPECIAL_RULE sp_rule; + } _rule_data; + bool is_special; + + rule(map bindings) : _rule_data(std::move(bindings)), is_special(false) {} + rule(SPECIAL_RULE sp_rule) : _rule_data(sp_rule), is_special(true) {} + + rule(const rule& other) : is_special(other.is_special) { + if (is_special) { + new (&_rule_data) _rule(other._rule_data.sp_rule); // Copy the special rule + } else { + new (&_rule_data) _rule(other._rule_data.bindings_); // Copy the bindings map + } + } +}; + +// Overload operator<< for rule +std::ostream& operator<<(std::ostream& os, const rule& r) { + os << "rule: ["; + if(r.is_special) + os << r._rule_data.sp_rule; + else { + for (const auto& binding : r._rule_data.bindings_) { + os << binding.first << ": " << binding.second << ", "; + } + } + os << "]"; + return os; +} + +class build { +public: + build( + list outputs, + list implicit_outputs, + rule rule, + list inputs, + list implicit_inputs, + list order_only_inputs, + map bindings) + : outputs_(std::move(outputs)), + implicit_outputs_(std::move(implicit_outputs)), + rule_(rule), + inputs_(std::move(inputs)), + implicit_inputs_(std::move(implicit_inputs)), + order_only_inputs_(std::move(order_only_inputs)), + bindings_(std::move(bindings)) { + //std::cout << "creating build: "; + //std::cout << "creating build outputs: "; + //std::cout << this->outputs_ << std::endl; + } + + list outputs_; + list implicit_outputs_; + rule rule_; + list inputs_; + list implicit_inputs_; + list order_only_inputs_; + map bindings_; +}; + +// Overload operator<< for build +std::ostream& operator<<(std::ostream& os, const build& b) { + os << "build: { " + << "outputs: " << b.outputs_ << ", " + << "implicit_outputs: " << b.implicit_outputs_ << ", " + << "rule: " << b.rule_ << ", " + << "inputs: " << b.inputs_ << ", " + << "implicit_inputs: " << b.implicit_inputs_ << ", " + << "order_only_inputs: " << b.order_only_inputs_ << ", " + << "bindings: ["; + for (const auto& binding : b.bindings_) { + os << binding.first << ": " << binding.second << ", "; + } + os << "] }"; + return os; +} + +class buildGroup { +public: + buildGroup(std::vector builds) : builds(std::move(builds)) {} + + std::vector builds; +}; + +// Overload operator<< for buildGroup +std::ostream& operator<<(std::ostream& os, const buildGroup& bg) { + os << "buildGroup: ["; + for (const auto& b : bg.builds) { + os << b << ", "; + } + os << "]"; + return os; +} + +static auto in = "in"_v; +static auto out = "out"_v; + +} // namespace shadowdash + +#define let(name, ...) \ + var name { \ + #name, str { \ + __VA_ARGS__ \ + } \ + } + +#define bind(name, ...) \ + { \ + #name, str { \ + __VA_ARGS__ \ + } \ + } diff --git a/converter/run-tests.sh b/converter/run-tests.sh new file mode 100755 index 0000000000..daa69d5fc4 --- /dev/null +++ b/converter/run-tests.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +CONVERTER=../debug-build/shadowdash +TEST_DIR=testing/ + +# Build converter +cd .. +/bin/bash build.sh +cd converter + +# Run tests +# loop through each test build.ninja file +for input_file in "$TEST_DIR"/*; do + # extract the base filename (e.g., "test1" from "test_inputs/test1.txt") + base_name=$(basename "$input_file") + + # run the binary, passing the input file and directing output to the output directory + $CONVERTER -f "$input_file" > output.cc + + # check if the binary exited successfully + if [ $? -ne 0 ]; then + echo "test failed for $base_name: non-zero exit code" + continue + fi + + # check if compilation works of the converter generated output.cc + clang++ -shared -fPIC -o libmanifest.so -I include/ output.cc + # check if the binary exited successfully + if [ $? -ne 0 ]; then + echo "test failed for $base_name: unable to compile it" + continue + fi + echo "test passed for $base_name" + + # cleanup + rm -f output.cc libmanifest.so +done diff --git a/converter/testing/example.build.ninja b/converter/testing/example.build.ninja new file mode 100644 index 0000000000..0fe588dc65 --- /dev/null +++ b/converter/testing/example.build.ninja @@ -0,0 +1,13 @@ +flags = -O3 +rule compile + command = g++ $flags -c $in -o $out + +rule link + command = g++ $in -o $out + +build hello.o: compile hello.cpp + flags = -O2 + +build hello: link hello.o + +default hello diff --git a/converter/testing/zlib.build.ninja b/converter/testing/zlib.build.ninja new file mode 100644 index 0000000000..ccc15a10d9 --- /dev/null +++ b/converter/testing/zlib.build.ninja @@ -0,0 +1,744 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Ninja" Generator, CMake Version 3.22 + +# This file contains all the build statements describing the +# compilation DAG. + +# ============================================================================= +# Write statements declared in CMakeLists.txt: +# +# Which is the root file. +# ============================================================================= + +# ============================================================================= +# Project: zlib +# Configurations: +# ============================================================================= + +############################################# +# Minimal version of Ninja required by this file + +ninja_required_version = 1.5 + +# ============================================================================= +# Include auxiliary files. + + +############################################# +# Include rules file. + +# CMAKE generated file: DO NOT EDIT! +# Generated by "Ninja" Generator, CMake Version 3.22 + +# This file contains all the rules used to get the outputs files +# built from the input files. +# It is included in the main 'build.ninja'. + +# ============================================================================= +# Project: zlib +# Configurations: +# ============================================================================= +# ============================================================================= + +############################################# +# Rule for compiling C files. + +rule C_COMPILER__zlib_ + depfile = $DEP_FILE + deps = gcc + command = /usr/bin/cc $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in + description = Building C object $out + + +############################################# +# Rule for linking C shared library. + +rule C_SHARED_LIBRARY_LINKER__zlib_ + command = $PRE_LINK && /usr/bin/cc -fPIC $LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS $LINK_FLAGS -shared $SONAME_FLAG$SONAME -o $TARGET_FILE $in $LINK_PATH $LINK_LIBRARIES && $POST_BUILD + description = Linking C shared library $TARGET_FILE + restat = $RESTAT + + +############################################# +# Rule for creating library symlink. + +rule CMAKE_SYMLINK_LIBRARY + command = /usr/bin/cmake -E cmake_symlink_library $in $SONAME $out && $POST_BUILD + description = Creating library symlink $out + + +############################################# +# Rule for compiling C files. + +rule C_COMPILER__zlibstatic_ + depfile = $DEP_FILE + deps = gcc + command = /usr/bin/cc $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in + description = Building C object $out + + +############################################# +# Rule for linking C static library. + +rule C_STATIC_LIBRARY_LINKER__zlibstatic_ + command = $PRE_LINK && /usr/bin/cmake -E rm -f $TARGET_FILE && /usr/bin/ar qc $TARGET_FILE $LINK_FLAGS $in && /usr/bin/ranlib $TARGET_FILE && $POST_BUILD + description = Linking C static library $TARGET_FILE + restat = $RESTAT + + +############################################# +# Rule for compiling C files. + +rule C_COMPILER__example_ + depfile = $DEP_FILE + deps = gcc + command = /usr/bin/cc $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in + description = Building C object $out + + +############################################# +# Rule for linking C executable. + +rule C_EXECUTABLE_LINKER__example_ + command = $PRE_LINK && /usr/bin/cc $FLAGS $LINK_FLAGS $in -o $TARGET_FILE $LINK_PATH $LINK_LIBRARIES && $POST_BUILD + description = Linking C executable $TARGET_FILE + restat = $RESTAT + + +############################################# +# Rule for compiling C files. + +rule C_COMPILER__minigzip_ + depfile = $DEP_FILE + deps = gcc + command = /usr/bin/cc $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in + description = Building C object $out + + +############################################# +# Rule for linking C executable. + +rule C_EXECUTABLE_LINKER__minigzip_ + command = $PRE_LINK && /usr/bin/cc $FLAGS $LINK_FLAGS $in -o $TARGET_FILE $LINK_PATH $LINK_LIBRARIES && $POST_BUILD + description = Linking C executable $TARGET_FILE + restat = $RESTAT + + +############################################# +# Rule for compiling C files. + +rule C_COMPILER__example64_ + depfile = $DEP_FILE + deps = gcc + command = /usr/bin/cc $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in + description = Building C object $out + + +############################################# +# Rule for linking C executable. + +rule C_EXECUTABLE_LINKER__example64_ + command = $PRE_LINK && /usr/bin/cc $FLAGS $LINK_FLAGS $in -o $TARGET_FILE $LINK_PATH $LINK_LIBRARIES && $POST_BUILD + description = Linking C executable $TARGET_FILE + restat = $RESTAT + + +############################################# +# Rule for compiling C files. + +rule C_COMPILER__minigzip64_ + depfile = $DEP_FILE + deps = gcc + command = /usr/bin/cc $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in + description = Building C object $out + + +############################################# +# Rule for linking C executable. + +rule C_EXECUTABLE_LINKER__minigzip64_ + command = $PRE_LINK && /usr/bin/cc $FLAGS $LINK_FLAGS $in -o $TARGET_FILE $LINK_PATH $LINK_LIBRARIES && $POST_BUILD + description = Linking C executable $TARGET_FILE + restat = $RESTAT + + +############################################# +# Rule for running custom commands. + +rule CUSTOM_COMMAND + command = $COMMAND + description = $DESC + + +############################################# +# Rule for re-running cmake. + +rule RERUN_CMAKE + command = /usr/bin/cmake --regenerate-during-build -S/home/opensource/zlib -B/home/opensource/zlib + description = Re-running CMake... + generator = 1 + + +############################################# +# Rule for cleaning all built files. + +rule CLEAN + command = /usr/bin/ninja $FILE_ARG -t clean $TARGETS + description = Cleaning all built files... + + +############################################# +# Rule for printing all primary targets available. + +rule HELP + command = /usr/bin/ninja -t targets + description = All primary targets available: + + + +# ============================================================================= + +############################################# +# Logical path to working directory; prefix for absolute paths. + +cmake_ninja_workdir = /home/opensource/zlib/ +# ============================================================================= +# Object build statements for SHARED_LIBRARY target zlib + + +############################################# +# Order-only phony target for zlib + +build cmake_object_order_depends_target_zlib: phony || CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/adler32.c.o: C_COMPILER__zlib_ /home/opensource/zlib/adler32.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/adler32.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/compress.c.o: C_COMPILER__zlib_ /home/opensource/zlib/compress.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/compress.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/crc32.c.o: C_COMPILER__zlib_ /home/opensource/zlib/crc32.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/crc32.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/deflate.c.o: C_COMPILER__zlib_ /home/opensource/zlib/deflate.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/deflate.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/gzclose.c.o: C_COMPILER__zlib_ /home/opensource/zlib/gzclose.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/gzclose.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/gzlib.c.o: C_COMPILER__zlib_ /home/opensource/zlib/gzlib.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/gzlib.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/gzread.c.o: C_COMPILER__zlib_ /home/opensource/zlib/gzread.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/gzread.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/gzwrite.c.o: C_COMPILER__zlib_ /home/opensource/zlib/gzwrite.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/gzwrite.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/inflate.c.o: C_COMPILER__zlib_ /home/opensource/zlib/inflate.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/inflate.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/infback.c.o: C_COMPILER__zlib_ /home/opensource/zlib/infback.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/infback.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/inftrees.c.o: C_COMPILER__zlib_ /home/opensource/zlib/inftrees.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/inftrees.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/inffast.c.o: C_COMPILER__zlib_ /home/opensource/zlib/inffast.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/inffast.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/trees.c.o: C_COMPILER__zlib_ /home/opensource/zlib/trees.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/trees.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/uncompr.c.o: C_COMPILER__zlib_ /home/opensource/zlib/uncompr.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/uncompr.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + +build CMakeFiles/zlib.dir/zutil.c.o: C_COMPILER__zlib_ /home/opensource/zlib/zutil.c || cmake_object_order_depends_target_zlib + DEFINES = -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlib.dir/zutil.c.o.d + FLAGS = -fPIC + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlib.dir + OBJECT_FILE_DIR = CMakeFiles/zlib.dir + + +# ============================================================================= +# Link build statements for SHARED_LIBRARY target zlib + + +############################################# +# Link the shared library libz.so.1.3.1.1-motley + +build libz.so.1.3.1.1-motley: C_SHARED_LIBRARY_LINKER__zlib_ CMakeFiles/zlib.dir/adler32.c.o CMakeFiles/zlib.dir/compress.c.o CMakeFiles/zlib.dir/crc32.c.o CMakeFiles/zlib.dir/deflate.c.o CMakeFiles/zlib.dir/gzclose.c.o CMakeFiles/zlib.dir/gzlib.c.o CMakeFiles/zlib.dir/gzread.c.o CMakeFiles/zlib.dir/gzwrite.c.o CMakeFiles/zlib.dir/inflate.c.o CMakeFiles/zlib.dir/infback.c.o CMakeFiles/zlib.dir/inftrees.c.o CMakeFiles/zlib.dir/inffast.c.o CMakeFiles/zlib.dir/trees.c.o CMakeFiles/zlib.dir/uncompr.c.o CMakeFiles/zlib.dir/zutil.c.o + LINK_FLAGS = -Wl,--version-script,"/home/opensource/zlib/zlib.map" + OBJECT_DIR = CMakeFiles/zlib.dir + POST_BUILD = : + PRE_LINK = : + SONAME = libz.so.1 + SONAME_FLAG = -Wl,-soname, + TARGET_FILE = libz.so.1.3.1.1-motley + TARGET_PDB = z.so.dbg + + +############################################# +# Create library symlink libz.so + +build libz.so.1 libz.so: CMAKE_SYMLINK_LIBRARY libz.so.1.3.1.1-motley + POST_BUILD = : + +# ============================================================================= +# Object build statements for STATIC_LIBRARY target zlibstatic + + +############################################# +# Order-only phony target for zlibstatic + +build cmake_object_order_depends_target_zlibstatic: phony || CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/adler32.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/adler32.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/adler32.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/compress.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/compress.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/compress.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/crc32.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/crc32.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/crc32.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/deflate.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/deflate.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/deflate.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/gzclose.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/gzclose.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/gzclose.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/gzlib.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/gzlib.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/gzlib.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/gzread.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/gzread.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/gzread.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/gzwrite.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/gzwrite.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/gzwrite.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/inflate.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/inflate.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/inflate.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/infback.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/infback.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/infback.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/inftrees.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/inftrees.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/inftrees.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/inffast.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/inffast.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/inffast.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/trees.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/trees.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/trees.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/uncompr.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/uncompr.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/uncompr.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + +build CMakeFiles/zlibstatic.dir/zutil.c.o: C_COMPILER__zlibstatic_ /home/opensource/zlib/zutil.c || cmake_object_order_depends_target_zlibstatic + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/zlibstatic.dir/zutil.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/zlibstatic.dir + OBJECT_FILE_DIR = CMakeFiles/zlibstatic.dir + + +# ============================================================================= +# Link build statements for STATIC_LIBRARY target zlibstatic + + +############################################# +# Link the static library libz.a + +build libz.a: C_STATIC_LIBRARY_LINKER__zlibstatic_ CMakeFiles/zlibstatic.dir/adler32.c.o CMakeFiles/zlibstatic.dir/compress.c.o CMakeFiles/zlibstatic.dir/crc32.c.o CMakeFiles/zlibstatic.dir/deflate.c.o CMakeFiles/zlibstatic.dir/gzclose.c.o CMakeFiles/zlibstatic.dir/gzlib.c.o CMakeFiles/zlibstatic.dir/gzread.c.o CMakeFiles/zlibstatic.dir/gzwrite.c.o CMakeFiles/zlibstatic.dir/inflate.c.o CMakeFiles/zlibstatic.dir/infback.c.o CMakeFiles/zlibstatic.dir/inftrees.c.o CMakeFiles/zlibstatic.dir/inffast.c.o CMakeFiles/zlibstatic.dir/trees.c.o CMakeFiles/zlibstatic.dir/uncompr.c.o CMakeFiles/zlibstatic.dir/zutil.c.o + OBJECT_DIR = CMakeFiles/zlibstatic.dir + POST_BUILD = : + PRE_LINK = : + TARGET_FILE = libz.a + TARGET_PDB = z.a.dbg + +# ============================================================================= +# Object build statements for EXECUTABLE target example + + +############################################# +# Order-only phony target for example + +build cmake_object_order_depends_target_example: phony || cmake_object_order_depends_target_zlib + +build CMakeFiles/example.dir/test/example.c.o: C_COMPILER__example_ /home/opensource/zlib/test/example.c || cmake_object_order_depends_target_example + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/example.dir/test/example.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/example.dir + OBJECT_FILE_DIR = CMakeFiles/example.dir/test + + +# ============================================================================= +# Link build statements for EXECUTABLE target example + + +############################################# +# Link the executable example + +build example: C_EXECUTABLE_LINKER__example_ CMakeFiles/example.dir/test/example.c.o | libz.so.1.3.1.1-motley || libz.so libz.so + LINK_LIBRARIES = -Wl,-rpath,/home/opensource/zlib libz.so.1.3.1.1-motley + OBJECT_DIR = CMakeFiles/example.dir + POST_BUILD = : + PRE_LINK = : + TARGET_FILE = example + TARGET_PDB = example.dbg + +# ============================================================================= +# Object build statements for EXECUTABLE target minigzip + + +############################################# +# Order-only phony target for minigzip + +build cmake_object_order_depends_target_minigzip: phony || cmake_object_order_depends_target_zlib + +build CMakeFiles/minigzip.dir/test/minigzip.c.o: C_COMPILER__minigzip_ /home/opensource/zlib/test/minigzip.c || cmake_object_order_depends_target_minigzip + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/minigzip.dir/test/minigzip.c.o.d + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/minigzip.dir + OBJECT_FILE_DIR = CMakeFiles/minigzip.dir/test + + +# ============================================================================= +# Link build statements for EXECUTABLE target minigzip + + +############################################# +# Link the executable minigzip + +build minigzip: C_EXECUTABLE_LINKER__minigzip_ CMakeFiles/minigzip.dir/test/minigzip.c.o | libz.so.1.3.1.1-motley || libz.so libz.so + LINK_LIBRARIES = -Wl,-rpath,/home/opensource/zlib libz.so.1.3.1.1-motley + OBJECT_DIR = CMakeFiles/minigzip.dir + POST_BUILD = : + PRE_LINK = : + TARGET_FILE = minigzip + TARGET_PDB = minigzip.dbg + +# ============================================================================= +# Object build statements for EXECUTABLE target example64 + + +############################################# +# Order-only phony target for example64 + +build cmake_object_order_depends_target_example64: phony || cmake_object_order_depends_target_zlib + +build CMakeFiles/example64.dir/test/example.c.o: C_COMPILER__example64_ /home/opensource/zlib/test/example.c || cmake_object_order_depends_target_example64 + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/example64.dir/test/example.c.o.d + FLAGS = -D_FILE_OFFSET_BITS=64 + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/example64.dir + OBJECT_FILE_DIR = CMakeFiles/example64.dir/test + + +# ============================================================================= +# Link build statements for EXECUTABLE target example64 + + +############################################# +# Link the executable example64 + +build example64: C_EXECUTABLE_LINKER__example64_ CMakeFiles/example64.dir/test/example.c.o | libz.so.1.3.1.1-motley || libz.so libz.so + LINK_LIBRARIES = -Wl,-rpath,/home/opensource/zlib libz.so.1.3.1.1-motley + OBJECT_DIR = CMakeFiles/example64.dir + POST_BUILD = : + PRE_LINK = : + TARGET_FILE = example64 + TARGET_PDB = example64.dbg + +# ============================================================================= +# Object build statements for EXECUTABLE target minigzip64 + + +############################################# +# Order-only phony target for minigzip64 + +build cmake_object_order_depends_target_minigzip64: phony || cmake_object_order_depends_target_zlib + +build CMakeFiles/minigzip64.dir/test/minigzip.c.o: C_COMPILER__minigzip64_ /home/opensource/zlib/test/minigzip.c || cmake_object_order_depends_target_minigzip64 + DEFINES = -D_LARGEFILE64_SOURCE=1 + DEP_FILE = CMakeFiles/minigzip64.dir/test/minigzip.c.o.d + FLAGS = -D_FILE_OFFSET_BITS=64 + INCLUDES = -I/home/opensource/zlib + OBJECT_DIR = CMakeFiles/minigzip64.dir + OBJECT_FILE_DIR = CMakeFiles/minigzip64.dir/test + + +# ============================================================================= +# Link build statements for EXECUTABLE target minigzip64 + + +############################################# +# Link the executable minigzip64 + +build minigzip64: C_EXECUTABLE_LINKER__minigzip64_ CMakeFiles/minigzip64.dir/test/minigzip.c.o | libz.so.1.3.1.1-motley || libz.so libz.so + LINK_LIBRARIES = -Wl,-rpath,/home/opensource/zlib libz.so.1.3.1.1-motley + OBJECT_DIR = CMakeFiles/minigzip64.dir + POST_BUILD = : + PRE_LINK = : + TARGET_FILE = minigzip64 + TARGET_PDB = minigzip64.dbg + + +############################################# +# Utility command for test + +build CMakeFiles/test.util: CUSTOM_COMMAND + COMMAND = cd /home/opensource/zlib && /usr/bin/ctest --force-new-ctest-process + DESC = Running tests... + pool = console + restat = 1 + +build test: phony CMakeFiles/test.util + + +############################################# +# Utility command for edit_cache + +build CMakeFiles/edit_cache.util: CUSTOM_COMMAND + COMMAND = cd /home/opensource/zlib && /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available. + DESC = No interactive CMake dialog available... + restat = 1 + +build edit_cache: phony CMakeFiles/edit_cache.util + + +############################################# +# Utility command for rebuild_cache + +build CMakeFiles/rebuild_cache.util: CUSTOM_COMMAND + COMMAND = cd /home/opensource/zlib && /usr/bin/cmake --regenerate-during-build -S/home/opensource/zlib -B/home/opensource/zlib + DESC = Running CMake to regenerate build system... + pool = console + restat = 1 + +build rebuild_cache: phony CMakeFiles/rebuild_cache.util + + +############################################# +# Utility command for list_install_components + +build list_install_components: phony + + +############################################# +# Utility command for install + +build CMakeFiles/install.util: CUSTOM_COMMAND all + COMMAND = cd /home/opensource/zlib && /usr/bin/cmake -P cmake_install.cmake + DESC = Install the project... + pool = console + restat = 1 + +build install: phony CMakeFiles/install.util + + +############################################# +# Utility command for install/local + +build CMakeFiles/install/local.util: CUSTOM_COMMAND all + COMMAND = cd /home/opensource/zlib && /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake + DESC = Installing only the local directory... + pool = console + restat = 1 + +build install/local: phony CMakeFiles/install/local.util + + +############################################# +# Utility command for install/strip + +build CMakeFiles/install/strip.util: CUSTOM_COMMAND all + COMMAND = cd /home/opensource/zlib && /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake + DESC = Installing the project stripped... + pool = console + restat = 1 + +build install/strip: phony CMakeFiles/install/strip.util + +# ============================================================================= +# Target aliases. + +build zlib: phony libz.so + +build zlibstatic: phony libz.a + +# ============================================================================= +# Folder targets. + +# ============================================================================= + +############################################# +# Folder: /home/opensource/zlib + +build all: phony libz.so libz.a example minigzip example64 minigzip64 + +# ============================================================================= +# Built-in targets + + +############################################# +# Re-run CMake if any of its inputs changed. + +build build.ninja: RERUN_CMAKE | /usr/share/cmake-3.22/Modules/CMakeCInformation.cmake /usr/share/cmake-3.22/Modules/CMakeCommonLanguageInclude.cmake /usr/share/cmake-3.22/Modules/CMakeGenericSystem.cmake /usr/share/cmake-3.22/Modules/CMakeInitializeConfigs.cmake /usr/share/cmake-3.22/Modules/CMakeLanguageInformation.cmake /usr/share/cmake-3.22/Modules/CMakeSystemSpecificInformation.cmake /usr/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake /usr/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake /usr/share/cmake-3.22/Modules/CheckFunctionExists.cmake /usr/share/cmake-3.22/Modules/CheckIncludeFile.cmake /usr/share/cmake-3.22/Modules/CheckIncludeFileCXX.cmake /usr/share/cmake-3.22/Modules/CheckTypeSize.cmake /usr/share/cmake-3.22/Modules/Compiler/CMakeCommonCompilerMacros.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU-C.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU.cmake /usr/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU-C.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU.cmake /usr/share/cmake-3.22/Modules/Platform/Linux.cmake /usr/share/cmake-3.22/Modules/Platform/UnixPaths.cmake CMakeCache.txt CMakeFiles/3.22.1/CMakeCCompiler.cmake CMakeFiles/3.22.1/CMakeSystem.cmake CMakeLists.txt zconf.h.cmakein zlib.pc.cmakein + pool = console + + +############################################# +# A missing CMake input file is not an error. + +build /usr/share/cmake-3.22/Modules/CMakeCInformation.cmake /usr/share/cmake-3.22/Modules/CMakeCommonLanguageInclude.cmake /usr/share/cmake-3.22/Modules/CMakeGenericSystem.cmake /usr/share/cmake-3.22/Modules/CMakeInitializeConfigs.cmake /usr/share/cmake-3.22/Modules/CMakeLanguageInformation.cmake /usr/share/cmake-3.22/Modules/CMakeSystemSpecificInformation.cmake /usr/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake /usr/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake /usr/share/cmake-3.22/Modules/CheckFunctionExists.cmake /usr/share/cmake-3.22/Modules/CheckIncludeFile.cmake /usr/share/cmake-3.22/Modules/CheckIncludeFileCXX.cmake /usr/share/cmake-3.22/Modules/CheckTypeSize.cmake /usr/share/cmake-3.22/Modules/Compiler/CMakeCommonCompilerMacros.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU-C.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU.cmake /usr/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU-C.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU.cmake /usr/share/cmake-3.22/Modules/Platform/Linux.cmake /usr/share/cmake-3.22/Modules/Platform/UnixPaths.cmake CMakeCache.txt CMakeFiles/3.22.1/CMakeCCompiler.cmake CMakeFiles/3.22.1/CMakeSystem.cmake CMakeLists.txt zconf.h.cmakein zlib.pc.cmakein: phony + + +############################################# +# Clean all the built files. + +build clean: CLEAN + + +############################################# +# Print all primary targets available. + +build help: HELP + + +############################################# +# Make the all target the default. + +default all diff --git a/src/manifest_parser.cc b/src/manifest_parser.cc index c4b2980164..73d6807cbf 100644 --- a/src/manifest_parser.cc +++ b/src/manifest_parser.cc @@ -69,6 +69,13 @@ bool ManifestParser::Parse(const string& filename, const string& input, if (name == "ninja_required_version") CheckNinjaVersion(value); env_->AddBinding(name, value); + + // handle conversion of let + g_output_ss << "\n\tlet("; + g_output_ss << name; + g_output_ss << ", {\""; + g_output_ss << value; // parent function gets value this way + g_output_ss << "\"});\n"; break; } case Lexer::INCLUDE: @@ -131,6 +138,51 @@ bool ManifestParser::ParsePool(string* err) { return true; } +std::vector split_by_spaces(const std::string& line) { + std::vector tokens; + std::istringstream iss(line); + std::string token; + + while (iss >> token) { + tokens.push_back(token); // Extract token and push to vector + } + + return tokens; +} + +std::string extract_variable(const std::string& token) { + // Check if the token starts with '$' and contains both '${' and '}' + if (token[0] == '$' && token.find("${") == 0 && token.find('}') != std::string::npos) { + // Extract the content between '${' and '}' + size_t start = token.find("{") + 1; + size_t end = token.find("}"); + return token.substr(start, end - start); + } + + // Return an empty string if it's not a valid ${} expression + return ""; +} + +void escape_quotes_in_place(std::string& input) { + for (size_t i = 0; i < input.size(); ++i) { + if (input[i] == '"') { + input.insert(i, "\\"); + ++i; // skip the added backslash + } + } +} + +std::string extract_token(std::string& token){ + escape_quotes_in_place(token); + std::string output = extract_variable(token); + if (output.empty()){ + return "\"" + token + "\""; + } + else { + return "\"" + output + "\"_v"; + } +} + bool ManifestParser::ParseRule(string* err) { string name; @@ -170,6 +222,22 @@ bool ManifestParser::ParseRule(string* err) { return lexer_.Error("expected 'command =' line", err); env_->AddRule(rule); + + // add rule here to the stringstream + g_output_ss << "\nauto " << rule->name_ << " = rule{{\n" + << " "; + g_output_ss << "bind(command, {"; + + std::vector tokens = split_by_spaces(rule->bindings_.at("command").Unparse()); + + for (size_t i=0; i < tokens.size(); ++i) { + g_output_ss << extract_token(tokens[i]); + if (i != tokens.size() - 1) { + g_output_ss << ","; + } + } + g_output_ss << "})\n" << "}};\n"; + return true; } @@ -180,6 +248,7 @@ bool ManifestParser::ParseLet(string* key, EvalString* value, string* err) { return false; if (!lexer_.ReadVarValue(value, err)) return false; + return true; } @@ -200,6 +269,11 @@ bool ManifestParser::ParseDefault(string* err) { if (!state_->AddDefault(path, &default_err)) return lexer_.Error(default_err, err); +/* +// add to converter output for each default: default(str("hello")); + g_output_ss << "\n\tdefault(str(\""; + g_output_ss << path << "\"));\n"; +*/ eval.Clear(); if (!lexer_.ReadPath(&eval, err)) return false; @@ -308,6 +382,8 @@ bool ManifestParser::ParseEdge(string* err) { // Bindings on edges are rare, so allocate per-edge envs only when needed. bool has_indent_token = lexer_.PeekToken(Lexer::INDENT); BindingEnv* env = has_indent_token ? new BindingEnv(env_) : env_; + + std::map savedBindings; while (has_indent_token) { string key; EvalString val; @@ -315,6 +391,10 @@ bool ManifestParser::ParseEdge(string* err) { return false; env->AddBinding(key, val.Evaluate(env_)); + + // mr: save bindings for adding later + savedBindings[key] = val.Evaluate(env_); + has_indent_token = lexer_.PeekToken(Lexer::INDENT); } @@ -409,8 +489,53 @@ bool ManifestParser::ParseEdge(string* err) { } assert(!edge->dyndep_->generated_by_dep_loader()); } - - return true; + + // add edge here to the stringstream + g_output_ss << "\nauto build" << g_build_count++ << " = build("; + + g_output_ss << "list{{"; + for (auto it = outs.begin(); it != outs.end(); ++it) + { + g_output_ss << "str{{\"" << it->Evaluate(env) << "\"}}"; + if (std::next(it) != outs.end()) { + g_output_ss << ", "; + } + } + g_output_ss << "}},\n"; + + g_output_ss << "\tlist{{}},\n"; + + std::string tmp_rule_name = rule->name_; + if (tmp_rule_name == "phony") tmp_rule_name = "rule::phony"; + g_output_ss << "\t" << tmp_rule_name << ",\n"; + + g_output_ss << "\tlist{{ "; + for (auto it = ins.begin(); it != ins.end(); ++it) + { + g_output_ss << "\t\tstr{{\"" << it->Evaluate(env) << "\"}}"; + if (std::next(it) != ins.end()) { + g_output_ss << ", "; + } + } + g_output_ss << " } },\n"; + + g_output_ss << "\tlist{{}},\n"; + g_output_ss << "\tlist{{}},\n"; + + g_output_ss << "{"; + for (auto it = savedBindings.begin(); it != savedBindings.end(); ++it) { + escape_quotes_in_place(it->second); + g_output_ss << "\tbind(" << it->first << ", {\"" << it->second << "\"})"; + if (std::next(it) != savedBindings.end()) { + g_output_ss << ",\n"; + } else { + g_output_ss << "\n"; + } + } + g_output_ss << "}"; + + g_output_ss << ");\n"; + return true; } bool ManifestParser::ParseFileInclude(bool new_scope, string* err) { diff --git a/src/ninja.cc b/src/ninja.cc index 2902359f15..3bcc6ac5d5 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -21,6 +21,8 @@ #include #include +#include + #ifdef _WIN32 #include "getopt.h" #include @@ -52,6 +54,9 @@ #include "util.h" #include "version.h" +// mr: +#include + using namespace std; #ifdef _WIN32 @@ -1562,9 +1567,29 @@ NORETURN void real_main(int argc, char** argv) { exit((ninja.*options.tool->func)(&options, argc, argv)); } + // add preamble + g_output_ss << "#include \"manifest.h\"\n\n"; + g_output_ss << "using namespace shadowdash;\n\n"; + +/* for later + g_output_ss << "\ +Token operator\"\" _l(const char* value, std::size_t len) {\n\ + return Token(Token::Type::LITERAL, std::string(value, len));\n\ +}\n\n\ +Token operator\"\" _v(const char* value, std::size_t len) {\n\ + return Token(Token::Type::VAR, std::string(value, len));\n\ +}\n\n"; +*/ + g_output_ss << "extern \"C\" {\n"; + g_output_ss << "\tbuildGroup manifest() {\n"; // start manifest() function + + /* // Limit number of rebuilds, to prevent infinite loops. const int kCycleLimit = 100; for (int cycle = 1; cycle <= kCycleLimit; ++cycle) { + } +} +*/ NinjaMain ninja(ninja_command, config); ManifestParserOptions parser_opts; @@ -1577,7 +1602,37 @@ NORETURN void real_main(int argc, char** argv) { status->Error("%s", err.c_str()); exit(1); } + + g_output_ss << "return buildGroup({"; + for(int i=1; iwhen == Tool::RUN_AFTER_LOAD) exit((ninja.*options.tool->func)(&options, argc, argv)); @@ -1615,6 +1670,7 @@ NORETURN void real_main(int argc, char** argv) { options.input_file, kCycleLimit); exit(1); } +*/ } // anonymous namespace diff --git a/src/util.cc b/src/util.cc index ac1b14e55f..6819e37d44 100644 --- a/src/util.cc +++ b/src/util.cc @@ -60,6 +60,10 @@ #include "edit_distance.h" +// my globals +std::stringstream g_output_ss; +int g_build_count = 1; + using namespace std; void Fatal(const char* msg, ...) { diff --git a/src/util.h b/src/util.h index 211a43d348..e032208897 100644 --- a/src/util.h +++ b/src/util.h @@ -48,6 +48,11 @@ NORETURN void Fatal(const char* msg, ...); # define NINJA_FALLTHROUGH // nothing #endif +// my globals +#include +extern std::stringstream g_output_ss; +extern int g_build_count; + /// Log a warning message. void Warning(const char* msg, ...); void Warning(const char* msg, va_list ap);