Prohibit the use of --newlinesoff with targets that do not support putting a whole script on one line
This commit is contained in:
		
							parent
							
								
									96bd6bf708
								
							
						
					
					
						commit
						26421597f2
					
				| @ -15,6 +15,7 @@ class Target { | |||||||
|     constexpr static const char* const interpolationString = "${"; |     constexpr static const char* const interpolationString = "${"; | ||||||
|     constexpr static const char* const interpolationCloseString = "}"; |     constexpr static const char* const interpolationCloseString = "}"; | ||||||
| protected: | protected: | ||||||
|  |     virtual constexpr bool supportsOneLine() { return true; }; | ||||||
|     std::stringstream output; |     std::stringstream output; | ||||||
|     INCLUDECOMPONENT(StandardComponents::Define); |     INCLUDECOMPONENT(StandardComponents::Define); | ||||||
|     INCLUDECOMPONENT(StandardComponents::types::String); |     INCLUDECOMPONENT(StandardComponents::types::String); | ||||||
| @ -102,7 +103,7 @@ shared_ptr<Target> Target::forName(string_view name, const bool newLines = true) | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     shared_ptr<Target> target; |     shared_ptr<Target> target; | ||||||
|     #define ADDTARGET(X) target = shared_ptr<X>(new X(newLines)); |     #define ADDTARGET(X) target = shared_ptr<X>(new X(newLines)) | ||||||
|     switch (selected) { |     switch (selected) { | ||||||
|     #ifdef LUA_HPP |     #ifdef LUA_HPP | ||||||
|         case LUA: ADDTARGET(LUA_HPP); break; |         case LUA: ADDTARGET(LUA_HPP); break; | ||||||
| @ -123,6 +124,10 @@ shared_ptr<Target> Target::forName(string_view name, const bool newLines = true) | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     #undef ADDTARGET |     #undef ADDTARGET | ||||||
|  |     if (not newLines and not target->supportsOneLine()) { | ||||||
|  |         cout << "--newlinesoff cannot be used with --target=" << name.substr(1) << endl; | ||||||
|  |         exit(0); | ||||||
|  |     } | ||||||
|     return target; |     return target; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ | |||||||
| #define PY_HPP PyTarget | #define PY_HPP PyTarget | ||||||
| 
 | 
 | ||||||
| struct PyTarget: Target { | struct PyTarget: Target { | ||||||
|  |     bool supportsOneLine() final { return false; } | ||||||
|     void on(const StandardComponents::Define &parseComponent) override { |     void on(const StandardComponents::Define &parseComponent) override { | ||||||
|         output << parseComponent.name << " = "; |         output << parseComponent.name << " = "; | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user