From 272cf44df2a24f200a8a63238fe47154cd70378d Mon Sep 17 00:00:00 2001 From: Nicole Mazzuca Date: Sun, 21 Oct 2018 10:13:44 -0700 Subject: [PATCH 1/5] Add meson build system Also get it compiling with VS2017 --- .gitignore | 4 + meson.build | 27 ++++++ meson.options | 15 +++ src/ast/attrs.hpp | 84 ++++++++-------- src/meson.build | 154 ++++++++++++++++++++++++++++++ src/mir/from_hir.hpp | 8 ++ subprojects/zlib.wrap | 10 ++ tools/common/meson.build | 12 +++ tools/minicargo/meson.build | 0 tools/standalone_miri/meson.build | 0 tools/testrunner/meson.build | 0 11 files changed, 270 insertions(+), 44 deletions(-) create mode 100644 meson.build create mode 100644 meson.options create mode 100644 src/meson.build create mode 100644 subprojects/zlib.wrap create mode 100644 tools/common/meson.build create mode 100644 tools/minicargo/meson.build create mode 100644 tools/standalone_miri/meson.build create mode 100644 tools/testrunner/meson.build diff --git a/.gitignore b/.gitignore index e60401677..cd0489dd2 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,7 @@ /bnf/rust.tab.h /bnf/rust.output /bnf/test.bin + +/subprojects/* +!/subprojects/*.wrap +/build* diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..d1185b438 --- /dev/null +++ b/meson.build @@ -0,0 +1,27 @@ +project( + 'mrustc', + 'cpp', + version: '0.8.0', + license: 'MIT', + default_options: [ + 'cpp_std=c++14', + 'werror=false', + 'warning_level=2', + ], +) + +compiler = meson.get_compiler('cpp').get_id() +if compiler == 'msvc' + add_project_arguments('-wd4267', '-wd4244', '-wd4099', '-wd4996', language: 'cpp') +endif + +# TODO: add downloading rustc-source + +subdir('tools/common') +subdir('tools/minicargo') +subdir('tools/standalone_miri') +subdir('tools/testrunner') + +# TODO: add git info + +subdir('src') diff --git a/meson.options b/meson.options new file mode 100644 index 000000000..089958954 --- /dev/null +++ b/meson.options @@ -0,0 +1,15 @@ +option( + 'rustc_source_hash', + type: 'string', + value: 'https://github.com/rust-lang/rust/archive/1.19.0.tar.gz', + description: 'URL or local path of where rustc's source should be downloaded from.', +) + +option( + 'rustc_source_hash', + type: 'string', + value: 'SHA256=7e1ecb476118b79b5abed02bc7a724bb65413057e26f1d2b8538c572f7463be0', + description: + 'SHA256 of the file downloaded from MRUSTC_RUSTC_SOURCE_URL. ' + 'You can leave this empty to skip verifying whether the downloaded archive is correct.', +) diff --git a/src/ast/attrs.hpp b/src/ast/attrs.hpp index 0e1c8149d..c84e0c441 100644 --- a/src/ast/attrs.hpp +++ b/src/ast/attrs.hpp @@ -11,50 +11,7 @@ namespace AST { -// class Attribute; -::std::ostream& operator<<(::std::ostream& os, const Attribute& x); - -/// A list of attributes on an item (searchable by the attribute name) -class AttributeList -{ -public: - ::std::vector m_items; - - AttributeList() {} - AttributeList(::std::vector items): - m_items( mv$(items) ) - { - } - - // Move present - AttributeList(AttributeList&&) = default; - AttributeList& operator=(AttributeList&&) = default; - // No copy assign, but explicit copy - explicit AttributeList(const AttributeList&) = default; - AttributeList& operator=(const AttributeList&) = delete; - // Explicit clone - AttributeList clone() const; - - void push_back(Attribute i); - - const Attribute* get(const char *name) const; - Attribute* get(const char *name) { - return const_cast( const_cast(this)->get(name)); - } - bool has(const char *name) const { - return get(name) != 0; - } - - friend ::std::ostream& operator<<(::std::ostream& os, const AttributeList& x) { - for(const auto& i : x.m_items) { - os << "#[" << i << "]"; - } - return os; - } -}; - - TAGGED_UNION(AttributeData, None, (None, struct {}), (String, struct { @@ -70,7 +27,6 @@ TAGGED_UNION(AttributeData, None, // - A parenthesised token tree // > In 1.19 this was actually just sub-attributes // - an associated (string) literal - class Attribute { Span m_span; @@ -151,6 +107,46 @@ class Attribute } }; + +/// A list of attributes on an item (searchable by the attribute name) +class AttributeList +{ +public: + ::std::vector m_items; + + AttributeList() {} + AttributeList(::std::vector items): + m_items( mv$(items) ) + { + } + + // Move present + AttributeList(AttributeList&&) = default; + AttributeList& operator=(AttributeList&&) = default; + // No copy assign, but explicit copy + explicit AttributeList(const AttributeList&) = default; + AttributeList& operator=(const AttributeList&) = delete; + // Explicit clone + AttributeList clone() const; + + void push_back(Attribute i); + + const Attribute* get(const char *name) const; + Attribute* get(const char *name) { + return const_cast( const_cast(this)->get(name)); + } + bool has(const char *name) const { + return get(name) != 0; + } + + friend ::std::ostream& operator<<(::std::ostream& os, const AttributeList& x) { + for(const auto& i : x.m_items) { + os << "#[" << i << "]"; + } + return os; + } +}; + } // namespace AST #endif diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 000000000..7e8eddb6f --- /dev/null +++ b/src/meson.build @@ -0,0 +1,154 @@ +zdep = dependency('zlib', fallback: ['zlib', 'zlib_dep']) + +mrustc_includes = include_directories( + 'include', + '.', + + 'parse', + + 'expand', + 'macro_rules', + + 'ast', + + 'resolve', + 'hir', + 'hir_conv', + 'hir_typeck', + 'hir_expand', + + 'mir', + + 'trans', +) + +mrustc_args = [ + '-DVERSION_GIT_FULLHASH=' + '0', # git_head_hash + '-DVERSION_GIT_SHORTHASH=' + '0', # git_head_hash_short + '-DVERSION_GIT_BRANCH=' + 'master', # git_branch + '-DVERSION_GIT_ISDIRTY=' + 'false', # git_is_dirty + '-DVERSION_BUILDTIME=' + '0', # build_timestamp +] + +mrustc_exe = executable( + 'mrustc', + 'debug.cpp', + 'main.cpp', + 'ident.cpp', + 'span.cpp', + 'rc_string.cpp', + 'version.cpp', + + 'parse/root.cpp', + 'parse/types.cpp', + 'parse/tokentree.cpp', + 'parse/pattern.cpp', + 'parse/paths.cpp', + 'parse/ttstream.cpp', + 'parse/token.cpp', + 'parse/ttstream.hpp', + 'parse/expr.cpp', + 'parse/lex.cpp', + 'parse/interpolated_fragment.cpp', + 'parse/parseerror.cpp', + 'parse/tokenstream.cpp', + + 'expand/crate_tags.cpp', + 'expand/concat.cpp', + 'expand/format_args.cpp', + 'expand/derive.cpp', + 'expand/std_prelude.cpp', + 'expand/env.cpp', + 'expand/cfg.cpp', + 'expand/macro_rules.cpp', + 'expand/test_harness.cpp', + 'expand/include.cpp', + 'expand/mod.cpp', + 'expand/asm.cpp', + 'expand/file_line.cpp', + 'expand/lang_item.cpp', + 'expand/test.cpp', + 'expand/proc_macro.cpp', + 'expand/stringify.cpp', + 'expand/rustc_diagnostics.cpp', + 'macro_rules/parse.cpp', + 'macro_rules/mod.cpp', + 'macro_rules/eval.cpp', + + 'ast/types.cpp', + 'ast/dump.cpp', + 'ast/crate.cpp', + 'ast/pattern.cpp', + 'ast/expr.cpp', + 'ast/path.cpp', + 'ast/ast.cpp', + + 'resolve/absolute.cpp', + 'resolve/use.cpp', + 'resolve/index.cpp', + 'hir/generic_params.cpp', + 'hir/type.cpp', + 'hir/crate_post_load.cpp', + 'hir/dump.cpp', + 'hir/hir.cpp', + 'hir/pattern.cpp', + 'hir/expr_ptr.cpp', + 'hir/crate_ptr.cpp', + 'hir/from_ast.cpp', + 'hir/serialise.cpp', + 'hir/expr.cpp', + 'hir/pattern.hpp', + 'hir/visitor.cpp', + 'hir/serialise_lowlevel.cpp', + 'hir/path.cpp', + 'hir/deserialise.cpp', + 'hir/from_ast_expr.cpp', + 'hir_conv/bind.cpp', + 'hir_conv/expand_type.cpp', + 'hir_conv/resolve_ufcs.cpp', + 'hir_conv/markings.cpp', + 'hir_conv/constant_evaluation.cpp', + 'hir_expand/erased_types.cpp', + 'hir_expand/closures.cpp', + 'hir_expand/annotate_value_usage.cpp', + 'hir_expand/vtable.cpp', + 'hir_expand/ufcs_everything.cpp', + 'hir_expand/reborrow.cpp', + 'hir_typeck/helpers.cpp', + 'hir_typeck/expr_visit.cpp', + 'hir_typeck/expr_check.cpp', + 'hir_typeck/expr_cs.cpp', + 'hir_typeck/impl_ref.cpp', + 'hir_typeck/static.cpp', + 'hir_typeck/outer.cpp', + 'hir_typeck/common.cpp', + + 'mir/check_full.cpp', + 'mir/helpers.cpp', + 'mir/optimise.cpp', + 'mir/mir.cpp', + 'mir/dump.cpp', + 'mir/visit_crate_mir.cpp', + 'mir/mir_builder.cpp', + 'mir/from_hir_match.cpp', + 'mir/cleanup.cpp', + 'mir/check.cpp', + 'mir/from_hir.cpp', + 'mir/mir_ptr.cpp', + + 'trans/enumerate.cpp', + 'trans/codegen.cpp', + 'trans/monomorphise.hpp', + 'trans/mangling.cpp', + 'trans/target.cpp', + 'trans/trans_list.cpp', + 'trans/codegen_mmir.cpp', + 'trans/monomorphise.cpp', + 'trans/allocator.cpp', + 'trans/codegen_c.cpp', + 'trans/codegen_c_structured.cpp', + + include_directories: mrustc_includes, + dependencies: [zdep, common], + cpp_args: mrustc_args, +) diff --git a/src/mir/from_hir.hpp b/src/mir/from_hir.hpp index 0dcbd65bc..182a4b5d0 100644 --- a/src/mir/from_hir.hpp +++ b/src/mir/from_hir.hpp @@ -82,6 +82,14 @@ struct SplitArm { //BasicBlockId source_block; ::std::map states; ::std::map arg_states; + + SplitArm(const SplitArm&) = delete; + SplitArm(SplitArm&&) = default; + + SplitArm& operator=(const SplitArm&) = delete; + SplitArm& operator=(SplitArm&&) = default; + + ~SplitArm() = default; }; struct SplitEnd { ::std::map states; diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap new file mode 100644 index 000000000..97de00ef7 --- /dev/null +++ b/subprojects/zlib.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory = zlib-1.2.11 + +source_url = http://zlib.net/fossils/zlib-1.2.11.tar.gz +source_filename = zlib-1.2.11.tar.gz +source_hash = c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 + +patch_url = https://wrapdb.mesonbuild.com/v1/projects/zlib/1.2.11/3/get_zip +patch_filename = zlib-1.2.11-3-wrap.zip +patch_hash = f07dc491ab3d05daf00632a0591e2ae61b470615b5b73bcf9b3f061fff65cff0 diff --git a/tools/common/meson.build b/tools/common/meson.build new file mode 100644 index 000000000..2eb7c3183 --- /dev/null +++ b/tools/common/meson.build @@ -0,0 +1,12 @@ +common_include_directories = include_directories('.') + +common = declare_dependency( + link_with: static_library( + 'common', + 'debug.cpp', + 'path.cpp', + 'toml.cpp', + include_directories: common_include_directories, + ), + include_directories: common_include_directories, +) diff --git a/tools/minicargo/meson.build b/tools/minicargo/meson.build new file mode 100644 index 000000000..e69de29bb diff --git a/tools/standalone_miri/meson.build b/tools/standalone_miri/meson.build new file mode 100644 index 000000000..e69de29bb diff --git a/tools/testrunner/meson.build b/tools/testrunner/meson.build new file mode 100644 index 000000000..e69de29bb From 2b470f53e98cea5187f5d0eb3b5ec296202aa593 Mon Sep 17 00:00:00 2001 From: Nicole Mazzuca Date: Mon, 22 Oct 2018 13:20:00 -0700 Subject: [PATCH 2/5] Add support for versioning --- meson.build | 33 ++++++++++++++-- src/include/version.hpp | 15 +++---- src/meson.build | 2 +- src/version.cpp | 37 ------------------ version.py | 87 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 48 deletions(-) delete mode 100644 src/version.cpp create mode 100644 version.py diff --git a/meson.build b/meson.build index d1185b438..905908b62 100644 --- a/meson.build +++ b/meson.build @@ -10,11 +10,40 @@ project( ], ) +major_version = 0 +minor_version = 8 +patch_version = 0 + compiler = meson.get_compiler('cpp').get_id() if compiler == 'msvc' - add_project_arguments('-wd4267', '-wd4244', '-wd4099', '-wd4996', language: 'cpp') + add_project_arguments( + '-wd4267', + '-wd4244', + '-wd4099', + '-wd4996', + '-wd4146', + language: 'cpp', + ) endif +pymod = import('python') +python = pymod.find_installation('python3') +version_target = custom_target( + 'version', + input: 'version.py', + output: 'version.cpp', + build_always_stale: true, + install: false, + command: [ + python, '@INPUT@', + '--output-file', '@OUTPUT@', + '--major-version', major_version.to_string(), + '--minor-version', minor_version.to_string(), + '--patch-version', patch_version.to_string(), + ], +) +version_file = version_target[0] + # TODO: add downloading rustc-source subdir('tools/common') @@ -22,6 +51,4 @@ subdir('tools/minicargo') subdir('tools/standalone_miri') subdir('tools/testrunner') -# TODO: add git info - subdir('src') diff --git a/src/include/version.hpp b/src/include/version.hpp index 2270a5925..e09142fee 100644 --- a/src/include/version.hpp +++ b/src/include/version.hpp @@ -9,12 +9,13 @@ #include -extern unsigned int giVersion_Major; -extern unsigned int giVersion_Minor; -extern unsigned int giVersion_Patch; -extern const char* gsVersion_GitHash; -extern const char* gsVersion_GitShortHash; -extern const char* gsVersion_BuildTime; -extern bool gbVersion_GitDirty; +extern const unsigned int giVersion_Major; +extern const unsigned int giVersion_Minor; +extern const unsigned int giVersion_Patch; +extern const char gsVersion_GitHash[]; +extern const char gsVersion_GitShortHash[]; +extern const char gsVersion_GitBranch[]; +extern const char gsVersion_BuildTime[]; +extern const bool gbVersion_GitDirty; extern ::std::string Version_GetString(); diff --git a/src/meson.build b/src/meson.build index 7e8eddb6f..7cb7a142b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -37,7 +37,7 @@ mrustc_exe = executable( 'ident.cpp', 'span.cpp', 'rc_string.cpp', - 'version.cpp', + version_file, 'parse/root.cpp', 'parse/types.cpp', diff --git a/src/version.cpp b/src/version.cpp deleted file mode 100644 index b40196ffe..000000000 --- a/src/version.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * MRustC - Rust Compiler - * - By John Hodge (Mutabah/thePowersGang) - * - * version.cpp - * - Compiler version number - */ -#include -#include - -#define VERSION_MAJOR 0 -#define VERSION_MINOR 8 -#define VERSION_PATCH 0 - -#ifdef _WIN32 -# define VERSION_GIT_ISDIRTY 1 -# define VERSION_GIT_FULLHASH "" -# define VERSION_GIT_SHORTHASH "" -# define VERSION_BUILDTIME "" -# define VERSION_GIT_BRANCH "" -#endif - -unsigned int giVersion_Major = VERSION_MAJOR; -unsigned int giVersion_Minor = VERSION_MINOR; -unsigned int giVersion_Patch = VERSION_PATCH; -bool gbVersion_GitDirty = VERSION_GIT_ISDIRTY; -const char* gsVersion_GitHash = VERSION_GIT_FULLHASH; -const char* gsVersion_GitShortHash = VERSION_GIT_SHORTHASH; -const char* gsVersion_BuildTime = VERSION_BUILDTIME; - - -::std::string Version_GetString() -{ - ::std::stringstream ss; - ss << "v" << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_PATCH << " " << VERSION_GIT_BRANCH << ":" << VERSION_GIT_SHORTHASH; - return ss.str(); -} diff --git a/version.py b/version.py new file mode 100644 index 000000000..189d4095d --- /dev/null +++ b/version.py @@ -0,0 +1,87 @@ +import argparse +import string + +def get_arguments(): + parser = argparse.ArgumentParser( + description= 'Create a version.cpp file - this is run by meson on every build', + allow_abbrev=False, + ) + + parser.add_argument( + '--output-file', + action='store', + metavar='PATH', + required=True, + help='Where to put the generated version file', + ) + + parser.add_argument( + '--major-version', + action='store', + metavar='X', + required=True, + type=int, + help='Major version number', + ) + + parser.add_argument( + '--minor-version', + action='store', + metavar='Y', + required=True, + type=int, + help='Minor version number', + ) + + parser.add_argument( + '--patch-version', + action='store', + metavar='Z', + required=True, + type=int, + help='Patch version number', + ) + + return parser.parse_args() + +def main(): + arguments = get_arguments() + + templated = TEMPLATE_FILE.safe_substitute( + MAJOR=arguments.major_version, + MINOR=arguments.minor_version, + PATCH=arguments.patch_version, + GIT_ISDIRTY=1, + GIT_FULLHASH='', + GIT_SHORTHASH='', + GIT_BRANCH='master', + BUILDTIME='', + ) + + with open(arguments.output_file, 'w') as f: + f.write(templated) + +TEMPLATE_FILE = string.Template(''' +#include +#include + +const unsigned int giVersion_Major = $MAJOR; +const unsigned int giVersion_Minor = $MINOR; +const unsigned int giVersion_Patch = $PATCH; +const bool gbVersion_GitDirty = $GIT_ISDIRTY; +const char gsVersion_GitHash[] = "$GIT_FULLHASH"; +const char gsVersion_GitShortHash[] = "$GIT_SHORTHASH"; +const char gsVersion_GitBranch[] = "$GIT_BRANCH"; +const char gsVersion_BuildTime[] = "$BUILDTIME"; + + +::std::string Version_GetString() +{ + ::std::stringstream ss; + ss << 'v' << giVersion_Major << '.' << giVersion_Minor << '.' << giVersion_Patch << ' ' << gsVersion_GitBranch << ':' << gsVersion_GitShortHash; + return ss.str(); +} +''') + +if __name__ == '__main__': + main() From 309b9153b0f210d8b3f2b6c8e204c15b4d08c026 Mon Sep 17 00:00:00 2001 From: Nicole Mazzuca Date: Tue, 23 Oct 2018 12:52:41 -0700 Subject: [PATCH 3/5] finish off version.py --- meson.build | 18 +------------ src/include/version.hpp | 2 +- src/meson.build | 25 ++++++++++------- version.py => src/version.py | 52 ++++++++++++++++++++++++++++++++---- 4 files changed, 65 insertions(+), 32 deletions(-) rename version.py => src/version.py (63%) diff --git a/meson.build b/meson.build index 905908b62..ae687725c 100644 --- a/meson.build +++ b/meson.build @@ -26,23 +26,7 @@ if compiler == 'msvc' ) endif -pymod = import('python') -python = pymod.find_installation('python3') -version_target = custom_target( - 'version', - input: 'version.py', - output: 'version.cpp', - build_always_stale: true, - install: false, - command: [ - python, '@INPUT@', - '--output-file', '@OUTPUT@', - '--major-version', major_version.to_string(), - '--minor-version', minor_version.to_string(), - '--patch-version', patch_version.to_string(), - ], -) -version_file = version_target[0] +python = import('python').find_installation('python3') # TODO: add downloading rustc-source diff --git a/src/include/version.hpp b/src/include/version.hpp index e09142fee..a34509781 100644 --- a/src/include/version.hpp +++ b/src/include/version.hpp @@ -12,10 +12,10 @@ extern const unsigned int giVersion_Major; extern const unsigned int giVersion_Minor; extern const unsigned int giVersion_Patch; +extern const bool gbVersion_GitDirty; extern const char gsVersion_GitHash[]; extern const char gsVersion_GitShortHash[]; extern const char gsVersion_GitBranch[]; extern const char gsVersion_BuildTime[]; -extern const bool gbVersion_GitDirty; extern ::std::string Version_GetString(); diff --git a/src/meson.build b/src/meson.build index 7cb7a142b..28d247b55 100644 --- a/src/meson.build +++ b/src/meson.build @@ -22,13 +22,21 @@ mrustc_includes = include_directories( 'trans', ) -mrustc_args = [ - '-DVERSION_GIT_FULLHASH=' + '0', # git_head_hash - '-DVERSION_GIT_SHORTHASH=' + '0', # git_head_hash_short - '-DVERSION_GIT_BRANCH=' + 'master', # git_branch - '-DVERSION_GIT_ISDIRTY=' + 'false', # git_is_dirty - '-DVERSION_BUILDTIME=' + '0', # build_timestamp -] +version = custom_target( + 'version', + input: 'version.py', + output: 'version.cpp', + build_always_stale: true, + install: false, + command: [ + python, '@INPUT@', + '--output-file', '@OUTPUT@', + '--major-version', major_version.to_string(), + '--minor-version', minor_version.to_string(), + '--patch-version', patch_version.to_string(), + ], +) +version_cpp = version[0] mrustc_exe = executable( 'mrustc', @@ -37,7 +45,7 @@ mrustc_exe = executable( 'ident.cpp', 'span.cpp', 'rc_string.cpp', - version_file, + version_cpp, 'parse/root.cpp', 'parse/types.cpp', @@ -150,5 +158,4 @@ mrustc_exe = executable( include_directories: mrustc_includes, dependencies: [zdep, common], - cpp_args: mrustc_args, ) diff --git a/version.py b/src/version.py similarity index 63% rename from version.py rename to src/version.py index 189d4095d..fd355c26a 100644 --- a/version.py +++ b/src/version.py @@ -1,4 +1,5 @@ import argparse +from datetime import datetime import string def get_arguments(): @@ -44,18 +45,59 @@ def get_arguments(): return parser.parse_args() +def git_info(): + from subprocess import run + is_dirty = 1 + fullhash = '' + shorthash = '' + branch = '' + + try: + is_dirty_output = run( + ['git', 'status', '--porcelain'], + capture_output=True) + + if not is_dirty_output.stdout: + is_dirty = 0 + + fullhash_output = run( + ['git', 'rev-parse', 'HEAD'], + capture_output=True + ) + fullhash = fullhash_output.stdout.decode().strip() + + shorthash_output = run( + ['git', 'rev-parse', '--short', 'HEAD'], + capture_output=True, + ) + shorthash = shorthash_output.stdout.decode().strip() + + branch_output = run( + ['git', 'rev-parse', '--abbrev-ref', 'HEAD'], + capture_output=True, + ) + branch = branch_output.stdout.decode().strip() + except: + pass + + return { + 'GIT_ISDIRTY': is_dirty, + 'GIT_FULLHASH': fullhash, + 'GIT_SHORTHASH': shorthash, + 'GIT_BRANCH': branch, + } + def main(): arguments = get_arguments() + buildtime = datetime.utcnow().isoformat() + templated = TEMPLATE_FILE.safe_substitute( + git_info(), MAJOR=arguments.major_version, MINOR=arguments.minor_version, PATCH=arguments.patch_version, - GIT_ISDIRTY=1, - GIT_FULLHASH='', - GIT_SHORTHASH='', - GIT_BRANCH='master', - BUILDTIME='', + BUILDTIME=buildtime, ) with open(arguments.output_file, 'w') as f: From 1d7a03c96563461fbe0f57bf5643555e3e54683b Mon Sep 17 00:00:00 2001 From: Nicole Mazzuca Date: Tue, 23 Oct 2018 13:03:53 -0700 Subject: [PATCH 4/5] fix formatting --- src/version.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/version.py b/src/version.py index fd355c26a..e8219f913 100644 --- a/src/version.py +++ b/src/version.py @@ -54,28 +54,20 @@ def git_info(): try: is_dirty_output = run( - ['git', 'status', '--porcelain'], - capture_output=True) - + ['git', 'status', '--porcelain'], capture_output=True) if not is_dirty_output.stdout: is_dirty = 0 fullhash_output = run( - ['git', 'rev-parse', 'HEAD'], - capture_output=True - ) + ['git', 'rev-parse', 'HEAD'], capture_output=True) fullhash = fullhash_output.stdout.decode().strip() shorthash_output = run( - ['git', 'rev-parse', '--short', 'HEAD'], - capture_output=True, - ) + ['git', 'rev-parse', '--short', 'HEAD'], capture_output=True) shorthash = shorthash_output.stdout.decode().strip() branch_output = run( - ['git', 'rev-parse', '--abbrev-ref', 'HEAD'], - capture_output=True, - ) + ['git', 'rev-parse', '--abbrev-ref', 'HEAD'], capture_output=True) branch = branch_output.stdout.decode().strip() except: pass From e73bdc1e6b1ebe272cc2441f33e9cd9a560483a3 Mon Sep 17 00:00:00 2001 From: Nicole Mazzuca Date: Tue, 23 Oct 2018 20:36:27 -0700 Subject: [PATCH 5/5] minor changes I'm probably not going to do the downloading and building of rustc unless @thePowersGang gives the go-ahead, but here's how it might start to look --- meson.build | 20 ++++++++++++++++---- meson.options => meson_options.txt | 7 +++---- src/version.py | 2 ++ 3 files changed, 21 insertions(+), 8 deletions(-) rename meson.options => meson_options.txt (59%) diff --git a/meson.build b/meson.build index ae687725c..79ceeffeb 100644 --- a/meson.build +++ b/meson.build @@ -10,6 +10,7 @@ project( ], ) +python = import('python').find_installation('python3') major_version = 0 minor_version = 8 patch_version = 0 @@ -26,13 +27,24 @@ if compiler == 'msvc' ) endif -python = import('python').find_installation('python3') - -# TODO: add downloading rustc-source - subdir('tools/common') subdir('tools/minicargo') subdir('tools/standalone_miri') subdir('tools/testrunner') subdir('src') + +rustc_source_url = get_option('rustc_source_url') +rustc_source_hash = get_option('rustc_source_hash') +'''rustc_source = custom_target( + 'rustc_source', + input: 'download_rustc_source.py', + build_always_stale: true, + install: false, + command: [ + python, '@INPUT@', + '--output-directory', 'rustc_source', + '--source-url', rustc_source_url, + '--source-hash', rustc_source_hash, + ], +)''' diff --git a/meson.options b/meson_options.txt similarity index 59% rename from meson.options rename to meson_options.txt index 089958954..9a143809f 100644 --- a/meson.options +++ b/meson_options.txt @@ -1,8 +1,8 @@ option( - 'rustc_source_hash', + 'rustc_source_url', type: 'string', value: 'https://github.com/rust-lang/rust/archive/1.19.0.tar.gz', - description: 'URL or local path of where rustc's source should be downloaded from.', + description: 'URL or local path of where rustc\'s source should be downloaded from.', ) option( @@ -10,6 +10,5 @@ option( type: 'string', value: 'SHA256=7e1ecb476118b79b5abed02bc7a724bb65413057e26f1d2b8538c572f7463be0', description: - 'SHA256 of the file downloaded from MRUSTC_RUSTC_SOURCE_URL. ' - 'You can leave this empty to skip verifying whether the downloaded archive is correct.', + 'SHA256 of the file downloaded from MRUSTC_RUSTC_SOURCE_URL. You can leave this empty to skip verifying whether the downloaded archive is correct.', ) diff --git a/src/version.py b/src/version.py index e8219f913..204329b50 100644 --- a/src/version.py +++ b/src/version.py @@ -80,7 +80,9 @@ def git_info(): } def main(): + from os import getcwd arguments = get_arguments() + print('---', getcwd()) buildtime = datetime.utcnow().isoformat()