/** * Compile a file context. * * @return The compiled result. */ public Output compile(FileContext context, ImportStack importStack) throws CompilationException { NativeFileContext nativeContext = convertToNativeContext(context, importStack); return compileFile(nativeContext); }
/** * Compile a string context. * * @return The compiled result. */ public Output compile(StringContext context, ImportStack importStack) { NativeStringContext nativeContext = convertToNativeContext(context, importStack); return compileString(nativeContext); }
/** * Determine the right FreeBSD library depending on the architecture. * * @param library The library name. * @param osName The operating system name. * @param osArch The system architecture. * @return The library resource. * @throws UnsupportedOperationException Throw an exception if no native library for this platform * was found. */ private static String determineFreebsdLibrary( final String library, final String osName, final String osArch ) { String resourceName; String platform = null; String fileExtension = "so"; switch (osArch) { case ARCH_AMD64: case ARCH_X86_64: platform = "freebsd-x64"; break; default: unsupportedPlatform(osName, osArch); } resourceName = "/" + platform + "/" + library + "." + fileExtension; return resourceName; }
private NativeFileContext convertToNativeContext( FileContext context, ImportStack importStack ) { String inputPath = convertToString(context.getInputPath()); String outputPath = convertToString(context.getOutputPath()); NativeOptions options = convertToNativeOptions(context, importStack); return new NativeFileContext(inputPath, outputPath, options); }
private NativeStringContext convertToNativeContext( StringContext context, ImportStack importStack ) { String source = context.getString(); String inputPath = convertToString(context.getInputPath()); String outputPath = convertToString(context.getOutputPath()); NativeOptions options = convertToNativeOptions(context, importStack); return new NativeStringContext(source, inputPath, outputPath, options); }
/** * Find the right shared library, depending on the operating system and architecture. * * @throws UnsupportedOperationException Throw an exception if no native library for this platform * was found. */ private static URL findLibraryResource(final String libraryFileName) { String osName = System.getProperty("os.name").toLowerCase(); String osArch = System.getProperty("os.arch").toLowerCase(); String resourceName = null; if (osName.startsWith(OS_WIN)) { resourceName = determineWindowsLibrary(libraryFileName, osName, osArch); } else if (osName.startsWith(OS_LINUX)) { resourceName = determineLinuxLibrary(libraryFileName, osName, osArch); } else if (osName.startsWith(OS_FREEBSD)) { resourceName = determineFreebsdLibrary(libraryFileName, osName, osArch); } else if (osName.startsWith(OS_MAC)) { resourceName = determineMacLibrary(libraryFileName); } else { unsupportedPlatform(osName, osArch); } URL resource = NativeLoader.class.getResource(resourceName); if (null == resource) { unsupportedPlatform(osName, osArch, resourceName); } return resource; }
/** * Load the shared libraries. */ static void loadLibrary() { try { File dir = Files.createTempDirectory("libjsass-").toFile(); dir.deleteOnExit(); if (System.getProperty("os.name").toLowerCase().startsWith("win")) { System.load(saveLibrary(dir, "sass")); } System.load(saveLibrary(dir, "jsass")); } catch (Exception exception) { LOG.warn(exception.getMessage(), exception); throw new LoaderException(exception); } }
/** * Compile a string context. * * @param context The string context. * @return The compilation output. * @throws CompilationException If the compilation failed. */ public Output compile(StringContext context) throws CompilationException { final ImportStack importStack = new ImportStack(); return adapter.compile(context, importStack); }
/** * Create new compiler. */ public Compiler() { FunctionArgumentSignatureFactory functionArgumentSignatureFactory = new FunctionArgumentSignatureFactory(); FunctionWrapperFactory functionWrapperFactory = new FunctionWrapperFactory(functionArgumentSignatureFactory); adapter = new NativeAdapter(functionWrapperFactory); }
private static NativeImporterWrapper[] getImporters(ImportStack importStack, Options options) { Collection<Importer> importersList = options.getImporters(); return importersList .stream() .map(i -> new NativeImporterWrapper(importStack, i)) .collect(Collectors.toList()) .toArray(new NativeImporterWrapper[importersList.size()]); }
private NativeImport createPostImport(Import importSource) { StringBuilder postSource = new StringBuilder(); // $jsass-void: jsass_import_stack_pop() !global; postSource.append("$jsass-void: jsass_import_stack_pop() !global;\n"); try { return new NativeImport( new Import( new URI(importSource.getAbsoluteUri() + "/JSASS_POST_IMPORT.scss"), new URI(importSource.getAbsoluteUri() + "/JSASS_POST_IMPORT.scss"), postSource.toString() ) ); } catch (URISyntaxException e) { throw new RuntimeException(e); } } }
private NativeFileContext convertToNativeContext( FileContext context, ImportStack importStack ) { String inputPath = convertToString(context.getInputPath()); String outputPath = convertToString(context.getOutputPath()); NativeOptions options = convertToNativeOptions(context, importStack); return new NativeFileContext(inputPath, outputPath, options); }
private NativeStringContext convertToNativeContext( StringContext context, ImportStack importStack ) { String source = context.getString(); String inputPath = convertToString(context.getInputPath()); String outputPath = convertToString(context.getOutputPath()); NativeOptions options = convertToNativeOptions(context, importStack); return new NativeStringContext(source, inputPath, outputPath, options); }
/** * Compile a file context. * * @return The compiled result. */ public Output compile(FileContext context, ImportStack importStack) { NativeFileContext nativeContext = convertToNativeContext(context, importStack); return compileFile(nativeContext); }
/** * Compile a string context. * * @return The compiled result. */ public Output compile(StringContext context, ImportStack importStack) throws CompilationException { NativeStringContext nativeContext = convertToNativeContext(context, importStack); return compileString(nativeContext); }
/** * Compile file. * * @param context The file context. * @return The compilation output. * @throws CompilationException If the compilation failed. */ public Output compile(FileContext context) throws CompilationException { final ImportStack importStack = new ImportStack(); return adapter.compile(context, importStack); } }
/** * Create new compiler. */ public Compiler() { FunctionArgumentSignatureFactory functionArgumentSignatureFactory = new FunctionArgumentSignatureFactory(); FunctionWrapperFactory functionWrapperFactory = new FunctionWrapperFactory(functionArgumentSignatureFactory); adapter = new NativeAdapter(functionWrapperFactory); }
unsupportedPlatform(osName, osArch);
/** * Compile file. * * @param context The file context. * @return The compilation output. * @throws CompilationException If the compilation failed. */ public Output compile(FileContext context) throws CompilationException { final ImportStack importStack = new ImportStack(); return adapter.compile(context, importStack); } }
/** * Compile a string context. * * @param context The string context. * @return The compilation output. * @throws CompilationException If the compilation failed. */ public Output compile(StringContext context) throws CompilationException { final ImportStack importStack = new ImportStack(); return adapter.compile(context, importStack); }