From cfe8c31260fe2fabba1a3ce77adb6a85fc1fae47 Mon Sep 17 00:00:00 2001
From: Li Jin <dragon-fly@qq.com>
Date: Wed, 16 Nov 2022 10:53:09 +0800
Subject: fix build. update doc.

---
 src/3rdParty/efsw/FileInfo.hpp            |  4 +++-
 src/3rdParty/efsw/FileWatcherFSEvents.cpp |  6 +++---
 src/3rdParty/efsw/FileWatcherKqueue.cpp   |  4 ++--
 src/3rdParty/efsw/String.cpp              | 16 ++++++++--------
 src/3rdParty/efsw/Utf.inl                 |  6 +++---
 src/3rdParty/efsw/WatcherFSEvents.cpp     |  2 +-
 src/yue.cpp                               | 11 ++++++++---
 7 files changed, 28 insertions(+), 21 deletions(-)

(limited to 'src')

diff --git a/src/3rdParty/efsw/FileInfo.hpp b/src/3rdParty/efsw/FileInfo.hpp
index a8dd3d3..f1bcf4b 100755
--- a/src/3rdParty/efsw/FileInfo.hpp
+++ b/src/3rdParty/efsw/FileInfo.hpp
@@ -18,10 +18,12 @@ class FileInfo {
 
 	FileInfo();
 
-	FileInfo( const std::string& filepath );
+	explicit FileInfo( const std::string& filepath );
 
 	FileInfo( const std::string& filepath, bool linkInfo );
 
+	FileInfo( const FileInfo& ) = default;
+
 	bool operator==( const FileInfo& Other ) const;
 
 	bool operator!=( const FileInfo& Other ) const;
diff --git a/src/3rdParty/efsw/FileWatcherFSEvents.cpp b/src/3rdParty/efsw/FileWatcherFSEvents.cpp
index 970810d..bcfdbe6 100755
--- a/src/3rdParty/efsw/FileWatcherFSEvents.cpp
+++ b/src/3rdParty/efsw/FileWatcherFSEvents.cpp
@@ -41,7 +41,7 @@ bool FileWatcherFSEvents::isGranular() {
 	return getOSXReleaseNumber() >= 11;
 }
 
-void FileWatcherFSEvents::FSEventCallback( ConstFSEventStreamRef streamRef, void* userData,
+void FileWatcherFSEvents::FSEventCallback( ConstFSEventStreamRef /*streamRef*/, void* userData,
 										   size_t numEvents, void* eventPaths,
 										   const FSEventStreamEventFlags eventFlags[],
 										   const FSEventStreamEventId eventIds[] ) {
@@ -208,8 +208,8 @@ void FileWatcherFSEvents::run() {
 	mRunLoopRef = NULL;
 }
 
-void FileWatcherFSEvents::handleAction( Watcher* watch, const std::string& filename,
-										unsigned long action, std::string oldFilename ) {
+void FileWatcherFSEvents::handleAction( Watcher* /*watch*/, const std::string& /*filename*/,
+										unsigned long /*action*/, std::string /*oldFilename*/ ) {
 	/// Not used
 }
 
diff --git a/src/3rdParty/efsw/FileWatcherKqueue.cpp b/src/3rdParty/efsw/FileWatcherKqueue.cpp
index 9c86755..38ffad9 100755
--- a/src/3rdParty/efsw/FileWatcherKqueue.cpp
+++ b/src/3rdParty/efsw/FileWatcherKqueue.cpp
@@ -181,8 +181,8 @@ void FileWatcherKqueue::run() {
 	} while ( mInitOK );
 }
 
-void FileWatcherKqueue::handleAction( Watcher* watch, const std::string& filename,
-									  unsigned long action, std::string oldFilename ) {}
+void FileWatcherKqueue::handleAction( Watcher* /*watch*/, const std::string& /*filename*/,
+									  unsigned long /*action*/, std::string /*oldFilename*/ ) {}
 
 std::list<std::string> FileWatcherKqueue::directories() {
 	std::list<std::string> dirs;
diff --git a/src/3rdParty/efsw/String.cpp b/src/3rdParty/efsw/String.cpp
index 8c9a3cc..e3ba68f 100755
--- a/src/3rdParty/efsw/String.cpp
+++ b/src/3rdParty/efsw/String.cpp
@@ -382,7 +382,7 @@ String& String::assign( const String& str, size_t pos, size_t n ) {
 	return *this;
 }
 
-String& String::assign( const char* s, size_t n ) {
+String& String::assign( const char* s, size_t /*n*/ ) {
 	String tmp( s );
 
 	mString.assign( tmp.mString );
@@ -416,7 +416,7 @@ String& String::append( const String& str, size_t pos, size_t n ) {
 	return *this;
 }
 
-String& String::append( const char* s, size_t n ) {
+String& String::append( const char* s, size_t /*n*/ ) {
 	String tmp( s );
 
 	mString.append( tmp.mString );
@@ -510,7 +510,7 @@ std::size_t String::find( const String& str, std::size_t start ) const {
 	return mString.find( str.mString, start );
 }
 
-std::size_t String::find( const char* s, std::size_t pos, std::size_t n ) const {
+std::size_t String::find( const char* s, std::size_t pos, std::size_t /*n*/ ) const {
 	return find( String( s ), pos );
 }
 
@@ -526,7 +526,7 @@ std::size_t String::rfind( const String& str, std::size_t pos ) const {
 	return mString.rfind( str.mString, pos );
 }
 
-std::size_t String::rfind( const char* s, std::size_t pos, std::size_t n ) const {
+std::size_t String::rfind( const char* s, std::size_t pos, std::size_t /*n*/ ) const {
 	return rfind( String( s ), pos );
 }
 
@@ -575,7 +575,7 @@ std::size_t String::find_first_of( const String& str, std::size_t pos ) const {
 	return mString.find_first_of( str.mString, pos );
 }
 
-std::size_t String::find_first_of( const char* s, std::size_t pos, std::size_t n ) const {
+std::size_t String::find_first_of( const char* s, std::size_t pos, std::size_t /*n*/ ) const {
 	return find_first_of( String( s ), pos );
 }
 
@@ -591,7 +591,7 @@ std::size_t String::find_last_of( const String& str, std::size_t pos ) const {
 	return mString.find_last_of( str.mString, pos );
 }
 
-std::size_t String::find_last_of( const char* s, std::size_t pos, std::size_t n ) const {
+std::size_t String::find_last_of( const char* s, std::size_t pos, std::size_t /*n*/ ) const {
 	return find_last_of( String( s ), pos );
 }
 
@@ -607,7 +607,7 @@ std::size_t String::find_first_not_of( const String& str, std::size_t pos ) cons
 	return mString.find_first_not_of( str.mString, pos );
 }
 
-std::size_t String::find_first_not_of( const char* s, std::size_t pos, std::size_t n ) const {
+std::size_t String::find_first_not_of( const char* s, std::size_t pos, std::size_t /*n*/ ) const {
 	return find_first_not_of( String( s ), pos );
 }
 
@@ -623,7 +623,7 @@ std::size_t String::find_last_not_of( const String& str, std::size_t pos ) const
 	return mString.find_last_not_of( str.mString, pos );
 }
 
-std::size_t String::find_last_not_of( const char* s, std::size_t pos, std::size_t n ) const {
+std::size_t String::find_last_not_of( const char* s, std::size_t pos, std::size_t /*n*/ ) const {
 	return find_last_not_of( String( s ), pos );
 }
 
diff --git a/src/3rdParty/efsw/Utf.inl b/src/3rdParty/efsw/Utf.inl
index 7e3e9d6..5b6c2e0 100755
--- a/src/3rdParty/efsw/Utf.inl
+++ b/src/3rdParty/efsw/Utf.inl
@@ -375,17 +375,17 @@ template <typename In, typename Out> Out Utf<16>::ToUtf32( In begin, In end, Out
 	return output;
 }
 
-template <typename In> In Utf<32>::Decode( In begin, In end, Uint32& output, Uint32 ) {
+template <typename In> In Utf<32>::Decode( In begin, In /*end*/, Uint32& output, Uint32 ) {
 	output = *begin++;
 	return begin;
 }
 
-template <typename Out> Out Utf<32>::Encode( Uint32 input, Out output, Uint32 replacement ) {
+template <typename Out> Out Utf<32>::Encode( Uint32 input, Out output, Uint32 /*replacement*/ ) {
 	*output++ = input;
 	return output;
 }
 
-template <typename In> In Utf<32>::Next( In begin, In end ) {
+template <typename In> In Utf<32>::Next( In begin, In /*end*/ ) {
 	return ++begin;
 }
 
diff --git a/src/3rdParty/efsw/WatcherFSEvents.cpp b/src/3rdParty/efsw/WatcherFSEvents.cpp
index 6ccf527..b562d3c 100755
--- a/src/3rdParty/efsw/WatcherFSEvents.cpp
+++ b/src/3rdParty/efsw/WatcherFSEvents.cpp
@@ -11,7 +11,7 @@ WatcherFSEvents::WatcherFSEvents() :
 	Watcher(), FWatcher( NULL ), FSStream( NULL ), WatcherGen( NULL ), initializedAsync( false ) {}
 
 WatcherFSEvents::WatcherFSEvents( WatchID id, std::string directory, FileWatchListener* listener,
-								  bool recursive, WatcherFSEvents* parent ) :
+								  bool recursive, WatcherFSEvents* /*parent*/ ) :
 	Watcher( id, directory, listener, recursive ),
 	FWatcher( NULL ),
 	FSStream( NULL ),
diff --git a/src/yue.cpp b/src/yue.cpp
index 49fa3e1..4f5be8d 100644
--- a/src/yue.cpp
+++ b/src/yue.cpp
@@ -196,7 +196,7 @@ static std::string compileFile(const fs::path& srcFile, yue::YueConfig conf, con
 
 class UpdateListener : public efsw::FileWatchListener {
 public:
-	void handleFileAction(efsw::WatchID, const std::string& dir, const std::string& filename, efsw::Action action, std::string oldFilename) override {
+	void handleFileAction(efsw::WatchID, const std::string& dir, const std::string& filename, efsw::Action action, std::string) override {
 		switch(action) {
 			case efsw::Actions::Add:
 				if (auto res = compileFile(fs::path(dir) / filename, config, workPath); !res.empty()) {
@@ -246,6 +246,7 @@ int main(int narg, const char** args) {
 		"   -b       Dump compile time (doesn't write output)\n"
 		"   -g       Dump global variables used in NAME LINE COLUMN\n"
 		"   -l       Write line numbers from source codes\n"
+		"   -w path  Watch changes and compile every file under directory\n"
 		"   -v       Print version\n"
 #ifndef YUE_COMPILER_ONLY
 		"   --       Read from standard in, print to standard out\n"
@@ -581,14 +582,18 @@ int main(int narg, const char** args) {
 		}
 	}
 	if (!watchFiles && files.empty()) {
-		std::cout << help;
+		std::cout << "no input files\n"sv;
 		return 0;
 	}
 	if (!resultFile.empty() && files.size() > 1) {
 		std::cout << "Error: -o can not be used with multiple input files\n"sv;
-		std::cout << help;
+		return 1;
 	}
 	if (watchFiles) {
+		if (!targetPath.empty()) {
+			std::cout << "Error: -t can not be used with watching mode\n"sv;
+			return 1;
+		}
 		auto fullWorkPath = fs::absolute(fs::path(workPath)).string();
 		std::list<std::future<std::string>> results;
 		for (const auto& file : files) {
-- 
cgit v1.2.3-55-g6feb